Discussion:
largefile: improve and document
Bruno Haible
2017-05-13 01:04:05 UTC
Permalink
The 'largefile' module already supports native Windows since 2012.
This patch improves it: on mingw, with _FILE_OFFSET_BITS set to 64,
there is no need to redefine off_t since mingw already defines it to
a 64-bit type.


2017-05-13 Bruno Haible <***@clisp.org>

largefile: Improve and document.
* m4/largefile.m4 (gl_LARGEFILE): Set WINDOWS_64_BIT_ST_SIZE to 0 if
the mingw headers already define 'stat' appropriately.
* modules/largefile (Description): Clarify.
* doc/largefile.texi: New file.
* doc/gnulib.texi: Include it.
* doc/posix-headers/sys_types.texi: Update.

diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 094a98c..9a25553 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -6323,6 +6323,7 @@ to POSIX that it can be treated like any other Unix-like platform.

@menu
* Libtool and Windows::
+* Large File Support::
* Precise file timestamps on Windows::
* Windows sockets::
* Native Windows Support without MSVC Support::
@@ -6330,6 +6331,8 @@ to POSIX that it can be treated like any other Unix-like platform.

@include windows-libtool.texi

+@include largefile.texi
+
@include windows-stat-timespec.texi

@include windows-sockets.texi
diff --git a/doc/largefile.texi b/doc/largefile.texi
new file mode 100644
index 0000000..61e110d
--- /dev/null
+++ b/doc/largefile.texi
@@ -0,0 +1,8 @@
+@node Large File Support
+@section Large File Support
+
+The module provides support for files larger than 2 GB.
+To this effect, it ensures that @code{off_t} is a 64-bit integer type
+at least on the following platforms:
+glibc, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris,
+Cygwin, mingw, MSVC.
diff --git a/doc/posix-headers/sys_types.texi b/doc/posix-headers/sys_types.texi
index cf44bea..0f018b7 100644
--- a/doc/posix-headers/sys_types.texi
+++ b/doc/posix-headers/sys_types.texi
@@ -37,4 +37,4 @@ glibc x32

This module, together with the module @code{largefile}, also defines the type
@code{off_t} to a 64-bit integer type on some platforms:
-mingw (except mingw64), MSVC 9.
+mingw, MSVC 9.
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index 790f7c0..edc1a9b 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -126,9 +126,24 @@ AC_DEFUN([gl_LARGEFILE],
else
WINDOWS_64_BIT_OFF_T=0
fi
- dnl But all native Windows platforms (including mingw64) have a 32-bit
- dnl st_size member in 'struct stat'.
- WINDOWS_64_BIT_ST_SIZE=1
+ dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
+ dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
+ dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
+ AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ struct stat buf;
+ int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
+ ]],
+ [[]])],
+ [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
+ ])
+ if test $gl_cv_member_st_size_64 = no; then
+ WINDOWS_64_BIT_ST_SIZE=1
+ else
+ WINDOWS_64_BIT_ST_SIZE=0
+ fi
;;
*)
dnl Nothing to do on gnulib's side.
diff --git a/modules/largefile b/modules/largefile
index 4700bef..fcae113 100644
--- a/modules/largefile
+++ b/modules/largefile
@@ -1,5 +1,5 @@
Description:
-Use large files.
+Support for files larger than 2 GB.

Files:
m4/largefile.m4
Bruno Haible
2017-05-13 14:17:33 UTC
Permalink
And a small simplification:


2017-05-13 Bruno Haible <***@clisp.org>

largefile: Simplify.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Remove unused definition
of _GL_WINDOWS_64_BIT_ST_SIZE.

diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index 155667d..8934278 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 30 -*- Autoconf -*-
+# sys_stat_h.m4 serial 31 -*- Autoconf -*-
dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -27,18 +27,13 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
])
AC_SUBST([WINDOWS_STAT_TIMESPEC])

- dnl Whether to override 'struct stat'.
+ dnl Whether to ensure that struct stat.st_size is 64-bit wide.
m4_ifdef([gl_LARGEFILE], [
AC_REQUIRE([gl_LARGEFILE])
], [
WINDOWS_64_BIT_ST_SIZE=0
])
AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
- if test $WINDOWS_64_BIT_ST_SIZE = 1; then
- AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1],
- [Define to 1 if Gnulib overrides 'struct stat' on Windows so that
- struct stat.st_size becomes 64-bit.])
- fi

dnl Define types that are supposed to be defined in <sys/types.h> or
dnl <sys/stat.h>.

Loading...