Commits

Armin Rigo  committed 2467ae1

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

  • Participants
  • Parent commits e333a0a

Comments (0)

Files changed (2)

File pypy/rpython/module/ll_os.py

         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)

File pypy/translator/c/test/test_extfunc.py

         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():