[pypy-commit] pypy errno-again: fixes

arigo noreply at buildbot.pypy.org
Wed Jan 14 18:48:48 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: errno-again
Changeset: r75330:8eed807e65cb
Date: 2015-01-14 18:43 +0100
http://bitbucket.org/pypy/pypy/changeset/8eed807e65cb/

Log:	fixes

diff --git a/rpython/memory/gc/inspector.py b/rpython/memory/gc/inspector.py
--- a/rpython/memory/gc/inspector.py
+++ b/rpython/memory/gc/inspector.py
@@ -4,7 +4,7 @@
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, llgroup
 from rpython.rlib.objectmodel import free_non_gc_object
 from rpython.rtyper.module.ll_os import UNDERSCORE_ON_WIN32
-from rpython.rlib import rposix, rgc
+from rpython.rlib import rposix, rgc, jit
 
 from rpython.memory.support import AddressDict, get_address_stack
 
@@ -123,6 +123,7 @@
         lltype.free(self.writebuffer, flavor='raw')
         free_non_gc_object(self)
 
+    @jit.dont_look_inside
     def flush(self):
         if self.buf_count > 0:
             bytes = self.buf_count * rffi.sizeof(rffi.LONG)
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -57,17 +57,23 @@
 def llexternal(*args, **kwargs):
     return rffi.llexternal(*args, compilation_info=eci, **kwargs)
 
-c_fopen = llexternal('fopen', [rffi.CCHARP, rffi.CCHARP], FILEP)
-c_popen = llexternal('popen', [rffi.CCHARP, rffi.CCHARP], FILEP)
+c_fopen = llexternal('fopen', [rffi.CCHARP, rffi.CCHARP], FILEP,
+                     save_err=rffi.RFFI_SAVE_ERRNO)
+c_popen = llexternal('popen', [rffi.CCHARP, rffi.CCHARP], FILEP,
+                     save_err=rffi.RFFI_SAVE_ERRNO)
 c_fdopen = llexternal(('_' if os.name == 'nt' else '') + 'fdopen',
-                      [rffi.INT, rffi.CCHARP], FILEP)
-c_tmpfile = llexternal('tmpfile', [], FILEP)
+                      [rffi.INT, rffi.CCHARP], FILEP,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
+c_tmpfile = llexternal('tmpfile', [], FILEP,
+                       save_err=rffi.RFFI_SAVE_ERRNO)
 
 c_setvbuf = llexternal('setvbuf', [FILEP, rffi.CCHARP, rffi.INT, rffi.SIZE_T],
                        rffi.INT)
 
