aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-05 15:41:06 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-14 00:07:02 +0200
commita0ce077c9fa91fb440e0d38cab33ec232a0375f8 (patch)
treed03fa89402da5b55b7a42539917ce9a5fc422a26
parent7f4170c8d5dc20aa930f0195fd64aca79fe40a16 (diff)
downloadsparse-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.c6
-rw-r--r--symbol.c7
-rw-r--r--symbol.h3
-rw-r--r--target-h8300.c2
-rw-r--r--target-s390.c3
-rw-r--r--target-sh.c2
-rw-r--r--target.c3
-rw-r--r--target.h3
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);
diff --git a/symbol.c b/symbol.c
index 6ee521ba..c0ca79e4 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 67464d65..c2b60ce9 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 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;
diff --git a/target.c b/target.c
index f320ab52..308386b8 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 5bbce397..8ffd8e88 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;