File tree Expand file tree Collapse file tree 5 files changed +17
-8
lines changed
Expand file tree Collapse file tree 5 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 254254
255255typedef void (* dispatch_function_t )(void * _Nullable );
256256
257+ #ifdef __SIZEOF_POINTER__
258+ #define DISPATCH_PTR_SIZE __SIZEOF_POINTER__
259+ #elif defined(_WIN64 )
260+ #define DISPATCH_PTR_SIZE 8
261+ #elif defined(_WIN32 )
262+ #define DISPATCH_PTR_SIZE 4
263+ #elif defined(_MSC_VER )
264+ #error "could not determine pointer size as a constant int for MSVC"
265+ #else
266+ #define DISPATCH_PTR_SIZE sizeof(void *)
267+ #endif
268+
257269#endif
Original file line number Diff line number Diff line change @@ -1557,7 +1557,7 @@ _dispatch_mach_notify_port_init(void *context DISPATCH_UNUSED)
15571557 kern_return_t kr ;
15581558#if HAVE_MACH_PORT_CONSTRUCT
15591559 mach_port_options_t opts = { .flags = MPO_CONTEXT_AS_GUARD | MPO_STRICT };
1560- #ifdef __LP64__
1560+ #if DISPATCH_PTR_SIZE == 8
15611561 const mach_port_context_t guard = 0xfeed09071f1ca7edull ;
15621562#else
15631563 const mach_port_context_t guard = 0xff1ca7edull ;
Original file line number Diff line number Diff line change 225225 .do_xref_cnt = DISPATCH_OBJECT_GLOBAL_REFCNT
226226#endif
227227
228- #ifdef __LP64__
228+ #if DISPATCH_PTR_SIZE == 8
229229// the bottom nibble must not be zero, the rest of the bits should be random
230230// we sign extend the 64-bit version so that a better instruction encoding is
231231// 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);
748748 void *dc_ctxt; \
749749 void *dc_data; \
750750 void *dc_other
751- #define _DISPATCH_SIZEOF_PTR 8
752751#elif OS_OBJECT_HAVE_OBJC1
753752#define DISPATCH_CONTINUATION_HEADER (x ) \
754753 dispatch_function_t dc_func; \
@@ -766,7 +765,6 @@ dispatch_queue_attr_t _dispatch_get_default_queue_attr(void);
766765 void *dc_ctxt; \
767766 void *dc_data; \
768767 void *dc_other
769- #define _DISPATCH_SIZEOF_PTR 4
770768#else
771769#define DISPATCH_CONTINUATION_HEADER (x ) \
772770 union { \
@@ -784,17 +782,16 @@ dispatch_queue_attr_t _dispatch_get_default_queue_attr(void);
784782 void *dc_ctxt; \
785783 void *dc_data; \
786784 void *dc_other
787- #define _DISPATCH_SIZEOF_PTR 4
788785#endif
789786#define _DISPATCH_CONTINUATION_PTRS 8
790787#if DISPATCH_HW_CONFIG_UP
791788// UP devices don't contend on continuations so we don't need to force them to
792789// occupy a whole cacheline (which is intended to avoid contention)
793790#define DISPATCH_CONTINUATION_SIZE \
794- (_DISPATCH_CONTINUATION_PTRS * _DISPATCH_SIZEOF_PTR )
791+ (_DISPATCH_CONTINUATION_PTRS * DISPATCH_PTR_SIZE )
795792#else
796793#define DISPATCH_CONTINUATION_SIZE ROUND_UP_TO_CACHELINE_SIZE( \
797- (_DISPATCH_CONTINUATION_PTRS * _DISPATCH_SIZEOF_PTR ))
794+ (_DISPATCH_CONTINUATION_PTRS * DISPATCH_PTR_SIZE ))
798795#endif
799796#define ROUND_UP_TO_CONTINUATION_SIZE (x ) \
800797 (((x) + (DISPATCH_CONTINUATION_SIZE - 1u)) & \
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ main(void)
5050{
5151 dispatch_test_start ("Dispatch Queue Finalizer" );
5252
53- #ifdef __LP64__
53+ #if DISPATCH_PTR_SIZE == 8
5454 ctxt_magic = (void * )((uintptr_t )arc4random () << 32 | arc4random ());
5555#else
5656 ctxt_magic = (void * )arc4random ();
You can’t perform that action at this time.
0 commit comments