[pypy-svn] pypy default: use {get, set}intfield when reading and writing to time data

bivab commits-noreply at bitbucket.org
Sat Jan 22 08:50:12 CET 2011


Author: David Schneider <david.schneider at picle.org>
Branch: 
Changeset: r41198:976bc301d7a8
Date: 2011-01-22 08:47 +0100
http://bitbucket.org/pypy/pypy/changeset/976bc301d7a8/

Log:	use {get,set}intfield when reading and writing to time data

diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -124,7 +124,7 @@
             res = _gettimeofday(now, None)
             if res < 0:
                 raise OSError(rposix.get_errno(), "gettimeofday failed")
-            return now[0].c_tv_sec, now[0].c_tv_usec
+            return rffi.getintfield(now[0], 'c_tv_sec'), rffi.getintfield(now[0], 'c_tv_usec')
         finally:
             lltype.free(now, flavor='raw')
 
@@ -257,10 +257,13 @@
             now_sec, now_usec = gettimeofday()
 
             deadline = lltype.malloc(TIMESPECP.TO, 1, flavor='raw')
-            deadline[0].c_tv_sec = now_sec + sec
-            rffi.setintfield(deadline[0], "c_tv_nsec", now_usec * 1000 + nsec)
-            deadline[0].c_tv_sec += (deadline[0].c_tv_nsec / 1000000000)
-            deadline[0].c_tv_nsec %= 1000000000
+            rffi.setintfield(deadline[0], 'c_tv_sec', now_sec + sec)
+            rffi.setintfield(deadline[0], 'c_tv_nsec', now_usec * 1000 + nsec)
+            val = rffi.getintfield(deadline[0], 'c_tv_sec') + \
+                                rffi.getintfield(deadline[0], 'c_tv_nsec') / 1000000000
+            rffi.setintfield(deadline[0], 'c_tv_sec', val)
+            val = rffi.getintfield(deadline[0], 'c_tv_nsec') % 1000000000
+            rffi.setintfield(deadline[0], 'c_tv_nsec', val)
         try:
             while True:
                 try:


More information about the Pypy-commit mailing list