[Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.23,2.24

Fred L. Drake python-dev@python.org
Sun, 1 Oct 2000 10:50:50 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv15121/Modules

Modified Files:
	mmapmodule.c 
Log Message:

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.


Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.23
retrieving revision 2.24
diff -C2 -r2.23 -r2.24
*** mmapmodule.c	2000/09/25 13:16:15	2.23
--- mmapmodule.c	2000/10/01 17:50:46	2.24
***************
*** 27,30 ****
--- 27,37 ----
  #ifdef MS_WIN32
  #include <windows.h>
+ static int
+ my_getpagesize(void)
+ {
+     SYSTEM_INFO si;
+     GetSystemInfo(&si);
+     return si.dwPageSize;
+ }
  #endif
  
***************
*** 39,42 ****
--- 46,59 ----
  #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 */
  
***************
*** 982,998 ****
  #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 */
! 
  }
  
--- 999,1004 ----
  #endif
  
  	PyDict_SetItemString (dict, "PAGESIZE",
! 			      PyInt_FromLong( (long)my_getpagesize() ) );
  }