summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-01 17:50:46 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-01 17:50:46 (GMT)
commit145f96eb36a0ec8cb9a7f5926f94fbbcf2beebcf (patch)
treeb695aeb19f1e73b4748daa02596d56a45f6d2c38
parent370a29fe42e8581fca51c59de62c11b7d28abaab (diff)
downloadcpython-145f96eb36a0ec8cb9a7f5926f94fbbcf2beebcf.zip
cpython-145f96eb36a0ec8cb9a7f5926f94fbbcf2beebcf.tar.gz
cpython-145f96eb36a0ec8cb9a7f5926f94fbbcf2beebcf.tar.bz2
my_getpagesize(): New function; returns the size of a page of memory.
Versions are defined for Windows and Unix; the Unix flavor uses sysconf() to get the page size; this avoids the use of getpagesize(), which is deprecated and requires an additional library on some platforms (specifically, Reliant UNIX). This partially closes SourceForge bug #113797.
-rw-r--r--Modules/mmapmodule.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index cbb2452..b245c89 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -26,6 +26,13 @@
#ifdef MS_WIN32
#include <windows.h>
+static int
+my_getpagesize(void)
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return si.dwPageSize;
+}
#endif
#ifdef UNIX
@@ -38,6 +45,16 @@
#define MS_SYNC 0
#endif
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+static int
+my_getpagesize(void)
+{
+ return sysconf(_SC_PAGESIZE);
+}
+#else
+#define my_getpagesize getpagesize
+#endif
+
#endif /* UNIX */
#include <string.h>
@@ -981,18 +998,7 @@ initmmap(void)
PyInt_FromLong(MAP_ANON) );
#endif
-#ifdef UNIX
PyDict_SetItemString (dict, "PAGESIZE",
- PyInt_FromLong( (long)getpagesize() ) );
-#endif
-#ifdef MS_WIN32
- {
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- PyDict_SetItemString (dict, "PAGESIZE",
- PyInt_FromLong( si.dwPageSize ) );
- }
-#endif /* MS_WIN32 */
-
+ PyInt_FromLong( (long)my_getpagesize() ) );
}