@@ -153,15 +153,20 @@ package
153
153
version (AsmX86_64_Posix) {} else
154
154
version (AsmExternal) {} else
155
155
{
156
- // NOTE: The ucontext implementation requires architecture specific
157
- // data definitions to operate so testing for it must be done
158
- // by checking for the existence of ucontext_t rather than by
159
- // a version identifier. Please note that this is considered
160
- // an obsolescent feature according to the POSIX spec, so a
161
- // custom solution is still preferred.
162
- import core.sys.posix.ucontext : getcontext, makecontext, MINSIGSTKSZ , swapcontext, ucontext_t;
156
+ version = ucontext_Posix;
163
157
}
164
158
}
159
+
160
+ version (ucontext_Posix)
161
+ {
162
+ // NOTE: The ucontext implementation requires architecture specific
163
+ // data definitions to operate so testing for it must be done
164
+ // by checking for the existence of ucontext_t.
165
+ // Please note that ucontext is considered an obsolescent
166
+ // feature according to the POSIX spec, so a custom
167
+ // solution is still preferred.
168
+ import core.sys.posix.ucontext : getcontext, makecontext, MINSIGSTKSZ , swapcontext, ucontext_t;
169
+ }
165
170
}
166
171
167
172
// /////////////////////////////////////////////////////////////////////////////
@@ -188,7 +193,16 @@ package
188
193
// default stack created by Fiber.initStack or the initial
189
194
// switch into a new context will fail.
190
195
191
- version (AsmX86_Windows)
196
+ version (ucontext_Posix)
197
+ {
198
+ Fiber cfib = Fiber .getThis();
199
+ void * ucur = cfib.m_ucur;
200
+
201
+ * oldp = &ucur;
202
+ swapcontext( ** (cast (ucontext_t*** ) oldp),
203
+ * (cast (ucontext_t** ) newp) );
204
+ }
205
+ else version (AsmX86_Windows)
192
206
{
193
207
asm pure nothrow @nogc
194
208
{
@@ -363,15 +377,6 @@ package
363
377
jmp RCX ;
364
378
}
365
379
}
366
- else static if ( __traits( compiles, ucontext_t ) )
367
- {
368
- Fiber cfib = Fiber .getThis();
369
- void * ucur = cfib.m_ucur;
370
-
371
- * oldp = &ucur;
372
- swapcontext( ** (cast (ucontext_t*** ) oldp),
373
- * (cast (ucontext_t** ) newp) );
374
- }
375
380
else
376
381
static assert (0 , " Not implemented" );
377
382
}
@@ -866,7 +871,17 @@ protected:
866
871
}
867
872
}
868
873
869
- version (AsmX86_Windows)
874
+ version (ucontext_Posix)
875
+ {
876
+ getcontext( &m_utxt );
877
+ m_utxt.uc_stack.ss_sp = m_pmem;
878
+ m_utxt.uc_stack.ss_size = m_size;
879
+ makecontext( &m_utxt, &fiber_entryPoint, 0 );
880
+ // NOTE: If ucontext is being used then the top of the stack will
881
+ // be a pointer to the ucontext_t struct for that fiber.
882
+ push( cast (size_t ) &m_utxt );
883
+ }
884
+ else version (AsmX86_Windows)
870
885
{
871
886
version (StackGrowsDown) {} else static assert ( false );
872
887
@@ -1232,16 +1247,6 @@ protected:
1232
1247
*/
1233
1248
pstack += int .sizeof * 1 ;
1234
1249
}
1235
- else static if ( __traits( compiles, ucontext_t ) )
1236
- {
1237
- getcontext( &m_utxt );
1238
- m_utxt.uc_stack.ss_sp = m_pmem;
1239
- m_utxt.uc_stack.ss_size = m_size;
1240
- makecontext( &m_utxt, &fiber_entryPoint, 0 );
1241
- // NOTE: If ucontext is being used then the top of the stack will
1242
- // be a pointer to the ucontext_t struct for that fiber.
1243
- push( cast (size_t ) &m_utxt );
1244
- }
1245
1250
else
1246
1251
static assert (0 , " Not implemented" );
1247
1252
}
0 commit comments