Skip to content

Commit c768564

Browse files
compnerdktopley-apple
authored andcommitted
use reserved spelling for inline assembly
Use the reserved spelling for `asm` as it is a non-standard compiler extension. Rather than trying to enumerate the user label prefix on the various targets, rely on the compiler. The GNU compilers define `__USER_LABEL_PREFIX__` to "_" as appropriate. In the case that you are using a non-GNU compiler, it is possible to specify the macro according to your target. This simplifies and unifies the code. Signed-off-by: Daniel A. Steffen <[email protected]>
1 parent 037637a commit c768564

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
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/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/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/introspection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ dispatch_introspection_hooks_s _dispatch_introspection_hook_callouts_enabled = {
447447

448448
#define DISPATCH_INTROSPECTION_INTERPOSABLE_HOOK(h) \
449449
DISPATCH_EXPORT void _dispatch_introspection_hook_##h(void) \
450-
asm("_dispatch_introspection_hook_" #h); \
450+
__asm__("_dispatch_introspection_hook_" #h); \
451451
void _dispatch_introspection_hook_##h(void) {}
452452

453453
#define DISPATCH_INTROSPECTION_INTERPOSABLE_HOOK_CALLOUT(h, ...)\

src/object_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#if USE_OBJC
5151
#define DISPATCH_OBJC_CLASS_DECL(name) \
5252
extern void *DISPATCH_CLASS_SYMBOL(name) \
53-
asm(DISPATCH_CLASS_RAW_SYMBOL_NAME(name))
53+
__asm__(DISPATCH_CLASS_RAW_SYMBOL_NAME(name))
5454
#endif
5555

5656
// define a new proper class
@@ -65,7 +65,7 @@
6565
}; \
6666
OS_OBJECT_EXTRA_VTABLE_DECL(name, name) \
6767
extern const struct name##_vtable_s OS_OBJECT_CLASS_SYMBOL(name) \
68-
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
68+
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
6969

7070
#if OS_OBJECT_SWIFT3
7171
#define OS_OBJECT_INTERNAL_CLASS_DECL(name, super, ...) \
@@ -101,7 +101,7 @@
101101
struct name##_s; \
102102
OS_OBJECT_EXTRA_VTABLE_DECL(name, super) \
103103
extern const struct super##_vtable_s OS_OBJECT_CLASS_SYMBOL(name) \
104-
asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
104+
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
105105

106106
#define DISPATCH_SUBCLASS_DECL(name, super) \
107107
OS_OBJECT_SUBCLASS_DECL(dispatch_##name, super)

src/source.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ _dispatch_source_timer_telemetry(dispatch_source_t ds, dispatch_clock_t clock,
12201220
if (_dispatch_trace_timer_configure_enabled() ||
12211221
_dispatch_source_timer_telemetry_enabled()) {
12221222
_dispatch_source_timer_telemetry_slow(ds, clock, values);
1223-
asm(""); // prevent tailcall
1223+
__asm__ __volatile__ (""); // prevent tailcall
12241224
}
12251225
}
12261226

0 commit comments

Comments
 (0)