Skip to content

Commit 98cafa0

Browse files
committed
use reserved spelling for inline assembly
Use the reserved spelling for `asm` as it is a non-standard compiler extension. NFC.
1 parent d36aebc commit 98cafa0

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ extern "C" {
110110
// we try to reference it directly, but the linker still sees it.
111111
extern void DISPATCH_BLOCK_SPECIAL_INVOKE(void *)
112112
#if defined(__linux__) || defined(__FreeBSD__)
113-
asm("___dispatch_block_create_block_invoke");
113+
__asm__("___dispatch_block_create_block_invoke");
114114
#else
115-
asm("____dispatch_block_create_block_invoke");
115+
__asm__("____dispatch_block_create_block_invoke");
116116
#endif
117117
void (*_dispatch_block_special_invoke)(void*) = DISPATCH_BLOCK_SPECIAL_INVOKE;
118118
}

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__(""); // 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__(""); // prevent tailcall
12241224
}
12251225
}
12261226

tests/Foundation/bench.mm

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void __attribute__((noinline))
150150
{
151151
uint32_t lo, hi;
152152

153-
asm volatile("rdtsc" : "=a" (lo), "=d" (hi));
153+
__asm__ volatile("rdtsc" : "=a" (lo), "=d" (hi));
154154

155155
return (uint64_t)hi << 32 | lo;
156156
}
@@ -245,7 +245,7 @@ static void __attribute__((noinline))
245245

246246
s = mach_absolute_time();
247247
for (i = cnt; i; i--) {
248-
asm volatile("");
248+
__asm__ volatile("");
249249
}
250250
print_result(s, "Empty loop:");
251251

@@ -374,69 +374,69 @@ static void __attribute__((noinline))
374374

375375
s = mach_absolute_time();
376376
for (i = cnt; i; i--) {
377-
asm("nop");
377+
__asm__("nop");
378378
}
379379
print_result(s, "raw 'nop':");
380380

381381
#if defined(__i386__) || defined(__x86_64__)
382382
s = mach_absolute_time();
383383
for (i = cnt; i; i--) {
384-
asm("pause");
384+
__asm__("pause");
385385
}
386386
print_result(s, "raw 'pause':");
387387

388388
s = mach_absolute_time();
389389
for (i = cnt; i; i--) {
390-
asm("mfence");
390+
__asm__("mfence");
391391
}
392392
print_result(s, "Atomic mfence:");
393393

394394
s = mach_absolute_time();
395395
for (i = cnt; i; i--) {
396-
asm("lfence");
396+
__asm__("lfence");
397397
}
398398
print_result(s, "Atomic lfence:");
399399

400400
s = mach_absolute_time();
401401
for (i = cnt; i; i--) {
402-
asm("sfence");
402+
__asm__("sfence");
403403
}
404404
print_result(s, "Atomic sfence:");
405405

406406
s = mach_absolute_time();
407407
for (i = cnt; i; i--) {
408408
uint64_t sidt_rval;
409-
asm("sidt %0" : "=m" (sidt_rval));
409+
__asm__("sidt %0" : "=m" (sidt_rval));
410410
}
411411
print_result(s, "'sidt' instruction:");
412412

