diff options
-rwxr-xr-x | configure | 19 | ||||
-rw-r--r-- | ffi.c | 18 | ||||
-rw-r--r-- | stdlib/doc-syms.tl | 18 | ||||
-rw-r--r-- | txr.1 | 16 |
4 files changed, 62 insertions, 9 deletions
@@ -1571,6 +1571,25 @@ then printf "typedef superulong_t double_uintptr_t;\n" >> config.h fi +printf "Checking for intmax_t ... " +cat > conftest.c <<! +#include <inttypes.h> + +int main(void) +{ + intmax_t i = 0; + untmax_t u = 0; + return (uintmax_t) i + u; +} +! + +if conftest ; then + printf "yes\n" + printf "#define HAVE_INTMAX_T 1\n" >> config.h +else + printf "no\n" +fi + # # Endianness. # @@ -38,6 +38,9 @@ #include <wchar.h> #include <time.h> #include "config.h" +#if HAVE_INTMAX_T +#include <stdint.h> +#endif #if HAVE_LIBFFI #include <ffi.h> #endif @@ -4702,6 +4705,21 @@ static void ffi_init_extra_types(void) ffi_typedef(intern(lit("wint-t"), user_package), type_by_size[convert(wint_t, -1) > 0][sizeof (wint_t)]); + { +#if HAVE_INTMAX_T + typedef intmax_t imax_t; +#else + typedef long long imax_t; +#endif + + if (sizeof(imax_t) <= 8) { + ffi_typedef(intern(lit("intmax-t"), user_package), + type_by_size[0][sizeof (imax_t)]); + ffi_typedef(intern(lit("uintmax-t"), user_package), + type_by_size[1][sizeof (imax_t)]); + } + } + #if HAVE_SYS_TYPES_H ffi_typedef(intern(lit("blkcnt-t"), user_package), type_by_size[convert(blkcnt_t, -1) > 0][sizeof (blkcnt_t)]); diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl index 34e139b6..179ce5e1 100644 --- a/stdlib/doc-syms.tl +++ b/stdlib/doc-syms.tl @@ -331,7 +331,7 @@ ("clear-struct" "N-03A968CA") ("clearhash" "N-00836D97") ("clocal" "N-01B1B5DF") - ("clock-t" "N-00AB2580") + ("clock-t" "N-01B6F219") ("clockid-t" "N-01153D9E") ("close" "D-0016") ("close-stream" "N-00596930") @@ -1007,7 +1007,7 @@ ("int-chr" "N-000AEC8B") ("int-cptr" "N-01768FB9") ("int-flo" "N-03F852CF") - ("int-ptr-t" "N-00AB2580") + ("int-ptr-t" "N-01B6F219") ("int-str" "N-028043AE") ("int16" "N-03D0AA7B") ("int32" "N-03D0AA7B") @@ -1018,6 +1018,7 @@ ("intern-fb" "N-02722B58") ("interp-fun-p" "N-00AC0CF7") ("interpose" "N-0030734D") + ("intmax-t" "N-01B6F219") ("inv-cum-norm" "N-0036EAFB") ("invoke-catch" "N-0337FC1B") ("ip" "N-011CFC0C") @@ -1494,7 +1495,7 @@ ("ptr-out" "N-03D4DF7E") ("ptr-out-d" "N-02036BEC") ("ptr-out-s" "N-02D36BEC") - ("ptrdiff-t" "N-00AB2580") + ("ptrdiff-t" "N-01B6F219") ("pure-rel-path-p" "N-019DEA44") ("purge-deferred-warning" "N-0077C4FE") ("push" "N-01C211C1") @@ -1735,7 +1736,7 @@ ("shut-wr" "N-028953A4") ("sig-abrt" "N-0176430F") ("sig-alrm" "N-0176430F") - ("sig-atomic-t" "N-00AB2580") + ("sig-atomic-t" "N-01B6F219") ("sig-bus" "N-0176430F") ("sig-check" "N-0360A99A") ("sig-chld" "N-0176430F") @@ -1774,7 +1775,7 @@ ("sin" "D-000B") ("sinh" "D-0066") ("sixth" "N-01B0FA33") - ("size-t" "N-00AB2580") + ("size-t" "N-01B6F219") ("size-vec" "N-01000634") ("sizeof" "N-0235DCAE") ("skip" "N-021FCB7C") @@ -1986,7 +1987,7 @@ ("time-string-utc" "N-00F192AD") ("time-struct-local" "N-00B758FD") ("time-struct-utc" "N-00B758FD") - ("time-t" "N-00AB2580") + ("time-t" "N-01B6F219") ("time-usec" "N-03B6DB3D") ("time-utc" "N-001284ED") ("tmpfile" "N-00FF7C41") @@ -2067,11 +2068,12 @@ ("uint" "N-0235F4E4") ("uint-buf" "N-00DCFA5F") ("uint-carray" "N-00797A01") - ("uint-ptr-t" "N-00AB2580") + ("uint-ptr-t" "N-01B6F219") ("uint16" "N-03D0AA7B") ("uint32" "N-03D0AA7B") ("uint64" "N-03D0AA7B") ("uint8" "N-0131FBF2") + ("uintmax-t" "N-01B6F219") ("ulong" "N-0235F4E4") ("ulonglong" "N-02299408") ("umask" "N-0068D92E") @@ -2172,7 +2174,7 @@ ("window-map" "N-015AFD48") ("window-mapdo" "N-015AFD48") ("window-mappend" "N-015AFD48") - ("wint-t" "N-00AB2580") + ("wint-t" "N-01B6F219") ("with" "N-03098987") ("with-clobber-expander" "N-0181ED4C") ("with-compilation-unit" "N-013AAB51") @@ -80783,10 +80783,24 @@ the most strictly alignment member of the structure. The alignment of all other bitfields is ignored. .SS* Additional Types -.coNP FFI types @, size-t @, ptrdiff-t @, int-ptr-t @, uint-ptr-t @, wint-t @, sig-atomic-t @ time-t and @ clock-t +.coNP FFI types @, size-t @, ptrdiff-t @, int-ptr-t @, uint-ptr-t @, intmax-t @, uintmax-t @ wint-t @, sig-atomic-t @ time-t and @ clock-t +.desc These additional FFI types for common C language types are provided as .code typedef aliases. +The +.code intmax-t +and +.code uintmax-t +types are provided only if the host platform's +.code intmax_t +is no wider than 64 bits. If the host platform lacks +.code intmax_t +then the above two FFI types are defined as aliases for +.code longlong +and +.codn ulonglong , +respectively. .coNP FFI type @ qref .synb |