[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mingw and AC_SYS_LARGEFILE
From: |
Bruno Haible |
Subject: |
Re: mingw and AC_SYS_LARGEFILE |
Date: |
Sat, 14 Apr 2012 23:28:16 +0200 |
User-agent: |
KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; ) |
Here's a proposed patch for Large File Support for native Windows platforms.
Tested on mingw, mingw64 (32-bit), MSVC 9.
It turns out there's nothing to do with open(), creat() - because there is
no need for O_LARGEFILE on Windows - and also nothing to do with fopen(),
fgetpos(), fsetpos() - because fpos_t is already 64-bit on Windows -.
Opinions? Objections? Jim, in particular it touches the 'ftruncate' module,
which is yours.
2012-04-14 Bruno Haible <address@hidden>
Large File Support for native Windows platforms.
* m4/largefile.m4 (gl_LARGEFILE): New macro.
* modules/largefile (configure.ac): Require gl_LARGEFILE.
* lib/sys_types.in.h (off_t) [USE_64_BIT_OFF_T]: Define to a 64-bit
type.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set USE_64_BIT_OFF_T.
* modules/sys_types (Makefile.am): Substitute USE_64_BIT_OFF_T.
* doc/posix-headers/sys_types.texi: Mention the effect of the
'largefile'
module.
* lib/fcntl.in.h: Add comments about off_t.
* modules/fcntl-h (Depends-on): Add sys_types.
* lib/unistd.in.h [USE_64_BIT_OFF_T]: Include <sys/types.h>.
(ftruncate): Replace it if REPLACE_FTRUNCATE is 1.
* m4/unistd_h.m4 (gl_UNISTD_H): Require gl_SYS_TYPES_H.
(gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FTRUNCATE.
* modules/unistd (Depends-on): Add sys_types.
(Makefile.am): Substitute USE_64_BIT_OFF_T, REPLACE_FTRUNCATE.
* lib/lseek.c (rpl_lseek) [_GL_USE_64_BIT_OFF_T]: Use _lseeki64 instead
of lseek.
* m4/lseek.m4 (gl_FUNC_LSEEK): Require gl_SYS_TYPES_H. Set REPLACE_LSEEK
if USE_64_BIT_OFF_T is 1.
* modules/lseek (Depends-on): Add sys_types.
* lib/ftruncate.c: Put under GPLv3+. Include <windows.h>,
msvc-nothrow.h.
(SetFileSize): New function.
(ftruncate) [_GL_USE_64_BIT_OFF_T]: New implementation.
* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Require gl_SYS_TYPES_H. Set
REPLACE_FTRUNCATE if USE_64_BIT_OFF_T is 1.
* modules/ftruncate (configure.ac): Consider REPLACE_FTRUNCATE.
(Depends-on): Add sys_types, msvc-nothrow. Update conditions.
* lib/sys_stat.in.h: Add comments about off_t.
(stat, fstat) [USE_64_BIT_OFF_T]: Define to variants that use a 64-bit
integer for st_size in 'struct stat'.
* modules/sys_stat (Depends-on): Add sys_types.
(Makefile.am): Substitute USE_64_BIT_OFF_T.
* lib/stat.c (stat) [_GL_USE_64_BIT_OFF_T]: Define to _stati64 instead
of stat or _stat.
* lib/fstat.c [_GL_USE_64_BIT_OFF_T]: Use _fstati64 and 'struct
_stati64'
instead of fstat and 'struct stat'.
* m4/fstat.m4 (gl_FUNC_FSTAT): Require gl_SYS_TYPES_H. Set REPLACE_FSTAT
if USE_64_BIT_OFF_T is 1.
* modules/fstat (Depends-on): Add sys_types.
* lib/stdio.in.h: Add comments about off_t.
* modules/stdio (Depends-on): Add sys_types.
* lib/ftello.c [_GL_USE_64_BIT_OFF_T]: Use _ftelli64 or ftello64 instead
of ftello.
* m4/ftello.m4 (gl_FUNC_FTELLO): Require gl_SYS_TYPES_H. Set
REPLACE_FTELLO if USE_64_BIT_OFF_T is 1.
(gl_PREREQ_FTELLO): New macro.
* modules/ftello (Depends-on): Add sys_types.
(configure.ac): Incoke gl_PREREQ_FTELLO.
* lib/fseeko.c [_GL_USE_64_BIT_OFF_T]: Use _fseeki64 or fseeko64 instead
of fseeko.
* m4/fseeko.m4 (gl_FUNC_FSEEKO): Require gl_SYS_TYPES_H. Set
REPLACE_FSEEKO if USE_64_BIT_OFF_T is 1.
(gl_PREREQ_FSEEKO): New macro.
* modules/fseeko (Depends-on): Add sys_types.
(configure.ac): Invoke gl_PREREQ_FSEEKO.
Reported by Ray Satiro <address@hidden>.
--- doc/posix-headers/sys_types.texi.orig Sat Apr 14 22:55:20 2012
+++ doc/posix-headers/sys_types.texi Sat Apr 14 22:28:42 2012
@@ -27,5 +27,8 @@
On some platforms the types @code{blksize_t} and @code{suseconds_t}
are signed integer types that are wider than @code{long}:
glibc x32
-
@end itemize
+
+This module, together with the module @code{largefile}, also defines the type
address@hidden to a 64-bit integer type on some platforms:
+mingw, MSVC 9.
--- lib/fcntl.in.h.orig Sat Apr 14 22:55:20 2012
+++ lib/fcntl.in.h Sat Apr 14 22:28:42 2012
@@ -25,6 +25,8 @@
#if defined __need_system_fcntl_h
/* Special invocation convention. */
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
@@ -42,6 +44,8 @@
#ifndef address@hidden@_FCNTL_H
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
--- lib/fseeko.c.orig Sat Apr 14 22:55:20 2012
+++ lib/fseeko.c Sat Apr 14 22:28:42 2012
@@ -31,6 +31,14 @@
# undef fseek
# define fseeko fseek
#endif
+#if _GL_USE_64_BIT_OFF_T
+# undef fseeko
+# if HAVE__FSEEKI64 /* msvc, mingw64 */
+# define fseeko _fseeki64
+# else /* mingw */
+# define fseeko fseeko64
+# endif
+#endif
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
--- lib/fstat.c.orig Sat Apr 14 22:55:20 2012
+++ lib/fstat.c Sat Apr 14 22:28:42 2012
@@ -23,6 +23,10 @@
/* Get the original definition of fstat. It might be defined as a macro. */
#include <sys/types.h>
#include <sys/stat.h>
+#if _GL_USE_64_BIT_OFF_T
+# define stat _stati64
+# define fstat _fstati64
+#endif
#undef __need_system_sys_stat_h
static inline int
--- lib/ftello.c.orig Sat Apr 14 22:55:20 2012
+++ lib/ftello.c Sat Apr 14 22:28:42 2012
@@ -31,6 +31,14 @@
# undef ftell
# define ftello ftell
#endif
+#if _GL_USE_64_BIT_OFF_T
+# undef ftello
+# if HAVE__FTELLI64 /* msvc, mingw64 */
+# define ftello _ftelli64
+# else /* mingw */
+# define ftello ftello64
+# endif
+#endif
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
--- lib/ftruncate.c.orig Sat Apr 14 22:55:20 2012
+++ lib/ftruncate.c Sat Apr 14 22:28:42 2012
@@ -1,5 +1,18 @@
/* ftruncate emulations for native Windows.
- This file is in the public domain. */
+ Copyright (C) 1992-2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
@@ -7,12 +20,143 @@
#include <unistd.h>
#if HAVE_CHSIZE
+/* A native Windows platform. */
# include <errno.h>
-# include <io.h>
-# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-# include "msvc-inval.h"
+# if _GL_USE_64_BIT_OFF_T
+
+/* Large File Support: off_t is 64-bit, but chsize() takes only a 32-bit
+ argument. So, define a 64-bit safe SetFileSize function ourselves. */
+
+/* Ensure that <windows.h> declares GetFileSizeEx. */
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x500
+
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* Get _get_osfhandle. */
+# include "msvc-nothrow.h"
+
+static BOOL
+SetFileSize (HANDLE h, LONGLONG size)
+{
+ LARGE_INTEGER old_size;
+
+ if (!GetFileSizeEx (h, &old_size))
+ return FALSE;
+
+ if (size != old_size.QuadPart)
+ {
+ /* Duplicate the handle, so we are free to modify its file position. */
+ HANDLE curr_process = GetCurrentProcess ();
+ HANDLE tmph;
+
+ if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
+ h, /* SourceHandle */
+ curr_process, /* TargetProcessHandle */
+ (PHANDLE) &tmph, /* TargetHandle */
+ (DWORD) 0, /* DesiredAccess */
+ FALSE, /* InheritHandle */
+ DUPLICATE_SAME_ACCESS)) /* Options */
+ return FALSE;
+
+ if (size < old_size.QuadPart)
+ {
+ /* Reduce the size. */
+ LONG size_hi = (LONG) (size >> 32);
+ if (SetFilePointer (tmph, (LONG) size, &size_hi, FILE_BEGIN)
+ == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ if (!SetEndOfFile (tmph))
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Increase the size by adding zero bytes at the end. */
+ static char zero_bytes[1024];
+ LONG pos_hi = 0;
+ LONG pos_lo = SetFilePointer (tmph, (LONG) 0, &pos_hi, FILE_END);
+ LONGLONG pos;
+ if (pos_lo == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ pos = ((LONGLONG) pos_hi << 32) | (ULONGLONG) (ULONG) pos_lo;
+ while (pos < size)
+ {
+ DWORD written;
+ LONGLONG count = size - pos;
+ if (count > sizeof (zero_bytes))
+ count = sizeof (zero_bytes);
+ if (!WriteFile (tmph, zero_bytes, (DWORD) count, &written, NULL)
+ || written == 0)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ pos += (ULONGLONG) (ULONG) written;
+ }
+ }
+ /* Close the handle. */
+ CloseHandle (tmph);
+ }
+ return TRUE;
+}
+
+int
+ftruncate (int fd, off_t length)
+{
+ HANDLE handle = (HANDLE) _get_osfhandle (fd);
+
+ if (handle == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (length < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ if (!SetFileSize (handle, length))
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_ACCESS_DENIED:
+ errno = EACCES;
+ break;
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ case ERROR_DISK_TOO_FRAGMENTED:
+ errno = ENOSPC;
+ break;
+ default:
+ errno = EIO;
+ break;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+# else
+
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
static inline int
chsize_nothrow (int fd, long length)
{
@@ -31,8 +175,8 @@
return result;
}
-# define chsize chsize_nothrow
-# endif
+# define chsize chsize_nothrow
+# endif
int
ftruncate (int fd, off_t length)
@@ -40,4 +184,5 @@
return chsize (fd, length);
}
+# endif
#endif
--- lib/lseek.c.orig Sat Apr 14 22:55:20 2012
+++ lib/lseek.c Sat Apr 14 22:28:42 2012
@@ -59,5 +59,9 @@
return -1;
}
#endif
+#if _GL_USE_64_BIT_OFF_T
+ return _lseeki64 (fd, offset, whence);
+#else
return lseek (fd, offset, whence);
+#endif
}
--- lib/stat.c.orig Sat Apr 14 22:55:20 2012
+++ lib/stat.c Sat Apr 14 22:32:45 2012
@@ -27,13 +27,18 @@
#include <sys/stat.h>
#undef __need_system_sys_stat_h
-#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
- && REPLACE_FUNC_STAT_FILE
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if _GL_USE_64_BIT_OFF_T
+# define stat _stati64
+# define REPLACE_FUNC_STAT_DIR 1
+# undef REPLACE_FUNC_STAT_FILE
+# elif REPLACE_FUNC_STAT_FILE
/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
Bypass it. */
-# define stat _stat
-# define REPLACE_FUNC_STAT_DIR 1
-# undef REPLACE_FUNC_STAT_FILE
+# define stat _stat
+# define REPLACE_FUNC_STAT_DIR 1
+# undef REPLACE_FUNC_STAT_FILE
+# endif
#endif
static inline int
--- lib/stdio.in.h.orig Sat Apr 14 22:55:20 2012
+++ lib/stdio.in.h Sat Apr 14 22:28:42 2012
@@ -52,7 +52,8 @@
#include <stddef.h>
/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
- and eglibc 2.11.2. */
+ and eglibc 2.11.2.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* The __attribute__ feature is available in gcc versions 2.5 and later.
--- lib/sys_stat.in.h.orig Sat Apr 14 22:55:20 2012
+++ lib/sys_stat.in.h Sat Apr 14 22:28:42 2012
@@ -35,7 +35,8 @@
#ifndef address@hidden@_SYS_STAT_H
-/* Get nlink_t. */
+/* Get nlink_t.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* Get struct timespec. */
@@ -66,6 +67,11 @@
# include <io.h>
#endif
+/* Large File Support on native Windows. */
+#if @USE_64_BIT_OFF_T@
+# define stat _stati64
+#endif
+
#ifndef S_IFIFO
# ifdef _S_IFIFO
# define S_IFIFO _S_IFIFO
@@ -335,6 +341,9 @@
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
# endif
_GL_CXXALIASWARN (fstat);
+#elif @USE_64_BIT_OFF_T@
+/* Above, we define stat to _stati64. */
+# define fstat _fstati64
#elif defined GNULIB_POSIXCHECK
# undef fstat
# if HAVE_RAW_DECL_FSTAT
@@ -620,6 +629,28 @@
so we have to replace stat64() instead of stat(). */
# undef stat64
# define stat64(name, st) rpl_stat (name, st)
+# elif @USE_64_BIT_OFF_T@
+ /* Above, we define stat to _stati64. */
+# if defined __MINGW32__ && defined _stati64
+# ifndef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# elif defined _MSC_VER && defined _stati64
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# else
+# undef _stati64
+# define _stati64(name, st) rpl_stat (name, st)
+# endif
# elif defined __MINGW32__ && defined stat
# ifdef _USE_32BIT_TIME_T
/* The system headers define stat to _stat32i64. */
--- lib/sys_types.in.h.orig Sat Apr 14 22:55:20 2012
+++ lib/sys_types.in.h Sat Apr 14 22:28:42 2012
@@ -28,6 +28,18 @@
#ifndef address@hidden@_SYS_TYPES_H
#define address@hidden@_SYS_TYPES_H
+/* Override off_t if Large File Support is requested on native Windows. */
+#if @USE_64_BIT_OFF_T@
+/* Same as int64_t in <stdint.h>. */
+# if defined _MSC_VER
+# define off_t __int64
+# else
+# define off_t long long int
+# endif
+/* Indicator, for gnulib internal purposes. */
+# define _GL_USE_64_BIT_OFF_T 1
+#endif
+
/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
/* But avoid namespace pollution on glibc systems. */
#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
--- lib/unistd.in.h.orig Sat Apr 14 22:55:20 2012
+++ lib/unistd.in.h Sat Apr 14 22:28:42 2012
@@ -107,8 +107,9 @@
# include <netdb.h>
#endif
-/* MSVC defines off_t in <sys/types.h>. */
-#if address@hidden@
+/* MSVC defines off_t in <sys/types.h>.
+ May also define off_t to a 64-bit type on native Windows. */
+#if address@hidden@ || @USE_64_BIT_OFF_T@
/* Get off_t. */
# include <sys/types.h>
#endif
@@ -562,10 +563,19 @@
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2008 specification
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>.
*/
-# if address@hidden@
+# if @REPLACE_FTRUNCATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ftruncate
+# define ftruncate rpl_ftruncate
+# endif
+_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
+_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
+# else
+# if address@hidden@
_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
-# endif
+# endif
_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
+# endif
_GL_CXXALIASWARN (ftruncate);
#elif defined GNULIB_POSIXCHECK
# undef ftruncate
--- m4/fseeko.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/fseeko.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 15
+# fseeko.m4 serial 16
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ AC_REQUIRE([gl_SYS_TYPES_H])
AC_REQUIRE([AC_PROG_CC])
dnl Persuade glibc <stdio.h> to declare fseeko().
@@ -28,6 +29,9 @@
if test $gl_cv_func_fseeko = no; then
HAVE_FSEEKO=0
else
+ if test $USE_64_BIT_OFF_T = 1; then
+ REPLACE_FSEEKO=1
+ fi
if test $gl_cv_var_stdin_large_offset = no; then
REPLACE_FSEEKO=1
fi
@@ -59,3 +63,11 @@
[gl_cv_var_stdin_large_offset=yes],
[gl_cv_var_stdin_large_offset=no])])
])
+
+# Prerequisites of lib/fseeko.c.
+AC_DEFUN([gl_PREREQ_FSEEKO],
+[
+ dnl Native Windows has the function _fseeki64. mingw hides it, but mingw64
+ dnl makes it usable again.
+ AC_CHECK_FUNCS([_fseeki64])
+])
--- m4/fstat.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/fstat.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# fstat.m4 serial 1
+# fstat.m4 serial 2
dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,17 @@
AC_DEFUN([gl_FUNC_FSTAT],
[
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+
AC_REQUIRE([gl_MSVC_INVAL])
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
REPLACE_FSTAT=1
fi
+
+ AC_REQUIRE([gl_SYS_TYPES_H])
+ if test $USE_64_BIT_OFF_T = 1; then
+ REPLACE_FSTAT=1
+ fi
+
dnl Replace fstat() for supporting the gnulib-defined open() on directories.
m4_ifdef([gl_FUNC_FCHDIR], [
gl_TEST_FCHDIR
--- m4/ftello.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/ftello.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# ftello.m4 serial 10
+# ftello.m4 serial 11
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ AC_REQUIRE([gl_SYS_TYPES_H])
dnl Persuade glibc <stdio.h> to declare ftello().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -30,9 +31,13 @@
if test $gl_cv_func_ftello = no; then
HAVE_FTELLO=0
else
+ if test $USE_64_BIT_OFF_T = 1; then
+ REPLACE_FTELLO=1
+ fi
if test $gl_cv_var_stdin_large_offset = no; then
REPLACE_FTELLO=1
- else
+ fi
+ if test $REPLACE_FTELLO = 0; then
dnl Detect bug on Solaris.
dnl ftell and ftello produce incorrect results after putc that followed a
dnl getc call that reached EOF on Solaris. This is because the _IOREAD
@@ -125,3 +130,11 @@
fi
fi
])
+
+# Prerequisites of lib/ftello.c.
+AC_DEFUN([gl_PREREQ_FTELLO],
+[
+ dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
+ dnl makes it usable again.
+ AC_CHECK_FUNCS([_ftelli64])
+])
--- m4/ftruncate.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/ftruncate.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# serial 18
+# serial 19
# See if we need to emulate a missing ftruncate function using chsize.
@@ -10,8 +10,13 @@
AC_DEFUN([gl_FUNC_FTRUNCATE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([gl_SYS_TYPES_H])
AC_CHECK_FUNCS_ONCE([ftruncate])
- if test $ac_cv_func_ftruncate = no; then
+ if test $ac_cv_func_ftruncate = yes; then
+ if test $USE_64_BIT_OFF_T = 1; then
+ REPLACE_FTRUNCATE=1
+ fi
+ else
HAVE_FTRUNCATE=0
fi
])
--- m4/largefile.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/largefile.m4 Sat Apr 14 22:28:42 2012
@@ -102,3 +102,16 @@
])# AC_SYS_LARGEFILE
])# m4_version_prereq 2.69
+
+# Enable large files on systems where this is implemented by Gnulib, not by the
+# system headers.
+AC_DEFUN([gl_LARGEFILE],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw*) # native Windows
+ USE_64_BIT_OFF_T=1 ;;
+ *)
+ USE_64_BIT_OFF_T=0 ;;
+ esac
+])
--- m4/lseek.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/lseek.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# lseek.m4 serial 8
+# lseek.m4 serial 9
dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,7 @@
AC_DEFUN([gl_FUNC_LSEEK],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
AC_REQUIRE([AC_PROG_CC])
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
@@ -45,4 +46,9 @@
AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
[Define to 1 if lseek does not detect pipes.])
fi
+
+ AC_REQUIRE([gl_SYS_TYPES_H])
+ if test $USE_64_BIT_OFF_T = 1; then
+ REPLACE_LSEEK=1
+ fi
])
--- m4/sys_types_h.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/sys_types_h.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# sys_types_h.m4 serial 2
+# sys_types_h.m4 serial 3
dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -14,6 +14,14 @@
dnl Ensure the type mode_t gets defined.
AC_REQUIRE([AC_TYPE_MODE_T])
+
+ dnl Whether to override the 'off_t' type.
+ m4_ifdef([gl_LARGEFILE], [
+ AC_REQUIRE([gl_LARGEFILE])
+ ], [
+ USE_64_BIT_OFF_T=0
+ ])
+ AC_SUBST([USE_64_BIT_OFF_T])
])
AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
--- m4/unistd_h.m4.orig Sat Apr 14 22:55:20 2012
+++ m4/unistd_h.m4 Sat Apr 14 22:28:42 2012
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 63
+# unistd_h.m4 serial 64
dnl Copyright (C) 2006-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -24,6 +24,9 @@
dnl Ensure the type pid_t gets defined.
AC_REQUIRE([AC_TYPE_PID_T])
+ dnl Determine USE_64_BIT_OFF_T.
+ AC_REQUIRE([gl_SYS_TYPES_H])
+
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[
@@ -155,6 +158,7 @@
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
+ REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
--- modules/fcntl-h.orig Sat Apr 14 22:55:20 2012
+++ modules/fcntl-h Sat Apr 14 22:28:42 2012
@@ -12,6 +12,7 @@
snippet/arg-nonnull
snippet/c++defs
snippet/warn-on-use
+sys_types
unistd
configure.ac:
--- modules/fseeko.orig Sat Apr 14 22:55:20 2012
+++ modules/fseeko Sat Apr 14 22:28:42 2012
@@ -11,6 +11,7 @@
largefile
lseek
stdio
+sys_types
# Just to guarantee consistency between fseek() and fseeko().
fseek
@@ -21,6 +22,7 @@
gl_FUNC_FSEEKO
if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
AC_LIBOBJ([fseeko])
+ gl_PREREQ_FSEEKO
fi
gl_STDIO_MODULE_INDICATOR([fseeko])
--- modules/fstat.orig Sat Apr 14 22:55:20 2012
+++ modules/fstat Sat Apr 14 22:28:42 2012
@@ -7,6 +7,7 @@
Depends-on:
sys_stat
+sys_types
largefile
unistd [test $REPLACE_STAT = 1]
msvc-inval [test $REPLACE_STAT = 1]
--- modules/ftello.orig Sat Apr 14 22:55:20 2012
+++ modules/ftello Sat Apr 14 22:28:42 2012
@@ -11,6 +11,7 @@
stdio
extensions
largefile
+sys_types
lseek [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1]
# Just to guarantee consistency between ftell() and ftello().
ftell
@@ -22,6 +23,7 @@
gl_FUNC_FTELLO
if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
AC_LIBOBJ([ftello])
+ gl_PREREQ_FTELLO
fi
gl_STDIO_MODULE_INDICATOR([ftello])
--- modules/ftruncate.orig Sat Apr 14 22:55:20 2012
+++ modules/ftruncate Sat Apr 14 22:28:42 2012
@@ -7,12 +7,14 @@
Depends-on:
unistd
+sys_types
largefile
-msvc-inval [test $HAVE_FTRUNCATE = 0]
+msvc-nothrow [test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1]
+msvc-inval [test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1]
configure.ac:
gl_FUNC_FTRUNCATE
-if test $HAVE_FTRUNCATE = 0; then
+if test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1; then
AC_LIBOBJ([ftruncate])
gl_PREREQ_FTRUNCATE
fi
--- modules/largefile.orig Sat Apr 14 22:55:20 2012
+++ modules/largefile Sat Apr 14 22:28:42 2012
@@ -10,6 +10,7 @@
AC_REQUIRE([AC_SYS_LARGEFILE])
configure.ac:
+AC_REQUIRE([gl_LARGEFILE])
Makefile.am:
--- modules/lseek.orig Sat Apr 14 22:55:20 2012
+++ modules/lseek Sat Apr 14 22:28:42 2012
@@ -7,6 +7,7 @@
Depends-on:
unistd
+sys_types
largefile
msvc-nothrow [test $REPLACE_LSEEK = 1]
fstat [test $REPLACE_LSEEK = 1]
--- modules/stdio.orig Sat Apr 14 22:55:20 2012
+++ modules/stdio Sat Apr 14 22:28:42 2012
@@ -12,6 +12,7 @@
snippet/warn-on-use
ssize_t
stddef
+sys_types
configure.ac:
gl_STDIO_H
--- modules/sys_stat.orig Sat Apr 14 22:55:20 2012
+++ modules/sys_stat Sat Apr 14 22:28:42 2012
@@ -11,6 +11,7 @@
snippet/arg-nonnull
snippet/c++defs
snippet/warn-on-use
+sys_types
time
configure.ac:
@@ -31,6 +32,7 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''USE_64_BIT_OFF_T''@|$(USE_64_BIT_OFF_T)|g' \
-e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
-e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
-e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
--- modules/sys_types.orig Sat Apr 14 22:55:20 2012
+++ modules/sys_types Sat Apr 14 22:28:42 2012
@@ -27,6 +27,7 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+ -e 's|@''USE_64_BIT_OFF_T''@|$(USE_64_BIT_OFF_T)|g' \
< $(srcdir)/sys_types.in.h; \
} > address@hidden && \
mv address@hidden $@
--- modules/unistd.orig Sat Apr 14 22:55:20 2012
+++ modules/unistd Sat Apr 14 22:28:42 2012
@@ -12,6 +12,7 @@
snippet/warn-on-use
ssize_t
stddef
+sys_types
configure.ac:
gl_UNISTD_H
@@ -30,6 +31,7 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+ -e 's|@''USE_64_BIT_OFF_T''@|$(USE_64_BIT_OFF_T)|g' \
-e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
-e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
-e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
@@ -128,6 +130,7 @@
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
-e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
- mingw: ioctl.c HANDLE not defined and fstat question, Ray Satiro, 2012/04/11
- Re: mingw and AC_SYS_LARGEFILE, Bruno Haible, 2012/04/12
- Re: mingw and AC_SYS_LARGEFILE,
Bruno Haible <=
- Re: mingw and AC_SYS_LARGEFILE, Jim Meyering, 2012/04/15
- Re: mingw and AC_SYS_LARGEFILE, Bruno Haible, 2012/04/15
- Re: mingw and AC_SYS_LARGEFILE, Jim Meyering, 2012/04/15
- Re: mingw and AC_SYS_LARGEFILE, Paul Eggert, 2012/04/15
- Re: mingw and AC_SYS_LARGEFILE, Bruno Haible, 2012/04/15
- Re: mingw and AC_SYS_LARGEFILE, Bruno Haible, 2012/04/21
- Re: mingw and AC_SYS_LARGEFILE, Ray Satiro, 2012/04/22
Re: mingw and AC_SYS_LARGEFILE, Bruno Haible, 2012/04/15