Skip to content

Commit 8aa52e2

Browse files
compnerdparkera
authored andcommitted
Halt (#372)
* Base: collapse two CPP branches The two branches are identical and just define the same macro on different architectures. Collapse them to simplify. Yes, Windows is supported on all those architectures. * Base: tweak __builtin_unreachable on Windows Windows could be using a GNU compatible compiler (i.e. clang). In such a scenario, assume that __builtin_unreachable() is available (any newer clang or gcc would suffice). However, since we require clang for swift, it makes sense to require clang for Foundation build. The minimal require clang already has __builtin_unreachable supported. On a non-GNU-like compiler, use the MSVC intrinsic `__assume` which gives a proper `__builtin_unreachable` equivalent. * Base: spell DebugBreak __builtin_trap Use another macro to make the two cases more similar. NFC.
1 parent 182d5c9 commit 8aa52e2

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,17 @@ CF_PRIVATE CFIndex __CFActiveProcessorCount();
158158
#endif
159159

160160
#if DEPLOYMENT_TARGET_WINDOWS
161-
#define __builtin_unreachable() do { } while (0)
161+
#if !defined(__GNUC__)
162+
#define __builtin_trap() DebugBreak()
163+
#define __builtin_unreachable() __assume(0)
164+
#endif
162165
#endif
163166

164-
#if defined(__i386__) || defined(__x86_64__)
165-
#if defined(__GNUC__)
166-
#define HALT do {__builtin_trap(); kill(getpid(), 9); __builtin_unreachable(); } while (0)
167-
#elif defined(_MSC_VER)
168-
#define HALT do { DebugBreak(); abort(); __builtin_unreachable(); } while (0)
169-
#else
170-
#error Compiler not supported
171-
#endif
172-
#elif defined(__ppc__) || (__arm__) || (__aarch64__)
167+
#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || (__arm__) || (__aarch64__)
173168
#if defined(__GNUC__)
174169
#define HALT do {__builtin_trap(); kill(getpid(), 9); __builtin_unreachable(); } while (0)
175170
#elif defined(_MSC_VER)
176-
#define HALT do { DebugBreak(); abort(); __builtin_unreachable(); } while (0)
171+
#define HALT do { __builtin_trap(); abort(); __builtin_unreachable(); } while (0)
177172
#else
178173
#error Compiler not supported
179174
#endif

0 commit comments

Comments
 (0)