File tree Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 254
254
255
255
typedef void (* dispatch_function_t )(void * _Nullable );
256
256
257
+ #ifdef __SIZEOF_POINTER__
258
+ #define DISPATCH_SIZEOF_PTR __SIZEOF_POINTER__
259
+ #elif defined(_WIN64 )
260
+ #define DISPATCH_SIZEOF_PTR 8
261
+ #elif defined(_WIN32 )
262
+ #define DISPATCH_SIZEOF_PTR 4
263
+ #elif defined(_MSC_VER )
264
+ #error "could not determine pointer size as a constant int for MSVC"
265
+ #elif defined(__LP64__ ) || defined(__LLP64__ )
266
+ #define DISPATCH_SIZEOF_PTR 8
267
+ #elif defined(__ILP32__ )
268
+ #define DISPATCH_SIZEOF_PTR 4
269
+ #else
270
+ #error "could not determine pointer size as a constant int"
271
+ #endif // __SIZEOF_POINTER__
272
+
257
273
#endif
Original file line number Diff line number Diff line change @@ -1557,7 +1557,7 @@ _dispatch_mach_notify_port_init(void *context DISPATCH_UNUSED)
1557
1557
kern_return_t kr ;
1558
1558
#if HAVE_MACH_PORT_CONSTRUCT
1559
1559
mach_port_options_t opts = { .flags = MPO_CONTEXT_AS_GUARD | MPO_STRICT };
1560
- #ifdef __LP64__
1560
+ #if DISPATCH_SIZEOF_PTR == 8
1561
1561
const mach_port_context_t guard = 0xfeed09071f1ca7edull ;
1562
1562
#else
1563
1563
const mach_port_context_t guard = 0xff1ca7edull ;
Original file line number Diff line number Diff line change 225
225
.do_xref_cnt = DISPATCH_OBJECT_GLOBAL_REFCNT
226
226
#endif
227
227
228
- #ifdef __LP64__
228
+ #if DISPATCH_SIZEOF_PTR == 8
229
229
// the bottom nibble must not be zero, the rest of the bits should be random
230
230
// we sign extend the 64-bit version so that a better instruction encoding is
231
231
// generated on Intel
Original file line number Diff line number Diff line change @@ -748,7 +748,6 @@ dispatch_queue_attr_t _dispatch_get_default_queue_attr(void);
748
748
void *dc_ctxt; \
749
749
void *dc_data; \
750
750
void *dc_other
751
- #define _DISPATCH_SIZEOF_PTR 8
752
751
#elif OS_OBJECT_HAVE_OBJC1
753
752
#define DISPATCH_CONTINUATION_HEADER (x ) \
754
753
dispatch_function_t dc_func; \
@@ -766,7 +765,6 @@ dispatch_queue_attr_t _dispatch_get_default_queue_attr(void);
766
765
void *dc_ctxt; \
767
766
void *dc_data; \
768
767
void *dc_other
769
- #define _DISPATCH_SIZEOF_PTR 4
770
768
#else
771
769
#define DISPATCH_CONTINUATION_HEADER (x ) \
772
770
union { \
@@ -784,17 +782,16 @@ dispatch_queue_attr_t _dispatch_get_default_queue_attr(void);
784
782
void *dc_ctxt; \
785
783
void *dc_data; \
786
784
void *dc_other
787
- #define _DISPATCH_SIZEOF_PTR 4
788
785
#endif
789
786
#define _DISPATCH_CONTINUATION_PTRS 8
790
787
#if DISPATCH_HW_CONFIG_UP
791
788
// UP devices don't contend on continuations so we don't need to force them to
792
789
// occupy a whole cacheline (which is intended to avoid contention)
793
790
#define DISPATCH_CONTINUATION_SIZE \
794
- (_DISPATCH_CONTINUATION_PTRS * _DISPATCH_SIZEOF_PTR )
791
+ (_DISPATCH_CONTINUATION_PTRS * DISPATCH_SIZEOF_PTR )
795
792
#else
796
793
#define DISPATCH_CONTINUATION_SIZE ROUND_UP_TO_CACHELINE_SIZE( \
797
- (_DISPATCH_CONTINUATION_PTRS * _DISPATCH_SIZEOF_PTR ))
794
+ (_DISPATCH_CONTINUATION_PTRS * DISPATCH_SIZEOF_PTR ))
798
795
#endif
799
796
#define ROUND_UP_TO_CONTINUATION_SIZE (x ) \
800
797
(((x) + (DISPATCH_CONTINUATION_SIZE - 1u)) & \
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ main(void)
50
50
{
51
51
dispatch_test_start ("Dispatch Queue Finalizer" );
52
52
53
- #ifdef __LP64__
53
+ #if DISPATCH_SIZEOF_PTR == 8
54
54
ctxt_magic = (void * )((uintptr_t )arc4random () << 32 | arc4random ());
55
55
#else
56
56
ctxt_magic = (void * )arc4random ();
You can’t perform that action at this time.
0 commit comments