summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-10 14:40:35 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-17 21:56:32 +0100
commitfc68f0d6103705f8988d7e94e815ec2260de7017 (patch)
tree200b26fa7a401745e64d5aab6073af2095a817e8
parentf5eabb34da68cddf76cfbfc75c8d1373d327e346 (diff)
downloadsparse-fc68f0d6103705f8988d7e94e815ec2260de7017.tar.gz
add predefined macros for [u]intmax
Seems to use [u]long for all LP64 archs and [u]llong and all LP32 ones (but OpenBSD but it seems to not defines the corresponding macros). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--lib.c6
-rw-r--r--target.c2
-rw-r--r--target.h2
-rw-r--r--validation/preprocessor/predef.c2
4 files changed, 12 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 8dfe10c0..9ff3bcdb 100644
--- a/lib.c
+++ b/lib.c
@@ -474,12 +474,16 @@ static void handle_arch_m64_finalize(void)
goto case_x86_64;
case ARCH_LP32:
/* default values */
+ intmax_ctype = &llong_ctype;
+ uintmax_ctype = &ullong_ctype;
return;
case ARCH_LP64:
bits_in_long = 64;
max_int_alignment = 8;
size_t_ctype = &ulong_ctype;
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;
@@ -1239,6 +1243,8 @@ static void predefined_macros(void)
predefined_sizeof("INT128", "", 128);
+ 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);
diff --git a/target.c b/target.c
index d4329fe5..70d4d3ee 100644
--- a/target.c
+++ b/target.c
@@ -6,6 +6,8 @@
struct symbol *size_t_ctype = &uint_ctype;
struct symbol *ssize_t_ctype = &int_ctype;
+struct symbol *intmax_ctype = &llong_ctype;
+struct symbol *uintmax_ctype = &ullong_ctype;
struct symbol *wchar_ctype = &int_ctype;
struct symbol *wint_ctype = &uint_ctype;
diff --git a/target.h b/target.h
index 998d25af..d764d418 100644
--- a/target.h
+++ b/target.h
@@ -3,6 +3,8 @@
extern struct symbol *size_t_ctype;
extern struct symbol *ssize_t_ctype;
+extern struct symbol *intmax_ctype;
+extern struct symbol *uintmax_ctype;
extern struct symbol *wchar_ctype;
extern struct symbol *wint_ctype;
diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c
index df0944b3..22e89bbc 100644
--- a/validation/preprocessor/predef.c
+++ b/validation/preprocessor/predef.c
@@ -17,6 +17,8 @@ int test(void)
TEST_SMAX(INT, int);
TEST_SMAX(LONG, long);
TEST_SMAX(LONG_LONG, long long);
+ TEST_SMAX(INTMAX, __INTMAX_TYPE__);
+ TEST_UMAX(UINTMAX, __UINTMAX_TYPE__);
TEST_SMAX(INTPTR, __INTPTR_TYPE__);
TEST_UMAX(UINTPTR, __UINTPTR_TYPE__);
TEST_SMAX(PTRDIFF, __PTRDIFF_TYPE__);