mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Patch #650412: Check whether the address of flock and getpagesize
can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.
This commit is contained in:
parent
852ba7eb2a
commit
f26d63b3e1
4 changed files with 144 additions and 11 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue