diff options
author | Björn Gustavsson <[email protected]> | 2019-03-05 12:28:57 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-03-06 15:42:43 +0100 |
commit | 405aca76c4bbc47352788858bf0c0749fb1f730d (patch) | |
tree | ef29c8f25e987174d7c042f7214539d14bdf62b5 /erts/emulator | |
parent | b96e5bd87c6aaaf96fa9c6e3679d95df74d1a499 (diff) | |
download | otp-405aca76c4bbc47352788858bf0c0749fb1f730d.tar.gz otp-405aca76c4bbc47352788858bf0c0749fb1f730d.tar.bz2 otp-405aca76c4bbc47352788858bf0c0749fb1f730d.zip |
sys.h: Check for overflow checking aritmethic builtins
Let sys.h define HAVE_OVERFLOW_CHECK_BUILTINS if the compiler supports
__builtin_mul_overflow() and the other overflow checking builtins.
The test is intentionally made in a sys.h and not as a configure test.
On Windows, beam_emu.c is always compiled using gcc, but the other
files are usually compiled with Microsoft's C compiler. With the
test in the header file, HAVE_OVERFLOW_CHECK_BUILTINS will be defined
when compiling beam_emu.c.
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/sys.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h index a69da4d762..a6312293cc 100644 --- a/erts/emulator/beam/sys.h +++ b/erts/emulator/beam/sys.h @@ -111,6 +111,23 @@ #endif #endif +/* + * Test for clang's convenient __has_builtin feature checking macro. + */ +#ifndef __has_builtin + #define __has_builtin(x) 0 +#endif + +/* + * Define HAVE_OVERFLOW_CHECK_BUILTINS if the overflow checking arithmetic + * builtins are available. + */ +#if ERTS_AT_LEAST_GCC_VSN__(5, 1, 0) +# define HAVE_OVERFLOW_CHECK_BUILTINS 1 +#elif __has_builtin(__builtin_mul_overflow) +# define HAVE_OVERFLOW_CHECK_BUILTINS 1 +#endif + #include "erl_misc_utils.h" /* |