[pypy-svn] r68484 - in pypy/trunk/pypy: rlib rpython/module
fijal at codespeak.net
fijal at codespeak.net
Thu Oct 15 11:52:12 CEST 2009
Author: fijal
Date: Thu Oct 15 11:52:12 2009
New Revision: 68484
Modified:
pypy/trunk/pypy/rlib/rpoll.py
pypy/trunk/pypy/rpython/module/ll_os.py
pypy/trunk/pypy/rpython/module/ll_time.py
Log:
(glavoie)
commit patch for mac os x snow leopard
Modified: pypy/trunk/pypy/rlib/rpoll.py
==============================================================================
--- pypy/trunk/pypy/rlib/rpoll.py (original)
+++ pypy/trunk/pypy/rlib/rpoll.py Thu Oct 15 11:52:12 2009
@@ -102,10 +102,10 @@
else:
ll_excl = lltype.nullptr(_c.fd_set.TO)
if timeout != -1.0:
- ll_timeval = lltype.malloc(_c.timeval, flavor='raw')
- frac = math.fmod(timeout, 1.0)
- ll_timeval.c_tv_sec = int(timeout)
- ll_timeval.c_tv_usec = int((timeout - int(timeout)) * 1000000.0)
+ ll_timeval = rffi.make(_c.timeval)
+ rffi.setintfield(ll_timeval, 'c_tv_sec', int(timeout))
+ rffi.setintfield(ll_timeval, 'c_tv_usec', int((timeout-int(timeout))
+ * 1000000))
else:
ll_timeval = lltype.nullptr(_c.timeval)
try:
Modified: pypy/trunk/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_os.py (original)
+++ pypy/trunk/pypy/rpython/module/ll_os.py Thu Oct 15 11:52:12 2009
@@ -328,11 +328,11 @@
import math
l_times = lltype.malloc(TIMEVAL2P.TO, 2, flavor='raw')
fracpart, intpart = math.modf(actime)
- l_times[0].c_tv_sec = int(intpart)
- l_times[0].c_tv_usec = int(fracpart * 1E6)
+ rffi.setintfield(l_times[0], 'c_tv_sec', int(intpart))
+ rffi.setintfield(l_times[0], 'c_tv_usec', int(fracpart * 1E6))
fracpart, intpart = math.modf(modtime)
- l_times[1].c_tv_sec = int(intpart)
- l_times[1].c_tv_usec = int(fracpart * 1E6)
+ rffi.setintfield(l_times[1], 'c_tv_sec', int(intpart))
+ rffi.setintfield(l_times[1], 'c_tv_usec', int(fracpart * 1E6))
error = os_utimes(path, l_times)
lltype.free(l_times, flavor='raw')
return error
Modified: pypy/trunk/pypy/rpython/module/ll_time.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_time.py (original)
+++ pypy/trunk/pypy/rpython/module/ll_time.py Thu Oct 15 11:52:12 2009
@@ -101,14 +101,17 @@
if self.HAVE_GETTIMEOFDAY:
t = lltype.malloc(self.TIMEVAL, flavor='raw')
+ errcode = -1
if self.GETTIMEOFDAY_NO_TZ:
- if rffi.cast(rffi.LONG, c_gettimeofday(t)) == 0:
- result = float(t.c_tv_sec) + \
- float(t.c_tv_usec) * 0.000001
+ errcode = g_gettimeofday(t)
else:
- if rffi.cast(rffi.LONG, c_gettimeofday(t, void)) == 0:
- result = float(t.c_tv_sec) + \
- float(t.c_tv_usec) * 0.000001
+ errcode = c_gettimeofday(t, void)
+
+ if rffi.cast(rffi.LONG, errcode) == 0:
+ result = float(rffi.cast(lltype.Signed, t.c_tv_sec)) \
+ + float(rffi.cast(lltype.Signed, t.c_tv_usec)) \
+ * 0.000001
+
lltype.free(t, flavor='raw')
if result != -1:
return result
@@ -181,8 +184,9 @@
t = lltype.malloc(self.TIMEVAL, flavor='raw')
try:
frac = math.fmod(secs, 1.0)
- t.c_tv_sec = int(secs)
- t.c_tv_usec = int(frac*1000000.0)
+ rffi.setintfield(t, 'c_tv_sec', int(secs))
+ rffi.setintfield(t, 'c_tv_usec', int(frac*1000000.0))
+
if rffi.cast(rffi.LONG, c_select(0, void, void, void, t)) != 0:
errno = rposix.get_errno()
if errno != EINTR:
More information about the Pypy-commit
mailing list