[pypy-commit] pypy kill-exported-symbols-list: (antocuni, arigo) pom pom progress more of the same
arigo
noreply at buildbot.pypy.org
Thu Oct 23 16:11:51 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: kill-exported-symbols-list
Changeset: r74125:26f9c7710d50
Date: 2014-10-23 16:11 +0200
http://bitbucket.org/pypy/pypy/changeset/26f9c7710d50/
Log: (antocuni, arigo) pom pom progress more of the same
diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -2763,7 +2763,6 @@
NB_TESTS = 100
c_source = []
all_tests = []
- export_symbols = []
def prepare_c_source():
"""Pick a random choice of argument types and length,
@@ -2796,12 +2795,10 @@
var_name)
c_source.append('static %s;' % var_decl)
getter_name = '%s_get%d' % (fn_name, i)
- export_symbols.append(getter_name)
- c_source.append('void %s(%s) { *p = %s; }' % (
+ c_source.append('RPY_EXPORTED void %s(%s) { *p = %s; }' % (
getter_name,
primitive.cdecl(primitive.PrimitiveType[ARG], '*p'),
var_name))
- export_symbols.append(fn_name)
c_source.append('')
c_source.append('static void real%s(%s)' % (
fn_name, ', '.join(fn_args)))
@@ -2809,7 +2806,7 @@
for i in range(len(ARGTYPES)):
c_source.append(' argcopy_%s_x%d = x%d;' % (fn_name, i, i))
c_source.append('}')
- c_source.append('void *%s(void)' % fn_name)
+ c_source.append('RPY_EXPORTED void *%s(void)' % fn_name)
c_source.append('{')
c_source.append(' return (void *)&real%s;' % fn_name)
c_source.append('}')
@@ -2819,8 +2816,7 @@
prepare_c_source()
eci = ExternalCompilationInfo(
- separate_module_sources=['\n'.join(c_source)],
- export_symbols=export_symbols)
+ separate_module_sources=['\n'.join(c_source)])
for k in range(NB_TESTS):
ARGTYPES, ffitypes, fn_name = all_tests[k]
@@ -3605,12 +3601,11 @@
# value in eax or rax.
eci = ExternalCompilationInfo(
separate_module_sources=["""
- long fn_test_result_of_call(long x)
+ RPY_EXPORTED long fn_test_result_of_call(long x)
{
return x + 1;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.Signed],
RESTYPE, compilation_info=eci, _nowrapper=True)
value = intmask(0xFFEEDDCCBBAA9988)
@@ -3639,12 +3634,11 @@
# value in eax or rax.
eci = ExternalCompilationInfo(
separate_module_sources=["""
- long fn_test_result_of_call(long x)
+ RPY_EXPORTED long fn_test_result_of_call(long x)
{
return x + 1;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.Signed],
RESTYPE, compilation_info=eci, _nowrapper=True)
value = intmask(0xFFEEDDCCBBAA9988)
@@ -3673,12 +3667,11 @@
from rpython.rlib.rarithmetic import r_longlong
eci = ExternalCompilationInfo(
separate_module_sources=["""
- long long fn_test_result_of_call(long long x)
+ RPY_EXPORTED long long fn_test_result_of_call(long long x)
{
return x - 100000000000000;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.SignedLongLong],
lltype.SignedLongLong,
compilation_info=eci, _nowrapper=True)
@@ -3701,12 +3694,11 @@
from rpython.rlib.rarithmetic import r_longlong
eci = ExternalCompilationInfo(
separate_module_sources=["""
- long long fn_test_result_of_call(long long x)
+ RPY_EXPORTED long long fn_test_result_of_call(long long x)
{
return x - 100000000000000;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.SignedLongLong],
lltype.SignedLongLong,
compilation_info=eci, _nowrapper=True)
@@ -3730,12 +3722,11 @@
from rpython.rlib.rarithmetic import r_singlefloat
eci = ExternalCompilationInfo(
separate_module_sources=["""
- float fn_test_result_of_call(float x)
+ RPY_EXPORTED float fn_test_result_of_call(float x)
{
return x / 2.0f;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.SingleFloat],
lltype.SingleFloat,
compilation_info=eci, _nowrapper=True)
@@ -3760,12 +3751,11 @@
from rpython.rlib.rarithmetic import r_singlefloat
eci = ExternalCompilationInfo(
separate_module_sources=["""
- float fn_test_result_of_call(float x)
+ RPY_EXPORTED float fn_test_result_of_call(float x)
{
return x / 2.0f;
}
- """],
- export_symbols=['fn_test_result_of_call'])
+ """])
f = rffi.llexternal('fn_test_result_of_call', [lltype.SingleFloat],
lltype.SingleFloat,
compilation_info=eci, _nowrapper=True)
diff --git a/rpython/rlib/_rffi_stacklet.py b/rpython/rlib/_rffi_stacklet.py
--- a/rpython/rlib/_rffi_stacklet.py
+++ b/rpython/rlib/_rffi_stacklet.py
@@ -19,14 +19,6 @@
else:
asmsrc = 'switch_x86_msvc.asm'
eci.separate_module_files += (cdir / 'src' / 'stacklet' / asmsrc, )
- eci.export_symbols += (
- 'stacklet_newthread',
- 'stacklet_deletethread',
- 'stacklet_new',
- 'stacklet_switch',
- 'stacklet_destroy',
- '_stacklet_translate_pointer',
- )
rffi_platform.verify_eci(eci.convert_sources_to_files())
diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py
--- a/rpython/rlib/clibffi.py
+++ b/rpython/rlib/clibffi.py
@@ -44,10 +44,12 @@
if _WIN32:
separate_module_sources = ['''
+ #include "src/precommondefs.h"
#include <stdio.h>
#include <windows.h>
/* Get the module where the "fopen" function resides in */
+ RPY_EXPORTED_FOR_TESTS
HANDLE pypy_get_libc_handle() {
MEMORY_BASIC_INFORMATION mi;
char buf[1000];
@@ -93,7 +95,6 @@
eci = ExternalCompilationInfo(
libraries = libraries,
includes = includes,
- export_symbols = [],
separate_module_sources = separate_module_sources,
)
@@ -113,15 +114,13 @@
eci = ExternalCompilationInfo(
includes = ['ffi.h', 'windows.h'],
libraries = ['kernel32'],
- include_dirs = [libffidir],
+ include_dirs = [libffidir, cdir],
separate_module_sources = separate_module_sources,
separate_module_files = [libffidir.join('ffi.c'),
libffidir.join('prep_cif.c'),
libffidir.join(asm_ifc),
libffidir.join('pypy_ffi.c'),
],
- export_symbols = ['ffi_call', 'ffi_prep_cif', 'ffi_prep_closure',
- 'pypy_get_libc_handle'],
)
FFI_TYPE_P = lltype.Ptr(lltype.ForwardReference())
diff --git a/rpython/rlib/rsignal.py b/rpython/rlib/rsignal.py
--- a/rpython/rlib/rsignal.py
+++ b/rpython/rlib/rsignal.py
@@ -41,11 +41,6 @@
includes = includes,
separate_module_files = [cdir / 'src' / 'signals.c'],
include_dirs = [str(cdir)],
- export_symbols = ['pypysig_poll', 'pypysig_default',
- 'pypysig_ignore', 'pypysig_setflag',
- 'pypysig_reinstall',
- 'pypysig_set_wakeup_fd',
- 'pypysig_getaddr_occurred'],
)
class CConfig:
diff --git a/rpython/rlib/test/test_clibffi.py b/rpython/rlib/test/test_clibffi.py
--- a/rpython/rlib/test/test_clibffi.py
+++ b/rpython/rlib/test/test_clibffi.py
@@ -3,6 +3,7 @@
"""
from rpython.translator.c.test.test_genc import compile
+from rpython.translator import cdir
from rpython.rlib.clibffi import *
from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rtyper.lltypesystem.ll2ctypes import ALLOCATED
@@ -268,6 +269,7 @@
c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
c_file.write(py.code.Source('''
+ #include "src/precommondefs.h"
#include <stdlib.h>
#include <stdio.h>
@@ -276,6 +278,7 @@
long y;
};
+ RPY_EXPORTED
long sum_x_y(struct x_y s) {
return s.x + s.y;
}
@@ -285,7 +288,7 @@
}
'''))
- eci = ExternalCompilationInfo(export_symbols=['sum_x_y'])
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
lib_name = str(platform.compile([c_file], eci, 'x', standalone=False))
lib = CDLL(lib_name)
@@ -319,6 +322,7 @@
c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
c_file.write(py.code.Source('''
+ #include "src/precommondefs.h"
#include <stdlib.h>
#include <stdio.h>
@@ -327,6 +331,7 @@
short y;
};
+ RPY_EXPORTED
struct s2h give(short x, short y) {
struct s2h out;
out.x = x;
@@ -334,6 +339,7 @@
return out;
}
+ RPY_EXPORTED
struct s2h perturb(struct s2h inp) {
inp.x *= 2;
inp.y *= 3;
@@ -341,7 +347,7 @@
}
'''))
- eci = ExternalCompilationInfo(export_symbols=['give', 'perturb'])
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
lib_name = str(platform.compile([c_file], eci, 'x', standalone=False))
lib = CDLL(lib_name)
@@ -395,11 +401,13 @@
c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
c_file.write(py.code.Source('''
+ #include "src/precommondefs.h"
+ RPY_EXPORTED
long fun(long i) {
return i + 42;
}
'''))
- eci = ExternalCompilationInfo(export_symbols=['fun'])
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
lib_name = str(platform.compile([c_file], eci, 'x', standalone=False))
lib = CDLL(lib_name)
diff --git a/rpython/rlib/test/test_libffi.py b/rpython/rlib/test/test_libffi.py
--- a/rpython/rlib/test/test_libffi.py
+++ b/rpython/rlib/test/test_libffi.py
@@ -7,6 +7,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper.lltypesystem.ll2ctypes import ALLOCATED
from rpython.rtyper.llinterp import LLException
+from rpython.translator import cdir
from rpython.rlib.libffi import (CDLL, ArgChain, types,
IS_32_BIT, array_getitem, array_setitem)
from rpython.rlib.libffi import (struct_getfield_int, struct_setfield_int,
@@ -204,7 +205,6 @@
def setup_class(cls):
from rpython.tool.udir import udir
from rpython.translator.tool.cbuild import ExternalCompilationInfo
- from rpython.translator.tool.cbuild import STANDARD_DEFINES
from rpython.translator.platform import platform
BaseFfiTest.setup_class()
@@ -213,7 +213,6 @@
c_file = udir.ensure("test_libffi", dir=1).join("foolib.c")
# automatically collect the C source from the docstrings of the tests
snippets = []
- exports = []
for name in dir(cls):
if name.startswith('test_'):
meth = getattr(cls, name)
@@ -221,12 +220,10 @@
# improved: so far we just check that there is a '{' :-)
if meth.__doc__ is not None and '{' in meth.__doc__:
snippets.append(meth.__doc__)
- import re
- for match in re.finditer(" ([A-Za-z_]+)\(", meth.__doc__):
- exports.append(match.group(1))
#
- c_file.write(STANDARD_DEFINES + str(py.code.Source('\n'.join(snippets))))
- eci = ExternalCompilationInfo(export_symbols=exports)
+ INCLUDE = '#include "src/precommondefs.h"\n'
+ c_file.write(INCLUDE + str(py.code.Source('\n'.join(snippets))))
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
cls.libfoo_name = str(platform.compile([c_file], eci, 'x',
standalone=False))
cls.dll = cls.CDLL(cls.libfoo_name)
@@ -269,6 +266,7 @@
def test_very_simple(self):
"""
+ RPY_EXPORTED
int diff_xy(int x, Signed y)
{
return x - y;
@@ -281,6 +279,7 @@
def test_simple(self):
"""
+ RPY_EXPORTED
int sum_xy(int x, double y)
{
return (x + (int)y);
@@ -299,6 +298,7 @@
def test_cast_result(self):
"""
+ RPY_EXPORTED
unsigned char cast_to_uchar_and_ovf(int x)
{
return 200+(unsigned char)x;
@@ -311,6 +311,7 @@
def test_cast_argument(self):
"""
+ RPY_EXPORTED
int many_args(char a, int b)
{
return a+b;
@@ -323,6 +324,7 @@
def test_char_args(self):
"""
+ RPY_EXPORTED
char sum_args(char a, char b) {
return a + b;
}
@@ -334,6 +336,7 @@
def test_unsigned_short_args(self):
"""
+ RPY_EXPORTED
unsigned short sum_xy_us(unsigned short x, unsigned short y)
{
return x+y;
@@ -347,6 +350,7 @@
def test_pointer_as_argument(self):
"""#include <stdlib.h>
+ RPY_EXPORTED
Signed inc(Signed* x)
{
Signed oldval;
@@ -391,6 +395,7 @@
struct pair my_static_pair = {10, 20};
+ RPY_EXPORTED
Signed* get_pointer_to_b()
{
return &my_static_pair.b;
@@ -404,7 +409,9 @@
def test_void_result(self):
"""
int dummy;
+ RPY_EXPORTED
void set_dummy(int val) { dummy = val; }
+ RPY_EXPORTED
int get_dummy() { return dummy; }
"""
libfoo = self.get_libfoo()
@@ -421,6 +428,7 @@
def test_single_float_args(self):
"""
+ RPY_EXPORTED
float sum_xy_float(float x, float y)
{
return x+y;
@@ -437,6 +445,7 @@
def test_slonglong_args(self):
"""
+ RPY_EXPORTED
long long sum_xy_longlong(long long x, long long y)
{
return x+y;
@@ -460,6 +469,7 @@
def test_ulonglong_args(self):
"""
+ RPY_EXPORTED
unsigned long long sum_xy_ulonglong(unsigned long long x,
unsigned long long y)
{
@@ -507,6 +517,7 @@
Signed y;
};
+ RPY_EXPORTED
Signed sum_point(struct Point p) {
return p.x + p.y;
}
@@ -532,6 +543,7 @@
def test_byval_result(self):
"""
+ RPY_EXPORTED
struct Point make_point(Signed x, Signed y) {
struct Point p;
p.x = x;
@@ -557,6 +569,7 @@
if os.name == 'nt':
def test_stdcall_simple(self):
"""
+ RPY_EXPORTED
int __stdcall std_diff_xy(int x, Signed y)
{
return x - y;
@@ -577,6 +590,7 @@
def test_by_ordinal(self):
"""
+ RPY_EXPORTED
int AAA_first_ordinal_function()
{
return 42;
@@ -591,6 +605,7 @@
def test_by_ordinal2(self):
"""
+ RPY_EXPORTED
int __stdcall BBB_second_ordinal_function()
{
return 24;
diff --git a/rpython/translator/c/src/signals.h b/rpython/translator/c/src/signals.h
--- a/rpython/translator/c/src/signals.h
+++ b/rpython/translator/c/src/signals.h
@@ -1,16 +1,26 @@
#ifndef _PYPY_SIGNALS_H
#define _PYPY_SIGNALS_H
+#include "src/precommondefs.h"
+
+
/* utilities to set a signal handler */
+RPY_EXPORTED_FOR_TESTS
void pypysig_ignore(int signum); /* signal will be ignored (SIG_IGN) */
+RPY_EXPORTED_FOR_TESTS
void pypysig_default(int signum); /* signal will do default action (SIG_DFL) */
+RPY_EXPORTED_FOR_TESTS
void pypysig_setflag(int signum); /* signal will set a flag which can be
queried with pypysig_poll() */
+RPY_EXPORTED_FOR_TESTS
void pypysig_reinstall(int signum);
+RPY_EXPORTED_FOR_TESTS
int pypysig_set_wakeup_fd(int fd);
/* utility to poll for signals that arrived */
+RPY_EXPORTED_FOR_TESTS
int pypysig_poll(void); /* => signum or -1 */
+RPY_EXPORTED_FOR_TESTS
void pypysig_pushback(int signum);
/* When a signal is received, pypysig_counter is set to -1. */
@@ -23,6 +33,7 @@
/* some C tricks to get/set the variable as efficiently as possible:
use macros when compiling as a stand-alone program, but still
export a function with the correct name for testing */
+RPY_EXPORTED_FOR_TESTS
void *pypysig_getaddr_occurred(void);
#define pypysig_getaddr_occurred() ((void *)(&pypysig_counter))
More information about the pypy-commit
mailing list