Skip to content

Commit 2df80a3

Browse files
authored
Merge pull request swiftlang#233 from amboar/master
lock: Avoid use of undefined DISPATCH_INTERNAL_CRASH
2 parents 3da8398 + d53fe63 commit 2df80a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: src/shims/lock.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,17 @@ _dispatch_once_xchg_done(dispatch_once_t *pred)
548548
return os_atomic_xchg(pred, DLOCK_ONCE_DONE, release);
549549
#elif defined(__linux__)
550550
if (unlikely(syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0) < 0)) {
551-
DISPATCH_INTERNAL_CRASH(errno, "sys_membarrier not supported");
551+
/*
552+
* sys_membarrier not supported
553+
*
554+
* Ideally we would call DISPATCH_INTERNAL_CRASH() here, but
555+
* due to ordering constraints in internal.h required by Darwin
556+
* the macro is undefined when this header is included.
557+
* Instead, open-code what would be a call to
558+
* _dispatch_hardware_crash() inside DISPATCH_INTERNAL_CRASH().
559+
*/
560+
__asm__("");
561+
__builtin_trap();
552562
}
553563
return os_atomic_xchg(pred, DLOCK_ONCE_DONE, relaxed);
554564
#else

0 commit comments

Comments
 (0)