diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-05 15:41:06 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-14 00:07:02 +0200 |
commit | a0ce077c9fa91fb440e0d38cab33ec232a0375f8 (patch) | |
tree | d03fa89402da5b55b7a42539917ce9a5fc422a26 | |
parent | 7f4170c8d5dc20aa930f0195fd64aca79fe40a16 (diff) | |
download | sparse-a0ce077c9fa91fb440e0d38cab33ec232a0375f8.tar.gz |
arch: allow target specific [u]intptr_t & ptrdiff_t
These types are aliased to size_t & ssize_t but this is not
correct for all architectures.
So, add a variable for them so that target files can adjust them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | predefine.c | 6 | ||||
-rw-r--r-- | symbol.c | 7 | ||||
-rw-r--r-- | symbol.h | 3 | ||||
-rw-r--r-- | target-h8300.c | 2 | ||||
-rw-r--r-- | target-s390.c | 3 | ||||
-rw-r--r-- | target-sh.c | 2 | ||||
-rw-r--r-- | target.c | 3 | ||||
-rw-r--r-- | target.h | 3 |
8 files changed, 23 insertions, 6 deletions
diff --git a/predefine.c b/predefine.c index 60ecc707..7120d438 100644 --- a/predefine.c +++ b/predefine.c @@ -165,9 +165,9 @@ void predefined_macros(void) predefined_ctype("INTMAX", intmax_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); predefined_ctype("UINTMAX", uintmax_ctype, PTYPE_MAX|PTYPE_TYPE); - predefined_ctype("INTPTR", ssize_t_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); - predefined_ctype("UINTPTR", size_t_ctype, PTYPE_MAX|PTYPE_TYPE); - predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); + predefined_ctype("INTPTR", intptr_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); + predefined_ctype("UINTPTR", uintptr_ctype, PTYPE_MAX|PTYPE_TYPE); + predefined_ctype("PTRDIFF", ptrdiff_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("SIZE", size_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("POINTER", &ptr_ctype, PTYPE_SIZEOF); predefined_ctype("SIG_ATOMIC", sig_atomic_ctype, PTYPE_MAX|PTYPE_MIN|PTYPE_TYPE|PTYPE_WIDTH); @@ -899,4 +899,11 @@ void init_ctype(void) char_ctype.ctype.modifiers |= MOD_UNSIGNED; char_ctype.ctype.modifiers &= ~MOD_SIGNED; } + + if (!ptrdiff_ctype) + ptrdiff_ctype = ssize_t_ctype; + if (!intptr_ctype) + intptr_ctype = ssize_t_ctype; + if (!uintptr_ctype) + uintptr_ctype = size_t_ctype; } @@ -304,9 +304,6 @@ extern struct symbol float128_ctype; extern struct symbol const_void_ctype, const_char_ctype; extern struct symbol const_ptr_ctype, const_string_ctype; -#define uintptr_ctype size_t_ctype -#define intptr_ctype ssize_t_ctype - /* Special internal symbols */ extern struct symbol zero_int; diff --git a/target-h8300.c b/target-h8300.c index 84d168b7..c3652350 100644 --- a/target-h8300.c +++ b/target-h8300.c @@ -5,6 +5,8 @@ static void init_h8300(const struct target *self) { + intptr_ctype = &int_ctype; + uintptr_ctype = &uint_ctype; ssize_t_ctype = &long_ctype; size_t_ctype = &ulong_ctype; wchar_ctype = &ushort_ctype; diff --git a/target-s390.c b/target-s390.c index cdbd685a..84889c0a 100644 --- a/target-s390.c +++ b/target-s390.c @@ -6,6 +6,9 @@ static void init_s390(const struct target *self) { + intptr_ctype = &int_ctype; + uintptr_ctype = &uint_ctype; + fast16_ctype = &int_ctype; ufast16_ctype = &uint_ctype; fast32_ctype = &int_ctype; diff --git a/target-sh.c b/target-sh.c index d4ddf455..d3a66180 100644 --- a/target-sh.c +++ b/target-sh.c @@ -7,6 +7,8 @@ static void init_sh(const struct target *self) { int64_ctype = &llong_ctype; uint64_ctype = &ullong_ctype; + intptr_ctype = &int_ctype; + uintptr_ctype = &uint_ctype; fast16_ctype = &int_ctype; ufast16_ctype = &uint_ctype; @@ -5,6 +5,9 @@ #include "target.h" #include "machine.h" +struct symbol *ptrdiff_ctype; +struct symbol *intptr_ctype; +struct symbol *uintptr_ctype; struct symbol *size_t_ctype = &ulong_ctype; struct symbol *ssize_t_ctype = &long_ctype; struct symbol *intmax_ctype = &long_ctype; @@ -5,6 +5,9 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; +extern struct symbol *ptrdiff_ctype; +extern struct symbol *intptr_ctype; +extern struct symbol *uintptr_ctype; extern struct symbol *intmax_ctype; extern struct symbol *uintmax_ctype; extern struct symbol *int64_ctype; |