Changes to automatically enable large file support on some systems.

I believe this works on Linux (tested both on a system with large file
support and one without it), and it may work on Solaris 2.7.

The changes are twofold:

(1) The configure script now boldly tries to set the two symbols that
    are recommended (for Solaris and Linux), and then tries a test
    script that does some simple seeking without writing.

(2) The _portable_{fseek,ftell} functions are a little more systematic
    in how they try the different large file support options: first
    try fseeko/ftello, but only if off_t is large; then try
    fseek64/ftell64; then try hacking with fgetpos/fsetpos.

I'm keeping my fingers crossed.  The meaning of the
HAVE_LARGEFILE_SUPPORT macro is not at all clear.

I'll see if I can get it to work on Windows as well.
This commit is contained in:
Guido van Rossum 2001-09-05 14:58:11 +00:00
parent 2f0047af3b
commit b855216099
5 changed files with 496 additions and 374 deletions

View File

@ -208,11 +208,15 @@ file_close(PyFileObject *f)
}
/* An 8-byte off_t-like type */
#if defined(HAVE_LARGEFILE_SUPPORT) && SIZEOF_OFF_T < 8 && SIZEOF_FPOS_T >= 8
/* Our very own off_t-like type, 64-bit if possible */
#if !defined(HAVE_LARGEFILE_SUPPORT)
typedef off_t Py_off_t;
#elif SIZEOF_OFF_T >= 8
typedef off_t Py_off_t;
#elif SIZEOF_FPOS_T >= 8
typedef fpos_t Py_off_t;
#else
typedef off_t Py_off_t;
#error "Large file support, but neither off_t nor fpos_t is large enough."
#endif
@ -221,13 +225,15 @@ typedef off_t Py_off_t;
static int
_portable_fseek(FILE *fp, Py_off_t offset, int whence)
{
#if defined(HAVE_FSEEKO)
#if !defined(HAVE_LARGEFILE_SUPPORT)
return fseek(fp, offset, whence);
#elif defined(HAVE_FSEEKO) && SIZEOF_OFF_T >= 8
return fseeko(fp, offset, whence);
#elif defined(HAVE_FSEEK64)
return fseek64(fp, offset, whence);
#elif defined(__BEOS__)
return _fseek(fp, offset, whence);
#elif defined(HAVE_LARGEFILE_SUPPORT) && SIZEOF_FPOS_T >= 8
#elif SIZEOF_FPOS_T >= 8
/* lacking a 64-bit capable fseek(), use a 64-bit capable fsetpos()
and fgetpos() to implement fseek()*/
fpos_t pos;
@ -245,7 +251,7 @@ _portable_fseek(FILE *fp, Py_off_t offset, int whence)
}
return fsetpos(fp, &offset);
#else
return fseek(fp, offset, whence);
#error "Large file support, but no way to fseek."
#endif
}
@ -256,17 +262,19 @@ _portable_fseek(FILE *fp, Py_off_t offset, int whence)
static Py_off_t
_portable_ftell(FILE* fp)
{
#if SIZEOF_FPOS_T >= 8 && defined(HAVE_LARGEFILE_SUPPORT)
#if !defined(HAVE_LARGEFILE_SUPPORT)
return ftell(fp);
#elif defined(HAVE_FTELLO) && SIZEOF_OFF_T >= 8
return ftello(fp);
#elif defined(HAVE_FTELL64)
return ftell64(fp);
#elif SIZEOF_FPOS_T >= 8
fpos_t pos;
if (fgetpos(fp, &pos) != 0)
return -1;
return pos;
#elif defined(HAVE_FTELLO) && defined(HAVE_LARGEFILE_SUPPORT)
return ftello(fp);
#elif defined(HAVE_FTELL64) && defined(HAVE_LARGEFILE_SUPPORT)
return ftell64(fp);
#else
return ftell(fp);
#error "Large file support, but no way to ftell."
#endif
}

View File

