[pypy-svn] r77799 - pypy/branch/fast-forward/pypy/module/_multiprocessing
afa at codespeak.net
afa at codespeak.net
Mon Oct 11 17:55:30 CEST 2010
Author: afa
Date: Mon Oct 11 17:55:28 2010
New Revision: 77799
Modified:
pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py
pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py
pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
Log:
Various translation fixes
Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py (original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py Mon Oct 11 17:55:28 2010
@@ -25,6 +25,9 @@
return OperationError(space.w_ValueError,
space.wrap("BUFFERTOOSHORT"))
+def w_handle(space, handle):
+ return space.wrap(rffi.cast(rffi.INTPTR_T, handle))
+
class W_BaseConnection(Wrappable):
BUFFER_SIZE = 1024
@@ -323,7 +326,6 @@
@unwrap_spec('self', ObjSpace)
def fileno(self, space):
- from pypy.module._multiprocessing.interp_win32 import w_handle
return w_handle(space, self.handle)
def do_close(self):
Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py (original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py Mon Oct 11 17:55:28 2010
@@ -7,6 +7,7 @@
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rpython.tool import rffi_platform as platform
from pypy.module.thread import ll_thread
+from pypy.module._multiprocessing.interp_connection import w_handle
import sys, os, time, errno
RECURSIVE_MUTEX, SEMAPHORE = range(2)
@@ -15,6 +16,8 @@
from pypy.rlib import rwin32
from pypy.interpreter.error import wrap_windowserror
+ SEM_VALUE_MAX = sys.maxint
+
_CreateSemaphore = rwin32.winexternal(
'CreateSemaphoreA', [rffi.VOIDP, rffi.LONG, rffi.LONG, rwin32.LPCSTR],
rwin32.HANDLE)
@@ -34,7 +37,7 @@
'ResetEvent', [rwin32.HANDLE], rwin32.BOOL)
# This is needed because the handler function must have the "WINAPI"
- # callinf convention, which is not supported by lltype.Ptr.
+ # calling convention, which is not supported by lltype.Ptr.
eci = ExternalCompilationInfo(
separate_module_sources=['''
#include <windows.h>
@@ -166,7 +169,7 @@
res = _sem_getvalue(sem, sval_ptr)
if res < 0:
raise OSError(rposix.get_errno(), "sem_getvalue failed")
- return sval_ptr[0]
+ return rffi.cast(lltype.Signed, sval_ptr[0])
finally:
lltype.free(sval_ptr, flavor='raw')
@@ -175,7 +178,7 @@
try:
res = _gettimeofday(now, None)
if res < 0:
- raise OSError(rposix.get_errno(), "sem_getvalue failed")
+ raise OSError(rposix.get_errno(), "gettimeofday failed")
return now[0].c_tv_sec, now[0].c_tv_usec
finally:
lltype.free(now, flavor='raw')
@@ -206,9 +209,6 @@
return value
if sys.platform == 'win32':
- SEM_VALUE_MAX = sys.maxint
- from pypy.module._multiprocessing.interp_win32 import w_handle
-
def create_semaphore(space, name, val, max):
rwin32.SetLastError(0)
handle = _CreateSemaphore(rffi.NULL, val, max, rffi.NULL)
@@ -290,16 +290,13 @@
space, WindowsError(err, "ReleaseSemaphore"))
else:
- def w_handle(space, value):
- return space.newint(value)
-
def create_semaphore(space, name, val, max):
- res = sem_open(name, os.O_CREAT | os.O_EXCL, 0600, val)
+ sem = sem_open(name, os.O_CREAT | os.O_EXCL, 0600, val)
try:
sem_unlink(name)
except OSError:
pass
- return res
+ return sem
def semlock_acquire(self, space, block, w_timeout):
if not block:
Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py (original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py Mon Oct 11 17:55:28 2010
@@ -6,6 +6,7 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rpython.tool import rffi_platform
+from pypy.module._multiprocessing import w_handle
CONSTANTS = """
PIPE_ACCESS_INBOUND PIPE_ACCESS_DUPLEX
@@ -31,8 +32,6 @@
def handle_w(space, w_handle):
return rffi.cast(rwin32.HANDLE, space.int_w(w_handle))
-def w_handle(space, handle):
- return space.wrap(rffi.cast(rffi.INTPTR_T, handle))
_CreateNamedPipe = rwin32.winexternal(
'CreateNamedPipeA', [
More information about the Pypy-commit
mailing list