[pypy-svn] pypy default: os.major(), os.minor(), in translation.

arigo commits-noreply at bitbucket.org
Sat Jan 29 16:11:04 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41447:2467ae13e0e7
Date: 2011-01-29 16:06 +0100
http://bitbucket.org/pypy/pypy/changeset/2467ae13e0e7/

Log:	os.major(), os.minor(), in translation.

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -795,6 +795,22 @@
         return extdef([], (float, float, float),
                       "ll_os.ll_getloadavg", llimpl=getloadavg_llimpl)
 
+    @registering_if(os, 'major')
+    def register_os_major(self):
+        c_major = self.llexternal('major', [rffi.INT], rffi.INT)
+        def major_llimpl(dev):
+            return c_major(dev)
+        return extdef([int], int,
+                      "ll_os.ll_major", llimpl=major_llimpl)
+
+    @registering_if(os, 'minor')
+    def register_os_minor(self):
+        c_minor = self.llexternal('minor', [rffi.INT], rffi.INT)
+        def minor_llimpl(dev):
+            return c_minor(dev)
+        return extdef([int], int,
+                      "ll_os.ll_minor", llimpl=minor_llimpl)
+
 # ------------------------------- os.read -------------------------------
 
     @registering(os.read)

diff --git a/pypy/translator/c/test/test_extfunc.py b/pypy/translator/c/test/test_extfunc.py
--- a/pypy/translator/c/test/test_extfunc.py
+++ b/pypy/translator/c/test/test_extfunc.py
@@ -845,6 +845,16 @@
         res = f()
         assert type(res) is float and res >= 0.0
 
+if hasattr(os, 'major'):
+    def test_os_major_minor():
+        def does_stuff(n):
+            a = os.major(n)
+            b = os.minor(n)
+            return '%d,%d' % (a, b)
+        f = compile(does_stuff, [int])
+        res = f(12345)
+        assert res == '%d,%d' % (os.major(12345), os.minor(12345))
+
 if hasattr(os, 'fchdir'):
     def test_os_fchdir():
         def does_stuff():


More information about the Pypy-commit mailing list