@@ -161,24 +161,39 @@ typedef int boolean_t;
161
161
#include <sys/stat.h> // mode_t
162
162
#endif
163
163
164
- #if TARGET_OS_LINUX || TARGET_OS_BSD
164
+ #if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32
165
165
// Implemented in CFPlatform.c
166
- bool OSAtomicCompareAndSwapPtr (void * oldp , void * newp , void * volatile * dst );
167
- bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst );
168
- bool OSAtomicCompareAndSwapPtrBarrier (void * oldp , void * newp , void * volatile * dst );
169
- bool OSAtomicCompareAndSwap64Barrier ( int64_t __oldValue , int64_t __newValue , volatile int64_t * __theValue );
166
+ CF_EXPORT bool OSAtomicCompareAndSwapPtr (void * oldp , void * newp , void * volatile * dst );
167
+ CF_EXPORT bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst );
168
+ CF_EXPORT bool OSAtomicCompareAndSwapPtrBarrier (void * oldp , void * newp , void * volatile * dst );
169
+ CF_EXPORT bool OSAtomicCompareAndSwap64Barrier ( int64_t __oldValue , int64_t __newValue , volatile int64_t * __theValue );
170
+
171
+ CF_EXPORT int32_t OSAtomicDecrement32Barrier (volatile int32_t * dst );
172
+ CF_EXPORT int32_t OSAtomicIncrement32Barrier (volatile int32_t * dst );
173
+ CF_EXPORT int32_t OSAtomicIncrement32 (volatile int32_t * theValue );
174
+ CF_EXPORT int32_t OSAtomicDecrement32 (volatile int32_t * theValue );
170
175
171
- int32_t OSAtomicDecrement32Barrier (volatile int32_t * dst );
172
- int32_t OSAtomicIncrement32Barrier (volatile int32_t * dst );
173
- int32_t OSAtomicIncrement32 (volatile int32_t * theValue );
174
- int32_t OSAtomicDecrement32 (volatile int32_t * theValue );
176
+ CF_EXPORT int32_t OSAtomicAdd32 ( int32_t theAmount , volatile int32_t * theValue );
177
+ CF_EXPORT int32_t OSAtomicAdd32Barrier ( int32_t theAmount , volatile int32_t * theValue );
178
+ CF_EXPORT bool OSAtomicCompareAndSwap32Barrier ( int32_t oldValue , int32_t newValue , volatile int32_t * theValue );
175
179
176
- int32_t OSAtomicAdd32 ( int32_t theAmount , volatile int32_t * theValue );
177
- int32_t OSAtomicAdd32Barrier ( int32_t theAmount , volatile int32_t * theValue );
178
- bool OSAtomicCompareAndSwap32Barrier ( int32_t oldValue , int32_t newValue , volatile int32_t * theValue );
180
+ CF_EXPORT void OSMemoryBarrier ();
179
181
180
- void OSMemoryBarrier ();
181
- #endif // TARGET_OS_LINUX || TARGET_OS_BSD
182
+ #include <time.h>
183
+
184
+ CF_INLINE uint64_t mach_absolute_time () {
185
+ #if TARGET_OS_WIN32
186
+ LARGE_INTEGER count ;
187
+ QueryPerformanceCounter (& count );
188
+ // mach_absolute_time is unsigned, but this function returns a signed value.
189
+ return (uint64_t )count .QuadPart ;
190
+ #else
191
+ struct timespec ts ;
192
+ clock_gettime (CLOCK_MONOTONIC , & ts );
193
+ return (uint64_t )ts .tv_nsec + (uint64_t )ts .tv_sec * 1000000000UL ;
194
+ #endif
195
+ }
196
+ #endif // TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WIN32
182
197
183
198
#if TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__ )
184
199
#define strtod_l (a ,b ,locale ) strtod(a,b)
@@ -219,13 +234,6 @@ CF_INLINE size_t malloc_size(void *memblock) {
219
234
return malloc_usable_size (memblock );
220
235
}
221
236
222
- #include <time.h>
223
- CF_INLINE uint64_t mach_absolute_time () {
224
- struct timespec ts ;
225
- clock_gettime (CLOCK_MONOTONIC , & ts );
226
- return (uint64_t )ts .tv_nsec + (uint64_t )ts .tv_sec * 1000000000UL ;
227
- }
228
-
229
237
#define malloc_default_zone () (void *)0
230
238
231
239
#endif
@@ -341,13 +349,6 @@ CF_INLINE size_t malloc_size(void *memblock) {
341
349
return _msize (memblock );
342
350
}
343
351
344
- CF_INLINE uint64_t mach_absolute_time () {
345
- LARGE_INTEGER count ;
346
- QueryPerformanceCounter (& count );
347
- // mach_absolute_time is unsigned, but this function returns a signed value.
348
- return (uint64_t )count .QuadPart ;
349
- }
350
-
351
352
CF_INLINE long long llabs (long long v ) {
352
353
if (v < 0 ) return - v ;
353
354
return v ;
@@ -362,22 +363,6 @@ CF_INLINE long long llabs(long long v) {
362
363
363
364
#define issetugid () 0
364
365
365
- // CF exports these useful atomic operation functions on Windows
366
- CF_EXPORT bool OSAtomicCompareAndSwapPtr (void * oldp , void * newp , void * volatile * dst );
367
- CF_EXPORT bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst );
368
- CF_EXPORT bool OSAtomicCompareAndSwapPtrBarrier (void * oldp , void * newp , void * volatile * dst );
369
-
370
- CF_EXPORT int32_t OSAtomicDecrement32Barrier (volatile int32_t * dst );
371
- CF_EXPORT int32_t OSAtomicIncrement32Barrier (volatile int32_t * dst );
372
- CF_EXPORT int32_t OSAtomicIncrement32 (volatile int32_t * theValue );
373
- CF_EXPORT int32_t OSAtomicDecrement32 (volatile int32_t * theValue );
374
-
375
- CF_EXPORT int32_t OSAtomicAdd32 ( int32_t theAmount , volatile int32_t * theValue );
376
- CF_EXPORT int32_t OSAtomicAdd32Barrier ( int32_t theAmount , volatile int32_t * theValue );
377
- CF_EXPORT bool OSAtomicCompareAndSwap32Barrier ( int32_t oldValue , int32_t newValue , volatile int32_t * theValue );
378
-
379
- void OSMemoryBarrier ();
380
-
381
366
#include <io.h>
382
367
#include <fcntl.h>
383
368
#include <errno.h>
0 commit comments