@@ -27,21 +27,23 @@ class coroState {
27
27
~coroState () = default ;
28
28
void * label;
29
29
};
30
- }
30
+ } // namespace util
31
31
32
32
/* *
33
33
* @brief
34
34
*
35
35
* @param context context of the coroutine
36
36
*
37
37
*/
38
- #define CR_BEGIN (context ) \
39
- util::coroState& localState = context; \
40
- do { \
41
- if (localState.label == nullptr ) { \
42
- localState.label = &&CR_START; \
43
- } \
44
- goto * localState.label ; \
38
+ #define CR_BEGIN (context ) \
39
+ util::coroState& localState = context; \
40
+ do { \
41
+ if (localState.label == nullptr ) { \
42
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
43
+ localState.label = &&CR_START; \
44
+ _Pragma (" GCC diagnostic pop" ); \
45
+ } \
46
+ goto * localState.label ; \
45
47
CR_START:;
46
48
47
49
/* *
@@ -50,20 +52,24 @@ class coroState {
50
52
* @param retval return value to pass
51
53
*
52
54
*/
53
- #define CR_END (retval ) \
54
- localState.label = &&CR_START; \
55
- return retval; \
56
- } \
55
+ #define CR_END (retval ) \
56
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
57
+ localState.label = &&CR_START; \
58
+ _Pragma (" GCC diagnostic pop" ); \
59
+ return retval; \
60
+ } \
57
61
while (0 )
58
62
59
63
/* *
60
64
* @brief End of void function coroutines
61
65
*
62
66
*/
63
- #define CR_END_V () \
64
- localState.label = &&CR_START; \
65
- return ; \
66
- } \
67
+ #define CR_END_V () \
68
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
69
+ localState.label = &&CR_START; \
70
+ _Pragma (" GCC diagnostic pop" ); \
71
+ return ; \
72
+ } \
67
73
while (0 )
68
74
69
75
/* *
@@ -72,22 +78,26 @@ class coroState {
72
78
* @param retval return value to pass
73
79
*
74
80
*/
75
- #define CR_YIELD (retval ) \
76
- do { \
77
- localState.label = &&CR_LABEL; \
78
- return (retval); \
79
- CR_LABEL:; \
81
+ #define CR_YIELD (retval ) \
82
+ do { \
83
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
84
+ localState.label = &&CR_LABEL; \
85
+ _Pragma (" GCC diagnostic pop" ); \
86
+ return (retval); \
87
+ CR_LABEL:; \
80
88
} while (0 )
81
89
82
90
/* *
83
91
* @brief Yield the coroutine
84
92
*
85
93
*/
86
- #define CR_YIELD_V () \
87
- do { \
88
- localState.label = &&CR_LABEL; \
89
- return ; \
90
- CR_LABEL:; \
94
+ #define CR_YIELD_V () \
95
+ do { \
96
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
97
+ localState.label = &&CR_LABEL; \
98
+ _Pragma (" GCC diagnostic pop" ); \
99
+ return ; \
100
+ CR_LABEL:; \
91
101
} while (0 )
92
102
93
103
/* *
@@ -97,11 +107,14 @@ class coroState {
97
107
* @param cond condition to wait for
98
108
*
99
109
*/
100
- #define CR_WAIT (retval, cond ) \
101
- do { \
102
- localState.label = &&CR_LABEL; \
103
- CR_LABEL:; \
104
- if (!(cond)) return retval; \
110
+ #define CR_WAIT (retval, cond ) \
111
+ do { \
112
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
113
+ localState.label = &&CR_LABEL; \
114
+ _Pragma (" GCC diagnostic pop" ); \
115
+ CR_LABEL:; \
116
+ if (!(cond)) \
117
+ return retval; \
105
118
} while (0 )
106
119
107
120
/* *
@@ -110,11 +123,14 @@ class coroState {
110
123
* @param cond condition to wait for
111
124
*
112
125
*/
113
- #define CR_WAIT_V (cond ) \
114
- do { \
115
- localState.label = &&CR_LABEL; \
116
- CR_LABEL:; \
117
- if (!(cond)) return ; \
126
+ #define CR_WAIT_V (cond ) \
127
+ do { \
128
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
129
+ localState.label = &&CR_LABEL; \
130
+ _Pragma (" GCC diagnostic pop" ); \
131
+ CR_LABEL:; \
132
+ if (!(cond)) \
133
+ return ; \
118
134
} while (0 )
119
135
120
136
/* *
@@ -123,20 +139,24 @@ class coroState {
123
139
* @param retval return value to pass
124
140
*
125
141
*/
126
- #define CR_STOP (retval ) \
127
- do { \
128
- localState.label = &&CR_START; \
129
- return (retval); \
142
+ #define CR_STOP (retval ) \
143
+ do { \
144
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
145
+ localState.label = &&CR_START; \
146
+ _Pragma (" GCC diagnostic pop" ); \
147
+ return (retval); \
130
148
} while (0 )
131
149
132
150
/* *
133
151
* @brief Stop coroutine and go to beginning
134
152
*
135
153
*/
136
- #define CR_STOP_V (context ) \
137
- do { \
138
- localState.label = &&CR_START; \
139
- return ; \
154
+ #define CR_STOP_V (context ) \
155
+ do { \
156
+ _Pragma (" GCC diagnostic ignored \" -Wdangling-pointer\" " ); \
157
+ localState.label = &&CR_START; \
158
+ _Pragma (" GCC diagnostic pop" ); \
159
+ return ; \
140
160
} while (0 )
141
161
142
162
#endif
0 commit comments