@@ -15,8 +15,6 @@ import numem.core.memory;
15
15
import core.sync.exception ;
16
16
import core.time : convert;
17
17
18
- mixin CheckOS;
19
-
20
18
version (Windows ) {
21
19
22
20
import core.sys.windows.basetsd ;
@@ -25,7 +23,7 @@ version(Windows) {
25
23
import core.sys.windows.winerror ;
26
24
27
25
alias SemaphoreHandle = HANDLE ;
28
- } else version (AppleOS ) {
26
+ } else static if (IsAppleOS ) {
29
27
30
28
import core.sync.config ;
31
29
import core.stdc.errno ;
@@ -70,7 +68,7 @@ public:
70
68
bool rc = true ;
71
69
72
70
version (Windows ) rc = cast (bool )CloseHandle(handle);
73
- else version (AppleOS ) rc = ! semaphore_destroy(mach_task_self(), handle);
71
+ else static if (IsAppleOS ) rc = ! semaphore_destroy(mach_task_self(), handle);
74
72
else version (Posix ) rc = ! sem_destroy(&handle);
75
73
assert (rc, " Unable to destroy semahpore" );
76
74
}
@@ -84,7 +82,7 @@ public:
84
82
handle = CreateSemaphoreA(null , cast (LONG )count, int .max, null );
85
83
if (handle == handle.init)
86
84
throw nogc_new! SyncError(" Unable to create semaphore" );
87
- } else version (AppleOS ) {
85
+ } else static if (IsAppleOS ) {
88
86
89
87
auto rc = semaphore_create(mach_task_self(), &handle, SYNC_POLICY_FIFO , cast (int )count);
90
88
if (rc)
@@ -118,10 +116,10 @@ public:
118
116
throw nogc_new! SyncError(" Unable to wait for semaphore" );
119
117
120
118
this .subCount();
121
- } else version (AppleOS ) {
119
+ } else static if (IsAppleOS ) {
122
120
mach_timespec_t timeout = mach_timespec_t(
123
- tv_sec: convert! (" msecs" , " seconds" )(timeoutMs),
124
- tv_nsec: convert! (" msecs" , " nsecs" )(timeoutMs)
121
+ tv_sec: cast ( uint ) convert! (" msecs" , " seconds" )(timeoutMs),
122
+ tv_nsec: cast (clock_res_t) convert! (" msecs" , " nsecs" )(timeoutMs)
125
123
);
126
124
127
125
while (true ) {
@@ -166,7 +164,7 @@ public:
166
164
167
165
this .subCount();
168
166
169
- } else version (AppleOS ) {
167
+ } else static if (IsAppleOS ) {
170
168
171
169
while (true ) {
172
170
auto rc = semaphore_wait(handle);
@@ -206,7 +204,7 @@ public:
206
204
version (Windows ) {
207
205
if (! ReleaseSemaphore(handle, 1 , null ))
208
206
throw nogc_new! SyncError(" Unable to signal semaphore" );
209
- } else version (AppleOS ) {
207
+ } else static if (IsAppleOS ) {
210
208
auto rc = semaphore_signal(handle);
211
209
if (rc)
212
210
throw nogc_new! SyncError(" Unable to signal semaphore" );
0 commit comments