From bde9854a8160549029a8e8b7e9d8cf84f84baa0f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 23 Nov 2020 19:51:40 -0600 Subject: [PATCH] vm: Make macos almost compile. To fully compile mach_signal.cpp needs a fix. --- GNUmakefile | 2 +- vm/Config.macosx.arm64 | 2 +- vm/bitwise_hacks.hpp | 12 ++++++++++++ vm/master.hpp | 2 ++ vm/platform.hpp | 5 +++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index a12916cf41..c549b78659 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -188,7 +188,7 @@ macosx-x86-64: macosx-x86-fat: $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.x86.fat -macosx-arm64-64: +macosx-arm64: $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.arm64 linux-arm-64: diff --git a/vm/Config.macosx.arm64 b/vm/Config.macosx.arm64 index 95affb370d..d5f31f153b 100644 --- a/vm/Config.macosx.arm64 +++ b/vm/Config.macosx.arm64 @@ -2,4 +2,4 @@ include vm/Config.macosx include vm/Config.arm64.64 PLAF_DLL_OBJS += vm/cpu-arm.64.cpp -PLAF_MASTER_HEADERS += vm/os-macosx-arm64.64.hpp +PLAF_MASTER_HEADERS += vm/os-macosx-arm64.hpp diff --git a/vm/bitwise_hacks.hpp b/vm/bitwise_hacks.hpp index 8a7078b3dd..5332b8c7b2 100644 --- a/vm/bitwise_hacks.hpp +++ b/vm/bitwise_hacks.hpp @@ -8,6 +8,7 @@ inline cell log2(cell x) { #else asm("bsr %1, %0;" : "=r"(n) : "r"(x)); #endif + #elif defined(FACTOR_AMD64) #if defined(_MSC_VER) n = 0; @@ -15,18 +16,29 @@ inline cell log2(cell x) { #else asm("bsr %1, %0;" : "=r"(n) : "r"(x)); #endif + +#elif defined(FACTOR_ARM64) +#if defined(_MSC_VER) + n = 0; + _BitScanReverse64((unsigned long*)&n, x); +#else + asm("bsr %1, %0;" : "=r"(n) : "r"(x)); +#endif + #elif defined(FACTOR_PPC64) #if defined(__GNUC__) n = (63 - __builtin_clzll(x)); #else #error Unsupported compiler #endif + #elif defined(FACTOR_PPC32) #if defined(__GNUC__) n = (31 - __builtin_clz(x)); #else #error Unsupported compiler #endif + #else #error Unsupported CPU #endif diff --git a/vm/master.hpp b/vm/master.hpp index bac9e5f7ed..dec7c8d677 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -64,6 +64,8 @@ // Detect target CPU type #if defined(__arm__) #define FACTOR_ARM +#elif defined(__aarch64__) +#define FACTOR_ARM64 #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) #define FACTOR_AMD64 #define FACTOR_64 diff --git a/vm/platform.hpp b/vm/platform.hpp index c72b7b6334..3f85a07172 100644 --- a/vm/platform.hpp +++ b/vm/platform.hpp @@ -22,6 +22,8 @@ #include "os-macosx-x86.32.hpp" #elif defined(FACTOR_AMD64) #include "os-macosx-x86.64.hpp" + #elif defined(FACTOR_ARM64) + #include "os-macosx-arm64.hpp" #else #error "Unsupported Mac OS X flavor" #endif @@ -67,6 +69,9 @@ #include "cpu-ppc.hpp" #elif defined(FACTOR_ARM) #include "cpu-arm.hpp" +#elif defined(FACTOR_ARM64) + #include "cpu-arm.64.hpp" + #include "cpu-arm.hpp" #else #error "Unsupported CPU" #endif -- 2.34.1