diff options
author | Richard Carlsson <[email protected]> | 2017-04-27 14:44:10 +0200 |
---|---|---|
committer | Richard Carlsson <[email protected]> | 2017-04-27 14:48:40 +0200 |
commit | 282a7cab9989abb7a1b2daca7aec907d53163ff4 (patch) | |
tree | ae66254176af7dd2d8e48668cdcd178521dd4636 /erts/emulator/sys/common | |
parent | d9c2e78d4e7b6166245e79a70bd4d95c8a1b742a (diff) | |
download | otp-282a7cab9989abb7a1b2daca7aec907d53163ff4.tar.gz otp-282a7cab9989abb7a1b2daca7aec907d53163ff4.tar.bz2 otp-282a7cab9989abb7a1b2daca7aec907d53163ff4.zip |
Rename macro and add clarifying comment
The macro previously named 'LOG2' is in fact computing the LSB (not the MSB)
of its input, and can only be used to compute log2(n) when n is is a power
of 2, that is, when its LSB is also its MSB.
Diffstat (limited to 'erts/emulator/sys/common')
-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) |