]> Savannah Git Hosting - gnulib.git/commitdiff
sys_types: Ensure off64_t is defined on all platforms.
authorBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2024 17:46:34 +0000 (19:46 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 27 Apr 2024 18:03:56 +0000 (20:03 +0200)
* 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.

ChangeLog
doc/posix-headers/sys_types.texi
lib/sys_types.in.h
m4/off64_t.m4 [new file with mode: 0644]
m4/sys_types_h.m4
modules/sys_types
tests/test-sys_types.c

index e341b629682aecab28bddb5bb9ee9e02dc965e4a..8467f57a50b0a8eeed4e5456e7a04e13b391cfe2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-04-27  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2024-04-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        nullptr: work around GCC 14 nullptr sentinel bug
index 8739cc2625d6062414bb4c65937594db537ee7c3..f30d8b9d79ede8549528c89fd15c33b7c6cb1bd7 100644 (file)
@@ -20,6 +20,9 @@ MSVC 14.
 The type @code{mode_t} is not defined on some platforms:
 MSVC 14.
 @item
+The type @code{off64_t} is not defined on some platforms:
+macOS 12.5, FreeBSD 10.4, NetBSD 10.0, OpenBSD 7.5, MSVC 14, Cygwin, Haiku, Minix 3.3.
+@item
 Some systems leak definitions of @code{major}, @code{minor}, and
 @code{makedev} through this header; however, when
 @file{sys/sysmacros.h} exists, that file should also be included to
index 0a0ccc3c3791171425b77395ee002eceb4bc9f87..4eb2e926960aceaf5e1f899ff3928a7007cd9110 100644 (file)
 # define _GL_WINDOWS_64_BIT_OFF_T 1
 #endif
 
+/* Define the off64_t type.  */
+#if !@HAVE_OFF64_T@
+# if !GNULIB_defined_off64_t
+/* Define off64_t to int64_t always.  */
+typedef long long off64_t;
+#  define GNULIB_defined_off64_t 1
+# endif
+#endif
+
 /* Override dev_t and ino_t if distinguishable inodes support is requested
    on native Windows.  */
 #if @WINDOWS_STAT_INODES@
diff --git a/m4/off64_t.m4 b/m4/off64_t.m4
new file mode 100644 (file)
index 0000000..34fa21e
--- /dev/null
@@ -0,0 +1,31 @@
+# off64_t.m4
+# serial 1
+dnl Copyright (C) 2024 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Check whether <sys/types.h> defines the 'off64_t' type.
+dnl Set HAVE_OFF64_T.
+
+AC_DEFUN([gl_TYPE_OFF64_T],
+[
+  dnl Persuade glibc <sys/types.h>, <stdio.h>, <fcntl.h>, <unistd.h>, <aio.h>
+  dnl to define off64_t.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CACHE_CHECK([for off64_t], [gl_cv_off64_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>]],
+          [[int x = sizeof (off64_t *) + sizeof (off64_t);
+            return !x;]])],
+       [gl_cv_off64_t=yes], [gl_cv_off64_t=no])])
+
+  if test $gl_cv_off64_t != no; then
+    HAVE_OFF64_T=1
+  else
+    HAVE_OFF64_T=0
+  fi
+  AC_SUBST([HAVE_OFF64_T])
+])
index 00d2437b0346bbea39dde282f17420b68cbc85ee..7c7f26552729f1a3bede987aeadcf34d74fbee2b 100644 (file)
@@ -1,5 +1,5 @@
 # sys_types_h.m4
-# serial 13
+# serial 14
 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,6 +23,9 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
   dnl Whether to override the 'off_t' type.
   AC_REQUIRE([gl_TYPE_OFF_T])
 
+  dnl Whether to define the 'off64_t' type.
+  AC_REQUIRE([gl_TYPE_OFF64_T])
+
   dnl Whether to override the 'dev_t' and 'ino_t' types.
   m4_ifdef([gl_WINDOWS_STAT_INODES], [
     AC_REQUIRE([gl_WINDOWS_STAT_INODES])
index 96849aa3b1772e2bb741b2551498a2876c8980ca..3518b17dbe6d3afbf5b68b120f19241bc5745114 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/sys_types.in.h
 m4/sys_types_h.m4
 m4/off_t.m4
+m4/off64_t.m4
 m4/pid_t.m4
 
 Depends-on:
@@ -12,6 +13,9 @@ gen-header
 include_next
 ssize_t
 
+configure.ac-early:
+AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
 configure.ac:
 gl_SYS_TYPES_H
 gl_SYS_TYPES_H_REQUIRE_DEFAULTS
@@ -31,6 +35,7 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
              -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+             -e 's|@''HAVE_OFF64_T''@|$(HAVE_OFF64_T)|g' \
              -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
              $(srcdir)/sys_types.in.h > $@-t
        $(AM_V_at)mv $@-t $@
index f661a921539f4e443e663c853f2d9a5870b3e94e..46da846ef253c1bf361b62acf9c134aa1ebfd42f 100644 (file)
@@ -26,6 +26,7 @@ size_t t2;
 ssize_t t3;
 off_t t4;
 mode_t t5;
+off64_t t6;
 
 int
 main (void)