[Python-checkins] r68574 - in sandbox/trunk/io-c: _fileio.c _iomodule.h _textio.c
antoine.pitrou
python-checkins at python.org
Tue Jan 13 17:09:04 CET 2009
Author: antoine.pitrou
Date: Tue Jan 13 17:09:03 2009
New Revision: 68574
Log:
centralize Py_off_t definition in _iomodule.h
Modified:
sandbox/trunk/io-c/_fileio.c
sandbox/trunk/io-c/_iomodule.h
sandbox/trunk/io-c/_textio.c
Modified: sandbox/trunk/io-c/_fileio.c
==============================================================================
--- sandbox/trunk/io-c/_fileio.c (original)
+++ sandbox/trunk/io-c/_fileio.c Tue Jan 13 17:09:03 2009
@@ -588,12 +588,6 @@
/* XXX Windows support below is likely incomplete */
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
-typedef PY_LONG_LONG Py_off_t;
-#else
-typedef off_t Py_off_t;
-#endif
-
/* Cribbed from posix_lseek() */
static PyObject *
portable_lseek(int fd, PyObject *posobj, int whence)
Modified: sandbox/trunk/io-c/_iomodule.h
==============================================================================
--- sandbox/trunk/io-c/_iomodule.h (original)
+++ sandbox/trunk/io-c/_iomodule.h Tue Jan 13 17:09:03 2009
@@ -52,6 +52,27 @@
} PyBlockingIOErrorObject;
PyObject *PyExc_BlockingIOError;
+
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+typedef PY_LONG_LONG Py_off_t;
+#define PyNumber_AsOff_t PyLong_AsLongLong
+#define PyLong_FromOff_t PyLong_FromLongLong
+#else
+typedef off_t Py_off_t;
+#if (SIZEOF_OFF_T == SIZEOF_SIZE_T)
+#define PyNumber_AsOff_t PyNumber_AsSsize_t
+#define PyLong_FromOff_t PyLong_FromSsize_t
+#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG)
+#define PyNumber_AsOff_t PyLong_AsLongLong
+#define PyLong_FromOff_t PyLong_FromLongLong
+#elif (SIZEOF_OFF_T == SIZEOF_LONG)
+#define PyNumber_AsOff_t PyLong_AsLong
+#define PyLong_FromOff_t PyLong_FromLong
+#else
+#error off_t does not have the same width as either size_t, long, or long long!
+#endif
+#endif
+
/* Implementation details */
extern PyObject *_PyIO_str_close;
Modified: sandbox/trunk/io-c/_textio.c
==============================================================================
--- sandbox/trunk/io-c/_textio.c (original)
+++ sandbox/trunk/io-c/_textio.c Tue Jan 13 17:09:03 2009
@@ -1313,12 +1313,6 @@
/* Seek and Tell */
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
-typedef PY_LONG_LONG Py_off_t;
-#else
-typedef off_t Py_off_t;
-#endif
-
typedef struct {
Py_off_t start_pos;
int dec_flags;
More information about the Python-checkins
mailing list