aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_hashmap.h
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-01-21 16:08:17 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 19:15:25 +0100
commit0d10df770cfd1407bb79c31da34108dda1b868a5 (patch)
treefc928d9ef3e768a98e691734c531dc9b3f1bf68c /erts/emulator/beam/erl_hashmap.h
parent3cdd2d25859275fd0bc2111c52a8bbd2505ff048 (diff)
downloadotp-0d10df770cfd1407bb79c31da34108dda1b868a5.tar.gz
otp-0d10df770cfd1407bb79c31da34108dda1b868a5.tar.bz2
otp-0d10df770cfd1407bb79c31da34108dda1b868a5.zip
erts: Add fallback for builtin clz
* __builtin_clz may not exist * fix bitcount fallback
Diffstat (limited to 'erts/emulator/beam/erl_hashmap.h')
-rw-r--r--erts/emulator/beam/erl_hashmap.h17
1 files changed, 4 insertions, 13 deletions
diff --git a/erts/emulator/beam/erl_hashmap.h b/erts/emulator/beam/erl_hashmap.h
index 8ba249b053..1964787218 100644
--- a/erts/emulator/beam/erl_hashmap.h
+++ b/erts/emulator/beam/erl_hashmap.h
@@ -40,21 +40,12 @@ int hashmap_key_hash_cmp(Eterm* ap, Eterm* bp);
/* HASH */
-
#if defined(__GNUC__)
-#define hashmap_bitcount(x) (Uint32) __builtin_popcount((unsigned int) (x))
+#define hashmap_clz(x) ((Uint32) __builtin_clz((unsigned int)(x)))
+#define hashmap_bitcount(x) ((Uint32) __builtin_popcount((unsigned int) (x)))
#else
-const Uint32 SK5 = 0x55555555, SK3 = 0x33333333;
-const Uint32 SKF0 = 0xF0F0F0F, SKFF = 0xFF00FF;
-
-/* CTPOP emulation */
-Uint32 hashmap_bitcount(Uint32 map) {
- map -= (( map >> 1 ) & SK5 );
- map = ( map & SK3 ) + (( map >> 2 ) & SK3 );
- map = ( map & SKF0 ) + (( map >> 4 ) & SKF0);
- map += map >> 8;
- return ( map + ( map >> 16)) & 0x3F;
-}
+Uint32 hashmap_clz(Uint32 x);
+Uint32 hashmap_bitcount(Uint32 x);
#endif
/* hamt nodes v2.0