-c_fclose = llexternal('fclose', [FILEP], rffi.INT)
-c_pclose = llexternal('pclose', [FILEP], rffi.INT)
+c_fclose = llexternal('fclose', [FILEP], rffi.INT,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
+c_pclose = llexternal('pclose', [FILEP], rffi.INT,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
 
 # Note: the following two functions are called from __del__ methods,
 # so must be 'releasegil=False'.  Otherwise, a program using both
@@ -84,12 +90,16 @@
                      rffi.SIZE_T)
 
 c_fwrite = llexternal('fwrite', [rffi.CCHARP, rffi.SIZE_T, rffi.SIZE_T, FILEP],
-                      rffi.SIZE_T)
-c_fflush = llexternal('fflush', [FILEP], rffi.INT)
-c_ftruncate = llexternal(ftruncate, [rffi.INT, OFF_T], rffi.INT, macro=True)
+                      rffi.SIZE_T, save_err=rffi.RFFI_SAVE_ERRNO)
+c_fflush = llexternal('fflush', [FILEP], rffi.INT,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
+c_ftruncate = llexternal(ftruncate, [rffi.INT, OFF_T], rffi.INT, macro=True,
+                         save_err=rffi.RFFI_SAVE_ERRNO)
 
-c_fseek = llexternal('fseek', [FILEP, rffi.LONG, rffi.INT], rffi.INT)
-c_ftell = llexternal('ftell', [FILEP], rffi.LONG)
+c_fseek = llexternal('fseek', [FILEP, rffi.LONG, rffi.INT], rffi.INT,
+                     save_err=rffi.RFFI_SAVE_ERRNO)
+c_ftell = llexternal('ftell', [FILEP], rffi.LONG,
+                     save_err=rffi.RFFI_SAVE_ERRNO)
 c_fileno = llexternal(fileno, [FILEP], rffi.INT)
 
 c_feof = llexternal('feof', [FILEP], rffi.INT)
@@ -149,7 +159,7 @@
         try:
             ll_file = c_fopen(ll_name, ll_mode)
             if not ll_file:
-                errno = rposix.get_errno()
+                errno = rposix.get_saved_errno()
                 raise IOError(errno, os.strerror(errno))
         finally:
             lltype.free(ll_mode, flavor='raw')
@@ -169,7 +179,7 @@
     try:
         ll_file = c_fdopen(fd, ll_mode)
         if not ll_file:
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise OSError(errno, os.strerror(errno))
     finally:
         lltype.free(ll_mode, flavor='raw')
@@ -182,7 +192,7 @@
 def create_temp_rfile():
     res = c_tmpfile()
     if not res:
-        errno = rposix.get_errno()
+        errno = rposix.get_saved_errno()
         raise OSError(errno, os.strerror(errno))
     return RFile(res)
 
@@ -194,7 +204,7 @@
         try:
             ll_file = c_popen(ll_command, ll_type)
             if not ll_file:
-                errno = rposix.get_errno()
+                errno = rposix.get_saved_errno()
                 raise OSError(errno, os.strerror(errno))
         finally:
             lltype.free(ll_type, flavor='raw')
@@ -274,7 +284,7 @@
                 if do_close:
                     res = do_close(ll_file)
                     if res == -1:
-                        errno = rposix.get_errno()
+                        errno = rposix.get_saved_errno()
                         raise IOError(errno, os.strerror(errno))
             finally:
                 if self._setbuf:
@@ -474,7 +484,7 @@
             length = len(value)
             bytes = c_fwrite(ll_value, 1, length, self._ll_file)
             if bytes != length:
-                errno = rposix.get_errno()
+                errno = rposix.get_saved_errno()
                 c_clearerr(self._ll_file)
                 raise IOError(errno, os.strerror(errno))
         finally:
@@ -484,7 +494,7 @@
         self._check_closed()
         res = c_fflush(self._ll_file)
         if res != 0:
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise IOError(errno, os.strerror(errno))
 
     def truncate(self, arg=-1):
@@ -494,14 +504,14 @@
         self.flush()
         res = c_ftruncate(self.fileno(), arg)
         if res == -1:
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise IOError(errno, os.strerror(errno))
 
     def seek(self, pos, whence=0):
         self._check_closed()
         res = c_fseek(self._ll_file, pos, whence)
         if res == -1:
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise IOError(errno, os.strerror(errno))
         self._skipnextlf = False
 
@@ -509,7 +519,7 @@
         self._check_closed()
         res = intmask(c_ftell(self._ll_file))
         if res == -1:
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise IOError(errno, os.strerror(errno))
         if self._skipnextlf:
             c = c_getc(self._ll_file)
diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -108,13 +108,16 @@
 else:
     HAVE_LARGEFILE_SUPPORT = False
 
-def external(name, args, result, **kwargs):
+def external(name, args, result, save_err_on_unsafe=0, save_err_on_safe=0,
+             **kwargs):
     unsafe = rffi.llexternal(name, args, result,
                              compilation_info=CConfig._compilation_info_,
+                             save_err=save_err_on_unsafe,
                              **kwargs)
     safe = rffi.llexternal(name, args, result,
                            compilation_info=CConfig._compilation_info_,
                            sandboxsafe=True, releasegil=False,
+                           save_err=save_err_on_safe,
                            **kwargs)
     return unsafe, safe
 
@@ -142,10 +145,12 @@
 if _POSIX:
     has_mremap = cConfig['has_mremap']
     c_mmap, c_mmap_safe = external('mmap', [PTR, size_t, rffi.INT, rffi.INT,
-                                   rffi.INT, off_t], PTR, macro=True)
+                                   rffi.INT, off_t], PTR, macro=True,
+                                   save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO)
     # 'mmap' on linux32 is a macro that calls 'mmap64'
     _, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT)
-    c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT)
+    c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT,
+                          save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO)
     if has_mremap:
         c_mremap, _ = external('mremap',
                                [PTR, size_t, size_t, rffi.ULONG], PTR)
@@ -501,7 +506,7 @@
             elif _POSIX:
                 res = c_msync(start, size, MS_SYNC)
                 if res == -1:
-                    errno = rposix.get_errno()
+                    errno = rposix.get_saved_errno()
                     raise OSError(errno, os.strerror(errno))
 
         return 0
@@ -671,7 +676,7 @@
         #     to be annotated with a non-constant pointer.
         res = c_mmap(NonConstant(NULL), map_size, prot, flags, fd, offset)
         if res == rffi.cast(PTR, -1):
-            errno = rposix.get_errno()
+            errno = rposix.get_saved_errno()
             raise OSError(errno, os.strerror(errno))
 
         m.setdata(res, map_size)
diff --git a/rpython/rtyper/module/ll_os.py b/rpython/rtyper/module/ll_os.py
--- a/rpython/rtyper/module/ll_os.py
+++ b/rpython/rtyper/module/ll_os.py
@@ -20,7 +20,7 @@
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.tool import rffi_platform as platform
-from rpython.rlib import rposix
+from rpython.rlib import rposix, jit
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.rlib.objectmodel import specialize
 from rpython.translator import cdir
@@ -1785,6 +1785,7 @@
         os_fork = self.llexternal('fork', [], rffi.PID_T,
                                   _nowrapper = True)
 
+        @jit.dont_look_inside
         def fork_llimpl():
             # NB. keep forkpty() up-to-date, too
             ofs = debug.debug_offset()


More information about the pypy-commit mailing list