From 912c450e6e3782151098ee2ab52c5d8046d17c39 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Wed, 1 Apr 2026 19:04:41 +0100 Subject: [PATCH] core: add rosetta support --- core/include/fx/core/thread.h | 2 +- core/sys/rosetta/bitop.c | 16 ++++++++++++++++ core/sys/rosetta/random.c | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 core/sys/rosetta/bitop.c create mode 100644 core/sys/rosetta/random.c diff --git a/core/include/fx/core/thread.h b/core/include/fx/core/thread.h index cf5cab8..54dbee8 100644 --- a/core/include/fx/core/thread.h +++ b/core/include/fx/core/thread.h @@ -5,7 +5,7 @@ #include #include -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__rosetta__) #include #define FX_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER diff --git a/core/sys/rosetta/bitop.c b/core/sys/rosetta/bitop.c new file mode 100644 index 0000000..3653953 --- /dev/null +++ b/core/sys/rosetta/bitop.c @@ -0,0 +1,16 @@ +#include + +int fx_popcountl(long v) +{ + return __builtin_popcountl(v); +} + +int fx_ctzl(long v) +{ + return __builtin_ctzl(v); +} + +int fx_clzl(long v) +{ + return __builtin_clzl(v); +} diff --git a/core/sys/rosetta/random.c b/core/sys/rosetta/random.c new file mode 100644 index 0000000..c748d31 --- /dev/null +++ b/core/sys/rosetta/random.c @@ -0,0 +1,13 @@ +#include +#include +#include + +uint64_t z__fx_platform_random_seed() +{ + return 0; +} + +uint64_t z__fx_platform_random_seed_secure() +{ + return 0; +}