diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-01-31 21:38:54 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-04 00:34:46 +0100 |
commit | e7a833f32307dcffcd7370acde6ab5eeaecb704c (patch) | |
tree | 10a64ed053193b0304a22f50e43137c8757e525f | |
parent | a14a1c32f10ef3ca69682be15c5e8a92488f7f25 (diff) | |
download | sparse-e7a833f32307dcffcd7370acde6ab5eeaecb704c.tar.gz |
lib.c: move predefines out of handle_arch_m64_finalize()
In handle_arch_m64_finalize(), some types (like size_t_ctype)
are set to support the flag '-m64' and native 64-bit archs.
But some predefines are also issued.
As a preparatory step to fix a bug related to a inconstency
between this function and init_target(), move the predefines
to predefined_macros().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Tested-by: Uwe Kleine-König <uwe@kleine-koenig.org>
-rw-r--r-- | lib.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -477,11 +477,9 @@ static void handle_arch_m64_finalize(void) switch (arch_m64) { case ARCH_X32: max_int_alignment = 8; - predefine("__ILP32__", 1, "1"); - predefine("_ILP32", 1, "1"); int64_ctype = &llong_ctype; uint64_ctype = &ullong_ctype; - goto case_x86_64; + break; case ARCH_LP32: /* default values */ int64_ctype = &llong_ctype; @@ -496,8 +494,6 @@ static void handle_arch_m64_finalize(void) ssize_t_ctype = &long_ctype; intmax_ctype = &long_ctype; uintmax_ctype = &ulong_ctype; - predefine("__LP64__", 1, "1"); - predefine("_LP64", 1, "1"); goto case_64bit_common; case ARCH_LLP64: bits_in_long = 32; @@ -506,17 +502,10 @@ static void handle_arch_m64_finalize(void) ssize_t_ctype = &llong_ctype; int64_ctype = &llong_ctype; uint64_ctype = &ullong_ctype; - predefine("__LLP64__", 1, "1"); goto case_64bit_common; case_64bit_common: bits_in_pointer = 64; pointer_alignment = 8; - /* fall through */ - case_x86_64: -#if defined(__x86_64__) || defined(__x86_64) - predefine("__x86_64__", 1, "1"); - predefine("__x86_64", 1, "1"); -#endif break; } } @@ -1347,6 +1336,29 @@ static void predefined_macros(void) // Temporary hacks predefine("__extension__", 0, NULL); predefine("__pragma__", 0, NULL); + + switch (arch_m64) { + case ARCH_LP32: + break; + case ARCH_X32: + predefine("__ILP32__", 1, "1"); + predefine("_ILP32", 1, "1"); + break; + case ARCH_LP64: + predefine("__LP64__", 1, "1"); + predefine("_LP64", 1, "1"); + break; + case ARCH_LLP64: + predefine("__LLP64__", 1, "1"); + break; + } + + if (arch_m64 != ARCH_LP32) { +#if defined(__x86_64__) || defined(__x86_64) + predefine("__x86_64__", 1, "1"); + predefine("__x86_64", 1, "1"); +#endif + } } static void create_builtin_stream(void) |