VSF Documented
__vsf_task_common.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TASK_COMMON_H__
19#define __VSF_TASK_COMMON_H__
20
21/*============================ INCLUDES ======================================*/
23#if VSF_USE_KERNEL == ENABLED
24#include "../vsf_eda.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31/*============================ MACROFIED FUNCTIONS ===========================*/
32
33#define __vsf_pt_begin_common(__state) \
34 enum { \
35 count_offset = __COUNTER__ + 1, \
36 }; \
37 switch ((__state)) { \
38 case __COUNTER__ - count_offset:
39
40#define __vsf_pt_raw_next_common(__state) \
41 (__state) = (__COUNTER__ - count_offset + 1) >> 1
42#define __vsf_pt_raw_entry_common(__state, ...) \
43 __VA_ARGS__; \
44 case (__COUNTER__ - count_offset) >> 1:
45
46#define __vsf_pt_entry_common(__state, ...) \
47 __vsf_pt_raw_entry_common(__state, \
48 __vsf_pt_raw_next_common(__state); \
49 __VA_ARGS__ \
50 )
51
52#define __vsf_pt_end_common() } vsf_eda_return();
53
54//#define __vsf_pt_end_closure_common() \
55// } /* for switch */ \
56// __vsf_pt_end_common()
57
58#define __vsf_pt_wait_cond_common(__state, ...) \
59 do { \
60 evt = VSF_EVT_INVALID; \
61 __vsf_pt_entry_common(__state); \
62 if (!(__VA_ARGS__)) { \
63 return ; \
64 } \
65 } while (0)
66
67
68#define __vsf_pt_wfe_common(__state, __evt) \
69 __vsf_pt_wait_cond_common(__state, (evt == __evt))
70
71#define __vsf_pt_func_common(__name) vsf_pt_func_##__name
72#define __vsf_pt_common(__name) pt_cb_##__name
73
74#define __def_vsf_pt_common(__name, ...) \
75 struct __vsf_pt_common(__name) { \
76 __VA_ARGS__ \
77 }; \
78 struct __name { \
79 implement(vsf_pt_t) \
80 implement_ex(__vsf_pt_common(__name), param) \
81 };
82
83#define __declare_vsf_pt_common(__name) \
84 typedef struct __name __name; \
85 typedef struct __vsf_pt_common(__name) __vsf_pt_common(__name);
86
87
88#define __implement_vsf_pt_common(__name, __arg0) \
89 void __vsf_pt_func_common(__name)(__arg0, vsf_evt_t evt)
90
91#define __extern_vsf_pt_common(__name, __arg0) \
92 extern void __vsf_pt_func_common(__name)(__arg0, vsf_evt_t evt);
93
94
95
96/*============================ TYPES =========================================*/
97/*============================ GLOBAL VARIABLES ==============================*/
98/*============================ PROTOTYPES ====================================*/
99
100#ifdef __cplusplus
101}
102#endif
103
104#endif
105#endif