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). --- 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 6a6133499..4cf769b1d 100644 --- a/lib.c +++ b/lib.c @@ -492,12 +492,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; @@ -1260,6 +1264,8 @@ static void predefined_macros(void) predefined_ctype("UINTPTR", size_t_ctype, PTYPE_TYPE|PTYPE_MAX); predefined_ctype("INTPTR", ssize_t_ctype, PTYPE_TYPE|PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL|PTYPE_T); + predefined_ctype("INTMAX", intmax_ctype, PTYPE_TYPE|PTYPE_MAX); + predefined_ctype("UINTMAX", uintmax_ctype, PTYPE_TYPE|PTYPE_MAX); predefined_sizeof("POINTER", "", bits_in_pointer); predefined_sizeof("FLOAT", "", bits_in_float); diff --git a/target.c b/target.c index e09eff865..0b95e484f 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; /* diff --git a/target.h b/target.h index 74f51ffeb..684b8420a 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; /* diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index e14c04d7b..301d1ed0f 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -17,6 +17,8 @@ int test(void) TEST_MAX(PTRDIFF, __PTRDIFF_TYPE__); TEST_MAX(INTPTR, __INTPTR_TYPE__); TEST_MAX(UINTPTR, __UINTPTR_TYPE__); + TEST_MAX(INTMAX, __INTMAX_TYPE__); + TEST_MAX(UINTMAX, __UINTMAX_TYPE__); #define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 TEST_SIZEOF(SHORT, short); -- 2.19.0