[pypy-svn] r28253 - in pypy/dist/pypy/rpython/rctypes/tool: . test

hpk at codespeak.net hpk at codespeak.net
Sun Jun 4 14:58:20 CEST 2006


Author: hpk
Date: Sun Jun  4 14:58:19 2006
New Revision: 28253

Added:
   pypy/dist/pypy/rpython/rctypes/tool/libc.py   (contents, props changed)
   pypy/dist/pypy/rpython/rctypes/tool/test/test_libc.py   (contents, props changed)
Log:
add loading of libc in a central place (to be used
by modules and tests etc.)


Added: pypy/dist/pypy/rpython/rctypes/tool/libc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/rctypes/tool/libc.py	Sun Jun  4 14:58:19 2006
@@ -0,0 +1,22 @@
+import sys
+from ctypes import *
+
+# __________ the standard C library __________
+
+# LoadLibrary is deprecated in ctypes, this should be removed at some point
+if "load" in dir(cdll):
+    cdll_load = cdll.load
+else:
+    cdll_load = cdll.LoadLibrary
+
+if sys.platform == 'win32':
+    libc = cdll_load('msvcrt.dll')
+elif sys.platform == 'linux2':
+    libc = cdll_load('libc.so.6')
+elif sys.platform == 'darwin':
+    libc = cdll_load('libc.dylib') 
+else:
+    raise ImportError("don't know how to load the c lib for %s" % sys.platform)
+# ____________________________________________
+
+

Added: pypy/dist/pypy/rpython/rctypes/tool/test/test_libc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/rctypes/tool/test/test_libc.py	Sun Jun  4 14:58:19 2006
@@ -0,0 +1,4 @@
+
+def test_libc():
+    from pypy.rpython.rctypes.tool.libc import libc 
+    t = libc.time



More information about the Pypy-commit mailing list