Skip to content

Commit 2d6d1fd

Browse files
authored
Merge pull request #334 from compnerd/reserved-asm
use reserved spelling for inline assembly
2 parents dc01e36 + cfa1ad8 commit 2d6d1fd

23 files changed

+90
-94
lines changed

os/object_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#endif
8787
#define OS_OBJECT_OBJC_CLASS_DECL(name) \
8888
extern void *OS_OBJECT_CLASS_SYMBOL(name) \
89-
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
89+
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
9090
#else
9191
#define OS_OBJECT_HAVE_OBJC1 0
9292
#define OS_OBJECT_HAVE_OBJC2 0

src/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
285285
.dc_ctxt = ctxt,
286286
.dc_data = dq,
287287
};
288-
dispatch_apply_t da = (typeof(da))_dispatch_continuation_alloc();
288+
dispatch_apply_t da = (__typeof__(da))_dispatch_continuation_alloc();
289289
da->da_index = 0;
290290
da->da_todo = iterations;
291291
da->da_iterations = iterations;

src/block.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ extern "C" {
109109
// The compiler hides the name of the function it generates, and changes it if
110110
// we try to reference it directly, but the linker still sees it.
111111
extern void DISPATCH_BLOCK_SPECIAL_INVOKE(void *)
112-
#if defined(__linux__) || defined(__FreeBSD__)
113-
asm("___dispatch_block_create_block_invoke");
114-
#else
115-
asm("____dispatch_block_create_block_invoke");
116-
#endif
112+
__asm__(OS_STRINGIFY(__USER_LABEL_PREFIX__) "___dispatch_block_create_block_invoke");
117113
void (*_dispatch_block_special_invoke)(void*) = DISPATCH_BLOCK_SPECIAL_INVOKE;
118114
}
119115

src/event/event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ _dispatch_unote_create(dispatch_source_type_t dst,
4949
du->du_can_be_wlh = dst->dst_per_trigger_qos;
5050
du->du_ident = (uint32_t)handle;
5151
du->du_filter = dst->dst_filter;
52-
du->du_fflags = (typeof(du->du_fflags))mask;
52+
du->du_fflags = (__typeof__(du->du_fflags))mask;
5353
if (dst->dst_flags & EV_UDATA_SPECIFIC) {
5454
du->du_is_direct = true;
5555
}

src/event/event_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
#if DISPATCH_TIMER_ASSERTIONS
6262
#define DISPATCH_TIMER_ASSERT(a, op, b, text) ({ \
63-
typeof(a) _a = (a); \
63+
__typeof__(a) _a = (a); \
6464
if (unlikely(!(_a op (b)))) { \
6565
DISPATCH_CLIENT_CRASH(_a, "Timer: " text); \
6666
} \

src/event/event_kevent.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define DISPATCH_KEVENT_MUXED_MARKER 1ul
3333
#define DISPATCH_MACH_AUDIT_TOKEN_PID (5)
3434

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

3737
typedef struct dispatch_muxnote_s {
3838
TAILQ_ENTRY(dispatch_muxnote_s) dmn_list;
@@ -738,9 +738,9 @@ _dispatch_kq_unote_set_kevent(dispatch_unote_t _du, dispatch_kevent_t dk,
738738
.flags = flags,
739739
.udata = (dispatch_kevent_udata_t)du,
740740
.fflags = du->du_fflags | dst->dst_fflags,
741-
.data = (typeof(dk->data))dst->dst_data,
741+
.data = (__typeof__(dk->data))dst->dst_data,
742742
#if DISPATCH_USE_KEVENT_QOS
743-
.qos = (typeof(dk->qos))pp,
743+
.qos = (__typeof__(dk->qos))pp,
744744
#endif
745745
};
746746
(void)pp; // if DISPATCH_USE_KEVENT_QOS == 0
@@ -1778,7 +1778,7 @@ _dispatch_mach_notify_update(dispatch_muxnote_t dmn, uint32_t new_flags,
17781778
mach_port_mscount_t notify_sync)
17791779
{
17801780
mach_port_t previous, port = (mach_port_t)dmn->dmn_kev.ident;
1781-
typeof(dmn->dmn_kev.data) prev = dmn->dmn_kev.data;
1781+
__typeof__(dmn->dmn_kev.data) prev = dmn->dmn_kev.data;
17821782
kern_return_t kr, krr = 0;
17831783

17841784
// Update notification registration state.

src/firehose/firehose_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
#define DISPATCH_PURE_C 1
2929
#define _safe_cast_to_long(x) \
30-
({ _Static_assert(sizeof(typeof(x)) <= sizeof(long), \
30+
({ _Static_assert(sizeof(__typeof__(x)) <= sizeof(long), \
3131
"__builtin_expect doesn't support types wider than long"); \
3232
(long)(x); })
33-
#define fastpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
34-
#define slowpath(x) ((typeof(x))__builtin_expect(_safe_cast_to_long(x), 0l))
33+
#define fastpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), ~0l))
34+
#define slowpath(x) ((__typeof__(x))__builtin_expect(_safe_cast_to_long(x), 0l))
3535
#define os_likely(x) __builtin_expect(!!(x), 1)
3636
#define os_unlikely(x) __builtin_expect(!!(x), 0)
3737
#define likely(x) __builtin_expect(!!(x), 1)
@@ -54,7 +54,7 @@
5454
#endif
5555

5656
#define _dispatch_wait_until(c) ({ \
57-
typeof(c) _c; \
57+
__typeof__(c) _c; \
5858
for (;;) { \
5959
if (likely(_c = (c))) break; \
6060
dispatch_hardware_pause(); \

src/firehose/firehose_inline_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
})
2828

2929
#define firehose_atomic_max2o(p, f, v, m) ({ \
30-
typeof((p)->f) _old; \
30+
__typeof__((p)->f) _old; \
3131
firehose_atomic_maxv2o(p, f, v, &_old, m); \
3232
})
3333

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ void
897897
_dispatch_temporary_resource_shortage(void)
898898
{
899899
sleep(1);
900-
asm(""); // prevent tailcall
900+
__asm__ __volatile__(""); // prevent tailcall
901901
}
902902

903903
void *

src/inline_internal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ _dispatch_queue_drain_try_unlock(dispatch_queue_t dq, uint64_t owned, bool done)
14841484
// type_t * {volatile,const,_Atomic,...} -> type_t *
14851485
// type_t[] -> type_t *
14861486
#define os_unqualified_pointer_type(expr) \
1487-
typeof(typeof(*(expr)) *)
1487+
__typeof__(__typeof__(*(expr)) *)
14881488

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

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

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

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

15701570
#define os_mpsc_prepend(q, _ns, head, tail, _o_next) ({ \
1571-
typeof(q) _q = (q); \
1571+
__typeof__(q) _q = (q); \
15721572
os_mpsc_node_type(_q, _ns) _head = (head), _tail = (tail), _n; \
15731573
os_atomic_store2o(_tail, _o_next, NULL, relaxed); \
15741574
if (unlikely(!os_atomic_cmpxchg2o(_q, _ns##_tail, NULL, _tail, release))) { \

0 commit comments

Comments
 (0)