[pypy-svn] r48904 - in pypy/dist/pypy: module/fcntl module/rctime rlib rpython/lltypesystem rpython/lltypesystem/module rpython/lltypesystem/test rpython/module translator/tool
fijal at codespeak.net
fijal at codespeak.net
Wed Nov 21 15:40:44 CET 2007
Author: fijal
Date: Wed Nov 21 15:40:43 2007
New Revision: 48904
Added:
pypy/dist/pypy/rlib/rposix.py (contents, props changed)
Modified:
pypy/dist/pypy/module/fcntl/interp_fcntl.py
pypy/dist/pypy/module/rctime/interp_time.py
pypy/dist/pypy/rlib/_rsocket_rffi.py
pypy/dist/pypy/rlib/rmmap.py
pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py
pypy/dist/pypy/rpython/lltypesystem/rffi.py
pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
pypy/dist/pypy/rpython/module/ll_os.py
pypy/dist/pypy/rpython/module/ll_os_environ.py
pypy/dist/pypy/rpython/module/ll_os_stat.py
pypy/dist/pypy/rpython/module/ll_strtod.py
pypy/dist/pypy/rpython/module/ll_time.py
pypy/dist/pypy/translator/tool/cbuild.py
Log:
(fijal, antocuni)
* Untangle a bit cexternvariable
* Move rffi.get/set_errno to rlib/rposix
Modified: pypy/dist/pypy/module/fcntl/interp_fcntl.py
==============================================================================
--- pypy/dist/pypy/module/fcntl/interp_fcntl.py (original)
+++ pypy/dist/pypy/module/fcntl/interp_fcntl.py Wed Nov 21 15:40:43 2007
@@ -2,6 +2,7 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.interpreter.error import OperationError
from pypy.interpreter.baseobjspace import W_Root, ObjSpace
+from pypy.rlib import rposix
import sys
class CConfig:
@@ -67,7 +68,7 @@
c_flock = external('flock', [rffi.INT, rffi.INT], rffi.INT)
def _get_error_msg():
- errno = rffi.get_errno()
+ errno = rposix.get_errno()
return rffi.charp2str(strerror(errno))
def _get_module_object(space, obj_name):
Modified: pypy/dist/pypy/module/rctime/interp_time.py
==============================================================================
--- pypy/dist/pypy/module/rctime/interp_time.py (original)
+++ pypy/dist/pypy/module/rctime/interp_time.py Wed Nov 21 15:40:43 2007
@@ -4,6 +4,7 @@
from pypy.interpreter.baseobjspace import W_Root, ObjSpace
from pypy.rpython.lltypesystem import lltype
from pypy.rlib.rarithmetic import ovfcheck_float_to_int
+from pypy.rlib import rposix
import math
import os
import sys
@@ -135,7 +136,7 @@
return timezone, daylight, tzname, altzone
def _get_error_msg():
- errno = rffi.get_errno()
+ errno = rposix.get_errno()
return os.strerror(errno)
def sleep(secs):
Modified: pypy/dist/pypy/rlib/_rsocket_rffi.py
==============================================================================
--- pypy/dist/pypy/rlib/_rsocket_rffi.py (original)
+++ pypy/dist/pypy/rlib/_rsocket_rffi.py Wed Nov 21 15:40:43 2007
@@ -3,7 +3,7 @@
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.tool import rffi_platform as platform
from pypy.rpython.lltypesystem.rffi import CCHARP
-from pypy.rpython.lltypesystem.rffi import get_errno as geterrno
+from pypy.rlib.rposix import get_errno as geterrno
from pypy.rlib.rarithmetic import intmask, r_uint
import os
Modified: pypy/dist/pypy/rlib/rmmap.py
==============================================================================
--- pypy/dist/pypy/rlib/rmmap.py (original)
+++ pypy/dist/pypy/rlib/rmmap.py Wed Nov 21 15:40:43 2007
@@ -1,6 +1,7 @@
from pypy.rpython.tool import rffi_platform
from pypy.rpython.lltypesystem import rffi, lltype, llmemory
+from pypy.rlib import rposix
import sys
import os
@@ -111,7 +112,7 @@
_get_page_size = external('getpagesize', [], rffi.INT)
def _get_error_no():
- return rffi.get_errno()
+ return rposix.get_errno()
elif _MS_WINDOWS:
Added: pypy/dist/pypy/rlib/rposix.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rlib/rposix.py Wed Nov 21 15:40:43 2007
@@ -0,0 +1,20 @@
+from pypy.rpython.lltypesystem.rffi import CConstant, CExternVariable
+from pypy.rpython.lltypesystem import lltype, ll2ctypes
+
+class CConstantErrno(CConstant):
+ # these accessors are used when calling get_errno() or set_errno()
+ # on top of CPython
+ def __getitem__(self, index):
+ assert index == 0
+ try:
+ return ll2ctypes.TLS.errno
+ except AttributeError:
+ raise ValueError("no C function call occurred so far, "
+ "errno is undefined")
+ def __setitem__(self, index, value):
+ assert index == 0
+ ll2ctypes.TLS.errno = value
+
+get_errno, set_errno = CExternVariable(lltype.Signed, 'errno', CConstantErrno,
+ includes=['errno.h'])
+
Modified: pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py Wed Nov 21 15:40:43 2007
@@ -14,6 +14,7 @@
from pypy.tool.tls import tlsobject
from pypy.rlib.rarithmetic import r_uint, r_singlefloat
from pypy.annotation import model as annmodel
+from pypy.translator.tool.cbuild import cache_c_module
def uaddressof(obj):
@@ -511,6 +512,16 @@
# ____________________________________________
+
+def compile_c_snippet(name, source):
+ from pypy.tool.udir import udir
+ cname = udir.join(name + '.c')
+ f = cname.open('w')
+ f.write(source)
+ f.write('\n')
+ f.close()
+ return cache_c_module([cname], name)
+
def get_ctypes_callable(funcptr, calling_conv):
if not ctypes:
raise ImportError("ctypes is needed to use ll2ctypes")
@@ -523,13 +534,16 @@
except AttributeError:
pass
- if getattr(funcptr._obj, 'sources', None):
- # give up - for tests with an inlined bit of C code
- raise NotImplementedError("cannot call a C function defined in "
- "a custom C source snippet")
+ sources = getattr(funcptr._obj, 'sources', None)
+ if sources:
+ assert len(sources) == 1
+ dllname = compile_c_snippet(funcptr._obj._name, sources[0])
+ libraries = [dllname]
+ else:
+ libraries = getattr(funcptr._obj, 'libraries', None)
+
FUNCTYPE = lltype.typeOf(funcptr).TO
funcname = funcptr._obj._name
- libraries = getattr(funcptr._obj, 'libraries', None)
if not libraries:
cfunc = get_on_lib(standard_c_lib, funcname)
# XXX magic: on Windows try to load the function from 'kernel32' too
@@ -688,7 +702,7 @@
# should have in C. We have to save it away from one external C function
# call to the next. Otherwise a non-zero value left behind will confuse
# CPython itself a bit later, and/or CPython will stamp on it before we
-# try to inspect it via rffi.get_errno().
+# try to inspect it via rposix.get_errno().
TLS = tlsobject()
# helpers to save/restore the C-level errno -- platform-specific because
Modified: pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/module/ll_math.py Wed Nov 21 15:40:43 2007
@@ -3,6 +3,7 @@
import py
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.tool.sourcetools import func_with_new_name
+from pypy.rlib import rposix
math_frexp = rffi.llexternal('frexp', [rffi.DOUBLE, rffi.INTP], rffi.DOUBLE,
sandboxsafe=True)
@@ -40,11 +41,11 @@
return r
def _error_reset():
- rffi.set_errno(0)
+ rposix.set_errno(0)
ERANGE = errno.ERANGE
def _check_error(x):
- errno = rffi.get_errno()
+ errno = rposix.get_errno()
if errno:
if errno == ERANGE:
if not x:
Modified: pypy/dist/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rffi.py Wed Nov 21 15:40:43 2007
@@ -242,40 +242,51 @@
def COpaquePtr(*args, **kwds):
return lltype.Ptr(COpaque(*args, **kwds))
-def CExternVariable(TYPE, name, _CConstantClass=CConstant):
+def CExternVariable(TYPE, name, _CConstantClass=CConstant, includes=[], include_dirs=[]):
"""Return a pair of functions - a getter and a setter - to access
the given global C variable.
"""
- # XXX THIS IS ONLY A QUICK HACK TO MAKE IT WORK
- # In general, we need to re-think a few things to be more consistent,
- # e.g. what if a CStruct, COpaque or CExternVariable requires
- # some #include...
- assert not isinstance(TYPE, lltype.ContainerType)
- CTYPE = lltype.FixedSizeArray(TYPE, 1)
- c_variable_ref = _CConstantClass('(&%s)' % (name,), lltype.Ptr(CTYPE))
- def getter():
- return c_variable_ref[0]
- def setter(newvalue):
- c_variable_ref[0] = newvalue
- return (func_with_new_name(getter, '%s_getter' % (name,)),
- func_with_new_name(setter, '%s_setter' % (name,)))
-
-
-class CConstantErrno(CConstant):
- # these accessors are used when calling get_errno() or set_errno()
- # on top of CPython
- def __getitem__(self, index):
- assert index == 0
- try:
- return ll2ctypes.TLS.errno
- except AttributeError:
- raise ValueError("no C function call occurred so far, "
- "errno is undefined")
- def __setitem__(self, index, value):
- assert index == 0
- ll2ctypes.TLS.errno = value
-
-get_errno, set_errno = CExternVariable(lltype.Signed, 'errno', CConstantErrno)
+ from pypy.translator.c.primitive import PrimitiveType
+ # XXX we cannot really enumerate all C types here, do it on a case-by-case
+ # basis
+ if TYPE == CCHARPP:
+ c_type = 'char **'
+ elif TYPE == CCHARP:
+ c_type = 'char *'
+ else:
+ c_type = PrimitiveType[TYPE]
+ assert c_type.endswith(' @')
+ c_type = c_type[:-2] # cut the trailing ' @'
+
+ getter_name = 'get_' + name
+ setter_name = 'set_' + name
+ c_getter = "%(c_type)s %(getter_name)s () { return %(name)s; }" % locals()
+ c_setter = "void %(setter_name)s (%(c_type)s v) { %(name)s = v; }" % locals()
+
+ lines = ["#include <%s>" % i for i in includes]
+ lines.append(c_getter)
+ lines.append(c_setter)
+ sources = ('\n'.join(lines),)
+
+ kwds = {'includes': includes, 'sources':sources,
+ 'include_dirs':include_dirs}
+ getter = llexternal(getter_name, [], TYPE, **kwds)
+ setter = llexternal(setter_name, [TYPE], lltype.Void, **kwds)
+ return getter, setter
+
+## # XXX THIS IS ONLY A QUICK HACK TO MAKE IT WORK
+## # In general, we need to re-think a few things to be more consistent,
+## # e.g. what if a CStruct, COpaque or CExternVariable requires
+## # some #include...
+## assert not isinstance(TYPE, lltype.ContainerType)
+## CTYPE = lltype.FixedSizeArray(TYPE, 1)
+## c_variable_ref = _CConstantClass('(&%s)' % (name,), lltype.Ptr(CTYPE))
+## def getter():
+## return c_variable_ref[0]
+## def setter(newvalue):
+## c_variable_ref[0] = newvalue
+## return (func_with_new_name(getter, '%s_getter' % (name,)),
+## func_with_new_name(setter, '%s_setter' % (name,)))
# char, represented as a Python character
# (use SIGNEDCHAR or UCHAR for the small integer types)
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Wed Nov 21 15:40:43 2007
@@ -8,7 +8,7 @@
from pypy.rpython.lltypesystem.ll2ctypes import uninitialized2ctypes
from pypy.rpython.lltypesystem.ll2ctypes import ALLOCATED
from pypy.rpython.annlowlevel import llhelper
-
+from pypy.rlib import rposix
class TestLL2Ctypes(object):
@@ -598,7 +598,7 @@
# the next line is a random external function call,
# to check that it doesn't reset errno
strlen("hi!")
- err = rffi.get_errno()
+ err = rposix.get_errno()
import errno
assert err == errno.EBADF
assert not ALLOCATED # detects memory leaks in the test
@@ -676,3 +676,8 @@
fcntl_str(12345, 3, "xxx")
fcntl_int(12345, 1, 0)
+ def test_llexternal_source(self):
+ fn = rffi.llexternal('fn', [], rffi.INT, sources = ["int fn() { return 42; }"])
+ res = fn()
+ assert res == 42
+
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py Wed Nov 21 15:40:43 2007
@@ -1,6 +1,7 @@
import py
from pypy.rpython.lltypesystem.rffi import *
+from pypy.rlib.rposix import get_errno, set_errno
from pypy.translator.c.test.test_genc import compile
from pypy.rpython.lltypesystem.lltype import Signed, Ptr, Char, malloc
from pypy.rpython.lltypesystem import lltype
@@ -287,8 +288,7 @@
assert offsetof(S, "c_b") == struct.calcsize("hi") - struct.calcsize("i")
assert offsetof(S, "c_c") == struct.calcsize("hii") - struct.calcsize("i")
-def test_prebuild_constant():
- py.test.skip("WIP")
+def test_prebuilt_constant():
h_source = py.code.Source("""
#ifndef _CONSTANTS
#define _CONSTANTS
Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os.py Wed Nov 21 15:40:43 2007
@@ -16,6 +16,7 @@
from pypy.rpython.lltypesystem import rffi
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.tool import rffi_platform as platform
+from pypy.rlib import rposix
posix = __import__(os.name)
if sys.platform.startswith('win'):
@@ -72,7 +73,7 @@
def c_func_llimpl():
res = rffi.cast(rffi.LONG, c_func())
if res == -1:
- raise OSError(rffi.get_errno(), "%s failed" % name)
+ raise OSError(rposix.get_errno(), "%s failed" % name)
return res
c_func_llimpl.func_name = name + '_llimpl'
@@ -84,7 +85,7 @@
def c_func_llimpl(arg):
res = rffi.cast(rffi.LONG, c_func(arg))
if res == -1:
- raise OSError(rffi.get_errno(), "%s failed" % name)
+ raise OSError(rposix.get_errno(), "%s failed" % name)
c_func_llimpl.func_name = name + '_llimpl'
@@ -100,7 +101,7 @@
l_args = rffi.liststr2charpp(args)
os_execv(path, l_args)
rffi.free_charpp(l_args)
- raise OSError(rffi.get_errno(), "execv failed")
+ raise OSError(rposix.get_errno(), "execv failed")
return extdef([str, [str]], s_ImpossibleValue, llimpl=execv_llimpl,
export_name="ll_os.ll_os_execv")
@@ -117,7 +118,7 @@
childpid = os_spawnv(mode, path, l_args)
rffi.free_charpp(l_args)
if childpid == -1:
- raise OSError(rffi.get_errno(), "os_spawnv failed")
+ raise OSError(rposix.get_errno(), "os_spawnv failed")
return rffi.cast(lltype.Signed, childpid)
return extdef([int, str, [str]], int, llimpl=spawnv_llimpl,
@@ -130,7 +131,7 @@
def dup_llimpl(fd):
newfd = rffi.cast(lltype.Signed, os_dup(rffi.cast(rffi.INT, fd)))
if newfd == -1:
- raise OSError(rffi.get_errno(), "dup failed")
+ raise OSError(rposix.get_errno(), "dup failed")
return newfd
return extdef([int], int, llimpl=dup_llimpl,
@@ -145,7 +146,7 @@
error = rffi.cast(lltype.Signed, os_dup2(rffi.cast(rffi.INT, fd),
rffi.cast(rffi.INT, newfd)))
if error == -1:
- raise OSError(rffi.get_errno(), "dup2 failed")
+ raise OSError(rposix.get_errno(), "dup2 failed")
return extdef([int, int], s_None, llimpl=dup2_llimpl,
export_name="ll_os.ll_os_dup2")
@@ -204,7 +205,7 @@
actime, modtime = tp
error = os_utime_platform(path, actime, modtime)
if error == -1:
- raise OSError(rffi.get_errno(), "os_utime failed")
+ raise OSError(rposix.get_errno(), "os_utime failed")
os_utime_llimpl._annspecialcase_ = 'specialize:argtype(1)'
s_string = SomeString()
@@ -287,7 +288,7 @@
try:
result = os_times(l_tmsbuf)
if result == rffi.cast(self.CLOCK_T, -1):
- raise OSError(rffi.get_errno(), "times failed")
+ raise OSError(rposix.get_errno(), "times failed")
return (
l_tmsbuf.c_tms_utime / CLOCK_TICKS_PER_SECOND,
l_tmsbuf.c_tms_stime / CLOCK_TICKS_PER_SECOND,
@@ -306,7 +307,7 @@
def setsid_llimpl():
result = rffi.cast(lltype.Signed, os_setsid())
if result == -1:
- raise OSError(rffi.get_errno(), "os_setsid failed")
+ raise OSError(rposix.get_errno(), "os_setsid failed")
return result
return extdef([], int, export_name="ll_os.ll_os_setsid",
@@ -333,7 +334,7 @@
l_utsbuf = lltype.malloc(UTSNAMEP.TO, flavor='raw')
result = os_uname(l_utsbuf)
if result == -1:
- raise OSError(rffi.get_errno(), "os_uname failed")
+ raise OSError(rposix.get_errno(), "os_uname failed")
retval = (
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_sysname)),
rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_nodename)),
@@ -380,7 +381,7 @@
def os_open_llimpl(path, flags, mode):
result = rffi.cast(rffi.LONG, os_open(path, flags, mode))
if result == -1:
- raise OSError(rffi.get_errno(), "os_open failed")
+ raise OSError(rposix.get_errno(), "os_open failed")
return result
def os_open_oofakeimpl(o_path, flags, mode):
@@ -405,7 +406,7 @@
got = rffi.cast(lltype.Signed, os_read(rffi.cast(rffi.INT, fd),
inbuf, rffi.cast(rffi.SIZE_T, count)))
if got < 0:
- raise OSError(rffi.get_errno(), "os_read failed")
+ raise OSError(rposix.get_errno(), "os_read failed")
# XXX too many copies of the data!
l = [inbuf[i] for i in range(got)]
finally:
@@ -434,7 +435,7 @@
rffi.cast(rffi.INT, fd),
outbuf, rffi.cast(rffi.SIZE_T, count)))
if written < 0:
- raise OSError(rffi.get_errno(), "os_write failed")
+ raise OSError(rposix.get_errno(), "os_write failed")
finally:
lltype.free(outbuf, flavor='raw')
return written
@@ -453,7 +454,7 @@
def close_llimpl(fd):
error = rffi.cast(lltype.Signed, os_close(rffi.cast(rffi.INT, fd)))
if error == -1:
- raise OSError(rffi.get_errno(), "close failed")
+ raise OSError(rposix.get_errno(), "close failed")
return extdef([int], s_None, llimpl=close_llimpl,
export_name="ll_os.ll_os_close", oofakeimpl=os.close)
@@ -492,7 +493,7 @@
rffi.cast(rffi.INT, how))
res = rffi.cast(lltype.SignedLongLong, res)
if res < 0:
- raise OSError(rffi.get_errno(), "os_lseek failed")
+ raise OSError(rposix.get_errno(), "os_lseek failed")
return res
def os_lseek_oofakeimpl(fd, pos, how):
@@ -515,7 +516,7 @@
os_ftruncate(rffi.cast(rffi.INT, fd),
rffi.cast(rffi.LONGLONG, length)))
if res < 0:
- raise OSError(rffi.get_errno(), "os_lseek failed")
+ raise OSError(rposix.get_errno(), "os_lseek failed")
return extdef([int, r_longlong], s_None,
llimpl = ftruncate_llimpl,
@@ -602,7 +603,7 @@
res = os_getcwd(buf, rffi.cast(rffi.SIZE_T, bufsize))
if res:
break # ok
- error = rffi.get_errno()
+ error = rposix.get_errno()
lltype.free(buf, flavor='raw')
if error != errno.ERANGE:
raise OSError(error, "getcwd failed")
@@ -710,13 +711,13 @@
def os_listdir_llimpl(path):
dirp = os_opendir(path)
if not dirp:
- raise OSError(rffi.get_errno(), "os_opendir failed")
- rffi.set_errno(0)
+ raise OSError(rposix.get_errno(), "os_opendir failed")
+ rposix.set_errno(0)
result = []
while True:
direntp = os_readdir(dirp)
if not direntp:
- error = rffi.get_errno()
+ error = rposix.get_errno()
break
namep = rffi.cast(rffi.CCHARP, direntp.c_d_name)
name = rffi.charp2str(namep)
@@ -773,7 +774,7 @@
write_fd = filedes[1]
lltype.free(filedes, flavor='raw')
if error != 0:
- raise OSError(rffi.get_errno(), "os_pipe failed")
+ raise OSError(rposix.get_errno(), "os_pipe failed")
return (read_fd, write_fd)
return extdef([], (int, int),
@@ -796,7 +797,7 @@
res = os_readlink(l_path, buf, bufsize)
lltype.free(l_path, flavor='raw')
if res < 0:
- error = rffi.get_errno() # failed
+ error = rposix.get_errno() # failed
lltype.free(buf, flavor='raw')
raise OSError(error, "readlink failed")
elif res < bufsize:
@@ -843,7 +844,7 @@
status = status_p[0]
lltype.free(status_p, flavor='raw')
if result == -1:
- raise OSError(rffi.get_errno(), "os_waitpid failed")
+ raise OSError(rposix.get_errno(), "os_waitpid failed")
return (rffi.cast(lltype.Signed, result),
rffi.cast(lltype.Signed, status))
@@ -893,7 +894,7 @@
def unlink_llimpl(pathname):
res = os_unlink(pathname)
if res < 0:
- raise OSError(rffi.get_errno(), "os_unlink failed")
+ raise OSError(rposix.get_errno(), "os_unlink failed")
return extdef([str], s_None, llimpl=unlink_llimpl,
export_name="ll_os.ll_os_unlink")
@@ -905,7 +906,7 @@
def chdir_llimpl(path):
res = os_chdir(path)
if res < 0:
- raise OSError(rffi.get_errno(), "os_chdir failed")
+ raise OSError(rposix.get_errno(), "os_chdir failed")
return extdef([str], s_None, llimpl=chdir_llimpl,
export_name="ll_os.ll_os_chdir")
@@ -926,7 +927,7 @@
else:
res = os_mkdir(pathname, mode)
if res < 0:
- raise OSError(rffi.get_errno(), "os_mkdir failed")
+ raise OSError(rposix.get_errno(), "os_mkdir failed")
return extdef([str, int], s_None, llimpl=mkdir_llimpl,
export_name="ll_os.ll_os_mkdir")
@@ -938,7 +939,7 @@
def rmdir_llimpl(pathname):
res = os_rmdir(pathname)
if res < 0:
- raise OSError(rffi.get_errno(), "os_rmdir failed")
+ raise OSError(rposix.get_errno(), "os_rmdir failed")
return extdef([str], s_None, llimpl=rmdir_llimpl,
export_name="ll_os.ll_os_rmdir")
@@ -951,7 +952,7 @@
def chmod_llimpl(path, mode):
res = os_chmod(path, rffi.cast(rffi.MODE_T, mode))
if res < 0:
- raise OSError(rffi.get_errno(), "os_chmod failed")
+ raise OSError(rposix.get_errno(), "os_chmod failed")
return extdef([str, int], s_None, llimpl=chmod_llimpl,
export_name="ll_os.ll_os_chmod")
@@ -964,7 +965,7 @@
def rename_llimpl(oldpath, newpath):
res = os_rename(oldpath, newpath)
if res < 0:
- raise OSError(rffi.get_errno(), "os_rename failed")
+ raise OSError(rposix.get_errno(), "os_rename failed")
return extdef([str, str], s_None, llimpl=rename_llimpl,
export_name="ll_os.ll_os_rename")
@@ -989,7 +990,7 @@
res = os_kill(rffi.cast(rffi.PID_T, pid),
rffi.cast(rffi.INT, sig))
if res < 0:
- raise OSError(rffi.get_errno(), "os_kill failed")
+ raise OSError(rposix.get_errno(), "os_kill failed")
return extdef([int, int], s_None, llimpl=kill_llimpl,
export_name="ll_os.ll_os_kill")
@@ -1002,7 +1003,7 @@
def link_llimpl(oldpath, newpath):
res = os_link(oldpath, newpath)
if res < 0:
- raise OSError(rffi.get_errno(), "os_link failed")
+ raise OSError(rposix.get_errno(), "os_link failed")
return extdef([str, str], s_None, llimpl=link_llimpl,
export_name="ll_os.ll_os_link")
@@ -1015,7 +1016,7 @@
def symlink_llimpl(oldpath, newpath):
res = os_symlink(oldpath, newpath)
if res < 0:
- raise OSError(rffi.get_errno(), "os_symlink failed")
+ raise OSError(rposix.get_errno(), "os_symlink failed")
return extdef([str, str], s_None, llimpl=symlink_llimpl,
export_name="ll_os.ll_os_symlink")
@@ -1027,7 +1028,7 @@
def fork_llimpl():
childpid = os_fork()
if childpid == -1:
- raise OSError(rffi.get_errno(), "os_fork failed")
+ raise OSError(rposix.get_errno(), "os_fork failed")
return rffi.cast(lltype.Signed, childpid)
return extdef([], int, llimpl=fork_llimpl,
@@ -1102,7 +1103,7 @@
def ttyname_llimpl(fd):
l_name = os_ttyname(fd)
if not l_name:
- raise OSError(rffi.get_errno(), "ttyname raised")
+ raise OSError(rposix.get_errno(), "ttyname raised")
return rffi.charp2str(l_name)
return extdef([int], str, "ll_os.ttyname",
Modified: pypy/dist/pypy/rpython/module/ll_os_environ.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os_environ.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os_environ.py Wed Nov 21 15:40:43 2007
@@ -3,6 +3,7 @@
from pypy.rpython.controllerentry import Controller
from pypy.rpython.extfunc import register_external
from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.rlib import rposix
# ____________________________________________________________
#
@@ -84,7 +85,7 @@
error = os_putenv(l_string)
if error:
rffi.free_charp(l_string)
- raise OSError(rffi.get_errno(), "os_putenv failed")
+ raise OSError(rposix.get_errno(), "os_putenv failed")
# keep 'l_string' alive - we know that the C library needs it
# until the next call to putenv() with the same 'name'.
l_oldstring = envkeepalive.byname.get(name, lltype.nullptr(rffi.CCHARP.TO))
@@ -115,7 +116,7 @@
error = os_unsetenv(l_name) # 'error' is None on OS/X
rffi.free_charp(l_name)
if error:
- raise OSError(rffi.get_errno(), "os_unsetenv failed")
+ raise OSError(rposix.get_errno(), "os_unsetenv failed")
try:
l_oldstring = envkeepalive.byname[name]
except KeyError:
Modified: pypy/dist/pypy/rpython/module/ll_os_stat.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os_stat.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os_stat.py Wed Nov 21 15:40:43 2007
@@ -10,6 +10,7 @@
from pypy.rpython.extfunc import register_external
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rpython.lltypesystem.rtupletype import TUPLE_TYPE
+from pypy.rlib import rposix
# XXX on Windows, stat() is flawed; see CPython's posixmodule.c for
# an implementation based on the Win32 API
@@ -208,7 +209,7 @@
if arg_is_path:
rffi.free_charp(arg)
if error != 0:
- raise OSError(rffi.get_errno(), "os_?stat failed")
+ raise OSError(rposix.get_errno(), "os_?stat failed")
return build_stat_result(stresult)
finally:
lltype.free(stresult, flavor='raw')
Modified: pypy/dist/pypy/rpython/module/ll_strtod.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_strtod.py (original)
+++ pypy/dist/pypy/rpython/module/ll_strtod.py Wed Nov 21 15:40:43 2007
@@ -6,6 +6,7 @@
from pypy.translator.tool.cbuild import cache_c_module
from pypy.tool.autopath import pypydir
from pypy.rpython.ootypesystem import ootype
+from pypy.rlib import rposix
class CConfig:
_includes_ = ['src/ll_strtod.h']
@@ -51,7 +52,7 @@
def llimpl(sign, beforept, afterpt, exponent):
res = ll_parts_to_float(sign, beforept, afterpt, exponent)
- if res == -1 and rffi.get_errno() == 42:
+ if res == -1 and rposix.get_errno() == 42:
raise ValueError("Wrong literal for float")
return res
Modified: pypy/dist/pypy/rpython/module/ll_time.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_time.py (original)
+++ pypy/dist/pypy/rpython/module/ll_time.py Wed Nov 21 15:40:43 2007
@@ -8,6 +8,7 @@
from pypy.rpython.tool import rffi_platform as platform
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.extfunc import BaseLazyRegistering, registering, extdef
+from pypy.rlib import rposix
class CConfig:
if sys.platform.startswith('win'):
@@ -163,9 +164,9 @@
t.c_tv_sec = int(secs)
t.c_tv_usec = int(frac*1000000.0)
if rffi.cast(rffi.LONG, c_select(0, void, void, void, t)) != 0:
- errno = rffi.get_errno()
+ errno = rposix.get_errno()
if errno != EINTR:
- raise OSError(rffi.get_errno(), "Select failed")
+ raise OSError(rposix.get_errno(), "Select failed")
finally:
lltype.free(t, flavor='raw')
Modified: pypy/dist/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/dist/pypy/translator/tool/cbuild.py (original)
+++ pypy/dist/pypy/translator/tool/cbuild.py Wed Nov 21 15:40:43 2007
@@ -158,6 +158,7 @@
modname = str(cache_dir.join(modname))
compile_c_module(cfiles, modname, include_dirs=include_dirs,
libraries=libraries)
+ return modname + '.so'
def make_module_from_c(cfile, include_dirs=None, libraries=[]):
cfile = py.path.local(cfile)
More information about the Pypy-commit
mailing list