From ace5874aa41f07d1e3239a4ede58fc528de821d7 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 27 Dec 2025 19:37:15 -0700 Subject: [PATCH] Add Configure probe for size of intmax_t Now that we require C99, we should be able to probe for this Some internal operations can benefit from using the widest type possible on the system, even if IVs and UVs don't use the full width. This data is kept in , which should always be available in C99-compliant build systems. Configure has a 'i_stdint', but it comes much later in Configure than this does. I tried moving it to earlier, but then it relies on stuff that would have to get moved too, and I think that stuff has to be later. It gets complicated trying to deal with this value not existing, as there is a separate unit for 'long long', which would have to be considered. Until and unless some platform comes along that this doesn't work for, I just assume that this C99 construct will work as expected. --- Configure | 11 ++++++++++- Cross/config.sh-arm-linux | 1 + Cross/config.sh-arm-linux-n770 | 1 + Porting/Glossary | 4 ++++ Porting/config.sh | 1 + config_h.SH | 5 +++++ configure.com | 6 ++++++ plan9/config_sh.sample | 1 + win32/config.gc | 1 + win32/config.vc | 1 + 10 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Configure b/Configure index ef2257f43838..27410e8f759c 100755 --- a/Configure +++ b/Configure @@ -1111,6 +1111,7 @@ installprefix='' installprefixexp='' installstyle='' installusrbinperl='' +intmaxsize='' intsize='' longsize='' shortsize='' @@ -5787,12 +5788,14 @@ case "$intsize" in #ifdef I_STDLIB #include #endif +#include #include int main() { printf("intsize=%d;\n", (int)sizeof(int)); printf("longsize=%d;\n", (int)sizeof(long)); printf("shortsize=%d;\n", (int)sizeof(short)); + printf("intmaxsize=%d;\n", (int)sizeof(intmax_t)); exit(0); } EOCP @@ -5802,6 +5805,7 @@ EOCP echo "Your integers are $intsize bytes long." echo "Your long integers are $longsize bytes long." echo "Your short integers are $shortsize bytes long." + echo "Your longest integers are $intmaxsize bytes long." else $cat >&4 <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un * This symbol contains the value of sizeof(short) so that the C * preprocessor can make decisions based on it. */ +/* INTMAXSIZE: + * This symbol contains the value of sizeof(intmax_t) so that the C + * preprocessor can make decisions based on it. + */ #define INTSIZE $intsize /**/ #define LONGSIZE $longsize /**/ #define SHORTSIZE $shortsize /**/ +#define INTMAXSIZE $intmaxsize /**/ /* MULTIARCH: * This symbol, if defined, signifies that the build diff --git a/configure.com b/configure.com index f800aecc6ea0..16ec73f2cf30 100644 --- a/configure.com +++ b/configure.com @@ -3263,6 +3263,7 @@ $ OS $ WS "#if defined(__DECC) || defined(__DECCXX)" $ WS "#include " $ WS "#endif" +$ WS "#include " $ WS "#include " $ WS "int main()" $ WS "{" @@ -5574,6 +5575,10 @@ $ gosub type_size_check $ intsize = tmp $ ENDIF $! +$ tmp = "''intmax_t'" +$ gosub type_size_check +$ intmaxsize = tmp +$! $ tmp = "''u32type'" $ gosub type_size_check $ u32size = tmp @@ -6615,6 +6620,7 @@ $ WC "installsitearch='" + installsitearch + "'" $ WC "installsitebin='" + sitebin + "'" $ WC "installsitelib='" + installsitelib + "'" $ WC "installusrbinperl='undef'" +$ WC "intmaxsize='" + intmaxsize + "'" $ WC "intsize='" + intsize + "'" $ WC "ivdformat='" + ivdformat + "'" $ WC "ivsize='" + ivsize + "'" diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 3da90256ec4a..9b142bd8aab1 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -850,6 +850,7 @@ installusrbinperl='undef' installvendorarch='' installvendorbin='' installvendorlib='' +intmaxsize='8' intsize='4' issymlink='/bin/test -h' ivdformat='"ld"' diff --git a/win32/config.gc b/win32/config.gc index 017c14d30abc..756fc2f406bc 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -862,6 +862,7 @@ installvendorlib='' installvendorman1dir='' installvendorman3dir='' installvendorscript='' +intmaxsize='8' intsize='4' issymlink='' ivdformat='"ld"' diff --git a/win32/config.vc b/win32/config.vc index 77351781cdc7..b13e276ff74d 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -861,6 +861,7 @@ installvendorlib='' installvendorman1dir='' installvendorman3dir='' installvendorscript='' +intmaxsize='8' intsize='4' issymlink='' ivdformat='"ld"'