Skip to content

use reserved spelling for inline assembly #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion os/object_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#endif
#define OS_OBJECT_OBJC_CLASS_DECL(name) \
extern void *OS_OBJECT_CLASS_SYMBOL(name) \
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
#else
#define OS_OBJECT_HAVE_OBJC1 0
#define OS_OBJECT_HAVE_OBJC2 0
Expand Down
2 changes: 1 addition & 1 deletion src/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
.dc_ctxt = ctxt,
.dc_data = dq,
};
dispatch_apply_t da = (typeof(da))_dispatch_continuation_alloc();
dispatch_apply_t da = (__typeof__(da))_dispatch_continuation_alloc();
da->da_index = 0;
da->da_todo = iterations;
da->da_iterations = iterations;
Expand Down
6 changes: 1 addition & 5 deletions src/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ extern "C" {
// The compiler hides the name of the function it generates, and changes it if
// we try to reference it directly, but the linker still sees it.
extern void DISPATCH_BLOCK_SPECIAL_INVOKE(void *)
#if defined(__linux__) || defined(__FreeBSD__)
asm("___dispatch_block_create_block_invoke");
#else
asm("____dispatch_block_create_block_invoke");
#endif
__asm__(OS_STRINGIFY(__USER_LABEL_PREFIX__) "___dispatch_block_create_block_invoke");
void (*_dispatch_block_special_invoke)(void*) = DISPATCH_BLOCK_SPECIAL_INVOKE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/event/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _dispatch_unote_create(dispatch_source_type_t dst,
du->du_can_be_wlh = dst->dst_per_trigger_qos;
du->du_ident = (uint32_t)handle;
du->du_filter = dst->dst_filter;
du->du_fflags = (typeof(du->du_fflags))mask;
du->du_fflags = (__typeof__(du->du_fflags))mask;
if (dst->dst_flags & EV_UDATA_SPECIFIC) {
du->du_is_direct = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/event/event_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

#if DISPATCH_TIMER_ASSERTIONS
#define DISPATCH_TIMER_ASSERT(a, op, b, text) ({ \
typeof(a) _a = (a); \
__typeof__(a) _a = (a); \
if (unlikely(!(_a op (b)))) { \
DISPATCH_CLIENT_CRASH(_a, "Timer: " text); \
} \
Expand Down
8 changes: 4 additions & 4 deletions src/event/event_kevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define DISPATCH_KEVENT_MUXED_MARKER 1ul
#define DISPATCH_MACH_AUDIT_TOKEN_PID (5)

#define dispatch_kevent_udata_t typeof(((dispatch_kevent_t)NULL)->udata)
#define dispatch_kevent_udata_t __typeof__(((dispatch_kevent_t)NULL)->udata)

typedef struct dispatch_muxnote_s {
TAILQ_ENTRY(dispatch_muxnote_s) dmn_list;
Expand Down Expand Up @@ -738,9 +738,9 @@ _dispatch_kq_unote_set_kevent(dispatch_unote_t _du, dispatch_kevent_t dk,
.flags = flags,
.udata = (dispatch_kevent_udata_t)du,
.fflags = du->du_fflags | dst->dst_fflags,
.data = (typeof(dk->data))dst->dst_data,
.data = (__typeof__(dk->data))dst->dst_data,
#if DISPATCH_USE_KEVENT_QOS
.qos = (typeof(dk->qos))pp,
.qos = (__typeof__(dk->qos))pp,
#endif
};
(void)pp; // if DISPATCH_USE_KEVENT_QOS == 0
Expand Down Expand Up @@ -1778,7 +1778,7 @@ _dispatch_mach_notify_update(dispatch_muxnote_t dmn, uint32_t new_flags,
mach_port_mscount_t notify_sync)
{
mach_port_t previous, port = (mach_port_t)dmn->dmn_kev.ident;
typeof(dmn->dmn_kev.data) prev = dmn->dmn_kev.data;
__typeof__(dmn->dmn_kev.data) prev = dmn->dmn_kev.data;
kern_return_t kr, krr = 0;

// Update notification registration state.
Expand Down
8 changes: 4 additions & 4 deletions src/firehose/firehose_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

#define DISPATCH_PURE_C 1
#define _safe_cast_to_long(x) \
({ _Static_assert(sizeof(typeof(x)) <= sizeof(long), \
({ _Static_assert(sizeof(__typeof__(x)) <= sizeof(long), \
"__builtin_expect doesn't support types wider than long"); \
(long)(x); })
#define fastpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
#define slowpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), 0l))
#define fastpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
#define slowpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), 0l))
#define os_likely(x) __builtin_expect(!!(x), 1)
#define os_unlikely(x) __builtin_expect(!!(x), 0)
#define likely(x) __builtin_expect(!!(x), 1)
Expand All @@ -54,7 +54,7 @@
#endif

#define _dispatch_wait_until(c) ({ \
typeof(c) _c; \
__typeof__(c) _c; \
for (;;) { \
if (likely(_c = (c))) break; \
dispatch_hardware_pause(); \
Expand Down
2 changes: 1 addition & 1 deletion src/firehose/firehose_inline_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
})

#define firehose_atomic_max2o(p, f, v, m) ({ \
typeof((p)->f) _old; \
__typeof__((p)->f) _old; \
firehose_atomic_maxv2o(p, f, v, &_old, m); \
})

Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ void
_dispatch_temporary_resource_shortage(void)
{
sleep(1);
asm(""); // prevent tailcall
__asm__ __volatile__(""); // prevent tailcall
}

void *
Expand Down
10 changes: 5 additions & 5 deletions src/inline_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
// type_t * {volatile,const,_Atomic,...} -> type_t *
// type_t[] -> type_t *
#define os_unqualified_pointer_type(expr) \
typeof(typeof(*(expr)) *)
__typeof__(__typeof__(*(expr)) *)

#define os_mpsc_node_type(q, _ns) \
os_unqualified_pointer_type((q)->_ns##_head)
Expand Down Expand Up @@ -1525,7 +1525,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
_dispatch_wait_until(os_atomic_load2o(_n, _o_next, dependency))

#define os_mpsc_pop_head(q, _ns, head, _o_next) ({ \
typeof(q) _q = (q); \
__typeof__(q) _q = (q); \
os_mpsc_node_type(_q, _ns) _head = (head), _n; \
_n = os_atomic_load2o(_head, _o_next, dependency); \
os_atomic_store2o(_q, _ns##_head, _n, relaxed); \
Expand All @@ -1540,7 +1540,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
})

#define os_mpsc_undo_pop_head(q, _ns, head, next, _o_next) ({ \
typeof(q) _q = (q); \
__typeof__(q) _q = (q); \
os_mpsc_node_type(_q, _ns) _head = (head), _n = (next); \
if (unlikely(!_n && \
!os_atomic_cmpxchg2o(_q, _ns##_tail, NULL, _head, relaxed))) { \
Expand All @@ -1551,7 +1551,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
})

#define os_mpsc_capture_snapshot(q, _ns, tail) ({ \
typeof(q) _q = (q); \
__typeof__(q) _q = (q); \
os_mpsc_node_type(_q, _ns) _head = os_mpsc_get_head(q, _ns); \
os_atomic_store2o(_q, _ns##_head, NULL, relaxed); \
/* 22708742: set tail to NULL with release, so that NULL write */ \
Expand All @@ -1568,7 +1568,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
_n; })

#define os_mpsc_prepend(q, _ns, head, tail, _o_next) ({ \
typeof(q) _q = (q); \
__typeof__(q) _q = (q); \
os_mpsc_node_type(_q, _ns) _head = (head), _tail = (tail), _n; \
os_atomic_store2o(_tail, _o_next, NULL, relaxed); \
if (unlikely(!os_atomic_cmpxchg2o(_q, _ns##_tail, NULL, _tail, release))) { \
Expand Down
20 changes: 10 additions & 10 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
/* I wish we had __builtin_expect_range() */
#if __GNUC__
#define _safe_cast_to_long(x) \
({ _Static_assert(sizeof(typeof(x)) <= sizeof(long), \
({ _Static_assert(sizeof(__typeof__(x)) <= sizeof(long), \
"__builtin_expect doesn't support types wider than long"); \
(long)(x); })
#define fastpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
#define slowpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), 0l))
#define fastpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
#define slowpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), 0l))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
Expand Down Expand Up @@ -455,7 +455,7 @@ void _dispatch_log(const char *msg, ...);
if (__builtin_constant_p(e)) { \
dispatch_static_assert(e); \
} else { \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(DISPATCH_DEBUG && !_e)) { \
_dispatch_abort(__LINE__, (long)_e); \
} \
Expand All @@ -479,7 +479,7 @@ _dispatch_assert(long e, size_t line)
if (__builtin_constant_p(e)) { \
dispatch_static_assert(e); \
} else { \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(DISPATCH_DEBUG && _e)) { \
_dispatch_abort(__LINE__, (long)_e); \
} \
Expand All @@ -502,7 +502,7 @@ _dispatch_assert_zero(long e, size_t line)
*/
#if __GNUC__
#define dispatch_assume(e) ({ \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(!_e)) { \
if (__builtin_constant_p(e)) { \
dispatch_static_assert(e); \
Expand All @@ -527,7 +527,7 @@ _dispatch_assume(long e, long line)
*/
#if __GNUC__
#define dispatch_assume_zero(e) ({ \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(_e)) { \
if (__builtin_constant_p(e)) { \
dispatch_static_assert(e); \
Expand All @@ -554,7 +554,7 @@ _dispatch_assume_zero(long e, long line)
if (__builtin_constant_p(e)) { \
dispatch_static_assert(e); \
} else { \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(DISPATCH_DEBUG && !_e)) { \
_dispatch_log("%s() 0x%lx: " msg, __func__, (long)_e, ##args); \
abort(); \
Expand All @@ -563,7 +563,7 @@ _dispatch_assume_zero(long e, long line)
} while (0)
#else
#define dispatch_debug_assert(e, msg, args...) do { \
typeof(e) _e = (e); /* always eval 'e' */ \
__typeof__(e) _e = (e); /* always eval 'e' */ \
if (unlikely(DISPATCH_DEBUG && !_e)) { \
_dispatch_log("%s() 0x%lx: " msg, __FUNCTION__, _e, ##args); \
abort(); \
Expand Down Expand Up @@ -594,7 +594,7 @@ _dispatch_object_debug(dispatch_object_t object, const char *message, ...);
((dispatch_function_t)((struct Block_layout *)bb)->invoke)
void *_dispatch_Block_copy(void *block);
#if __GNUC__
#define _dispatch_Block_copy(x) ((typeof(x))_dispatch_Block_copy(x))
#define _dispatch_Block_copy(x) ((__typeof__(x))_dispatch_Block_copy(x))
#endif
void _dispatch_call_block_and_release(void *block);
#endif /* __BLOCKS__ */
Expand Down
4 changes: 2 additions & 2 deletions src/introspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ dispatch_introspection_hooks_s _dispatch_introspection_hook_callouts_enabled = {
(slowpath(_dispatch_introspection_hooks.h))

#define DISPATCH_INTROSPECTION_HOOK_CALLOUT(h, ...) ({ \
typeof(_dispatch_introspection_hooks.h) _h; \
__typeof__(_dispatch_introspection_hooks.h) _h; \
_h = _dispatch_introspection_hooks.h; \
if (slowpath((void*)(_h) != DISPATCH_INTROSPECTION_NO_HOOK)) { \
_h(__VA_ARGS__); \
} })

#define DISPATCH_INTROSPECTION_INTERPOSABLE_HOOK(h) \
DISPATCH_EXPORT void _dispatch_introspection_hook_##h(void) \
asm("_dispatch_introspection_hook_" #h); \
__asm__("_dispatch_introspection_hook_" #h); \
void _dispatch_introspection_hook_##h(void) {}

#define DISPATCH_INTROSPECTION_INTERPOSABLE_HOOK_CALLOUT(h, ...)\
Expand Down
6 changes: 3 additions & 3 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ enum {
};

#define _dispatch_io_Block_copy(x) \
((typeof(x))_dispatch_Block_copy((dispatch_block_t)(x)))
((__typeof__(x))_dispatch_Block_copy((dispatch_block_t)(x)))

#pragma mark -
#pragma mark dispatch_io_debug
Expand Down Expand Up @@ -211,7 +211,7 @@ static struct dispatch_io_defaults_s {
};

#define _dispatch_iocntl_set_default(p, v) do { \
dispatch_io_defaults.p = (typeof(dispatch_io_defaults.p))(v); \
dispatch_io_defaults.p = (__typeof__(dispatch_io_defaults.p))(v); \
} while (0)

void
Expand Down Expand Up @@ -1829,7 +1829,7 @@ _dispatch_stream_cleanup_operations(dispatch_stream_t stream,
{
// On stream queue
dispatch_operation_t op, tmp;
typeof(*stream->operations) *operations;
__typeof__(*stream->operations) *operations;
operations = &stream->operations[DISPATCH_IO_RANDOM];
TAILQ_FOREACH_SAFE(op, operations, operation_list, tmp) {
if (!channel || op->channel == channel) {
Expand Down
8 changes: 4 additions & 4 deletions src/object_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#if USE_OBJC
#define DISPATCH_OBJC_CLASS_DECL(name) \
extern void *DISPATCH_CLASS_SYMBOL(name) \
asm(DISPATCH_CLASS_RAW_SYMBOL_NAME(name))
__asm__(DISPATCH_CLASS_RAW_SYMBOL_NAME(name))
#endif

// define a new proper class
Expand All @@ -65,7 +65,7 @@
}; \
OS_OBJECT_EXTRA_VTABLE_DECL(name, name) \
extern const struct name##_vtable_s OS_OBJECT_CLASS_SYMBOL(name) \
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))

#if OS_OBJECT_SWIFT3
#define OS_OBJECT_INTERNAL_CLASS_DECL(name, super, ...) \
Expand Down Expand Up @@ -101,7 +101,7 @@
struct name##_s; \
OS_OBJECT_EXTRA_VTABLE_DECL(name, super) \
extern const struct super##_vtable_s OS_OBJECT_CLASS_SYMBOL(name) \
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))

#define DISPATCH_SUBCLASS_DECL(name, super) \
OS_OBJECT_SUBCLASS_DECL(dispatch_##name, super)
Expand Down Expand Up @@ -590,7 +590,7 @@ size_t _dispatch_objc_debug(dispatch_object_t dou, char* buf, size_t bufsiz);
* reached -1.
*/
#define _os_atomic_refcnt_perform2o(o, f, op, n, m) ({ \
typeof(o) _o = (o); \
__typeof__(o) _o = (o); \
int _ref_cnt = _o->f; \
if (fastpath(_ref_cnt != _OS_OBJECT_GLOBAL_REFCNT)) { \
_ref_cnt = os_atomic_##op##2o(_o, f, n, m); \
Expand Down
4 changes: 2 additions & 2 deletions src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -2248,9 +2248,9 @@ _dispatch_pthread_root_queue_create(const char *label, unsigned long flags,
sizeof(struct dispatch_root_queue_context_s) +
sizeof(struct dispatch_pthread_root_queue_context_s));
qc = (void*)dq + dqs;
dispatch_assert((uintptr_t)qc % _Alignof(typeof(*qc)) == 0);
dispatch_assert((uintptr_t)qc % _Alignof(__typeof__(*qc)) == 0);
pqc = (void*)qc + sizeof(struct dispatch_root_queue_context_s);
dispatch_assert((uintptr_t)pqc % _Alignof(typeof(*pqc)) == 0);
dispatch_assert((uintptr_t)pqc % _Alignof(__typeof__(*pqc)) == 0);
if (label) {
const char *tmp = _dispatch_strdup_if_mutable(label);
if (tmp != label) {
Expand Down
2 changes: 1 addition & 1 deletion src/shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void __builtin_trap(void);

#if __has_feature(c_static_assert)
#define __dispatch_is_array(x) \
_Static_assert(!__builtin_types_compatible_p(typeof((x)[0]) *, typeof(x)), \
_Static_assert(!__builtin_types_compatible_p(__typeof__((x)[0]) *, __typeof__(x)), \
#x " isn't an array")
#define countof(x) \
({ __dispatch_is_array(x); sizeof(x) / sizeof((x)[0]); })
Expand Down
8 changes: 4 additions & 4 deletions src/shims/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
#define os_atomic(type) type _Atomic

#define _os_atomic_c11_atomic(p) \
((typeof(*(p)) _Atomic *)(p))
((__typeof__(*(p)) _Atomic *)(p))

// This removes the _Atomic and volatile qualifiers on the type of *p
#define _os_atomic_basetypeof(p) \
typeof(atomic_load_explicit(_os_atomic_c11_atomic(p), memory_order_relaxed))
__typeof__(atomic_load_explicit(_os_atomic_c11_atomic(p), memory_order_relaxed))

#define os_atomic_load(p, m) \
atomic_load_explicit(_os_atomic_c11_atomic(p), memory_order_##m)
Expand All @@ -71,7 +71,7 @@
#define _os_atomic_c11_op(p, v, m, o, op) \
({ _os_atomic_basetypeof(p) _v = (v), _r = \
atomic_fetch_##o##_explicit(_os_atomic_c11_atomic(p), _v, \
memory_order_##m); (typeof(*(p)))(_r op _v); })
memory_order_##m); (__typeof__(*(p)))(_r op _v); })
#define _os_atomic_c11_op_orig(p, v, m, o, op) \
atomic_fetch_##o##_explicit(_os_atomic_c11_atomic(p), v, \
memory_order_##m)
Expand Down Expand Up @@ -156,7 +156,7 @@

#define os_atomic_rmw_loop(p, ov, nv, m, ...) ({ \
bool _result = false; \
typeof(p) _p = (p); \
__typeof__(p) _p = (p); \
ov = os_atomic_load(_p, relaxed); \
do { \
__VA_ARGS__; \
Expand Down
6 changes: 3 additions & 3 deletions src/shims/atomic_sfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max)
"mov %[_all_ones], %[_bit]" "\n\t"
"3: \n\t"
: [_p] "=m" (*p), [_val] "=&r" (val), [_bit] "=&r" (bit)
: [_all_ones] "i" ((typeof(bit))UINT_MAX) : "memory", "cc");
: [_all_ones] "i" ((__typeof__(bit))UINT_MAX) : "memory", "cc");
} else {
__asm__ (
"1: \n\t"
Expand All @@ -68,8 +68,8 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max)
"mov %[_all_ones], %[_bit]" "\n\t"
"3: \n\t"
: [_p] "=m" (*p), [_val] "=&r" (val), [_bit] "=&r" (bit)
: [_all_ones] "i" ((typeof(bit))UINT_MAX),
[_max] "g" ((typeof(bit))max) : "memory", "cc");
: [_all_ones] "i" ((__typeof__(bit))UINT_MAX),
[_max] "g" ((__typeof__(bit))max) : "memory", "cc");
}
return (unsigned int)bit;
}
Expand Down
Loading