@@ -15,6 +15,7 @@ module core.thread.osthread;
1515import core.atomic ;
1616import core.internal.traits : externDFunc;
1717import core.memory : GC ;
18+ import core.stdc.stdlib : free, malloc, realloc;
1819import core.thread.context ;
1920import core.thread.threadbase ;
2021import core.thread.types ;
@@ -59,102 +60,6 @@ else version (D_InlineAsm_X86_64)
5960 }
6061}
6162
62- version (Windows )
63- {
64- import core.stdc.stdint : uintptr_t ; // for _beginthreadex decl below
65- import core.stdc.stdlib : free, malloc, realloc;
66- import core.sys.windows.basetsd /+ : HANDLE+/ ;
67- import core.sys.windows.threadaux /+ : getThreadStackBottom, impersonate_thread, OpenThreadHandle+/ ;
68- import core.sys.windows.winbase /+ : CloseHandle, CREATE_SUSPENDED, DuplicateHandle, GetCurrentThread,
69- GetCurrentThreadId, GetCurrentProcess, GetExitCodeThread, GetSystemInfo, GetThreadContext,
70- GetThreadPriority, INFINITE, ResumeThread, SetThreadPriority, Sleep, STILL_ACTIVE,
71- SuspendThread, SwitchToThread, SYSTEM_INFO, THREAD_PRIORITY_IDLE, THREAD_PRIORITY_NORMAL,
72- THREAD_PRIORITY_TIME_CRITICAL, WAIT_OBJECT_0, WaitForSingleObject+/ ;
73- import core.sys.windows.windef /+ : TRUE+/ ;
74- import core.sys.windows.winnt /+ : CONTEXT, CONTEXT_CONTROL, CONTEXT_INTEGER+/ ;
75-
76- private extern (Windows) alias btex_fptr = uint function (void * );
77- private extern (C) uintptr_t _beginthreadex(void * , uint , btex_fptr, void * , uint , uint * ) nothrow @nogc ;
78- }
79- else version (Posix )
80- {
81- static import core.sys.posix.pthread ;
82- import core.stdc.errno : EINTR , errno;
83-
84- version (WASI )
85- import core.sys.posix.pthread : pthread_attr_destroy, pthread_attr_getstack,
86- pthread_attr_init, pthread_attr_setstacksize, pthread_create, pthread_detach,
87- pthread_join, pthread_self, sched_yield;
88- else
89- {
90- static import core.sys.posix.signal ;
91-
92- import core.sys.posix.pthread : pthread_atfork, pthread_attr_destroy, pthread_attr_getstack,
93- pthread_attr_init, pthread_attr_setstacksize, pthread_create, pthread_detach, pthread_getschedparam,
94- pthread_join, pthread_self, pthread_setschedparam, sched_get_priority_max, sched_get_priority_min,
95- sched_param, sched_yield;
96-
97- import core.sys.posix.semaphore : sem_init, sem_post, sem_t, sem_wait;
98-
99- import core.sys.posix.signal : pthread_kill, sigaction, sigaction_t, sigdelset, sigfillset, sigset_t, sigsuspend,
100- SIGUSR1 , stack_t;
101- }
102-
103- import core.sys.posix.stdlib : free, malloc, realloc;
104- import core.sys.posix.sys.types : pthread_attr_t , pthread_key_t , pthread_t ;
105- import core.sys.posix.time : nanosleep, timespec;
106-
107- version (Darwin)
108- {
109- // Use macOS threads for suspend/resume
110- import core.sys.darwin.mach.kern_return : KERN_SUCCESS ;
111- import core.sys.darwin.mach.port : mach_port_t;
112- import core.sys.darwin.mach.thread_act : mach_msg_type_number_t,
113- thread_get_state, thread_resume, thread_suspend;
114- import core.sys.darwin.pthread : pthread_mach_thread_np;
115- version (X86 )
116- {
117- import core.sys.darwin.mach.thread_act :
118- x86_THREAD_STATE32, x86_THREAD_STATE32_COUNT, x86_thread_state32_t;
119- }
120- else version (X86_64 )
121- {
122- import core.sys.darwin.mach.thread_act :
123- x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT, x86_thread_state64_t;
124- }
125- else version (AArch64 )
126- {
127- import core.sys.darwin.mach.thread_act :
128- ARM_THREAD_STATE64 , ARM_THREAD_STATE64_COUNT , arm_thread_state64_t;
129- }
130- else version (PPC )
131- {
132- import core.sys.darwin.mach.thread_act :
133- PPC_THREAD_STATE , PPC_THREAD_STATE_COUNT , ppc_thread_state_t;
134- }
135- else version (PPC64 )
136- {
137- import core.sys.darwin.mach.thread_act :
138- PPC_THREAD_STATE64 , PPC_THREAD_STATE64_COUNT , ppc_thread_state64_t;
139- }
140- }
141- else version (Solaris )
142- {
143- // Use Solaris threads for suspend/resume
144- import core.sys.posix.sys.wait : idtype_t;
145- import core.sys.solaris.sys.priocntl : PC_CLNULL , PC_GETCLINFO , PC_GETPARMS , PC_SETPARMS , pcinfo_t, pcparms_t, priocntl;
146- import core.sys.solaris.sys.types : P_MYID , pri_t;
147- import core.sys.solaris.thread : thr_stksegment, thr_suspend, thr_continue;
148- import core.sys.solaris.sys.procfs : PR_STOPPED , lwpstatus_t;
149- }
150- else
151- {
152- // Use POSIX threads for suspend/resume
153- }
154- }
155- else
156- static assert (0 , " unsupported operating system" );
157-
15863version (GNU )
15964{
16065 import gcc.builtins;
0 commit comments