From f26d63b3e19bf57e93010ec4a0a5af1a87e3bcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 30 Mar 2003 17:23:49 +0000 Subject: Patch #650412: Check whether the address of flock and getpagesize can be taken, and use _SC_PAGE_SIZE if getpagesize is not available. --- Modules/resource.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'Modules/resource.c') diff --git a/Modules/resource.c b/Modules/resource.c index 003599d742..e82df6d976 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -5,6 +5,10 @@ #include #include #include +/* for sysconf */ +#if defined(HAVE_UNISTD_H) +#include +#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 */ -- cgit v1.2.1