@@ -75,6 +75,11 @@ static Polls polls = {0};
75
75
// TODO: ARM support
76
76
// Requires modifications in all the @arch places
77
77
78
+ typedef enum {
79
+ SM_NONE = 0 ,
80
+ SM_READ ,
81
+ SM_WRITE ,
82
+ } Sleep_Mode ;
78
83
79
84
// Linux x86_64 call convention
80
85
// %rdi, %rsi, %rdx, %rcx, %r8, and %r9
@@ -91,7 +96,7 @@ void __attribute__((naked)) coroutine_yield(void)
91
96
" pushq %r14\n"
92
97
" pushq %r15\n"
93
98
" movq %rsp, %rdi\n" // rsp
94
- " movq $0, %rsi\n" // sm
99
+ " movq $0, %rsi\n" // sm = SM_NONE
95
100
" jmp coroutine_switch_context\n" );
96
101
}
97
102
@@ -109,7 +114,7 @@ void __attribute__((naked)) coroutine_sleep_read(int fd)
109
114
" pushq %r15\n"
110
115
" movq %rdi, %rdx\n" // fd
111
116
" movq %rsp, %rdi\n" // rsp
112
- " movq $1, %rsi\n" // sm
117
+ " movq $1, %rsi\n" // sm = SM_READ
113
118
" jmp coroutine_switch_context\n" );
114
119
}
115
120
@@ -127,16 +132,10 @@ void __attribute__((naked)) coroutine_sleep_write(int fd)
127
132
" pushq %r15\n"
128
133
" movq %rdi, %rdx\n" // fd
129
134
" movq %rsp, %rdi\n" // rsp
130
- " movq $2, %rsi\n" // sm
135
+ " movq $2, %rsi\n" // sm = SM_WRITE
131
136
" jmp coroutine_switch_context\n" );
132
137
}
133
138
134
- typedef enum {
135
- SM_NONE = 0 ,
136
- SM_READ ,
137
- SM_WRITE ,
138
- } Sleep_Mode ;
139
-
140
139
void __attribute__((naked )) coroutine_restore_context (void * rsp )
141
140
{
142
141
// @arch
@@ -215,7 +214,7 @@ void coroutine_finish(void)
215
214
free (dead .items );
216
215
free (polls .items );
217
216
free (asleep .items );
218
- memset (& contexts , 0 , sizeof (contexts ));
217
+ memset (& contexts , 0 , sizeof (contexts ));
219
218
memset (& active , 0 , sizeof (active ));
220
219
memset (& dead , 0 , sizeof (dead ));
221
220
memset (& polls , 0 , sizeof (polls ));
0 commit comments