From 46d3ded0f69e0cc28d7d0c098385c705e63c4ffc Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 14 Nov 2024 18:32:58 +0000 Subject: [PATCH] core: add bitop implementations for darwin and linux --- core/sys/darwin/bitop.c | 16 ++++++++++++++++ core/sys/linux/bitop.c | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 core/sys/darwin/bitop.c create mode 100644 core/sys/linux/bitop.c diff --git a/core/sys/darwin/bitop.c b/core/sys/darwin/bitop.c new file mode 100644 index 0000000..141f252 --- /dev/null +++ b/core/sys/darwin/bitop.c @@ -0,0 +1,16 @@ +#include + +int b_popcountl(long v) +{ + return __builtin_popcountl(v); +} + +int b_ctzl(long v) +{ + return __builtin_ctzl(v); +} + +int b_clzl(long v) +{ + return __builtin_clzl(v); +} diff --git a/core/sys/linux/bitop.c b/core/sys/linux/bitop.c new file mode 100644 index 0000000..141f252 --- /dev/null +++ b/core/sys/linux/bitop.c @@ -0,0 +1,16 @@ +#include + +int b_popcountl(long v) +{ + return __builtin_popcountl(v); +} + +int b_ctzl(long v) +{ + return __builtin_ctzl(v); +} + +int b_clzl(long v) +{ + return __builtin_clzl(v); +}