Commits

Dan Villiom Podlaski Christiansen committed 801a312

New patch.

  • Participants
  • Parent commits c412b81

Comments (0)

Files changed (3)

File database-sentinels.diff

+# HG changeset patch
+# Parent ea38920cfd0b0669eede874f8bdaa2ada5a8aa6f
+# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
+Don't try to dereference small constant pointer values.
+
+Specifically, SEM_FAILED is defined to -1 on Darwin.
+
+diff --git a/pypy/translator/c/database.py b/pypy/translator/c/database.py
+--- a/pypy/translator/c/database.py
++++ b/pypy/translator/c/database.py
+@@ -212,6 +212,11 @@ class LowLevelDatabase(object):
+                     return funcname
+                     # /hack hack hack
+                 else:
++                    if isinstance(container, int):
++                        # special case for tagged odd-valued pointers
++                        return '((%s) %d)' % (cdecl(self.gettype(T), ''),
++                                              obj._obj)
++
+                     # hack hack hack
+                     if obj in self.idelayedfunctionnames:
+                         # this used to be a delayed function,
+@@ -223,10 +228,6 @@ class LowLevelDatabase(object):
+                         return forcename
+                     # /hack hack hack
+ 
+-                if isinstance(container, int):
+-                    # special case for tagged odd-valued pointers
+-                    return '((%s) %d)' % (cdecl(self.gettype(T), ''),
+-                                          obj._obj)
+                 node = self.getcontainernode(container)
+                 return node.getptrname()
+             else:
 diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
 --- a/pypy/module/_multiprocessing/interp_semaphore.py
 +++ b/pypy/module/_multiprocessing/interp_semaphore.py
-@@ -56,8 +56,13 @@ else:
+@@ -56,7 +56,8 @@ else:
      TIMESPEC      = config['TIMESPEC']
      TIMEVALP      = rffi.CArrayPtr(TIMEVAL)
      TIMESPECP     = rffi.CArrayPtr(TIMESPEC)
 -    SEM_T         = rffi.COpaquePtr('sem_t', compilation_info=eci)
--    SEM_FAILED    = rffi.cast(SEM_T, config['SEM_FAILED'])
-+    if sys.platform == 'darwin':
-+        SEM_T     = platform.SimpleType('sem_t', rffi.INT)
-+        SEM_TP    = rffi.INTP
-+    else:
-+        SEM_T     = rffi.COpaquePtr('sem_t', compilation_info=eci)
-+        SEM_TP    = rffi.CArrayPtr(SEM_T)
-+    SEM_FAILED    = rffi.cast(SEM_TP, config['SEM_FAILED'])
++    # this is not sem_t, strictly speaking, but a pointer to it
++    SEM_T         = rffi.VOIDP
+     SEM_FAILED    = rffi.cast(SEM_T, config['SEM_FAILED'])
      SEM_VALUE_MAX = config['SEM_VALUE_MAX']
      HAVE_BROKEN_SEM_GETVALUE = False
- 
-@@ -67,13 +72,13 @@ else:
- 
-     _sem_open = external('sem_open',
-                          [rffi.CCHARP, rffi.INT, rffi.INT, rffi.UINT],
--                         SEM_T)
-+                         SEM_TP)
-     _sem_unlink = external('sem_unlink', [rffi.CCHARP], rffi.INT)
--    _sem_wait = external('sem_wait', [SEM_T], rffi.INT)
--    _sem_trywait = external('sem_trywait', [SEM_T], rffi.INT)
--    _sem_timedwait = external('sem_timedwait', [SEM_T, TIMESPECP], rffi.INT)
--    _sem_post = external('sem_post', [SEM_T], rffi.INT)
--    _sem_getvalue = external('sem_getvalue', [SEM_T, rffi.INTP], rffi.INT)
-+    _sem_wait = external('sem_wait', [SEM_TP], rffi.INT)
-+    _sem_trywait = external('sem_trywait', [SEM_TP], rffi.INT)
-+    _sem_timedwait = external('sem_timedwait', [SEM_TP, TIMESPECP], rffi.INT)
-+    _sem_post = external('sem_post', [SEM_TP], rffi.INT)
-+    _sem_getvalue = external('sem_getvalue', [SEM_TP, rffi.INTP], rffi.INT)
- 
-     _gettimeofday = external('gettimeofday', [TIMEVALP, rffi.VOIDP], rffi.INT)
- 
-@@ -129,7 +134,7 @@ else:
-             lltype.free(now, flavor='raw')
- 
-     def handle_w(space, w_handle):
--        return rffi.cast(SEM_T, space.uint_w(w_handle))
-+        return rffi.cast(SEM_TP, space.uint_w(w_handle))
- 
- class CounterState:
-     def __init__(self, space):
 visibility.diff
 test-kwargs.diff
 sem_t.diff
+database-sentinels.diff