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@xxxxxxxxx> --- predefine.c | 6 +++--- symbol.c | 7 +++++++ symbol.h | 3 --- target-h8300.c | 2 ++ target-s390.c | 3 +++ target-sh.c | 2 ++ target.c | 3 +++ target.h | 3 +++ 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/predefine.c b/predefine.c index 60ecc7070045..7120d4381f16 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); diff --git a/symbol.c b/symbol.c index 6ee521ba48d8..c0ca79e42e96 100644 --- a/symbol.c +++ b/symbol.c @@ -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; } diff --git a/symbol.h b/symbol.h index 67464d659cc2..c2b60ce91c27 100644 --- a/symbol.h +++ b/symbol.h @@ -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 84d168b7410a..c3652350bac7 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 cdbd685a2099..84889c0aa7ad 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 d4ddf45504cf..d3a66180a0aa 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; diff --git a/target.c b/target.c index f320ab525dfb..308386b8fa7d 100644 --- a/target.c +++ b/target.c @@ -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; diff --git a/target.h b/target.h index 5bbce397bba5..8ffd8e882906 100644 --- a/target.h +++ b/target.h @@ -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; -- 2.27.0