[pypy-svn] r43757 - in pypy/branch/kill-ctypes/pypy/rpython/lltypesystem: . test
fijal at codespeak.net
fijal at codespeak.net
Sun May 27 23:29:53 CEST 2007
Author: fijal
Date: Sun May 27 23:29:53 2007
New Revision: 43757
Added:
pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rfficache.py
pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py
Log:
Add a sizeof gcc invoker
Added: pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rfficache.py
==============================================================================
--- (empty file)
+++ pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rfficache.py Sun May 27 23:29:53 2007
@@ -0,0 +1,31 @@
+
+""" This file creates and maintains _cache/rtypes.py, which
+keeps information about C type sizes on various platforms
+"""
+
+import py
+from pypy.translator.tool.cbuild import build_executable
+from subprocess import PIPE, Popen
+from pypy.tool.udir import udir
+
+def sizeof_c_type(c_typename, includes={}):
+ includes['stdio.h'] = True
+ include_string = "\n".join(["#include <%s>" % i for i in includes.keys()])
+ c_source = py.code.Source('''
+ // includes
+ %s
+
+ // checking code
+ int main(void)
+ {
+ printf("%%d\\n", sizeof(%s));
+ return (0);
+ }
+ ''' % (include_string, c_typename))
+ c_file = udir.join("typetest.c")
+ c_file.write(c_source)
+
+ c_exec = build_executable([str(c_file)])
+ pipe = Popen(c_exec, stdout=PIPE)
+ pipe.wait()
+ return int(pipe.stdout.read()) * 8
Added: pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py
==============================================================================
--- (empty file)
+++ pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py Sun May 27 23:29:53 2007
@@ -0,0 +1,6 @@
+
+from pypy.rpython.lltypesystem.rfficache import sizeof_c_type
+
+def test_sizeof_c_type():
+ sizeofchar = sizeof_c_type('char')
+ assert sizeofchar == 8
More information about the Pypy-commit
mailing list