summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-05 14:58:11 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-05 14:58:11 (GMT)
commitb855216099771117388fdf38df80e5214e812955 (patch)
tree2dc27e3ab556016dc2b0811956d9b7bdcfd1c424 /Objects
parent2f0047af3b54685e134d7baa9d2b80eff5f3d07f (diff)
downloadcpython-b855216099771117388fdf38df80e5214e812955.zip
cpython-b855216099771117388fdf38df80e5214e812955.tar.gz
cpython-b855216099771117388fdf38df80e5214e812955.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index e18e2a2..f592e7a 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -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
}