mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
370a29fe42
commit
145f96eb36
1 changed files with 18 additions and 12 deletions
|
@ -26,6 +26,13 @@
|
||||||
|
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
static int
|
||||||
|
my_getpagesize(void)
|
||||||
|
{
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
return si.dwPageSize;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
|
@ -38,6 +45,16 @@
|
||||||
#define MS_SYNC 0
|
#define MS_SYNC 0
|
||||||
#endif
|
#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 */
|
#endif /* UNIX */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -981,18 +998,7 @@ initmmap(void)
|
||||||
PyInt_FromLong(MAP_ANON) );
|
PyInt_FromLong(MAP_ANON) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UNIX
|
|
||||||
PyDict_SetItemString (dict, "PAGESIZE",
|
PyDict_SetItemString (dict, "PAGESIZE",
|
||||||
PyInt_FromLong( (long)getpagesize() ) );
|
PyInt_FromLong( (long)my_getpagesize() ) );
|
||||||
#endif
|
|
||||||
#ifdef MS_WIN32
|
|
||||||
{
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
PyDict_SetItemString (dict, "PAGESIZE",
|
|
||||||
PyInt_FromLong( si.dwPageSize ) );
|
|
||||||
}
|
|
||||||
#endif /* MS_WIN32 */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue