diff options
author | Sverker Eriksson <[email protected]> | 2017-04-28 14:43:45 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-28 14:43:45 +0200 |
commit | 2e2526b58f74c6c3209b3feca34866772be65335 (patch) | |
tree | dae03bda8fe8418cb874ae2074916f74087b7758 | |
parent | 28d64608d9f9e1d86d34323d1d1646ab17278d64 (diff) | |
parent | 282a7cab9989abb7a1b2daca7aec907d53163ff4 (diff) | |
download | otp-2e2526b58f74c6c3209b3feca34866772be65335.tar.gz otp-2e2526b58f74c6c3209b3feca34866772be65335.tar.bz2 otp-2e2526b58f74c6c3209b3feca34866772be65335.zip |
Merge PR-1431 from richcarl/mseg-debruijn-usage
Rename macro and add clarifying comment
-rw-r--r-- | erts/emulator/sys/common/erl_mseg.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/erts/emulator/sys/common/erl_mseg.c b/erts/emulator/sys/common/erl_mseg.c index d1895f3793..1e99078906 100644 --- a/erts/emulator/sys/common/erl_mseg.c +++ b/erts/emulator/sys/common/erl_mseg.c @@ -83,12 +83,13 @@ static const int debruijn[32] = { 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; -#define LOG2(X) (debruijn[((Uint32)(((X) & -(X)) * 0x077CB531U)) >> 27]) +#define LSB(X) (debruijn[((Uint32)(((X) & -(X)) * 0x077CB531U)) >> 27]) #define CACHE_AREAS (32 - MSEG_ALIGN_BITS) /* FIXME: segment sizes > 2 GB result in bogus negative indices */ -#define SIZE_TO_CACHE_AREA_IDX(S) (LOG2((S)) - MSEG_ALIGN_BITS) +/* NOTE: using LSB instead of proper log2 only works if S is a power of 2 */ +#define SIZE_TO_CACHE_AREA_IDX(S) (LSB((S)) - MSEG_ALIGN_BITS) #define MAX_CACHE_SIZE (30) #define MSEG_FLG_IS_2POW(X) ((X) & ERTS_MSEG_FLG_2POW) |