[PATCH v2 10/14] add predefined macros for [u]intmax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 lib.c                            | 6 ++++++
 target.c                         | 2 ++
 target.h                         | 2 ++
 validation/preprocessor/predef.c | 2 ++
 4 files changed, 12 insertions(+)

diff --git a/lib.c b/lib.c
index b030e17e4..0a0655784 100644
--- a/lib.c
+++ b/lib.c
@@ -493,12 +493,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;
@@ -1262,6 +1266,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 57866c337..8178450c4 100644
--- a/target.c
+++ b/target.c
@@ -5,6 +5,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 998d25af5..d764d4182 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 df0944b33..22e89bbc0 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__);
-- 
2.19.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux