summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-09 18:01:37 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-17 22:50:06 +0100
commitb56185087a198788ab03b6b7c22e2a08afdc5e2d (patch)
tree552a5392121d0a3ae5b564c59ba4329620de0131
parent841a80bb813e6a9d424193dd6cf7fbef70f7feb6 (diff)
downloadsparse-b56185087a198788ab03b6b7c22e2a08afdc5e2d.tar.gz
add predefined macros for [u]int32_t
These are a pain. All LP64 archs use [u]int. Good. But some LP32 archs use [u]int and some others use [u]long. Some even use [u]int for some ABI and [u]long for some others (bare metal). This really need to be target-specific to be correct. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--lib.c2
-rw-r--r--target.c19
-rw-r--r--target.h2
-rw-r--r--validation/preprocessor/predef.c2
4 files changed, 25 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 0241c24c..3803a8e4 100644
--- a/lib.c
+++ b/lib.c
@@ -1251,6 +1251,8 @@ static void predefined_macros(void)
predefined_ctype("UINT8", &uchar_ctype, PTYPE_MAX|PTYPE_TYPE);
predefined_ctype("INT16", &short_ctype, PTYPE_MAX|PTYPE_TYPE);
predefined_ctype("UINT16", &ushort_ctype, PTYPE_MAX|PTYPE_TYPE);
+ predefined_ctype("INT32", int32_ctype, PTYPE_MAX|PTYPE_TYPE);
+ predefined_ctype("UINT32", uint32_ctype, PTYPE_MAX|PTYPE_TYPE);
predefined_ctype("INT64", int64_ctype, PTYPE_MAX|PTYPE_TYPE);
predefined_ctype("UINT64", uint64_ctype, PTYPE_MAX|PTYPE_TYPE);
diff --git a/target.c b/target.c
index 666d24ef..12cd219a 100644
--- a/target.c
+++ b/target.c
@@ -10,6 +10,8 @@ struct symbol *intmax_ctype = &llong_ctype;
struct symbol *uintmax_ctype = &ullong_ctype;
struct symbol *int64_ctype = &long_ctype;
struct symbol *uint64_ctype = &ulong_ctype;
+struct symbol *int32_ctype = &int_ctype;
+struct symbol *uint32_ctype = &uint_ctype;
struct symbol *wchar_ctype = &int_ctype;
struct symbol *wint_ctype = &uint_ctype;
@@ -74,6 +76,23 @@ void init_target(void)
break;
}
+ switch (arch_mach) {
+ case MACH_MIPS64:
+ if (arch_m64 == ARCH_LP64)
+ break;
+ /* fall through */
+ case MACH_M68K:
+ case MACH_SPARC32:
+ case MACH_PPC32:
+ case MACH_MIPS32:
+ case MACH_RISCV32:
+ int32_ctype = &long_ctype;
+ uint32_ctype = &ulong_ctype;
+ break;
+ default:
+ break;
+ }
+
#if defined(__CYGWIN__)
wchar_ctype = &ushort_ctype;
#endif
diff --git a/target.h b/target.h
index 7b1d9649..8bbe494f 100644
--- a/target.h
+++ b/target.h
@@ -7,6 +7,8 @@ extern struct symbol *intmax_ctype;
extern struct symbol *uintmax_ctype;
extern struct symbol *int64_ctype;
extern struct symbol *uint64_ctype;
+extern struct symbol *int32_ctype;
+extern struct symbol *uint32_ctype;
extern struct symbol *wchar_ctype;
extern struct symbol *wint_ctype;
diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c
index f00a471f..5678aced 100644
--- a/validation/preprocessor/predef.c
+++ b/validation/preprocessor/predef.c
@@ -21,6 +21,8 @@ int test(void)
TEST_MAX(UINT8, 0xffU);
TEST_MAX( INT16, 0x7fff);
TEST_MAX(UINT16, 0xffffU);
+ TEST_MAX( INT32, 0x7fffffff);
+ TEST_MAX(UINT32, 0xffffffffU);
TEST_MAX( INT64, 0x7fffffffffffffffLL);
TEST_MAX(UINT64, 0xffffffffffffffffULL);
TEST_SMAX(INTMAX, __INTMAX_TYPE__);