413413
s = mach_absolute_time();
414414
for (i = cnt; i; i--) {
415415
long prev;
416-
asm volatile("cmpxchg %1,%2"
416+
__asm__ volatile("cmpxchg %1,%2"
417417
: "=a" (prev) : "r" (0l), "m" (global), "0" (1l));
418418
}
419419
print_result(s, "'cmpxchg' without the 'lock' prefix:");
420420

421421
s = mach_absolute_time();
422422
for (i = cnt; i; i--) {
423423
global = 0;
424-
asm volatile("mfence" ::: "memory");
424+
__asm__ volatile("mfence" ::: "memory");
425425
}
426426
print_result(s, "Store + mfence:");
427427

428428
s = mach_absolute_time();
429429
for (i = cnt; i; i--) {
430430
unsigned long _clbr;
431431
#ifdef __LP64__
432-
asm volatile("cpuid" : "=a" (_clbr)
432+
__asm__ volatile("cpuid" : "=a" (_clbr)
433433
: "0" (0) : "rbx", "rcx", "rdx", "cc", "memory");
434434
#else
435435
#ifdef __llvm__
436-
asm volatile("cpuid" : "=a" (_clbr) : "0" (0)
436+
__asm__ volatile("cpuid" : "=a" (_clbr) : "0" (0)
437437
: "ebx", "ecx", "edx", "cc", "memory" );
438438
#else // gcc does not allow inline i386 asm to clobber ebx
439-
asm volatile("pushl %%ebx\n\tcpuid\n\tpopl %%ebx"
439+
__asm__ volatile("pushl %%ebx\n\tcpuid\n\tpopl %%ebx"
440440
: "=a" (_clbr) : "0" (0) : "ecx", "edx", "cc", "memory" );
441441
#endif
442442
#endif
@@ -454,35 +454,35 @@ asm volatile("pushl %%ebx\n\tcpuid\n\tpopl %%ebx"
454454
#ifdef _ARM_ARCH_7
455455
s = mach_absolute_time();
456456
for (i = cnt; i; i--) {
457-
asm("yield");
457+
__asm__("yield");
458458
}
459459
print_result(s, "raw 'yield':");
460460
#endif
461461

462462
s = mach_absolute_time();
463463
for (i = cnt; i; i--) {
464464
#ifdef _ARM_ARCH_7
465-
asm volatile("dmb ish" : : : "memory");
465+
__asm__ volatile("dmb ish" : : : "memory");
466466
#else
467-
asm volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
467+
__asm__ volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
468468
#endif
469469
}
470470
print_result(s, "'dmb ish' instruction:");
471471

472472
#ifdef _ARM_ARCH_7
473473
s = mach_absolute_time();
474474
for (i = cnt; i; i--) {
475-
asm volatile("dmb ishst" : : : "memory");
475+
__asm__ volatile("dmb ishst" : : : "memory");
476476
}
477477
print_result(s, "'dmb ishst' instruction:");
478478
#endif
479479

480480
#ifdef _ARM_ARCH_7
481481
s = mach_absolute_time();
482482
for (i = cnt; i; i--) {
483-
asm volatile("str %[_r], [%[_p], %[_o]]" :
483+
__asm__ volatile("str %[_r], [%[_p], %[_o]]" :
484484
: [_p] "p" (&global), [_o] "M" (0), [_r] "r" (0) : "memory");
485-
asm volatile("dmb ishst" : : : "memory");
485+
__asm__ volatile("dmb ishst" : : : "memory");
486486
}
487487
print_result(s, "'str + dmb ishst' instructions:");
488488
#endif
@@ -493,10 +493,10 @@ asm volatile("str %[_r], [%[_p], %[_o]]" :
493493
uintptr_t prev;
494494
uint32_t t;
495495
do {
496-
asm volatile("ldrex %[_r], [%[_p], %[_o]]"
496+
__asm__ volatile("ldrex %[_r], [%[_p], %[_o]]"
497497
: [_r] "=&r" (prev) \
498498
: [_p] "p" (&global), [_o] "M" (0) : "memory");
499-
asm volatile("strex %[_t], %[_r], [%[_p], %[_o]]"
499+
__asm__ volatile("strex %[_t], %[_r], [%[_p], %[_o]]"
500500
: [_t] "=&r" (t) \
501501
: [_p] "p" (&global), [_o] "M" (0), [_r] "r" (0) : "memory");
502502
} while (t);
@@ -507,26 +507,26 @@ asm volatile("strex %[_t], %[_r], [%[_p], %[_o]]"
507507
s = mach_absolute_time();
508508
for (i = cnt; i; i--) {
509509
#ifdef _ARM_ARCH_7
510-
asm volatile("dsb ish" : : : "memory");
510+
__asm__ volatile("dsb ish" : : : "memory");
511511
#else
512-
asm volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory");
512+
__asm__ volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory");
513513
#endif
514514
}
515515
print_result(s, "'dsb ish' instruction:");
516516

517517
#if BENCH_SLOW
518518
s = mach_absolute_time();
519519
for (i = cnt; i; i--) {
520-
register long _swtch_pri asm("ip") = -59;
521-
asm volatile("svc 0x80" : : "r" (_swtch_pri) : "r0", "memory");
520+
register long _swtch_pri __asm__("ip") = -59;
521+
__asm__ volatile("svc 0x80" : : "r" (_swtch_pri) : "r0", "memory");
522522
}
523523
print_result(s, "swtch_pri syscall:");
524524

525525
s = mach_absolute_time();
526526
for (i = cnt; i; i--) {
527-
register long _r0 asm("r0") = 0, _r1 asm("r1") = 1, _r2 asm("r2") = 1;
528-
register long _thread_switch asm("ip") = -61;
529-
asm volatile("svc 0x80" : "+r" (_r0)
527+
register long _r0 __asm__("r0") = 0, _r1 __asm__("r1") = 1, _r2 __asm__("r2") = 1;
528+
register long _thread_switch __asm__("ip") = -61;
529+
__asm__ volatile("svc 0x80" : "+r" (_r0)
530530
: "r" (_r1), "r" (_r2), "r" (_thread_switch): "memory");
531531
}
532532
print_result(s, "thread_switch syscall:");
@@ -636,9 +636,9 @@ asm volatile("svc 0x80" : "+r" (_r0)
636636
while (!__sync_bool_compare_and_swap(&global, 0, 1)) {
637637
do {
638638
#if defined(__i386__) || defined(__x86_64__)
639-
asm("pause");
639+
__asm__("pause");
640640
#elif defined(__arm__) && defined _ARM_ARCH_7
641-
asm("yield");
641+
__asm__("yield");
642642
#endif
643643
} while (global);
644644
}

0 commit comments

Comments
 (0)