@ -25,6 +25,9 @@
/* Defined on Solaris to see additional function prototypes. */
#undef __EXTENSIONS__
/* This must be set to 64 on some systems to enable large file support */
#undef _FILE_OFFSET_BITS
/* Define if getpgrp() must be called as getpgrp(0). */
#undef GETPGRP_HAVE_ARG
@ -107,6 +110,9 @@
/* Define if the compiler provides a wchar.h header file. */
#undef HAVE_WCHAR_H
/* This must be defined on some systems to enable large file support */
#undef _LARGEFILE_SOURCE
/* Define if you want to have a Unicode type. */
#undef Py_USING_UNICODE

764
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -273,11 +273,12 @@ cygwin*)
;;
esac
# MacOSX framework builds need more magic. LDLIBRARY is the dynamic library that
# we build, but we do not want to link against it (we will find it with a -framework
# option). For this reason there is an extra variable BLDLIBRARY against which Python
# and the extension modules are linked, BLDLIBRARY. This is normally the same
# as LDLIBRARY, but empty for MacOSX framework builds.
# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
# library that we build, but we do not want to link against it (we
# will find it with a -framework option). For this reason there is an
# extra variable BLDLIBRARY against which Python and the extension
# modules are linked, BLDLIBRARY. This is normally the same as
# LDLIBRARY, but empty for MacOSX framework builds.
if test "$enable_framework"
then
LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
@ -1018,7 +1019,8 @@ ipv6trylibc=no
if test "$ipv6" = "yes"; then
AC_MSG_CHECKING([ipv6 stack type])
for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; do
for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
do
case $i in
inria)
dnl http://www.kame.net/
@ -1256,6 +1258,47 @@ AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
# Try defining symbols to enable large file support.
# The particular combination of symbols used here is known to work
# on Linux and Solaris [2.]7.
AC_MSG_CHECKING(for CFLAGS to enable large files)
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
AC_TRY_RUN([
#include <sys/types.h>
#include <stdio.h>
main() {
FILE *fp;
off_t seek = 0x80000000ul;
off_t tell = 0;
fp = fopen("conftestval", "wb");
if (fp == NULL) {
perror("conftestval");
exit(1);
}
if (fseeko(fp, seek, 0) < 0)
perror("fseeko");
else
tell = ftello(fp);
fclose(fp);
unlink("conftestval");
if (tell == seek) {
fprintf(stderr, "seek to 2**31 worked\n");
exit(0);
}
else {
exit(1);
fprintf(stderr, "seek to 2**31 didn't work\n");
}
}
],
AC_MSG_RESULT(yes)
AC_DEFINE(_LARGEFILE_SOURCE)
AC_DEFINE(_FILE_OFFSET_BITS,64),
AC_MSG_RESULT(no),
AC_MSG_RESULT(no (cross-compiling)))
CFLAGS="$OLD_CFLAGS"
# check for long file support functions
AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)

View File

@ -90,6 +90,9 @@
/* Defined on Solaris to see additional function prototypes. */
#undef __EXTENSIONS__
/* This must be set to 64 on some systems to enable large file support */
#undef _FILE_OFFSET_BITS
/* Define if getpgrp() must be called as getpgrp(0). */
#undef GETPGRP_HAVE_ARG
@ -166,6 +169,9 @@
/* Define if the compiler provides a wchar.h header file. */
#undef HAVE_WCHAR_H
/* This must be defined on some systems to enable large file support */
#undef _LARGEFILE_SOURCE
/* Define if you want to have a Unicode type. */
#undef Py_USING_UNICODE
@ -716,10 +722,3 @@
#define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
#endif
#endif
/* Define the macros needed if on a UnixWare 7.x system. */
#if defined(__USLC__) && defined(__SCO_VERSION__)
#define SCO_ACCEPT_BUG /* Use workaround for UnixWare accept() bug */
#define SCO_ATAN2_BUG /* Use workaround for UnixWare atan2() bug */
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
#endif