@@ -25,40 +25,40 @@ struct cr {
25
25
}
26
26
27
27
#define cr_func_name (name ) __cr_func_##name
28
- #define cr_func_def (name ) static void cr_func_name(name)(struct cr * __ct )
28
+ #define cr_define (name ) static void cr_func_name(name)(struct cr * ctx )
29
29
30
30
#define cr_run (name ) cr_func_name(name)(&cr_context_name(name))
31
31
32
- #define cr_arg (type ) (type *) (__ct ->arg)
33
- #define cr_arg_member (type , memb ) &((type *) (__ct ->arg))->memb;
32
+ #define cr_arg (type ) (type *) (ctx ->arg)
33
+ #define cr_arg_member (type , memb ) &((type *) (ctx ->arg))->memb;
34
34
#define cr_local static
35
35
36
36
#define cr_begin () \
37
37
do { \
38
- if ((__ct )->status == CR_FINISHED) \
38
+ if ((ctx )->status == CR_FINISHED) \
39
39
return; \
40
- if ((__ct )->label) \
41
- goto *(__ct )->label; \
40
+ if ((ctx )->label) \
41
+ goto *(ctx )->label; \
42
42
} while (0)
43
43
#define cr_label (o , stat ) \
44
44
do { \
45
45
(o)->status = (stat); \
46
46
__cr_line(label) : (o)->label = &&__cr_line(label); \
47
47
} while (0)
48
- #define cr_end () cr_label(__ct , CR_FINISHED)
48
+ #define cr_end () cr_label(ctx , CR_FINISHED)
49
49
50
50
#define cr_status (name ) cr_context_name(name).status
51
51
52
52
#define cr_wait (cond ) \
53
53
do { \
54
- cr_label(__ct , CR_BLOCKED); \
54
+ cr_label(ctx , CR_BLOCKED); \
55
55
if (!(cond)) \
56
56
return; \
57
57
} while (0)
58
58
59
59
#define cr_exit (stat ) \
60
60
do { \
61
- cr_label(__ct , stat); \
61
+ cr_label(ctx , stat); \
62
62
return; \
63
63
} while (0)
64
64
@@ -102,9 +102,9 @@ typedef cr_queue(uint8_t, 4096) byte_queue_t;
102
102
typedef struct {
103
103
int fd ;
104
104
byte_queue_t * queue ;
105
- } sock_w_loc_t ;
105
+ } conn_data_t ;
106
106
107
- cr_func_def (stdin_loop )
107
+ cr_define (stdin_loop )
108
108
{
109
109
byte_queue_t * out = cr_arg (byte_queue_t );
110
110
cr_local uint8_t b ;
@@ -122,10 +122,10 @@ cr_func_def(stdin_loop)
122
122
cr_end ();
123
123
}
124
124
125
- cr_func_def (socket_write_loop )
125
+ cr_define (socket_write_loop )
126
126
{
127
- byte_queue_t * in = * cr_arg_member (sock_w_loc_t , queue );
128
- int fd = * cr_arg_member (sock_w_loc_t , fd );
127
+ byte_queue_t * in = * cr_arg_member (conn_data_t , queue );
128
+ int fd = * cr_arg_member (conn_data_t , fd );
129
129
cr_local uint8_t * b ;
130
130
cr_begin ();
131
131
for (;;) {
@@ -136,7 +136,7 @@ cr_func_def(socket_write_loop)
136
136
cr_end ();
137
137
}
138
138
139
- cr_func_def (socket_read_loop )
139
+ cr_define (socket_read_loop )
140
140
{
141
141
int fd = * cr_arg (int );
142
142
cr_local uint8_t b ;
@@ -198,14 +198,14 @@ int main(int argc, char *argv[])
198
198
connect (fd , (struct sockaddr * ) & addr , sizeof (struct sockaddr_in ));
199
199
200
200
byte_queue_t queue = cr_queue_init ();
201
- sock_w_loc_t sock_w_loc = {
201
+ conn_data_t conn_data = {
202
202
.fd = fd ,
203
203
.queue = & queue ,
204
204
};
205
205
206
206
cr_context (stdin_loop ) = cr_context_init (& queue );
207
207
cr_context (socket_read_loop ) = cr_context_init (& fd );
208
- cr_context (socket_write_loop ) = cr_context_init (& sock_w_loc );
208
+ cr_context (socket_write_loop ) = cr_context_init (& conn_data );
209
209
210
210
while (cr_status (stdin_loop ) == CR_BLOCKED &&
211
211
cr_status (socket_read_loop ) == CR_BLOCKED ) {
0 commit comments