@@ -133,6 +133,8 @@ else version (Posix)
133133 // Use POSIX threads for suspend/resume
134134 }
135135}
136+ else
137+ static assert (0 , " unsupported operating system" );
136138
137139version (GNU )
138140{
@@ -252,6 +254,8 @@ class Thread : ThreadBase
252254 {
253255 alias TLSKey = pthread_key_t ;
254256 }
257+ else
258+ static assert (0 , " unsupported os" );
255259
256260 // /////////////////////////////////////////////////////////////////////////
257261 // Initialization
@@ -315,11 +319,13 @@ class Thread : ThreadBase
315319 if (m_addr != m_addr.init)
316320 pthread_detach( m_addr );
317321 m_addr = m_addr.init;
322+ version (Darwin)
323+ {
324+ m_tmach = m_tmach.init;
325+ }
318326 }
319- version (Darwin)
320- {
321- m_tmach = m_tmach.init;
322- }
327+ else
328+ static assert (0 , " unsupported OS" );
323329 }
324330
325331 //
@@ -475,19 +481,6 @@ class Thread : ThreadBase
475481 multiThreadedFlag = false ;
476482 }
477483
478- version (Windows ) {} else
479- version (Posix )
480- {
481- size_t stksz = adjustStackSize( m_sz );
482-
483- pthread_attr_t attr;
484-
485- if ( pthread_attr_init( &attr ) )
486- onThreadError( " Error initializing thread attributes" );
487- if ( stksz && pthread_attr_setstacksize( &attr, stksz ) )
488- onThreadError( " Error initializing thread stack size" );
489- }
490-
491484 version (Windows )
492485 {
493486 // NOTE: If a thread is just executing DllMain()
@@ -504,6 +497,19 @@ class Thread : ThreadBase
504497 if ( cast (size_t ) m_hndl == 0 )
505498 onThreadError( " Error creating thread" );
506499 }
500+ else version (Posix )
501+ {
502+ size_t stksz = adjustStackSize( m_sz );
503+
504+ pthread_attr_t attr;
505+
506+ if ( pthread_attr_init( &attr ) )
507+ onThreadError( " Error initializing thread attributes" );
508+ if ( stksz && pthread_attr_setstacksize( &attr, stksz ) )
509+ onThreadError( " Error initializing thread stack size" );
510+ }
511+ else
512+ static assert (0 , " unsupported OS" );
507513
508514 slock.lock_nothrow();
509515 scope (exit) slock.unlock_nothrow();
@@ -547,13 +553,16 @@ class Thread : ThreadBase
547553 }
548554 if ( pthread_attr_destroy( &attr ) != 0 )
549555 onThreadError( " Error destroying thread attributes" );
556+
557+ version (Darwin)
558+ {
559+ m_tmach = pthread_mach_thread_np( m_addr );
560+ if ( m_tmach == m_tmach.init )
561+ onThreadError( " Error creating thread" );
562+ }
550563 }
551- version (Darwin)
552- {
553- m_tmach = pthread_mach_thread_np( m_addr );
554- if ( m_tmach == m_tmach.init )
555- onThreadError( " Error creating thread" );
556- }
564+ else
565+ static assert (0 , " unsupported OS" );
557566
558567 return this ;
559568 }
@@ -598,6 +607,9 @@ class Thread : ThreadBase
598607 // on object destruction.
599608 m_addr = m_addr.init;
600609 }
610+ else
611+ static assert (0 , " unsupported OS" );
612+
601613 if ( m_unhandled )
602614 {
603615 if ( rethrow )
@@ -629,7 +641,7 @@ class Thread : ThreadBase
629641 return THREAD_PRIORITY_NORMAL ;
630642 }
631643 }
632- else
644+ else version ( Posix )
633645 {
634646 private struct Priority
635647 {
@@ -715,7 +727,7 @@ class Thread : ThreadBase
715727 result.PRIORITY_DEFAULT = 0 ;
716728 }
717729 }
718- else version ( Posix )
730+ else
719731 {
720732 int policy;
721733 sched_param param;
@@ -730,10 +742,6 @@ class Thread : ThreadBase
730742 result.PRIORITY_MAX != - 1 ||
731743 assert (0 , " Internal error in sched_get_priority_max" );
732744 }
733- else
734- {
735- static assert (0 , " Your code here." );
736- }
737745 return result;
738746 }
739747
@@ -773,6 +781,9 @@ class Thread : ThreadBase
773781 &loadGlobal! " PRIORITY_DEFAULT" )();
774782 }
775783 }
784+ else
785+ static assert (0 , " unsupported OS" );
786+
776787
777788 version (NetBSD )
778789 {
@@ -813,6 +824,8 @@ class Thread : ThreadBase
813824 }
814825 return param.sched_priority;
815826 }
827+ else
828+ static assert (0 , " unsupported os" );
816829 }
817830
818831
@@ -903,6 +916,8 @@ class Thread : ThreadBase
903916 }
904917 }
905918 }
919+ else
920+ static assert (0 , " unsupported os" );
906921 }
907922
908923
@@ -953,6 +968,8 @@ class Thread : ThreadBase
953968 {
954969 return atomicLoad (m_isRunning);
955970 }
971+ else
972+ static assert (0 , " unsupported os" );
956973 }
957974
958975
@@ -1027,6 +1044,8 @@ class Thread : ThreadBase
10271044 tin = tout;
10281045 }
10291046 }
1047+ else
1048+ static assert (0 , " unsupported os" );
10301049 }
10311050
10321051
@@ -1039,6 +1058,8 @@ class Thread : ThreadBase
10391058 SwitchToThread();
10401059 else version (Posix )
10411060 sched_yield();
1061+ else
1062+ static assert (0 , " unsupported os" );
10421063 }
10431064}
10441065
@@ -1265,6 +1286,8 @@ private extern (D) ThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow
12651286
12661287 atomicStore! (MemoryOrder.raw)(thisThread.toThread.m_isRunning, true );
12671288 }
1289+ else
1290+ static assert (0 , " unsupported os" );
12681291 thisThread.m_isDaemon = true ;
12691292 thisThread.tlsRTdataInit();
12701293 Thread .setThis( thisThread );
@@ -1531,24 +1554,24 @@ in (fn)
15311554 }
15321555 else version (AArch64 )
15331556 {
1534- // Callee-save registers, x19-x28 according to AAPCS64, section
1535- // 5.1.1. Include x29 fp because it optionally can be a callee
1536- // saved reg
1537- size_t [11 ] regs = void ;
1538- // store the registers in pairs
1539- asm pure nothrow @nogc
1540- {
1541- /*
1542- stp x19, x20, regs[0];
1543- stp x21, x22, regs[2];
1544- stp x23, x24, regs[4];
1545- stp x25, x26, regs[6];
1546- stp x27, x28, regs[8];
1547- str x29, regs[10];
1548- mov [sp], sp;
1549- */
1550- }
1551- assert (0 , " implement AArch64 inline assembler for callWithStackShell()" ); // TODO AArch64
1557+ // Callee-save registers, x19-x28 according to AAPCS64, section
1558+ // 5.1.1. Include x29 fp because it optionally can be a callee
1559+ // saved reg
1560+ size_t [11 ] regs = void ;
1561+ // store the registers in pairs
1562+ asm pure nothrow @nogc
1563+ {
1564+ /*
1565+ stp x19, x20, regs[0];
1566+ stp x21, x22, regs[2];
1567+ stp x23, x24, regs[4];
1568+ stp x25, x26, regs[6];
1569+ stp x27, x28, regs[8];
1570+ str x29, regs[10];
1571+ mov [sp], sp;
1572+ */
1573+ }
1574+ assert (0 , " implement AArch64 inline assembler for callWithStackShell()" ); // TODO AArch64
15521575 }
15531576 else
15541577 {
@@ -1575,6 +1598,8 @@ else version (Windows)
15751598{
15761599 alias getpid = imported! " core.sys.windows.winbase" .GetCurrentProcessId;
15771600}
1601+ else
1602+ static assert (0 , " unsupported os" );
15781603
15791604extern (C ) @nogc nothrow
15801605{
@@ -2053,6 +2078,8 @@ private extern (D) bool suspend( Thread t ) nothrow @nogc
20532078 t.m_curr.tstack = getStackTop();
20542079 }
20552080 }
2081+ else
2082+ static assert (0 , " unsupported os" );
20562083 return true ;
20572084}
20582085
@@ -2138,6 +2165,11 @@ extern (C) void thread_suspendAll() nothrow
21382165 }
21392166 }
21402167 }
2168+ else version (Windows )
2169+ {
2170+ }
2171+ else
2172+ static assert (0 , " unsupported os" );
21412173 }
21422174}
21432175
@@ -2247,7 +2279,10 @@ extern (C) void thread_init() @nogc nothrow
22472279 initLowlevelThreads();
22482280 Thread .initLocks();
22492281
2250- version (Darwin)
2282+ version (Windows )
2283+ {
2284+ }
2285+ else version (Darwin)
22512286 {
22522287 // thread id different in forked child process
22532288 static extern (C) void initChildAfterFork()
@@ -2339,6 +2374,8 @@ extern (C) void thread_init() @nogc nothrow
23392374 status = sem_init( &suspendCount, 0 , 0 );
23402375 assert ( status == 0 );
23412376 }
2377+ else
2378+ static assert (0 , " unsupported os" );
23422379 _mainThreadStore[] = cast (void []) __traits(initSymbol, Thread )[];
23432380 Thread .sm_main = attachThread((cast (Thread )_mainThreadStore.ptr).__ctor());
23442381}
@@ -3048,6 +3085,8 @@ ThreadID createLowLevelThread(void delegate() nothrow dg, uint stacksize = 0,
30483085
30493086 ll_pThreads[ll_nThreads - 1 ].tid = tid;
30503087 }
3088+ else
3089+ static assert (0 , " unsupported os" );
30513090 context = null ; // free'd in thread
30523091 return tid;
30533092}
@@ -3088,6 +3127,8 @@ void joinLowLevelThread(ThreadID tid) nothrow @nogc
30883127 if (pthread_join(tid, null ) != 0 )
30893128 onThreadError(" Unable to join thread" );
30903129 }
3130+ else
3131+ static assert (0 , " unsupported os" );
30913132}
30923133
30933134nothrow @nogc unittest
0 commit comments