[pypy-svn] r46154 - in pypy/branch/pypy-more-rtti-inprogress/rpython: . module

arigo at codespeak.net arigo at codespeak.net
Wed Aug 29 13:45:12 CEST 2007


Author: arigo
Date: Wed Aug 29 13:45:11 2007
New Revision: 46154

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
Log:
In-progress Windowsification.  I hope I didn't break it on Linux.


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/extfunc.py	Wed Aug 29 13:45:11 2007
@@ -32,6 +32,11 @@
     except (SystemExit, MemoryError, KeyboardInterrupt), e:
         raise
     except:
+        if 0:
+            import sys, traceback
+            print >> sys.stderr, 'WARNING: cannot register', func_or_list, ':'
+            traceback.print_exc()
+            import pdb; pdb.set_trace()
         exc, exc_inst, tb = sys.exc_info()
         for func in funcs:
             # if the function has already been registered and we got

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	Wed Aug 29 13:45:11 2007
@@ -20,43 +20,12 @@
 from pypy.rpython.tool import rffi_platform
 posix = __import__(os.name)
 
-class CConfig:
-    """
-    Definitions for platform integration.
-
-    Note: this must be processed through rffi_platform.configure() to provide
-    usable objects.  For example::
-
-        CLOCK_T = rffi_platform.configure(CConfig)['CLOCK_T']
-        register(function, [CLOCK_T], ...)
-
-    """
-    includes = ['sys/times.h']
-    # XXX argh, argh, argh, should be automatic
-    _header_ = "\n".join(["#include <%s>" % name for name in includes])
-
-    CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
-
-    TMS = rffi_platform.Struct(
-        'struct tms', [('tms_utime', rffi.INT),
-                       ('tms_stime', rffi.INT),
-                       ('tms_cutime', rffi.INT),
-                       ('tms_cstime', rffi.INT)])
-
 
 class RegisterOs(BaseLazyRegistering):
     UNISTD_INCL = ['unistd.h', 'sys/types.h']
 
     def __init__(self):
-        # Grab all of the platform type definitions and stash them as instance
-        # attributes (this is quite a hack, what a lazy programmer I must be).
-        self.__dict__.update(rffi_platform.configure(CConfig))
-        # Make some pointer types too
-        self.TMSP = lltype.Ptr(self.TMS)
-        # Here is a random extra platform parameter which is important.
-        # Strictly speaking, this should probably be retrieved at runtime, not
-        # at translation time.
-        self.CLOCK_TICKS_PER_SECOND = float(os.sysconf('SC_CLK_TCK'))
+        pass
 
     # a simple, yet usefull factory
     def extdef_for_os_function_returning_int(self, name, **kwds):
@@ -135,6 +104,9 @@
 
     @registering(os.utime)
     def register_os_utime(self):
+        #START
+        #print rffi.platform.has('utimes'), rffi.platform.has('utime')
+        #STOP
         TIME_T = rffi.INT    # XXX do the right thing
         UTIMEBUFP = rffi.CStructPtr('utimbuf', ('actime', TIME_T),
                                     ('modtime', TIME_T))
@@ -195,22 +167,56 @@
 
     @registering(os.times)
     def register_os_times(self):
-        # XXX sys/times.h isn't so portable, maybe.
-        os_times = rffi.llexternal('times', [self.TMSP], self.CLOCK_T,
+        # XXX sys/times.h isn't portable
+        class CConfig:
+            """
+            Definitions for platform integration.
+
+            Note: this must be processed through rffi_platform.configure() to 
+            provide usable objects.  For example::
+
+                CLOCK_T = rffi_platform.configure(CConfig)['CLOCK_T']
+                register(function, [CLOCK_T], ...)
+
+            """
+            includes = ['sys/times.h']
+            # XXX argh, argh, argh, should be automatic
+            _header_ = "\n".join(["#include <%s>" % name for name in includes])
+
+            CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
+
+            TMS = rffi_platform.Struct(
+                'struct tms', [('tms_utime', rffi.INT),
+                               ('tms_stime', rffi.INT),
+                               ('tms_cutime', rffi.INT),
+                               ('tms_cstime', rffi.INT)])
+
+        # Grab all of the platform type definitions
+        config = rffi_platform.configure(CConfig)
+        CLOCK_T = config['CLOCK_T']
+        TMS = config['TMS']
+        # Make some pointer types too
+        TMSP = lltype.Ptr(TMS)
+        # Here is a random extra platform parameter which is important.
+        # Strictly speaking, this should probably be retrieved at runtime, not
+        # at translation time.
+        CLOCK_TICKS_PER_SECOND = float(os.sysconf('SC_CLK_TCK'))
+
+        os_times = rffi.llexternal('times', [TMSP], CLOCK_T,
                                    includes=['sys/times.h'])
 
         def times_lltypeimpl():
-            l_tmsbuf = lltype.malloc(self.TMSP.TO, flavor='raw')
+            l_tmsbuf = lltype.malloc(TMSP.TO, flavor='raw')
             try:
                 result = os_times(l_tmsbuf)
                 if result == -1:
                     raise OSError(rffi.get_errno(), "times failed")
                 return (
-                    l_tmsbuf.c_tms_utime / self.CLOCK_TICKS_PER_SECOND,
-                    l_tmsbuf.c_tms_stime / self.CLOCK_TICKS_PER_SECOND,
-                    l_tmsbuf.c_tms_cutime / self.CLOCK_TICKS_PER_SECOND,
-                    l_tmsbuf.c_tms_cstime / self.CLOCK_TICKS_PER_SECOND,
-                    result / self.CLOCK_TICKS_PER_SECOND)
+                    l_tmsbuf.c_tms_utime / CLOCK_TICKS_PER_SECOND,
+                    l_tmsbuf.c_tms_stime / CLOCK_TICKS_PER_SECOND,
+                    l_tmsbuf.c_tms_cutime / CLOCK_TICKS_PER_SECOND,
+                    l_tmsbuf.c_tms_cstime / CLOCK_TICKS_PER_SECOND,
+                    result / CLOCK_TICKS_PER_SECOND)
             finally:
                 lltype.free(l_tmsbuf, flavor='raw')
         self.register(os.times, [], (float, float, float, float, float),



More information about the Pypy-commit mailing list