[pypy-commit] pypy kill-exported-symbols-list: pom pom pom
arigo
noreply at buildbot.pypy.org
Thu Oct 23 12:34:18 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: kill-exported-symbols-list
Changeset: r74105:745fbb3dd367
Date: 2014-10-23 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/745fbb3dd367/
Log: pom pom pom
diff --git a/pypy/module/_rawffi/alt/test/test_funcptr.py b/pypy/module/_rawffi/alt/test/test_funcptr.py
--- a/pypy/module/_rawffi/alt/test/test_funcptr.py
+++ b/pypy/module/_rawffi/alt/test/test_funcptr.py
@@ -1,4 +1,5 @@
from rpython.rtyper.lltypesystem import rffi
+from rpython.translator import cdir
from rpython.rlib.clibffi import get_libc_name
from rpython.rlib.libffi import types
from rpython.rlib.libffi import CDLL
@@ -18,11 +19,8 @@
c_file = udir.ensure("test__ffi", dir=1).join("foolib.c")
# automatically collect the C source from the docstrings of the tests
snippets = ["""
- #ifdef _WIN32
- #define DLLEXPORT __declspec(dllexport)
- #else
- #define DLLEXPORT
- #endif
+ #include "src/precommondefs.h"
+ #define DLLEXPORT RPY_EXPORTED
"""]
for name in dir(cls):
if name.startswith('test_'):
@@ -33,7 +31,7 @@
snippets.append(meth.__doc__)
#
c_file.write(py.code.Source('\n'.join(snippets)))
- eci = ExternalCompilationInfo(export_symbols=[])
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
return str(platform.compile([c_file], eci, 'x', standalone=False))
def setup_class(cls):
diff --git a/pypy/module/_rawffi/test/test__rawffi.py b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -1,5 +1,6 @@
from rpython.translator.platform import platform
from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.translator import cdir
from pypy.module._rawffi.interp_rawffi import TYPEMAP, TYPEMAP_FLOAT_LETTERS
from pypy.module._rawffi.tracker import Tracker
@@ -12,6 +13,7 @@
from rpython.tool.udir import udir
c_file = udir.ensure("test__rawffi", dir=1).join("xlib.c")
c_file.write(py.code.Source('''
+ #include "src/precommondefs.h"
#include <stdlib.h>
#include <stdio.h>
@@ -23,15 +25,18 @@
struct x* next;
};
+ RPY_EXPORTED
void nothing()
{
}
+ RPY_EXPORTED
char inner_struct_elem(struct x *x1)
{
return x1->next->x3;
}
+ RPY_EXPORTED
struct x* create_double_struct()
{
struct x* x1, *x2;
@@ -43,6 +48,7 @@
return x1;
}
+ RPY_EXPORTED
void free_double_struct(struct x* x1)
{
free(x1->next);
@@ -50,25 +56,32 @@
}
const char *static_str = "xxxxxx";
+ RPY_EXPORTED
long static_int = 42;
+ RPY_EXPORTED
double static_double = 42.42;
+ RPY_EXPORTED
long double static_longdouble = 42.42;
+ RPY_EXPORTED
unsigned short add_shorts(short one, short two)
{
return one + two;
}
+ RPY_EXPORTED
void* get_raw_pointer()
{
return (void*)add_shorts;
}
+ RPY_EXPORTED
char get_char(char* s, unsigned short num)
{
return s[num];
}
+ RPY_EXPORTED
const char *char_check(char x, char y)
{
if (y == static_str[0])
@@ -76,26 +89,31 @@
return NULL;
}
+ RPY_EXPORTED
int get_array_elem(int* stuff, int num)
{
return stuff[num];
}
+ RPY_EXPORTED
struct x* get_array_elem_s(struct x** array, int num)
{
return array[num];
}
+ RPY_EXPORTED
long long some_huge_value()
{
return 1LL<<42;
}
+ RPY_EXPORTED
unsigned long long some_huge_uvalue()
{
return 1LL<<42;
}
+ RPY_EXPORTED
long long pass_ll(long long x)
{
return x;
@@ -103,11 +121,13 @@
static int prebuilt_array1[] = {3};
+ RPY_EXPORTED
int* allocate_array()
{
return prebuilt_array1;
}
+ RPY_EXPORTED
long long runcallback(long long(*callback)())
{
return callback();
@@ -118,10 +138,12 @@
long y;
};
+ RPY_EXPORTED
long sum_x_y(struct x_y s) {
return s.x + s.y;
}
+ RPY_EXPORTED
long op_x_y(struct x_y s, long(*callback)(struct x_y))
{
return callback(s);
@@ -132,6 +154,7 @@
short y;
};
+ RPY_EXPORTED
struct s2h give(short x, short y) {
struct s2h out;
out.x = x;
@@ -139,6 +162,7 @@
return out;
}
+ RPY_EXPORTED
struct s2h perturb(struct s2h inp) {
inp.x *= 2;
inp.y *= 3;
@@ -149,6 +173,7 @@
int bah[2];
};
+ RPY_EXPORTED
struct s2a get_s2a(void) {
struct s2a outp;
outp.bah[0] = 4;
@@ -156,10 +181,12 @@
return outp;
}
+ RPY_EXPORTED
int check_s2a(struct s2a inp) {
return (inp.bah[0] == 4 && inp.bah[1] == 5);
}
+ RPY_EXPORTED
int AAA_first_ordinal_function()
{
return 42;
@@ -170,6 +197,7 @@
long y;
} UN;
+ RPY_EXPORTED
UN ret_un_func(UN inp)
{
inp.y = inp.x * 100;
@@ -177,21 +205,7 @@
}
'''))
- symbols = """get_char char_check get_raw_pointer
- add_shorts
- inner_struct_elem create_double_struct free_double_struct
- get_array_elem get_array_elem_s
- nothing
- some_huge_value some_huge_uvalue pass_ll
- runcallback
- allocate_array
- static_int static_double static_longdouble
- sum_x_y op_x_y
- give perturb get_s2a check_s2a
- AAA_first_ordinal_function
- ret_un_func
- """.split()
- eci = ExternalCompilationInfo(export_symbols=symbols)
+ eci = ExternalCompilationInfo(include_dirs=[cdir])
return str(platform.compile([c_file], eci, 'x', standalone=False))
prepare_c_example = staticmethod(prepare_c_example)
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -18,12 +18,12 @@
includes = ['src/thread.h'],
separate_module_files = [translator_c_dir / 'src' / 'thread.c'],
include_dirs = [translator_c_dir],
- export_symbols = ['RPyThreadGetIdent', 'RPyThreadLockInit',
- 'RPyThreadAcquireLock', 'RPyThreadAcquireLockTimed',
- 'RPyThreadReleaseLock',
- 'RPyThreadGetStackSize', 'RPyThreadSetStackSize',
- 'RPyOpaqueDealloc_ThreadLock',
- 'RPyThreadAfterFork']
+ #export_symbols = ['RPyThreadGetIdent', 'RPyThreadLockInit',
+ # 'RPyThreadAcquireLock', 'RPyThreadAcquireLockTimed',
+ # 'RPyThreadReleaseLock',
+ # 'RPyThreadGetStackSize', 'RPyThreadSetStackSize',
+ # 'RPyOpaqueDealloc_ThreadLock',
+ # 'RPyThreadAfterFork']
)
def llexternal(name, args, result, **kwds):
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -379,10 +379,11 @@
db = LowLevelDatabase()
implementationtypename = db.gettype(functype, argnames=argnames)
if functype.RESULT is lltype.Void:
- pattern = '%s { %s(%s); }'
+ pattern = '%s%s { %s(%s); }'
else:
- pattern = '%s { return %s(%s); }'
+ pattern = '%s%s { return %s(%s); }'
source = pattern % (
+ 'RPY_EXPORTED_FOR_TESTS ',
cdecl(implementationtypename, wrapper_name),
macro, ', '.join(argnames))
@@ -392,7 +393,6 @@
# first function)
ctypes_eci = eci.merge(ExternalCompilationInfo(
separate_module_sources=[source],
- export_symbols=[wrapper_name],
))
if hasattr(eci, '_with_ctypes'):
ctypes_eci = eci._with_ctypes.merge(ctypes_eci)
diff --git a/rpython/translator/c/src/precommondefs.h b/rpython/translator/c/src/precommondefs.h
new file mode 100644
--- /dev/null
+++ b/rpython/translator/c/src/precommondefs.h
@@ -0,0 +1,57 @@
+/***** Start of precommondefs.h *****/
+
+/* This is extracted from pyconfig.h from CPython. It sets the macros
+ that affect the features we get from system include files.
+ It must not #include anything. */
+
+#ifndef __PYPY_PRECOMMONDEFS_H
+#define __PYPY_PRECOMMONDEFS_H
+
+
+/* Define on Darwin to activate all library features */
+#define _DARWIN_C_SOURCE 1
+/* This must be set to 64 on some systems to enable large file support. */
+#define _FILE_OFFSET_BITS 64
+/* Define on Linux to activate all library features */
+#define _GNU_SOURCE 1
+/* This must be defined on some systems to enable large file support. */
+#define _LARGEFILE_SOURCE 1
+/* Define on NetBSD to activate all library features */
+#define _NETBSD_SOURCE 1
+/* Define to activate features from IEEE Stds 1003.1-2001 */
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
+/* Define on FreeBSD to activate all library features */
+#define __BSD_VISIBLE 1
+#define __XSI_VISIBLE 700
+/* Windows: winsock/winsock2 mess */
+#define WIN32_LEAN_AND_MEAN
+#ifdef _WIN64
+ typedef __int64 Signed;
+ typedef unsigned __int64 Unsigned;
+# define SIGNED_MIN LLONG_MIN
+#else
+ typedef long Signed;
+ typedef unsigned long Unsigned;
+# define SIGNED_MIN LONG_MIN
+#endif
+
+#if !defined(RPY_ASSERT) && !defined(RPY_LL_ASSERT)
+# define NDEBUG
+#endif
+
+
+#ifdef __GNUC__
+# define RPY_EXPORTED __attribute__((visibility("default")))
+#else
+# define RPY_EXPORTED __declspec(dllexport)
+#endif
+#ifndef RPY_EXPORTED_FOR_TESTS
+# define RPY_EXPORTED_FOR_TESTS /* nothing */
+#endif
+
+
+#endif /* __PYPY_PRECOMMONDEFS_H */
+
+/***** End of precommondefs.h *****/
diff --git a/rpython/translator/c/src/thread.h b/rpython/translator/c/src/thread.h
--- a/rpython/translator/c/src/thread.h
+++ b/rpython/translator/c/src/thread.h
@@ -1,5 +1,6 @@
#ifndef __PYPY_THREAD_H
#define __PYPY_THREAD_H
+#include "precommondefs.h"
#include <assert.h>
#define RPY_TIMEOUT_T long long
diff --git a/rpython/translator/c/src/thread_nt.h b/rpython/translator/c/src/thread_nt.h
--- a/rpython/translator/c/src/thread_nt.h
+++ b/rpython/translator/c/src/thread_nt.h
@@ -12,8 +12,10 @@
} NRMUTEX, *PNRMUTEX;
/* prototypes */
+RPY_EXPORTED_FOR_TESTS
long RPyThreadGetIdent(void);
long RPyThreadStart(void (*func)(void));
+RPY_EXPORTED_FOR_TESTS
int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
int RPyThreadAcquireLock(struct RPyOpaque_ThreadLock *lock, int waitflag);
diff --git a/rpython/translator/c/src/thread_pthread.h b/rpython/translator/c/src/thread_pthread.h
--- a/rpython/translator/c/src/thread_pthread.h
+++ b/rpython/translator/c/src/thread_pthread.h
@@ -59,8 +59,10 @@
/* prototypes */
+RPY_EXPORTED_FOR_TESTS
long RPyThreadGetIdent(void);
long RPyThreadStart(void (*func)(void));
+RPY_EXPORTED_FOR_TESTS
int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
int RPyThreadAcquireLock(struct RPyOpaque_ThreadLock *lock, int waitflag);
diff --git a/rpython/translator/tool/cbuild.py b/rpython/translator/tool/cbuild.py
--- a/rpython/translator/tool/cbuild.py
+++ b/rpython/translator/tool/cbuild.py
@@ -1,7 +1,8 @@
import py
-import sys, subprocess
+import sys, os, subprocess
from rpython.translator.platform import host
+from rpython.translator import cdir
from rpython.tool.udir import udir
@@ -239,7 +240,10 @@
return ExternalCompilationInfo(**attrs)
def write_c_header(self, fileobj):
- print >> fileobj, STANDARD_DEFINES
+ f = open(os.path.join(cdir, 'src', 'precommondefs.h'))
+ fileobj.write(f.read())
+ f.close()
+ print >> fileobj
for piece in self.pre_include_bits:
print >> fileobj, piece
for path in self.includes:
@@ -321,53 +325,3 @@
d['separate_module_files'] = ()
d['separate_module_sources'] = ()
return ExternalCompilationInfo(**d)
-
-
-# ____________________________________________________________
-#
-# This is extracted from pyconfig.h from CPython. It sets the macros
-# that affect the features we get from system include files.
-
-STANDARD_DEFINES = '''
-/* Define on Darwin to activate all library features */
-#define _DARWIN_C_SOURCE 1
-/* This must be set to 64 on some systems to enable large file support. */
-#define _FILE_OFFSET_BITS 64
-/* Define on Linux to activate all library features */
-#define _GNU_SOURCE 1
-/* This must be defined on some systems to enable large file support. */
-#define _LARGEFILE_SOURCE 1
-/* Define on NetBSD to activate all library features */
-#define _NETBSD_SOURCE 1
-/* Define to activate features from IEEE Stds 1003.1-2001 */
-#ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
-#endif
-/* Define on FreeBSD to activate all library features */
-#define __BSD_VISIBLE 1
-#define __XSI_VISIBLE 700
-/* Windows: winsock/winsock2 mess */
-#define WIN32_LEAN_AND_MEAN
-#ifdef _WIN64
- typedef __int64 Signed;
- typedef unsigned __int64 Unsigned;
-# define SIGNED_MIN LLONG_MIN
-#else
- typedef long Signed;
- typedef unsigned long Unsigned;
-# define SIGNED_MIN LONG_MIN
-#endif
-
-#if !defined(RPY_ASSERT) && !defined(RPY_LL_ASSERT)
-# define NDEBUG
-#endif
-
-#ifdef __GNUC__
-# define RPY_EXPORTED __attribute__((visibility("default")))
-#else
-# define RPY_EXPORTED __declspec(dllexport)
-#endif
-#ifndef RPY_EXPORTED_FOR_TESTS
-# define RPY_EXPORTED_FOR_TESTS /* nothing */
-#endif
-'''
More information about the pypy-commit
mailing list