diff options
author | Lukas Larsson <[email protected]> | 2013-02-08 10:24:18 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2013-02-13 14:08:50 +0100 |
commit | fc8ed627b5dc77cc294fcd207378cf803ba3f3dd (patch) | |
tree | 88b4eda4ea22f1ad29705d5e83f9c0780f2e0579 /erts/emulator/sys/common | |
parent | ddf8881308b27f308aa456bef3e4833bc0383413 (diff) | |
download | otp-fc8ed627b5dc77cc294fcd207378cf803ba3f3dd.tar.gz otp-fc8ed627b5dc77cc294fcd207378cf803ba3f3dd.tar.bz2 otp-fc8ed627b5dc77cc294fcd207378cf803ba3f3dd.zip |
Use macros instead of constants
This is needed as C90 (and therefore the win32 compiler) does
not allow constants to be calculations based on other constants.
Diffstat (limited to 'erts/emulator/sys/common')
-rw-r--r-- | erts/emulator/sys/common/erl_sys_common_misc.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c index 5523b6fc0b..6cdf7ca0ed 100644 --- a/erts/emulator/sys/common/erl_sys_common_misc.c +++ b/erts/emulator/sys/common/erl_sys_common_misc.c @@ -125,11 +125,20 @@ sys_double_to_chars(double fp, char *buffer, size_t buffer_size) * if compact != 0, the trailing 0's will be truncated */ int -sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals, int compact) +sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals, + int compact) { - /* Note that some C compilers don't support "static const double" propagation into - * arrays so we use a define */ + /* Note that some C compilers don't support "static const" propagation + * so we use a defines */ #define SYS_DOUBLE_RND_CONST 0.55555555555555555 + #define FRAC_SIZE 52 + #define EXP_SIZE 11 + #define EXP_MASK ((1ll << EXP_SIZE) - 1) + #define MAX_DECIMALS (sizeof(cs_sys_double_pow10) \ + / sizeof(cs_sys_double_pow10[0])) + #define FRAC_MASK ((1ll << FRAC_SIZE) - 1) + #define FRAC_MASK2 ((1ll << (FRAC_SIZE + 1)) - 1) + #define MAX_FLOAT (1ll << (FRAC_SIZE+1)) static const double cs_sys_double_pow10[] = { SYS_DOUBLE_RND_CONST / 1ll, @@ -153,15 +162,6 @@ sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals, SYS_DOUBLE_RND_CONST / 1000000000000000000ll }; - static const int FRAC_SIZE = 52; - static const int EXP_SIZE = 11; - static const int EXP_MASK = (1ll << EXP_SIZE) - 1; - static const int MAX_DECIMALS = sizeof(cs_sys_double_pow10) / sizeof(cs_sys_double_pow10[0]); - - static const long long FRAC_MASK = (1ll << FRAC_SIZE) - 1; - static const long long FRAC_MASK2 = (1ll << (FRAC_SIZE + 1)) - 1; - static const long long MAX_FLOAT = 1ll << (FRAC_SIZE+1); - long long mantissa, int_part = 0, frac_part = 0; short exp; int max; |