[pypy-svn] r55320 - pypy/branch/gc+thread/pypy/module/thread

arigo at codespeak.net arigo at codespeak.net
Tue May 27 22:40:53 CEST 2008


Author: arigo
Date: Tue May 27 22:40:50 2008
New Revision: 55320

Modified:
   pypy/branch/gc+thread/pypy/module/thread/gil.py
   pypy/branch/gc+thread/pypy/module/thread/ll_thread.py
Log:
Translation fixes.


Modified: pypy/branch/gc+thread/pypy/module/thread/gil.py
==============================================================================
--- pypy/branch/gc+thread/pypy/module/thread/gil.py	(original)
+++ pypy/branch/gc+thread/pypy/module/thread/gil.py	Tue May 27 22:40:50 2008
@@ -16,11 +16,11 @@
 
 class GILThreadLocals(OSThreadLocals):
     """A version of OSThreadLocals that enforces a GIL."""
-    ll_GIL = None
+    ll_GIL = thread.null_ll_lock
 
     def setup_threads(self, space):
         """Enable threads in the object space, if they haven't already been."""
-        if self.ll_GIL is None:
+        if not self.ll_GIL:
             try:
                 self.ll_GIL = thread.allocate_ll_lock()
             except thread.error:

Modified: pypy/branch/gc+thread/pypy/module/thread/ll_thread.py
==============================================================================
--- pypy/branch/gc+thread/pypy/module/thread/ll_thread.py	(original)
+++ pypy/branch/gc+thread/pypy/module/thread/ll_thread.py	Tue May 27 22:40:50 2008
@@ -110,7 +110,9 @@
         self._lock = ll_lock
 
     def acquire(self, flag):
-        return bool(c_thread_acquirelock(self._lock, int(flag)))
+        res = c_thread_acquirelock(self._lock, int(flag))
+        res = rffi.cast(lltype.Signed, res)
+        return bool(res)
 
     def release(self):
         # Sanity check: the lock must be locked
@@ -127,6 +129,8 @@
 #
 # GIL support wrappers
 
+null_ll_lock = lltype.nullptr(TLOCKP.TO)
+
 def allocate_ll_lock():
     ll_lock = lltype.malloc(TLOCKP.TO, flavor='raw')
     res = c_thread_lock_init(ll_lock)
@@ -136,8 +140,10 @@
     return ll_lock
 
 def acquire_NOAUTO(ll_lock, flag):
-    flag = rffi.cast(rffi.INT, flag)
-    return bool(c_thread_acquirelock_NOAUTO(ll_lock, flag))
+    flag = rffi.cast(rffi.INT, int(flag))
+    res = c_thread_acquirelock_NOAUTO(ll_lock, flag)
+    res = rffi.cast(lltype.Signed, res)
+    return bool(res)
 
 def release_NOAUTO(ll_lock):
     if not we_are_translated():



More information about the Pypy-commit mailing list