blob: f8b2182c750db5ef9f4498e3f223e9d4517041ec [file] [log] [blame]
From 392719612558fad818ab021db3628c25e763564d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Sun, 26 Apr 2020 04:59:35 +0300
Subject: [PATCH] Use __builtin_ffs instead of ffs (#554)
USE_BUILTIN_FFS is defined to 1 within __GNUC__, and the __builtin_ffs
function is available since GCC 3.x at least, while the ffs function
only exists on some OSes.
This fixes compilation for non-x86 mingw platforms. For x86,
USE_BUILTIN_FFS is explicitly disabled for windows targets - but
if USE_BUILTIN_FFS is enabled based on __GNUC__, it should also use
the builtin which actually is available correspondingly, not dependent
on the target OS.
---
src/dlmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dlmalloc.c b/src/dlmalloc.c
index d63dd36..1aba657 100644
--- a/src/dlmalloc.c
+++ b/src/dlmalloc.c
@@ -2371,7 +2371,7 @@ static size_t traverse_and_check(mstate m);
#else /* GNUC */
#if USE_BUILTIN_FFS
-#define compute_bit2idx(X, I) I = ffs(X)-1
+#define compute_bit2idx(X, I) I = __builtin_ffs(X)-1
#else /* USE_BUILTIN_FFS */
#define compute_bit2idx(X, I)\
--
2.30.0.windows.2