[pypy-commit] pypy kill-exported-symbols-list: raaaaaaaaaaaah
arigo
noreply at buildbot.pypy.org
Thu Oct 23 15:02:17 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: kill-exported-symbols-list
Changeset: r74114:be3b6bac8a16
Date: 2014-10-23 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/be3b6bac8a16/
Log: raaaaaaaaaaaah
diff --git a/pypy/module/cppyy/src/dummy_backend.cxx b/pypy/module/cppyy/src/dummy_backend.cxx
--- a/pypy/module/cppyy/src/dummy_backend.cxx
+++ b/pypy/module/cppyy/src/dummy_backend.cxx
@@ -1,3 +1,4 @@
+#include "src/precommondefs.h"
#include "cppyy.h"
#include "capi.h"
@@ -348,24 +349,29 @@
/* name to opaque C++ scope representation -------------------------------- */
+RPY_EXPORTED_FOR_TESTS
int cppyy_num_scopes(cppyy_scope_t handle) {
return 0;
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_resolve_name(const char* cppitem_name) {
return cppstring_to_cstring(cppitem_name);
}
+RPY_EXPORTED_FOR_TESTS
cppyy_scope_t cppyy_get_scope(const char* scope_name) {
return s_handles[scope_name]; // lookup failure will return 0 (== error)
}
+RPY_EXPORTED_FOR_TESTS
cppyy_type_t cppyy_actual_class(cppyy_type_t klass, cppyy_object_t /* obj */) {
return klass;
}
/* memory management ------------------------------------------------------ */
+RPY_EXPORTED_FOR_TESTS
void cppyy_destruct(cppyy_type_t handle, cppyy_object_t self) {
if (handle == s_handles["example01"])
delete (dummy::example01*)self;
@@ -373,6 +379,7 @@
/* method/function dispatching -------------------------------------------- */
+RPY_EXPORTED_FOR_TESTS
void cppyy_call_v(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
long idx = (long)method;
if (idx == s_methods["static_example01::staticSetPayload_payload*_double"]) {
@@ -462,6 +469,7 @@
}
}
+RPY_EXPORTED_FOR_TESTS
unsigned char cppyy_call_b(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
unsigned char result = 0;
const long idx = (long)method;
@@ -474,6 +482,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
char cppyy_call_c(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
char result = 0;
const long idx = (long)method;
@@ -489,6 +498,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
short cppyy_call_h(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
short result = 0;
const long idx = (long)method;
@@ -504,6 +514,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_call_i(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
int result = 0;
const long idx = (long)method;
@@ -536,6 +547,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
long cppyy_call_l(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
long result = 0;
const long idx = (long)method;
@@ -677,6 +689,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
long long cppyy_call_ll(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
long long result = 0;
const long idx = (long)method;
@@ -692,6 +705,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
float cppyy_call_f(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
float result = 0;
const long idx = (long)method;
@@ -704,6 +718,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
double cppyy_call_d(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
double result = 0.;
const long idx = (long)method;
@@ -725,6 +740,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) {
char* result = 0;
const long idx = (long)method;
@@ -737,6 +753,7 @@
return result;
}
+RPY_EXPORTED_FOR_TESTS
cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t handle, int nargs, void* args) {
void* result = 0;
const long idx = (long)method;
@@ -759,12 +776,14 @@
return (cppyy_object_t)result;
}
+RPY_EXPORTED_FOR_TESTS
cppyy_methptrgetter_t cppyy_get_methptr_getter(cppyy_type_t /* handle */, cppyy_index_t /* method_index */) {
return (cppyy_methptrgetter_t)0;
}
/* handling of function argument buffer ----------------------------------- */
+RPY_EXPORTED_FOR_TESTS
void* cppyy_allocate_function_args(int nargs) {
CPPYY_G__value* args = (CPPYY_G__value*)malloc(nargs*sizeof(CPPYY_G__value));
for (int i = 0; i < nargs; ++i)
@@ -774,30 +793,36 @@
/* handling of function argument buffer ----------------------------------- */
+RPY_EXPORTED_FOR_TESTS
void cppyy_deallocate_function_args(void* args) {
free(args);
}
+RPY_EXPORTED_FOR_TESTS
size_t cppyy_function_arg_sizeof() {
return sizeof(CPPYY_G__value);
}
+RPY_EXPORTED_FOR_TESTS
size_t cppyy_function_arg_typeoffset() {
return offsetof(CPPYY_G__value, type);
}
/* scope reflection information ------------------------------------------- */
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_namespace(cppyy_scope_t /* handle */) {
return 0;
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_enum(const char* /* type_name */) {
return 0;
}
/* class reflection information ------------------------------------------- */
+RPY_EXPORTED_FOR_TESTS
char* cppyy_final_name(cppyy_type_t handle) {
for (Handles_t::iterator isp = s_handles.begin(); isp != s_handles.end(); ++isp) {
if (isp->second == handle)
@@ -806,61 +831,75 @@
return cppstring_to_cstring("<unknown>");
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_scoped_final_name(cppyy_type_t handle) {
return cppyy_final_name(handle);
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_has_complex_hierarchy(cppyy_type_t /* handle */) {
return 0;
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_num_bases(cppyy_type_t /*handle*/) {
return 0;
}
/* method/function reflection information --------------------------------- */
+RPY_EXPORTED_FOR_TESTS
int cppyy_num_methods(cppyy_scope_t handle) {
return s_scopes[handle].m_methods.size();
}
+RPY_EXPORTED_FOR_TESTS
cppyy_index_t cppyy_method_index_at(cppyy_scope_t /* scope */, int imeth) {
return (cppyy_index_t)imeth;
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_method_name(cppyy_scope_t handle, cppyy_index_t method_index) {
return cppstring_to_cstring(s_scopes[handle].m_methods[(int)method_index].m_name);
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_method_result_type(cppyy_scope_t handle, cppyy_index_t method_index) {
return cppstring_to_cstring(s_scopes[handle].m_methods[method_index].m_returntype);
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_method_num_args(cppyy_scope_t handle, cppyy_index_t method_index) {
return s_scopes[handle].m_methods[method_index].m_argtypes.size();
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_method_req_args(cppyy_scope_t handle, cppyy_index_t method_index) {
return cppyy_method_num_args(handle, method_index);
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_method_arg_type(cppyy_scope_t handle, cppyy_index_t method_index, int arg_index) {
return cppstring_to_cstring(s_scopes[handle].m_methods[method_index].m_argtypes[arg_index]);
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_method_arg_default(
cppyy_scope_t /* handle */, cppyy_index_t /* method_index */, int /* arg_index */) {
return cppstring_to_cstring("");
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_method_signature(cppyy_scope_t /* handle */, cppyy_index_t /* method_index */) {
return cppstring_to_cstring("");
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_method_is_template(cppyy_scope_t /* handle */, cppyy_index_t /* method_index */) {
return 0;
}
+RPY_EXPORTED_FOR_TESTS
cppyy_method_t cppyy_get_method(cppyy_scope_t handle, cppyy_index_t method_index) {
if (s_scopes.find(handle) != s_scopes.end()) {
long id = s_scopes[handle].m_method_offset + (long)method_index;
@@ -872,6 +911,7 @@
/* method properties ----------------------------------------------------- */
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_constructor(cppyy_type_t handle, cppyy_index_t method_index) {
if (s_scopes.find(handle) != s_scopes.end())
return s_scopes[handle].m_methods[method_index].m_type == kConstructor;
@@ -879,6 +919,7 @@
return 0;
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_staticmethod(cppyy_type_t handle, cppyy_index_t method_index) {
if (s_scopes.find(handle) != s_scopes.end())
return s_scopes[handle].m_methods[method_index].m_type == kStatic;
@@ -888,28 +929,34 @@
/* data member reflection information ------------------------------------- */
+RPY_EXPORTED_FOR_TESTS
int cppyy_num_datamembers(cppyy_scope_t handle) {
return s_scopes[handle].m_datambrs.size();
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_datamember_name(cppyy_scope_t handle, int idatambr) {
return cppstring_to_cstring(s_scopes[handle].m_datambrs[idatambr].m_name);
}
+RPY_EXPORTED_FOR_TESTS
char* cppyy_datamember_type(cppyy_scope_t handle, int idatambr) {
return cppstring_to_cstring(s_scopes[handle].m_datambrs[idatambr].m_type);
}
+RPY_EXPORTED_FOR_TESTS
ptrdiff_t cppyy_datamember_offset(cppyy_scope_t handle, int idatambr) {
return s_scopes[handle].m_datambrs[idatambr].m_offset;
}
/* data member properties ------------------------------------------------ */
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_publicdata(cppyy_scope_t handle, int idatambr) {
return 1;
}
+RPY_EXPORTED_FOR_TESTS
int cppyy_is_staticdata(cppyy_scope_t handle, int idatambr) {
return s_scopes[handle].m_datambrs[idatambr].m_isstatic;
}
@@ -917,33 +964,44 @@
/* misc helpers ----------------------------------------------------------- */
#if defined(_MSC_VER)
+RPY_EXPORTED_FOR_TESTS
long long cppyy_strtoll(const char* str) {
return _strtoi64(str, NULL, 0);
}
-extern "C" unsigned long long cppyy_strtoull(const char* str) {
+extern "C" {
+RPY_EXPORTED_FOR_TESTS
+unsigned long long cppyy_strtoull(const char* str) {
return _strtoui64(str, NULL, 0);
}
+}
#else
+RPY_EXPORTED_FOR_TESTS
long long cppyy_strtoll(const char* str) {
return strtoll(str, NULL, 0);
}
-extern "C" unsigned long long cppyy_strtoull(const char* str) {
+extern "C" {
+RPY_EXPORTED_FOR_TESTS
+unsigned long long cppyy_strtoull(const char* str) {
return strtoull(str, NULL, 0);
}
+}
#endif
+RPY_EXPORTED_FOR_TESTS
void cppyy_free(void* ptr) {
free(ptr);
}
+RPY_EXPORTED_FOR_TESTS
cppyy_object_t cppyy_charp2stdstring(const char* str) {
void* arena = new char[sizeof(std::string)];
new (arena) std::string(str);
return (cppyy_object_t)arena;
}
+RPY_EXPORTED_FOR_TESTS
cppyy_object_t cppyy_stdstring2stdstring(cppyy_object_t ptr) {
void* arena = new char[sizeof(std::string)];
new (arena) std::string(*(std::string*)ptr);
diff --git a/pypy/module/cppyy/test/conftest.py b/pypy/module/cppyy/test/conftest.py
--- a/pypy/module/cppyy/test/conftest.py
+++ b/pypy/module/cppyy/test/conftest.py
@@ -38,6 +38,7 @@
import os
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.translator.platform import platform
+ from rpython.translator import cdir
from rpython.rtyper.lltypesystem import rffi
@@ -48,7 +49,8 @@
eci = ExternalCompilationInfo(
separate_module_files=[srcpath.join('dummy_backend.cxx')],
- include_dirs=[incpath, tstpath],
+ include_dirs=[incpath, tstpath, cdir],
+ compile_extra=['-DRPY_EXPORTED_FOR_TESTS=RPY_EXPORTED'],
use_cpp_linker=True,
)
diff --git a/pypy/module/cppyy/test/test_crossing.py b/pypy/module/cppyy/test/test_crossing.py
--- a/pypy/module/cppyy/test/test_crossing.py
+++ b/pypy/module/cppyy/test/test_crossing.py
@@ -49,6 +49,7 @@
kwds["compile_extra"]=["-Werror=implicit-function-declaration"]
modname = modname.split('.')[-1]
+ xxxxxxxxxxxxxxxxxxxxxxx
eci = ExternalCompilationInfo(
export_symbols=['init%s' % (modname,)]+symbols,
include_dirs=api.include_dirs,
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -775,6 +775,7 @@
struct PyPyAPI {
%(members)s
} _pypyAPI;
+ RPY_EXPORTED_FOR_TESTS
struct PyPyAPI* pypyAPI = &_pypyAPI;
""" % dict(members=structmembers)
@@ -946,9 +947,8 @@
name_no_star = process_va_name(name)
header = ('%s pypy_va_get_%s(va_list* vp)' %
(name, name_no_star))
- pypy_decls.append(header + ';')
+ pypy_decls.append('RPY_EXPORTED_FOR_TESTS ' + header + ';')
functions.append(header + '\n{return va_arg(*vp, %s);}\n' % name)
- export_symbols.append('pypy_va_get_%s' % (name_no_star,))
for name, (typ, expr) in GLOBALS.iteritems():
if name.endswith('#'):
@@ -974,7 +974,6 @@
"NOT_RPYTHON"
# Build code and get pointer to the structure
kwds = {}
- export_symbols_eci = export_symbols[:]
compile_extra=['-DPy_BUILD_CORE']
@@ -988,7 +987,6 @@
elif sys.platform.startswith('linux'):
compile_extra.append("-Werror=implicit-function-declaration")
compile_extra.append('-g')
- export_symbols_eci.append('pypyAPI')
else:
kwds["includes"] = ['Python.h'] # this is our Python.h
@@ -1009,6 +1007,7 @@
if sys.platform == 'win32':
get_pythonapi_source = '''
#include <windows.h>
+ RPY_EXPORTED_FOR_TESTS
HANDLE pypy_get_pythonapi_handle() {
MEMORY_BASIC_INFORMATION mi;
memset(&mi, 0, sizeof(mi));
@@ -1021,7 +1020,6 @@
}
'''
separate_module_sources.append(get_pythonapi_source)
- export_symbols_eci.append('pypy_get_pythonapi_handle')
eci = ExternalCompilationInfo(
include_dirs=include_dirs,
@@ -1044,7 +1042,6 @@
source_dir / "missing.c",
],
separate_module_sources=separate_module_sources,
- export_symbols=export_symbols_eci,
compile_extra=compile_extra,
**kwds
)
diff --git a/pypy/module/cpyext/include/Python.h b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -11,8 +11,8 @@
# include <errno.h>
# include <unistd.h>
# define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
-# define PyAPI_FUNC(RTYPE) RTYPE
-# define PyAPI_DATA(RTYPE) extern RTYPE
+# define PyAPI_FUNC(RTYPE) __attribute__((visibility("default"))) RTYPE
+# define PyAPI_DATA(RTYPE) extern PyAPI_FUNC(RTYPE)
# define Py_LOCAL_INLINE(type) static inline type
#else
# define MS_WIN32 1
@@ -47,7 +47,7 @@
# endif
#endif
#ifndef DL_EXPORT
-# define DL_EXPORT(RTYPE) RTYPE
+# define DL_EXPORT(RTYPE) PyAPI_FUNC(RTYPE)
#endif
#ifndef DL_IMPORT
# define DL_IMPORT(RTYPE) RTYPE
diff --git a/pypy/module/cpyext/include/bufferobject.h b/pypy/module/cpyext/include/bufferobject.h
--- a/pypy/module/cpyext/include/bufferobject.h
+++ b/pypy/module/cpyext/include/bufferobject.h
@@ -26,18 +26,18 @@
#define Py_END_OF_BUFFER (-1)
-PyObject* PyBuffer_FromObject(PyObject *base,
+PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
Py_ssize_t offset, Py_ssize_t size);
-PyObject* PyBuffer_FromReadWriteObject(PyObject *base,
+PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
Py_ssize_t offset,
Py_ssize_t size);
-PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
-PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
+PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
+PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
-PyObject* PyBuffer_New(Py_ssize_t size);
+PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
-PyTypeObject *_Py_get_buffer_type(void);
+PyAPI_FUNC(PyTypeObject *) _Py_get_buffer_type(void);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/include/eval.h b/pypy/module/cpyext/include/eval.h
--- a/pypy/module/cpyext/include/eval.h
+++ b/pypy/module/cpyext/include/eval.h
@@ -19,14 +19,14 @@
#define PyEval_CallObject(func,arg) \
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
-PyObject * PyEval_CallFunction(PyObject *obj, const char *format, ...);
-PyObject * PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...);
-PyObject * PyObject_CallFunction(PyObject *obj, const char *format, ...);
-PyObject * PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...);
-PyObject * _PyObject_CallFunction_SizeT(PyObject *obj, const char *format, ...);
-PyObject * _PyObject_CallMethod_SizeT(PyObject *obj, const char *name, const char *format, ...);
-PyObject * PyObject_CallFunctionObjArgs(PyObject *callable, ...);
-PyObject * PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...);
+PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, const char *format, ...);
+PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...);
+PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *obj, const char *format, ...);
+PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...);
+PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *obj, const char *format, ...);
+PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj, const char *name, const char *format, ...);
+PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, ...);
+PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...);
/* These constants are also defined in cpyext/eval.py */
#define Py_single_input 256
diff --git a/pypy/module/cpyext/include/modsupport.h b/pypy/module/cpyext/include/modsupport.h
--- a/pypy/module/cpyext/include/modsupport.h
+++ b/pypy/module/cpyext/include/modsupport.h
@@ -29,24 +29,24 @@
#define PYTHON_API_VERSION 1013
#define PYTHON_API_STRING "1013"
-int PyArg_Parse(PyObject *, const char *, ...);
-int PyArg_ParseTuple(PyObject *, const char *, ...);
-int PyArg_VaParse(PyObject *, const char *, va_list);
+PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
+PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
+PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
-int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
+PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
const char *, char **, ...);
-int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
+PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
const char *, char **, va_list);
-int _PyArg_Parse_SizeT(PyObject *, const char *, ...);
-int _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
-int _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
+PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
+PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
+PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
-int _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
+PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, ...);
-int _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
+PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, va_list);
-
+
/* to make sure that modules compiled with CPython's or PyPy's Python.h
are not importable on the other interpreter, use a #define to expect a
different symbol: (this function is implemented in ../modsupport.py) */
@@ -60,28 +60,28 @@
Py_InitModule4(name, methods, doc, (PyObject *)NULL, \
PYTHON_API_VERSION)
-int PyModule_AddObject(PyObject *m, const char *name, PyObject *o);
-int PyModule_AddIntConstant(PyObject *m, const char *name, long value);
-int PyModule_AddStringConstant(PyObject *m, const char *name, const char *value);
+PyAPI_FUNC(int) PyModule_AddObject(PyObject *m, const char *name, PyObject *o);
+PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *m, const char *name, long value);
+PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *m, const char *name, const char *value);
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
-PyObject * Py_BuildValue(const char *, ...);
-PyObject * Py_VaBuildValue(const char *, va_list);
-PyObject * _Py_BuildValue_SizeT(const char *, ...);
-PyObject * _Py_VaBuildValue_SizeT(const char *, va_list);
-int _PyArg_NoKeywords(const char *funcname, PyObject *kw);
+PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
+PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
+PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
+PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
+PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
-int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...);
+PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...);
/*
* This is from pyport.h. Perhaps it belongs elsewhere.
*/
#ifdef __cplusplus
-#define PyMODINIT_FUNC extern "C" void
+#define PyMODINIT_FUNC extern "C" PyAPI_FUNC(void)
#else
-#define PyMODINIT_FUNC void
+#define PyMODINIT_FUNC PyAPI_FUNC(void)
#endif
PyAPI_DATA(char *) _Py_PackageContext;
diff --git a/pypy/module/cpyext/include/numpy/arrayobject.h b/pypy/module/cpyext/include/numpy/arrayobject.h
--- a/pypy/module/cpyext/include/numpy/arrayobject.h
+++ b/pypy/module/cpyext/include/numpy/arrayobject.h
@@ -204,9 +204,9 @@
#define PyArray_EMPTY(nd, dims, type_num, fortran) \
PyArray_SimpleNew(nd, dims, type_num)
-void _PyArray_FILLWBYTE(PyObject* obj, int val);
-PyObject* _PyArray_ZEROS(int nd, npy_intp* dims, int type_num, int fortran);
-int _PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src);
+PyAPI_FUNC(void) _PyArray_FILLWBYTE(PyObject* obj, int val);
+PyAPI_FUNC(PyObject *) _PyArray_ZEROS(int nd, npy_intp* dims, int type_num, int fortran);
+PyAPI_FUNC(int) _PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src);
#define PyArray_FILLWBYTE _PyArray_FILLWBYTE
#define PyArray_ZEROS _PyArray_ZEROS
diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -563,13 +563,13 @@
#define Py_TRASHCAN_SAFE_END(pyObj)
/* Copied from CPython ----------------------------- */
-int PyObject_AsReadBuffer(PyObject *, const void **, Py_ssize_t *);
-int PyObject_AsWriteBuffer(PyObject *, void **, Py_ssize_t *);
-int PyObject_CheckReadBuffer(PyObject *);
+PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *, const void **, Py_ssize_t *);
+PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *, void **, Py_ssize_t *);
+PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *);
/* PyPy internal ----------------------------------- */
-int PyPyType_Register(PyTypeObject *);
+PyAPI_FUNC(int) PyPyType_Register(PyTypeObject *);
#define PyObject_Length PyObject_Size
#define _PyObject_GC_Del PyObject_GC_Del
diff --git a/pypy/module/cpyext/include/pycapsule.h b/pypy/module/cpyext/include/pycapsule.h
--- a/pypy/module/cpyext/include/pycapsule.h
+++ b/pypy/module/cpyext/include/pycapsule.h
@@ -50,7 +50,7 @@
PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
-PyTypeObject *_Py_get_capsule_type(void);
+PyAPI_FUNC(PyTypeObject *) _Py_get_capsule_type(void);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/include/pycobject.h b/pypy/module/cpyext/include/pycobject.h
--- a/pypy/module/cpyext/include/pycobject.h
+++ b/pypy/module/cpyext/include/pycobject.h
@@ -48,8 +48,8 @@
} PyCObject;
#endif
-PyTypeObject *_Py_get_cobject_type(void);
-
+PyAPI_FUNC(PyTypeObject *) _Py_get_cobject_type(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/pypy/module/cpyext/include/pyerrors.h b/pypy/module/cpyext/include/pyerrors.h
--- a/pypy/module/cpyext/include/pyerrors.h
+++ b/pypy/module/cpyext/include/pyerrors.h
@@ -11,9 +11,9 @@
(PyClass_Check((x)) || (PyType_Check((x)) && \
PyObject_IsSubclass((x), PyExc_BaseException)))
-PyObject *PyErr_NewException(const char *name, PyObject *base, PyObject *dict);
-PyObject *PyErr_NewExceptionWithDoc(const char *name, const char *doc, PyObject *base, PyObject *dict);
-PyObject *PyErr_Format(PyObject *exception, const char *format, ...);
+PyAPI_FUNC(PyObject *) PyErr_NewException(const char *name, PyObject *base, PyObject *dict);
+PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(const char *name, const char *doc, PyObject *base, PyObject *dict);
+PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *exception, const char *format, ...);
/* These APIs aren't really part of the error implementation, but
often needed to format error messages; the native C lib APIs are
diff --git a/pypy/module/cpyext/include/pysignals.h b/pypy/module/cpyext/include/pysignals.h
--- a/pypy/module/cpyext/include/pysignals.h
+++ b/pypy/module/cpyext/include/pysignals.h
@@ -9,8 +9,8 @@
typedef void (*PyOS_sighandler_t)(int);
-PyOS_sighandler_t PyOS_setsig(int sig, PyOS_sighandler_t handler);
-PyOS_sighandler_t PyOS_getsig(int sig);
+PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int sig, PyOS_sighandler_t handler);
+PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int sig);
#ifdef __cplusplus
diff --git a/pypy/module/cpyext/include/pythonrun.h b/pypy/module/cpyext/include/pythonrun.h
--- a/pypy/module/cpyext/include/pythonrun.h
+++ b/pypy/module/cpyext/include/pythonrun.h
@@ -6,7 +6,7 @@
extern "C" {
#endif
-void Py_FatalError(const char *msg);
+PyAPI_FUNC(void) Py_FatalError(const char *msg);
/* taken from Python-2.7.3/Include/pydebug.h */
PyAPI_DATA(int) Py_DebugFlag;
diff --git a/pypy/module/cpyext/include/stringobject.h b/pypy/module/cpyext/include/stringobject.h
--- a/pypy/module/cpyext/include/stringobject.h
+++ b/pypy/module/cpyext/include/stringobject.h
@@ -16,8 +16,8 @@
Py_ssize_t size;
} PyStringObject;
-PyObject *PyString_FromFormatV(const char *format, va_list vargs);
-PyObject *PyString_FromFormat(const char *format, ...);
+PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char *format, va_list vargs);
+PyAPI_FUNC(PyObject *) PyString_FromFormat(const char *format, ...);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/include/structseq.h b/pypy/module/cpyext/include/structseq.h
--- a/pypy/module/cpyext/include/structseq.h
+++ b/pypy/module/cpyext/include/structseq.h
@@ -19,7 +19,7 @@
int n_in_sequence;
} PyStructSequence_Desc;
-extern char* PyStructSequence_UnnamedField;
+PyAPI_DATA(char *) PyStructSequence_UnnamedField;
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc);
diff --git a/pypy/module/cpyext/include/tupleobject.h b/pypy/module/cpyext/include/tupleobject.h
--- a/pypy/module/cpyext/include/tupleobject.h
+++ b/pypy/module/cpyext/include/tupleobject.h
@@ -8,7 +8,7 @@
#endif
/* defined in varargswrapper.c */
-PyObject * PyTuple_Pack(Py_ssize_t, ...);
+PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
#define PyTuple_SET_ITEM PyTuple_SetItem
#define PyTuple_GET_ITEM PyTuple_GetItem
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -77,7 +77,6 @@
modname = modname.split('.')[-1]
eci = ExternalCompilationInfo(
- export_symbols=['init%s' % (modname,)],
include_dirs=api.include_dirs,
**kwds
)
@@ -263,7 +262,8 @@
#include <Python.h>
%(body)s
- void init%(name)s(void) {
+ PyMODINIT_FUNC
+ init%(name)s(void) {
%(init)s
}
""" % dict(name=name, init=init, body=body,
diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -91,6 +91,18 @@
return ""
return rffi.charp2str(res)
+ def _dlerror_on_dlopen_untranslated(name):
+ "NOT_RPYTHON: aaargh"
+ import ctypes
+ name = rffi.charp2str(name)
+ try:
+ ctypes.CDLL(name)
+ except OSError, e:
+ return str(e)
+ else:
+ return ("opening %r with ctypes.CDLL() works, "
+ "but not with c_dlopen()??" % (name,))
+
def dlopen(name, mode=-1):
""" Wrapper around C-level dlopen
"""
@@ -103,7 +115,10 @@
mode |= RTLD_NOW
res = c_dlopen(name, rffi.cast(rffi.INT, mode))
if not res:
- err = dlerror()
+ if not we_are_translated():
+ err = _dlerror_on_dlopen_untranslated(name)
+ else:
+ err = dlerror()
raise DLOpenError(err)
return res
More information about the pypy-commit
mailing list