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