From 59f1846249fbbb76e786d1e73e9be5c72a41fefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 13 Mar 2015 10:09:33 +0100 Subject: erts: Restrict GCC intrinsics by compiler version Intrinsics __builtin_clz and __builtin_popcount are only valid on GCC version 3.4 and above. --- erts/emulator/beam/erl_map.c | 3 ++- erts/emulator/beam/erl_map.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'erts') diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c index b7f07fa6c4..964c09e906 100644 --- a/erts/emulator/beam/erl_map.c +++ b/erts/emulator/beam/erl_map.c @@ -2768,7 +2768,7 @@ static Eterm hashmap_bld_tuple_uint(Uint **hpp, Uint *szp, Uint n, Uint nums[]) /* implementation of builtin emulations */ -#if !defined(__GNUC__) +#if !ERTS_AT_LEAST_GCC_VSN__(3, 4, 0) /* Count leading zeros emulation */ Uint32 hashmap_clz(Uint32 x) { Uint32 y; @@ -2780,6 +2780,7 @@ Uint32 hashmap_clz(Uint32 x) { y = x >> 1; if (y != 0) return n - 2; return n - x; } + const Uint32 SK5 = 0x55555555, SK3 = 0x33333333; const Uint32 SKF0 = 0xF0F0F0F, SKFF = 0xFF00FF; diff --git a/erts/emulator/beam/erl_map.h b/erts/emulator/beam/erl_map.h index ff5e6edd1e..d075d87c83 100644 --- a/erts/emulator/beam/erl_map.h +++ b/erts/emulator/beam/erl_map.h @@ -24,7 +24,7 @@ #include "sys.h" /* instrinsic wrappers */ -#if defined(__GNUC__) +#if ERTS_AT_LEAST_GCC_VSN__(3, 4, 0) #define hashmap_clz(x) ((Uint32) __builtin_clz((unsigned int)(x))) #define hashmap_bitcount(x) ((Uint32) __builtin_popcount((unsigned int) (x))) #else -- cgit v1.2.3