summaryrefslogtreecommitdiffstats
path: root/Modules/resource.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-03-30 17:23:49 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-03-30 17:23:49 (GMT)
commitf26d63b3e19bf57e93010ec4a0a5af1a87e3bcef (patch)
tree574b19e53c61179b25770b35107ba34162198982 /Modules/resource.c
parent852ba7eb2a38a4d57cea73bf34b11f8e65f004e1 (diff)
downloadcpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.zip
cpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.tar.gz
cpython-f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef.tar.bz2
Patch #650412: Check whether the address of flock and getpagesize
can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.
Diffstat (limited to 'Modules/resource.c')
-rw-r--r--Modules/resource.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/resource.c b/Modules/resource.c
index 003599d..e82df6d 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -5,6 +5,10 @@
#include <sys/time.h>
#include <string.h>
#include <errno.h>
+/* for sysconf */
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* On some systems, these aren't in any header file.
On others they are, with inconsistent prototypes.
@@ -193,7 +197,15 @@ resource_getpagesize(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ":getpagesize"))
return NULL;
- return Py_BuildValue("i", getpagesize());
+
+ long pagesize = 0;
+#if defined(HAVE_GETPAGESIZE)
+ pagesize = getpagesize();
+#elif defined(HAVE_SYSCONF)
+ pagesize = sysconf(_SC_PAGE_SIZE);
+#endif
+ return Py_BuildValue("i", pagesize);
+
}
/* List of functions */