diff --git a/src/co/co.cc b/src/co/co.cc index ebbec011c..08aad350a 100644 --- a/src/co/co.cc +++ b/src/co/co.cc @@ -8,6 +8,9 @@ #include // for clock_gettime #else #include // for gettimeofday +#ifndef __APPLE__ +#include // for getting proper threadid on modern BSDs but not Mac OSX +#endif #endif #endif @@ -100,7 +103,11 @@ uint32 thread_id() { return syscall(SYS_gettid); } #else /* for mac, bsd.. */ uint32 thread_id() { uint64 x; +#ifdef __APPLE__ pthread_threadid_np(0, &x); +#else + x = pthread_getthreadid_np(); +#endif return (uint32)x; } #endif diff --git a/src/co/context/arch.h b/src/co/context/arch.h index 27ab8af69..0b36920cc 100644 --- a/src/co/context/arch.h +++ b/src/co/context/arch.h @@ -53,6 +53,19 @@ defined(__mips__) #define ARCH_MIPS +#elif defined(loongarch) || \ + defined(_loongarch) || \ + defined(_loongarch64) || \ + defined(__loongarch__) + #define ARCH_LOONGARCH + +#elif defined(riscv) || \ + defined(_riscv) || \ + defined(_riscv64) || \ + defined(__riscv__) + #define ARCH_RISCV + + #else #error unknown arch #endif @@ -115,6 +128,8 @@ defined(__PPC64__) || \ defined(__ppc64__) || \ defined(__powerpc64__) || \ + defined(__loongarch64) || \ + defined(__riscv64) || \ defined(_M_X64) || \ defined(_M_AMD64) || \ defined(_M_IA64) || \