25
25
#define os_assert (_x ) assert(_x)
26
26
#endif
27
27
28
- #if TARGET_OS_WIN32
29
- #define _CRT_SECURE_NO_WARNINGS 1
30
- #include <windows.h>
31
- static __inline bool OSAtomicCompareAndSwapLong (long oldl , long newl , long volatile * dst )
32
- {
33
- // fixme barrier is overkill -- see objc-os.h
34
- long original = InterlockedCompareExchange (dst , newl , oldl );
35
- return (original == oldl );
36
- }
28
+ #if !defined(__has_builtin )
29
+ #define __has_builtin (builtin ) 0
30
+ #endif
37
31
38
- static __inline bool OSAtomicCompareAndSwapInt (int oldi , int newi , int volatile * dst )
39
- {
40
- // fixme barrier is overkill -- see objc-os.h
41
- int original = InterlockedCompareExchange (dst , newi , oldi );
42
- return (original == oldi );
32
+ #if __has_builtin (__sync_bool_compare_and_swap )
33
+ #define OSAtomicCompareAndSwapInt (Old , New , Ptr ) \
34
+ __sync_bool_compare_and_swap(Ptr, Old, New)
35
+ #elif TARGET_OS_WIN32
36
+ #define _CRT_SECURE_NO_WARNINGS 1
37
+ #include <Windows.h>
38
+ static __inline bool OSAtomicCompareAndSwapInt (int oldi , int newi ,
39
+ int volatile * dst ) {
40
+ // fixme barrier is overkill -- see objc-os.h
41
+ int original = InterlockedCompareExchange ((LONG volatile * )dst , newi , oldi );
42
+ return (original == oldi );
43
43
}
44
- #else
45
- #define OSAtomicCompareAndSwapLong (_Old , _New , _Ptr ) __sync_bool_compare_and_swap(_Ptr, _Old, _New)
46
- #define OSAtomicCompareAndSwapInt (_Old , _New , _Ptr ) __sync_bool_compare_and_swap(_Ptr, _Old, _New)
47
44
#endif
48
45
49
46
/***********************
@@ -142,7 +139,7 @@ GC support stub routines
142
139
143
140
144
141
145
- static void * _Block_alloc_default (const unsigned long size , const bool initialCountIsOne , const bool isObject ) {
142
+ static void * _Block_alloc_default (size_t size , const bool initialCountIsOne , const bool isObject ) {
146
143
return malloc (size );
147
144
}
148
145
@@ -190,7 +187,7 @@ static void _Block_destructInstance_default(const void *aBlock) {}
190
187
GC support callout functions - initially set to stub routines
191
188
***************************************************************************/
192
189
193
- static void * (* _Block_allocator )(const unsigned long , const bool isOne , const bool isObject ) = _Block_alloc_default ;
190
+ static void * (* _Block_allocator )(size_t , const bool isOne , const bool isObject ) = _Block_alloc_default ;
194
191
static void (* _Block_deallocator )(const void * ) = (void (* )(const void * ))free ;
195
192
static void (* _Block_assign )(void * value , void * * destptr ) = _Block_assign_default ;
196
193
static void (* _Block_setHasRefcount )(const void * ptr , const bool hasRefcount ) = _Block_setHasRefcount_default ;
@@ -208,7 +205,7 @@ GC support SPI functions - called from ObjC runtime and CoreFoundation
208
205
// Public SPI
209
206
// Called from objc-auto to turn on GC.
210
207
// version 3, 4 arg, but changed 1st arg
211
- void _Block_use_GC ( void * (* alloc )(const unsigned long , const bool isOne , const bool isObject ),
208
+ void _Block_use_GC ( void * (* alloc )(size_t , const bool isOne , const bool isObject ),
212
209
void (* setHasRefcount )(const void * , const bool ),
213
210
void (* gc_assign )(void * , void * * ),
214
211
void (* gc_assign_weak )(const void * , void * ),
@@ -231,7 +228,7 @@ void _Block_use_GC( void *(*alloc)(const unsigned long, const bool isOne, const
231
228
}
232
229
233
230
// transitional
234
- void _Block_use_GC5 ( void * (* alloc )(const unsigned long , const bool isOne , const bool isObject ),
231
+ void _Block_use_GC5 ( void * (* alloc )(size_t , const bool isOne , const bool isObject ),
235
232
void (* setHasRefcount )(const void * , const bool ),
236
233
void (* gc_assign )(void * , void * * ),
237
234
void (* gc_assign_weak )(const void * , void * )) {
0 commit comments