Skip to content

Commit 171fe32

Browse files
authored
Minor fixes for legacy macOS (#699)
* Fallback for missing pthread_threadid_np in macOS * hplatform.h: add powerpc
1 parent 4712d97 commit 171fe32

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

base/hplatform.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#elif defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
1818
#include <TargetConditionals.h>
1919
#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
20+
#include <AvailabilityMacros.h>
2021
#define OS_MAC
2122
#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
2223
#define OS_IOS
@@ -62,6 +63,10 @@
6263
#define ARCH_MIPS
6364
#elif defined(__riscv)
6465
#define ARCH_RISCV
66+
#elif defined(__ppc64__) || defined(__powerpc64__)
67+
#define ARCH_PPC64
68+
#elif defined(__ppc__) || defined(__powerpc__)
69+
#define ARCH_PPC
6570
#else
6671
#warning "Untested hardware architecture!"
6772
#endif
@@ -259,7 +264,8 @@
259264
defined(__MIPSEL) || defined(__MIPS64EL)
260265
#define BYTE_ORDER LITTLE_ENDIAN
261266
#elif defined(__ARMEB__) || defined(__AARCH64EB__) || \
262-
defined(__MIPSEB) || defined(__MIPS64EB)
267+
defined(__MIPSEB) || defined(__MIPS64EB) || \
268+
defined(__ppc__) || defined(__ppc64__)
263269
#define BYTE_ORDER BIG_ENDIAN
264270
#elif defined(OS_WIN)
265271
#define BYTE_ORDER LITTLE_ENDIAN

base/hthread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
#elif defined(OS_DARWIN)
2020
static inline long hv_gettid() {
2121
uint64_t tid = 0;
22+
/* pthread_threadid_np is not available before 10.6 and in 10.6 for ppc */
23+
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 || defined(__POWERPC__)
24+
tid = pthread_mach_thread_np(pthread_self());
25+
#else
2226
pthread_threadid_np(NULL, &tid);
27+
#endif
2328
return tid;
2429
}
2530
#elif HAVE_PTHREAD_H

0 commit comments

Comments
 (0)