[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf functions without INT_MAX limitation
From: |
Bruno Haible |
Subject: |
Re: printf functions without INT_MAX limitation |
Date: |
Sat, 27 Apr 2024 20:25:35 +0200 |
Paul Eggert wrote:
> now that you mention off64_t it strikes me that zoff_t would
> basically be off64_t, and off64_t has had its own problems: its only use
> in apps is to deal with deficient libraries, and it is a pain in
> libraries (where its only use is to deal with deficient apps :-). I
> don't offhand see why zoff_t would do any better than off64_t has done,
> or why we would need to give a new name to this unloved type.
You've convinced me to use off64_t instead of zoff_t.
My main argument against off64_t was that it is non-standard. But
- There is no platform where off64_t is different from int64_t.
- off64_t is defined by glibc, and since Gnulib's job is to offer
the APIs provided by glibc portably, as far as possible, below
are two patches that implement off64_t portably.
With that done, there is indeed no reason any more to invent zoff_t.
Some notes:
- In glibc, off64_t is defined in <sys/types.h>, <fcntl.h>, <stdio.h>,
<unistd.h>, <aio.h>.
- In POSIX, off_t is defined in the same header files, and also in
<sys/stat.h> and <sys/mman.h>.
- off64_t is existent and equivalent to 'long long' on
glibc, musl, FreeBSD, AIX, HP-UX, IRIX, Solaris, mingw, Android.
- off64_t is missing on
macOS, FreeBSD ≤ 10, NetBSD, OpenBSD, MSVC, Cygwin, Haiku, Minix.
- The configure.ac-early section is because otherwise I got an
autoconf warning
configure.ac:211: warning: AC_COMPILE_IFELSE was called before
AC_USE_SYSTEM_EXTENSIONS
glm4/off64_t.m4:11: gl_TYPE_OFF64_T is expanded from...
configure.ac:28: gl_INIT is expanded from...
configure.ac:211: the top level
configure.ac:211: warning: AC_CHECK_INCLUDES_DEFAULT was called before
AC_USE_SYSTEM_EXTENSIONS
glm4/off64_t.m4:11: gl_TYPE_OFF64_T is expanded from...
configure.ac:28: gl_INIT is expanded from...
configure.ac:211: the top level
I don't know why this has not already occurred earlier; we have
dozens of modules which require AC_USE_SYSTEM_EXTENSIONS.
2024-04-27 Bruno Haible <bruno@clisp.org>
fcntl-h, stdio, unistd: Ensure off64_t is defined on all platforms.
* lib/fcntl.in.h: Update comment regarding off64_t.
* lib/stdio.in.h: Likewise.
* lib/unistd.in.h: Likewise.
* tests/test-fcntl-h.c: Verify that off64_t is defined.
* tests/test-stdio.c: Likewise.
* tests/test-unistd.c: Likewise.
* doc/posix-headers/fcntl.texi: Mention the off64_t workaround.
* doc/posix-headers/stdio.texi: Likewise.
* doc/posix-headers/unistd.texi: Likewise.
* doc/posix-headers/aio.texi: Mention the problem with off64_t.
sys_types: Ensure off64_t is defined on all platforms.
* m4/off64_t.m4: New file.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Require gl_TYPE_OFF64_T.
* lib/sys_types.in.h (off64_t): New type.
(GNULIB_defined_off64_t): New macro.
* modules/sys_types (Files): Add m4/off64_t.m4.
(configure.ac-early): Require AC_USE_SYSTEM_EXTENSIONS.
(Makefile.am): Substitute HAVE_OFF64_T.
* tests/test-sys_types.c: Verify that off64_t is defined.
* doc/posix-headers/sys_types.texi: Mention the off64_t workaround.
0001-sys_types-Ensure-off64_t-is-defined-on-all-platforms.patch
Description: Text Data
0002-fcntl-h-stdio-unistd-Ensure-off64_t-is-defined-on-al.patch
Description: Text Data