Skip to content

Commit

Permalink
Try harder to define FFS correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
augustss committed Oct 6, 2024
1 parent def8252 commit 2d84d9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/runtime/config-unix-32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
//#define WORD_SIZE 32

#undef FFS
#if _POSIX_VERSION >= 200112L
#define FFS ffs
#endif

12 changes: 11 additions & 1 deletion src/runtime/config-unix-64.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@

/*
* Find First Set
* This macro must be defined.
* This macro should be defined.
* It returns the number of the least significant bit that is set.
* Numberings starts from 1. If no bit is set, it should return 0.
*/
#if defined(__gnu_linux__) || defined(__APPLE__) || defined(__FreeBSD__)
/* Only some platforms have 64 bit ffsl function directly. */
#define FFS ffsl
#elif defined(__GNUC__)
/* GCC has ffsl as a builtin. */
#define FFS __builtin_ffsl
/* CLANG has ffsl as a builtin. */
#elif defined(__clang__) && __has_builtin(__builtin__ffsl)
#define FFS __builtin_ffsl
#endif


/*
* This is the character used for comma-separation in printf.
Expand Down

0 comments on commit 2d84d9d

Please sign in to comment.