@@ -153,15 +153,17 @@ 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: Please note that ucontext is considered an obsolescent
163
+ // feature according to the POSIX spec, so a custom
164
+ // solution is still preferred.
165
+ import core.sys.posix.ucontext : getcontext, makecontext, MINSIGSTKSZ , swapcontext, ucontext_t;
166
+ }
165
167
}
166
168
167
169
// /////////////////////////////////////////////////////////////////////////////
@@ -188,7 +190,16 @@ package
188
190
// default stack created by Fiber.initStack or the initial
189
191
// switch into a new context will fail.
190
192
191
- version (AsmX86_Windows)
193
+ version (ucontext_Posix)
194
+ {
195
+ Fiber cfib = Fiber .getThis();
196
+ void * ucur = cfib.m_ucur;
197
+
198
+ * oldp = &ucur;
199
+ swapcontext( ** (cast (ucontext_t*** ) oldp),
200
+ * (cast (ucontext_t** ) newp) );
201
+ }
202
+ else version (AsmX86_Windows)
192
203
{
193
204
asm pure nothrow @nogc
194
205
{
@@ -363,15 +374,6 @@ package
363
374
jmp RCX ;
364
375
}
365
376
}
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
377
else
376
378
static assert (0 , " Not implemented" );
377
379
}
@@ -866,7 +868,17 @@ protected:
866
868
}
867
869
}
868
870
869
- version (AsmX86_Windows)
871
+ version (ucontext_Posix)
872
+ {
873
+ getcontext( &m_utxt );
874
+ m_utxt.uc_stack.ss_sp = m_pmem;
875
+ m_utxt.uc_stack.ss_size = m_size;
876
+ makecontext( &m_utxt, &fiber_entryPoint, 0 );
877
+ // NOTE: If ucontext is being used then the top of the stack will
878
+ // be a pointer to the ucontext_t struct for that fiber.
879
+ push( cast (size_t ) &m_utxt );
880
+ }
881
+ else version (AsmX86_Windows)
870
882
{
871
883
version (StackGrowsDown) {} else static assert ( false );
872
884
@@ -1232,16 +1244,6 @@ protected:
1232
1244
*/
1233
1245
pstack += int .sizeof * 1 ;
1234
1246
}
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
1247
else
1246
1248
static assert (0 , " Not implemented" );
1247
1249
}
0 commit comments