[Python-checkins] python/dist/src/Modules posixmodule.c,2.297,2.298

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Tue, 22 Apr 2003 19:39:20 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv9192/python/Modules

Modified Files:
	posixmodule.c 
Log Message:
Enable os.fsync() for Windows, mapping it to MS's _commit() there.  The
docs here are best-guess:  the MS docs I could find weren't clear, and
some even claimed _commit() has no effect on Win32 systems (which is
easily shown to be false just by trying it).


Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.297
retrieving revision 2.298
diff -C2 -d -r2.297 -r2.298
*** posixmodule.c	21 Apr 2003 14:22:36 -0000	2.297
--- posixmodule.c	23 Apr 2003 02:39:17 -0000	2.298
***************
*** 113,116 ****
--- 113,118 ----
  #define HAVE_SYSTEM	1
  #define HAVE_CWAIT	1
+ #define HAVE_FSYNC	1
+ #define fsync _commit
  #else
  #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
***************
*** 302,306 ****
  #endif
  
! #if defined(MAJOR_IN_MKDEV) 
  #include <sys/mkdev.h>
  #else
--- 304,308 ----
  #endif
  
! #if defined(MAJOR_IN_MKDEV)
  #include <sys/mkdev.h>
  #else
***************
*** 326,330 ****
  #if defined(__VMS)
  /* add some values to provide a similar environment like POSIX */
! static 
  void
  vms_add_posix_env(PyObject *d)
--- 328,332 ----
  #if defined(__VMS)
  /* add some values to provide a similar environment like POSIX */
! static
  void
  vms_add_posix_env(PyObject *d)
***************
*** 517,522 ****
  	                             PyUnicode_GET_SIZE(obj));
  	}
! 	return PyUnicode_FromEncodedObject(obj, 
! 	                                   Py_FileSystemDefaultEncoding, 
  	                                   "strict");
  }
--- 519,524 ----
  	                             PyUnicode_GET_SIZE(obj));
  	}
! 	return PyUnicode_FromEncodedObject(obj,
! 	                                   Py_FileSystemDefaultEncoding,
  	                                   "strict");
  }
***************
*** 622,631 ****
  
  #ifdef Py_WIN_WIDE_FILENAMES
! static int 
  unicode_file_names(void)
  {
  	static int canusewide = -1;
  	if (canusewide == -1) {
! 		/* As per doc for ::GetVersion(), this is the correct test for 
  		   the Windows NT family. */
  		canusewide = (GetVersion() < 0x80000000) ? 1 : 0;
--- 624,633 ----
  
  #ifdef Py_WIN_WIDE_FILENAMES
! static int
  unicode_file_names(void)
  {
  	static int canusewide = -1;
  	if (canusewide == -1) {
! 		/* As per doc for ::GetVersion(), this is the correct test for
  		   the Windows NT family. */
  		canusewide = (GetVersion() < 0x80000000) ? 1 : 0;
***************
*** 634,638 ****
  }
  #endif
!   
  static PyObject *
  posix_1str(PyObject *args, char *format, int (*func)(const char*),
--- 636,640 ----
  }
  #endif
! 
  static PyObject *
  posix_1str(PyObject *args, char *format, int (*func)(const char*),
***************
*** 679,683 ****
  
  static PyObject *
! posix_2str(PyObject *args, 
  	   char *format,
  	   int (*func)(const char *, const char *),
--- 681,685 ----
  
  static PyObject *
! posix_2str(PyObject *args,
  	   char *format,
  	   int (*func)(const char *, const char *),
***************
*** 972,976 ****
  
  static PyObject *
! posix_do_stat(PyObject *self, PyObject *args, 
  	      char *format,
  #ifdef __VMS
--- 974,978 ----
  
  static PyObject *
! posix_do_stat(PyObject *self, PyObject *args,
  	      char *format,
  #ifdef __VMS
***************
*** 1182,1186 ****
  	return posix_1str(args, "et:chdir", _chdir2, NULL, NULL);
  #elif defined(__VMS)
! 	return posix_1str(args, "et:chdir", (int (*)(const char *))chdir, 
  			  NULL, NULL);
  #else
--- 1184,1188 ----
  	return posix_1str(args, "et:chdir", _chdir2, NULL, NULL);
  #elif defined(__VMS)
! 	return posix_1str(args, "et:chdir", (int (*)(const char *))chdir,
  			  NULL, NULL);
  #else
***************
*** 1315,1319 ****
  	res = lchown(path, (uid_t) uid, (gid_t) gid);
  	Py_END_ALLOW_THREADS
! 	if (res < 0) 
  		return posix_error_with_allocated_filename(path);
  	PyMem_Free(path);
--- 1317,1321 ----
  	res = lchown(path, (uid_t) uid, (gid_t) gid);
  	Py_END_ALLOW_THREADS
! 	if (res < 0)
  		return posix_error_with_allocated_filename(path);
  	PyMem_Free(path);
***************
*** 1647,1651 ****
  
  			w = PyUnicode_FromEncodedObject(v,
! 					Py_FileSystemDefaultEncoding, 
  					"strict");
  			if (w != NULL) {
--- 1649,1653 ----
  
  			w = PyUnicode_FromEncodedObject(v,
! 					Py_FileSystemDefaultEncoding,
  					"strict");
  			if (w != NULL) {
***************
*** 1693,1697 ****
  			Py_UNICODE woutbuf[MAX_PATH*2];
  			Py_UNICODE *wtemp;
! 			if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po), 
  						sizeof(woutbuf)/sizeof(woutbuf[0]),
  						 woutbuf, &wtemp))
--- 1695,1699 ----
  			Py_UNICODE woutbuf[MAX_PATH*2];
  			Py_UNICODE *wtemp;
! 			if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po),
  						sizeof(woutbuf)/sizeof(woutbuf[0]),
  						 woutbuf, &wtemp))
***************
*** 3186,3190 ****
   * Variation on os2emx.popen2
   *
!  * The result of this function is 2 pipes - the processes stdin, 
   * and stdout+stderr combined as a single pipe.
   */
--- 3188,3192 ----
   * Variation on os2emx.popen2
   *
!  * The result of this function is 2 pipes - the processes stdin,
   * and stdout+stderr combined as a single pipe.
   */
***************
*** 3520,3524 ****
  			}
  		}
! 		     
  		/*
  		 * Clean up our localized references for the dictionary keys
--- 3522,3526 ----
  			}
  		}
! 
  		/*
  		 * Clean up our localized references for the dictionary keys
***************
*** 3937,3941 ****
  				cmdstring);
  			/* Not passing CREATE_NEW_CONSOLE has been known to
! 			   cause random failures on win9x.  Specifically a 
  			   dialog:
  			   "Your program accessed mem currently in use at xxx"
--- 3939,3943 ----
  				cmdstring);
  			/* Not passing CREATE_NEW_CONSOLE has been known to
! 			   cause random failures on win9x.  Specifically a
  			   dialog:
  			   "Your program accessed mem currently in use at xxx"