[pypy-svn] r45974 - pypy/branch/pypy-more-rtti-inprogress/rpython/module
fijal at codespeak.net
fijal at codespeak.net
Sat Aug 25 12:49:31 CEST 2007
Author: fijal
Date: Sat Aug 25 12:49:29 2007
New Revision: 45974
Modified:
pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py
Log:
Fix slightly ll_time. the problem now is that HAVE_XXX is always false,
next in my todo list.
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_time.py Sat Aug 25 12:49:29 2007
@@ -3,6 +3,7 @@
"""
import time, sys, math
+from errno import EINTR
from pypy.rpython.lltypesystem import rffi
from pypy.rpython.tool import rffi_platform as platform
from pypy.rpython.lltypesystem import lltype
@@ -10,12 +11,13 @@
class CConfig:
if sys.platform.startswith('win'):
- includes = ['sys/time.h', 'windows.h']
+ includes = ['time.h', 'windows.h']
else:
- includes = ['time.h', 'errno.h', 'sys/select.h', 'sys/types.h',
- 'unistd.h', 'sys/timeb.h']
+ includes = ['sys/time.h', 'time.h', 'errno.h', 'sys/select.h',
+ 'sys/types.h', 'unistd.h', 'sys/timeb.h']
# XXX argh, argh, argh, should be automatic
_header_ = "\n".join(["#include <%s>" % name for name in includes])
+
CLOCK_T = platform.SimpleType('clock_t', rffi.INT)
TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.INT),
('tv_usec', rffi.INT)])
@@ -126,15 +128,15 @@
# someone forgotten to call hop.exception_is_here
void = lltype.nullptr(rffi.VOIDP.TO)
t = lltype.malloc(self.TIMEVAL, flavor='raw')
- #try:
- frac = secs % 1.0
- t.c_tv_sec = int(secs)
- t.c_tv_usec = int(frac*1000000.0)
- if c_select(0, void, void, void, t) != 0:
- # XXX EINTR
+ try:
+ frac = math.fmod(secs, 1.0)
+ t.c_tv_sec = int(secs)
+ t.c_tv_usec = int(frac*1000000.0)
+ if c_select(0, void, void, void, t) != 0:
+ errno = rffi.get_errno()
+ if errno != EINTR:
+ raise OSError(rffi.get_errno(), "Select failed")
+ finally:
lltype.free(t, flavor='raw')
- raise IOError("Select failed")
- #finally:
- lltype.free(t, flavor='raw')
self.register(time.sleep, [float], None, llimpl=time_sleep_llimpl,
export_name='ll_time.ll_time_sleep')
More information about the Pypy-commit
mailing list