28
28
#define os_assert (_x ) assert(_x)
29
29
#endif
30
30
31
- #if TARGET_OS_WIN32
32
- #define _CRT_SECURE_NO_WARNINGS 1
33
- #include <windows.h>
34
- static __inline bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst )
35
- {
36
- // fixme barrier is overkill -- see objc-os.h
37
- long original = InterlockedCompareExchange (dst , newl , oldl );
38
- return (original == oldl );
39
- }
31
+ #if !defined(__has_builtin )
32
+ #define __has_builtin (builtin ) 0
33
+ #endif
40
34
41
- static __inline bool OSAtomicCompareAndSwapInt (int oldi , int newi , int volatile * dst )
42
- {
43
- // fixme barrier is overkill -- see objc-os.h
44
- int original = InterlockedCompareExchange (dst , newi , oldi );
45
- return (original == oldi );
46
- }
35
+ #if __has_builtin (__sync_bool_compare_and_swap )
36
+ #define OSAtomicCompareAndSwapInt (_Old , _New , _Ptr ) \
37
+ __sync_bool_compare_and_swap(_Ptr, _Old, _New)
47
38
#else
48
- #define OSAtomicCompareAndSwapLong (_Old , _New , _Ptr ) __sync_bool_compare_and_swap(_Ptr, _Old, _New)
49
- #define OSAtomicCompareAndSwapInt (_Old , _New , _Ptr ) __sync_bool_compare_and_swap(_Ptr, _Old, _New)
39
+ #define _CRT_SECURE_NO_WARNINGS 1
40
+ #include <Windows.h>
41
+ static __inline bool OSAtomicCompareAndSwapInt (int oldi , int newi ,
42
+ int volatile * dst ) {
43
+ // fixme barrier is overkill -- see objc-os.h
44
+ int original = InterlockedCompareExchange ((LONG volatile * )dst , newi , oldi );
45
+ return (original == oldi );
46
+ }
50
47
#endif
51
48
52
49
/***********************
@@ -141,13 +138,13 @@ static bool latching_decr_int_now_zero(volatile int32_t *where) {
141
138
/***********************
142
139
GC support stub routines
143
140
************************/
144
- #if !TARGET_OS_WIN32
141
+ #if !defined( _MSC_VER ) || defined( __clang__ )
145
142
#pragma mark GC Support Routines
146
143
#endif
147
144
148
145
149
146
150
- static void * _Block_alloc_default (const unsigned long size , const bool initialCountIsOne , const bool isObject ) {
147
+ static void * _Block_alloc_default (size_t size , const bool initialCountIsOne , const bool isObject ) {
151
148
(void )initialCountIsOne ;
152
149
(void )isObject ;
153
150
return malloc (size );
@@ -207,7 +204,7 @@ static void _Block_destructInstance_default(const void *aBlock) {
207
204
GC support callout functions - initially set to stub routines
208
205
***************************************************************************/
209
206
210
- static void * (* _Block_allocator )(const unsigned long , const bool isOne , const bool isObject ) = _Block_alloc_default ;
207
+ static void * (* _Block_allocator )(size_t , const bool isOne , const bool isObject ) = _Block_alloc_default ;
211
208
static void (* _Block_deallocator )(const void * ) = (void (* )(const void * ))free ;
212
209
static void (* _Block_assign )(void * value , void * * destptr ) = _Block_assign_default ;
213
210
static void (* _Block_setHasRefcount )(const void * ptr , const bool hasRefcount ) = _Block_setHasRefcount_default ;
@@ -226,7 +223,7 @@ GC support SPI functions - called from ObjC runtime and CoreFoundation
226
223
// Public SPI
227
224
// Called from objc-auto to turn on GC.
228
225
// version 3, 4 arg, but changed 1st arg
229
- void _Block_use_GC ( void * (* alloc )(const unsigned long , const bool isOne , const bool isObject ),
226
+ void _Block_use_GC ( void * (* alloc )(size_t , const bool isOne , const bool isObject ),
230
227
void (* setHasRefcount )(const void * , const bool ),
231
228
void (* gc_assign )(void * , void * * ),
232
229
void (* gc_assign_weak )(const void * , void * ),
@@ -249,7 +246,7 @@ void _Block_use_GC( void *(*alloc)(const unsigned long, const bool isOne, const
249
246
}
250
247
251
248
// transitional
252
- void _Block_use_GC5 ( void * (* alloc )(const unsigned long , const bool isOne , const bool isObject ),
249
+ void _Block_use_GC5 ( void * (* alloc )(size_t , const bool isOne , const bool isObject ),
253
250
void (* setHasRefcount )(const void * , const bool ),
254
251
void (* gc_assign )(void * , void * * ),
255
252
void (* gc_assign_weak )(const void * , void * )) {
@@ -339,7 +336,7 @@ static void _Block_call_dispose_helper(struct Block_layout *aBlock)
339
336
Internal Support routines for copying
340
337
********************************************************************************/
341
338
342
- #if !TARGET_OS_WIN32
339
+ #if !defined( _MSC_VER ) || defined( __clang__ )
343
340
#pragma mark Copy/Release support
344
341
#endif
345
342
@@ -500,7 +497,7 @@ static void _Block_byref_release(const void *arg) {
500
497
*
501
498
***********************************************************/
502
499
503
- #if !TARGET_OS_WIN32
500
+ #if !defined( _MSC_VER ) || defined( __clang__ )
504
501
#pragma mark SPI/API
505
502
#endif
506
503
@@ -632,7 +629,7 @@ const char * _Block_extended_layout(void *aBlock)
632
629
else return desc3 -> layout ;
633
630
}
634
631
635
- #if !TARGET_OS_WIN32
632
+ #if !defined( _MSC_VER ) || defined( __clang__ )
636
633
#pragma mark Compiler SPI entry points
637
634
#endif
638
635
0 commit comments