[pypy-commit] pypy default: We were missing the __attribute__((visibility("hidden"))) on all

arigo noreply at buildbot.pypy.org
Sun Nov 9 17:47:21 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r74415:56ba97730a23
Date: 2014-11-09 11:27 +0100
http://bitbucket.org/pypy/pypy/changeset/56ba97730a23/

Log:	We were missing the __attribute__((visibility("hidden"))) on all
	function and global variables declared in translator/c/src/. This
	should in theory close the performance gap between shared and non-
	shared pypy.

	See comments in translator/c/src/precommondefs.h.

diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py
--- a/rpython/rlib/clibffi.py
+++ b/rpython/rlib/clibffi.py
@@ -49,7 +49,7 @@
     #include <windows.h>
 
     /* Get the module where the "fopen" function resides in */
-    RPY_EXPORTED_FOR_TESTS
+    RPY_EXTERN
     HANDLE pypy_get_libc_handle() {
         MEMORY_BASIC_INFORMATION  mi;
         char buf[1000];
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -44,7 +44,7 @@
 
         /* This function emulates what the windows CRT
             does to validate file handles */
-        RPY_EXPORTED_FOR_TESTS int
+        RPY_EXTERN int
         _PyVerify_fd(int fd)
         {
             const int i1 = fd >> IOINFO_L2E;
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
@@ -383,7 +383,7 @@
     else:
         pattern = '%s%s { return %s(%s); }'
     source = pattern % (
-        'RPY_EXPORTED_FOR_TESTS ',
+        'RPY_EXTERN ',
         cdecl(implementationtypename, wrapper_name),
         macro, ', '.join(argnames))
 
@@ -628,9 +628,9 @@
     getter_name = 'get_' + name
     setter_name = 'set_' + name
     getter_prototype = (
-       "RPY_EXPORTED_FOR_TESTS %(c_type)s %(getter_name)s ();" % locals())
+       "RPY_EXTERN %(c_type)s %(getter_name)s ();" % locals())
     setter_prototype = (
-       "RPY_EXPORTED_FOR_TESTS void %(setter_name)s (%(c_type)s v);" % locals())
+       "RPY_EXTERN void %(setter_name)s (%(c_type)s v);" % locals())
     c_getter = "%(c_type)s %(getter_name)s () { return %(name)s; }" % locals()
     c_setter = "void %(setter_name)s (%(c_type)s v) { %(name)s = v; }" % locals()
 
diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -391,7 +391,7 @@
         h_source = py.code.Source("""
         #ifndef _CALLBACK_H
         #define _CALLBACK_H
-        extern Signed eating_callback(Signed arg, Signed(*call)(Signed));
+        RPY_EXTERN Signed eating_callback(Signed arg, Signed(*call)(Signed));
         #endif /* _CALLBACK_H */
         """)
 
@@ -401,7 +401,7 @@
         c_source = py.code.Source("""
         #include "src/precommondefs.h"
 
-        RPY_EXPORTED Signed eating_callback(Signed arg, Signed(*call)(Signed))
+        RPY_EXTERN Signed eating_callback(Signed arg, Signed(*call)(Signed))
         {
             Signed res = call(arg);
             if (res == -1)
diff --git a/rpython/translator/c/src/allocator.h b/rpython/translator/c/src/allocator.h
--- a/rpython/translator/c/src/allocator.h
+++ b/rpython/translator/c/src/allocator.h
@@ -1,4 +1,4 @@
 /* allocation functions prototypes */
-void *PyObject_Malloc(size_t n);
-void *PyObject_Realloc(void *p, size_t n);
-void PyObject_Free(void *p);
+RPY_EXTERN void *PyObject_Malloc(size_t n);
+RPY_EXTERN void *PyObject_Realloc(void *p, size_t n);
+RPY_EXTERN void PyObject_Free(void *p);
diff --git a/rpython/translator/c/src/asm_gcc_x86.h b/rpython/translator/c/src/asm_gcc_x86.h
--- a/rpython/translator/c/src/asm_gcc_x86.h
+++ b/rpython/translator/c/src/asm_gcc_x86.h
@@ -52,7 +52,7 @@
         : "0"(x), "g"(y)     /* inputs  */      \
         : "cc", "memory")    /* clobber */
 
-extern void op_int_overflowed(void)
+RPY_EXTERN void op_int_overflowed(void)
      asm ("_op_int_overflowed")
      __attribute__((used));
 
@@ -104,5 +104,5 @@
 
 #ifdef PYPY_X86_CHECK_SSE2
 #define PYPY_X86_CHECK_SSE2_DEFINED
-extern void pypy_x86_check_sse2(void);
+RPY_EXTERN void pypy_x86_check_sse2(void);
 #endif
diff --git a/rpython/translator/c/src/asm_msvc.h b/rpython/translator/c/src/asm_msvc.h
--- a/rpython/translator/c/src/asm_msvc.h
+++ b/rpython/translator/c/src/asm_msvc.h
@@ -1,4 +1,4 @@
 #ifdef PYPY_X86_CHECK_SSE2
 #define PYPY_X86_CHECK_SSE2_DEFINED
-extern void pypy_x86_check_sse2(void);
+RPY_EXTERN void pypy_x86_check_sse2(void);
 #endif
diff --git a/rpython/translator/c/src/debug_print.h b/rpython/translator/c/src/debug_print.h
--- a/rpython/translator/c/src/debug_print.h
+++ b/rpython/translator/c/src/debug_print.h
@@ -37,14 +37,14 @@
 /************************************************************/
 
 /* prototypes (internal use only) */
-void pypy_debug_ensure_opened(void);
-void pypy_debug_start(const char *category);
-void pypy_debug_stop(const char *category);
-long pypy_debug_offset(void);
-void pypy_debug_forked(long original_offset);
+RPY_EXTERN void pypy_debug_ensure_opened(void);
+RPY_EXTERN void pypy_debug_start(const char *category);
+RPY_EXTERN void pypy_debug_stop(const char *category);
+RPY_EXTERN long pypy_debug_offset(void);
+RPY_EXTERN void pypy_debug_forked(long original_offset);
 
-extern long pypy_have_debug_prints;
-extern RPY_EXPORTED FILE *pypy_debug_file;
+RPY_EXTERN long pypy_have_debug_prints;
+RPY_EXPORTED FILE *pypy_debug_file;
 
 #define OP_LL_READ_TIMESTAMP(val) READ_TIMESTAMP(val)
 
@@ -59,7 +59,7 @@
 #    define READ_TIMESTAMP(val) QueryPerformanceCounter((LARGE_INTEGER*)&(val))
 #  else
 
-long long pypy_read_timestamp();
+RPY_EXTERN long long pypy_read_timestamp(void);
 
 #    define READ_TIMESTAMP(val)  (val) = pypy_read_timestamp()
 
diff --git a/rpython/translator/c/src/debug_traceback.h b/rpython/translator/c/src/debug_traceback.h
--- a/rpython/translator/c/src/debug_traceback.h
+++ b/rpython/translator/c/src/debug_traceback.h
@@ -60,8 +60,8 @@
   void *exctype;
 };
 
-extern int pypydtcount;
-extern struct pypydtentry_s pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH];
+RPY_EXTERN int pypydtcount;
+RPY_EXTERN struct pypydtentry_s pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH];
 
-void pypy_debug_traceback_print(void);
-void pypy_debug_catch_fatal_exception(void);
+RPY_EXTERN void pypy_debug_traceback_print(void);
+RPY_EXTERN void pypy_debug_catch_fatal_exception(void);
diff --git a/rpython/translator/c/src/dtoa.h b/rpython/translator/c/src/dtoa.h
--- a/rpython/translator/c/src/dtoa.h
+++ b/rpython/translator/c/src/dtoa.h
@@ -1,11 +1,11 @@
 /* Exported functions from dtoa.c */
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 double _PyPy_dg_strtod(const char *str, char **ptr);
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 char * _PyPy_dg_dtoa(double d, int mode, int ndigits,
 		     int *decpt, int *sign, char **rve);
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void _PyPy_dg_freedtoa(char *s);
diff --git a/rpython/translator/c/src/entrypoint.h b/rpython/translator/c/src/entrypoint.h
--- a/rpython/translator/c/src/entrypoint.h
+++ b/rpython/translator/c/src/entrypoint.h
@@ -8,6 +8,6 @@
 #define PYPY_MAIN_FUNCTION main
 #endif
 
-char *RPython_StartupCode(void);
+RPY_EXTERN char *RPython_StartupCode(void);
 RPY_EXPORTED int PYPY_MAIN_FUNCTION(int argc, char *argv[]);
 #endif  /* PYPY_STANDALONE */
diff --git a/rpython/translator/c/src/exception.h b/rpython/translator/c/src/exception.h
--- a/rpython/translator/c/src/exception.h
+++ b/rpython/translator/c/src/exception.h
@@ -22,6 +22,7 @@
 #endif
 /* !DO_LOG_EXC: define the function anyway, so that we can shut
    off the prints of a debug_exc by remaking only testing_1.o */
+RPY_EXTERN
 void RPyDebugReturnShowException(const char *msg, const char *filename,
                                  long lineno, const char *functionname);
 
@@ -36,6 +37,7 @@
 
 /* prototypes */
 
+RPY_EXTERN
 void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc);
 
 #endif
diff --git a/rpython/translator/c/src/instrument.c b/rpython/translator/c/src/instrument.c
--- a/rpython/translator/c/src/instrument.c
+++ b/rpython/translator/c/src/instrument.c
@@ -1,5 +1,5 @@
+#include "common_header.h"
 #include <src/instrument.h>
-#include "common_header.h"
 
 #ifdef  PYPY_INSTRUMENT
 
diff --git a/rpython/translator/c/src/instrument.h b/rpython/translator/c/src/instrument.h
--- a/rpython/translator/c/src/instrument.h
+++ b/rpython/translator/c/src/instrument.h
@@ -1,10 +1,10 @@
 #ifndef _PYPY_INSTRUMENT_H
 #define _PYPY_INSTRUMENT_H
 
-void instrument_setup();
+RPY_EXTERN void instrument_setup();
 
 #ifdef PYPY_INSTRUMENT
-void instrument_count(long);
+RPY_EXTERN void instrument_count(long);
 #define PYPY_INSTRUMENT_COUNT(label) instrument_count(label)
 #else
 #define PYPY_INSTRUMENT_COUNT
diff --git a/rpython/translator/c/src/int.h b/rpython/translator/c/src/int.h
--- a/rpython/translator/c/src/int.h
+++ b/rpython/translator/c/src/int.h
@@ -238,7 +238,7 @@
 
 #define OP_BOOL_NOT(x, r) r = !(x)
 
-long long op_llong_mul_ovf(long long a, long long b);
+RPY_EXTERN long long op_llong_mul_ovf(long long a, long long b);
 
 /* The definitions above can be used with various types */ 
 
diff --git a/rpython/translator/c/src/libffi_msvc/ffi.h b/rpython/translator/c/src/libffi_msvc/ffi.h
--- a/rpython/translator/c/src/libffi_msvc/ffi.h
+++ b/rpython/translator/c/src/libffi_msvc/ffi.h
@@ -60,7 +60,7 @@
 
 /* ---- System configuration information --------------------------------- */
 
-#include <src/precommondefs.h> /* for RPY_EXPORTED_FOR_TESTS */
+#include <src/precommondefs.h> /* for RPY_EXTERN */
 #include <ffitarget.h>
 
 #ifndef LIBFFI_ASM
@@ -222,7 +222,7 @@
   void      *user_data;
 } ffi_closure;
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 ffi_status
 ffi_prep_closure (ffi_closure*,
 		  ffi_cif *,
@@ -266,14 +266,14 @@
 
 /* ---- Public interface definition -------------------------------------- */
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, 
 			ffi_abi abi,
 			unsigned int nargs, 
 			/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, 
 			/*@dependent@*/ ffi_type **atypes);
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int
 ffi_call(/*@dependent@*/ ffi_cif *cif, 
 	 void (*fn)(), 
diff --git a/rpython/translator/c/src/ll_math.c b/rpython/translator/c/src/ll_math.c
--- a/rpython/translator/c/src/ll_math.c
+++ b/rpython/translator/c/src/ll_math.c
@@ -36,7 +36,7 @@
  * ====================================================
  */
 
-double _pypy_math_log1p(double x);
+RPY_EXTERN double _pypy_math_log1p(double x);
 
 static const double ln2 = 6.93147180559945286227E-01;
 static const double two_pow_m28 = 3.7252902984619141E-09; /* 2**-28 */
diff --git a/rpython/translator/c/src/ll_math.h b/rpython/translator/c/src/ll_math.h
--- a/rpython/translator/c/src/ll_math.h
+++ b/rpython/translator/c/src/ll_math.h
@@ -3,9 +3,9 @@
 
 #include "src/precommondefs.h"
 
-RPY_EXPORTED_FOR_TESTS double _pypy_math_acosh(double x);
-RPY_EXPORTED_FOR_TESTS double _pypy_math_asinh(double x);
-RPY_EXPORTED_FOR_TESTS double _pypy_math_atanh(double x);
+RPY_EXTERN double _pypy_math_acosh(double x);
+RPY_EXTERN double _pypy_math_asinh(double x);
+RPY_EXTERN double _pypy_math_atanh(double x);
 
-RPY_EXPORTED_FOR_TESTS double _pypy_math_expm1(double x);
-RPY_EXPORTED_FOR_TESTS double _pypy_math_log1p(double x);
+RPY_EXTERN double _pypy_math_expm1(double x);
+RPY_EXTERN double _pypy_math_log1p(double x);
diff --git a/rpython/translator/c/src/ll_strtod.h b/rpython/translator/c/src/ll_strtod.h
--- a/rpython/translator/c/src/ll_strtod.h
+++ b/rpython/translator/c/src/ll_strtod.h
@@ -6,8 +6,10 @@
 #ifndef _PYPY_LL_STRTOD_H
 #define _PYPY_LL_STRTOD_H
 
+RPY_EXTERN
 double LL_strtod_parts_to_float(char *sign, char *beforept,
 				char *afterpt, char *exponent);
+RPY_EXTERN
 char *LL_strtod_formatd(double x, char code, int precision);
 
 #endif
diff --git a/rpython/translator/c/src/mem.h b/rpython/translator/c/src/mem.h
--- a/rpython/translator/c/src/mem.h
+++ b/rpython/translator/c/src/mem.h
@@ -70,9 +70,9 @@
                                                                 __FUNCTION__)
 #  define OP_TRACK_ALLOC_STOP(addr, r)   pypy_debug_alloc_stop(addr)
 
-void pypy_debug_alloc_start(void*, const char*);
-void pypy_debug_alloc_stop(void*);
-void pypy_debug_alloc_results(void);
+RPY_EXTERN void pypy_debug_alloc_start(void*, const char*);
+RPY_EXTERN void pypy_debug_alloc_stop(void*);
+RPY_EXTERN void pypy_debug_alloc_results(void);
 
 #endif /* RPY_ASSERT */
 
@@ -101,9 +101,9 @@
     else								\
 	GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj)
 
-extern int boehm_gc_finalizer_lock;
-void boehm_gc_startup_code(void);
-void boehm_gc_finalizer_notifier(void);
+RPY_EXTERN int boehm_gc_finalizer_lock;
+RPY_EXTERN void boehm_gc_startup_code(void);
+RPY_EXTERN void boehm_gc_finalizer_notifier(void);
 
 #define OP_GC__DISABLE_FINALIZERS(r)  boehm_gc_finalizer_lock++
 #define OP_GC__ENABLE_FINALIZERS(r)  (boehm_gc_finalizer_lock--,	\
@@ -146,10 +146,10 @@
 
 #ifndef _MSC_VER
 /* Implementation for Linux */
-extern char __gcmapstart;
-extern char __gcmapend;
-extern char __gccallshapes;
-extern long pypy_asm_stackwalk(void*, void*);
+RPY_EXTERN char __gcmapstart;
+RPY_EXTERN char __gcmapend;
+RPY_EXTERN char __gccallshapes;
+RPY_EXTERN long pypy_asm_stackwalk(void*, void*);
 #define __gcnoreorderhack __gcmapend
 
 /* The following pseudo-instruction is used by --gcrootfinder=asmgcc
@@ -186,7 +186,7 @@
 #define pypy_asm_stack_bottom() { asm volatile ("/* GC_STACK_BOTTOM */" : : : \
                                   "memory"); pypy_check_stack_count(); }
 #ifdef RPY_ASSERT
-void pypy_check_stack_count(void);
+RPY_EXTERN void pypy_check_stack_count(void);
 #else
 static void pypy_check_stack_count(void) { }
 #endif
@@ -200,10 +200,10 @@
 
 #else
 /* implementation of asmgcroot for Windows */
-extern void* __gcmapstart;
-extern void* __gcmapend;
-extern char* __gccallshapes;
-extern Signed pypy_asm_stackwalk(void*, void*);
+RPY_EXTERN void* __gcmapstart;
+RPY_EXTERN void* __gcmapend;
+RPY_EXTERN char* __gccallshapes;
+RPY_EXTERN Signed pypy_asm_stackwalk(void*, void*);
 
 /* With the msvc Microsoft Compiler, the optimizer seems free to move
    any code (even asm) that involves local memory (registers and stack).
diff --git a/rpython/translator/c/src/precommondefs.h b/rpython/translator/c/src/precommondefs.h
--- a/rpython/translator/c/src/precommondefs.h
+++ b/rpython/translator/c/src/precommondefs.h
@@ -42,15 +42,33 @@
 #endif
 
 
+/* All functions and global variables declared anywhere should use
+   one of the following attributes:
+
+   RPY_EXPORTED:  the symbol is exported out of libpypy-c.so.
+
+   RPY_EXTERN:    the symbol is not exported out of libpypy-c.so, but
+                  otherwise works like 'extern' by being available to
+                  other C sources.
+
+   static:        as usual, this means the symbol is local to this C file.
+
+   Don't use _RPY_HIDDEN directly.  For tests involving building a custom
+   .so, translator/tool/cbuild.py overrides RPY_EXTERN so that it becomes
+   equal to RPY_EXPORTED.
+
+   Any function or global variable declared with no attribute at all is
+   a bug; please report or fix it.
+*/
 #ifdef __GNUC__
-#  define RPY_EXPORTED __attribute__((visibility("default")))
-#  define RPY_HIDDEN   __attribute__((visibility("hidden")))
+#  define RPY_EXPORTED extern __attribute__((visibility("default")))
+#  define _RPY_HIDDEN  __attribute__((visibility("hidden")))
 #else
-#  define RPY_EXPORTED __declspec(dllexport)
-#  define RPY_HIDDEN   /* nothing */
+#  define RPY_EXPORTED extern __declspec(dllexport)
+#  define _RPY_HIDDEN  /* nothing */
 #endif
-#ifndef RPY_EXPORTED_FOR_TESTS
-#  define RPY_EXPORTED_FOR_TESTS  /* nothing */
+#ifndef RPY_EXTERN
+#  define RPY_EXTERN   extern _RPY_HIDDEN
 #endif
 
 
diff --git a/rpython/translator/c/src/profiling.c b/rpython/translator/c/src/profiling.c
--- a/rpython/translator/c/src/profiling.c
+++ b/rpython/translator/c/src/profiling.c
@@ -9,7 +9,7 @@
 static cpu_set_t base_cpu_set;
 static int profiling_setup = 0;
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypy_setup_profiling(void)
 {
   if (!profiling_setup) {
@@ -22,7 +22,7 @@
   }
 }
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypy_teardown_profiling(void)
 {
   if (profiling_setup) {
@@ -40,7 +40,7 @@
 static DWORD_PTR base_affinity_mask;
 static int profiling_setup = 0;
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypy_setup_profiling(void) {
     if (!profiling_setup) {
         DWORD_PTR affinity_mask, system_affinity_mask;
@@ -56,7 +56,7 @@
     }
 }
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypy_teardown_profiling(void) {
     if (profiling_setup) {
         SetProcessAffinityMask(GetCurrentProcess(), base_affinity_mask);
@@ -67,7 +67,7 @@
 #else
 
 /* Empty implementations for other platforms */
-RPY_EXPORTED_FOR_TESTS void pypy_setup_profiling(void) { }
-RPY_EXPORTED_FOR_TESTS void pypy_teardown_profiling(void) { }
+RPY_EXTERN void pypy_setup_profiling(void) { }
+RPY_EXTERN void pypy_teardown_profiling(void) { }
 
 #endif
diff --git a/rpython/translator/c/src/profiling.h b/rpython/translator/c/src/profiling.h
--- a/rpython/translator/c/src/profiling.h
+++ b/rpython/translator/c/src/profiling.h
@@ -1,7 +1,7 @@
 #ifndef _PYPY_PROFILING_H
 #define _PYPY_PROFILING_H
 
-RPY_EXPORTED_FOR_TESTS void pypy_setup_profiling(void);
-RPY_EXPORTED_FOR_TESTS void pypy_teardown_profiling(void);
+RPY_EXTERN void pypy_setup_profiling(void);
+RPY_EXTERN void pypy_teardown_profiling(void);
 
 #endif
diff --git a/rpython/translator/c/src/rtyper.h b/rpython/translator/c/src/rtyper.h
--- a/rpython/translator/c/src/rtyper.h
+++ b/rpython/translator/c/src/rtyper.h
@@ -9,6 +9,6 @@
 #define RPyUnicode_Size(rpu)		((rpu)->ru_chars.length)
 #define _RPyUnicode_AsUnicode(rpu)	((rpu)->ru_chars.items)
 
-char *RPyString_AsCharP(RPyString *rps);
-void RPyString_FreeCache(void);
-RPyString *RPyString_FromString(char *buf);
+RPY_EXTERN char *RPyString_AsCharP(RPyString *rps);
+RPY_EXTERN void RPyString_FreeCache(void);
+RPY_EXTERN RPyString *RPyString_FromString(char *buf);
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
@@ -5,22 +5,22 @@
 
 
 /* utilities to set a signal handler */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypysig_ignore(int signum);  /* signal will be ignored (SIG_IGN) */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypysig_default(int signum); /* signal will do default action (SIG_DFL) */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypysig_setflag(int signum); /* signal will set a flag which can be
                                      queried with pypysig_poll() */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypysig_reinstall(int signum);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int pypysig_set_wakeup_fd(int fd);
 
 /* utility to poll for signals that arrived */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int pypysig_poll(void);   /* => signum or -1 */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void pypysig_pushback(int signum);
 
 /* When a signal is received, pypysig_counter is set to -1. */
@@ -28,12 +28,12 @@
 struct pypysig_long_struct {
     long value;
 };
-extern struct pypysig_long_struct pypysig_counter;
+RPY_EXTERN struct pypysig_long_struct pypysig_counter;
 
 /* 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
+RPY_EXTERN
 void *pypysig_getaddr_occurred(void);
 #define pypysig_getaddr_occurred()   ((void *)(&pypysig_counter))
 
diff --git a/rpython/translator/c/src/stack.h b/rpython/translator/c/src/stack.h
--- a/rpython/translator/c/src/stack.h
+++ b/rpython/translator/c/src/stack.h
@@ -11,11 +11,13 @@
  * It is needed to have RPyThreadStaticTLS, too. */
 #include "threadlocal.h"
 
-extern char *_LLstacktoobig_stack_end;
-extern long _LLstacktoobig_stack_length;
-extern char _LLstacktoobig_report_error;
+RPY_EXTERN char *_LLstacktoobig_stack_end;
+RPY_EXTERN long _LLstacktoobig_stack_length;
+RPY_EXTERN char _LLstacktoobig_report_error;
 
+RPY_EXTERN
 char LL_stack_too_big_slowpath(long);    /* returns 0 (ok) or 1 (too big) */
+RPY_EXTERN
 void LL_stack_set_length_fraction(double);
 
 /* some macros referenced from rpython.rlib.rstack */
diff --git a/rpython/translator/c/src/stacklet/stacklet.h b/rpython/translator/c/src/stacklet/stacklet.h
--- a/rpython/translator/c/src/stacklet/stacklet.h
+++ b/rpython/translator/c/src/stacklet/stacklet.h
@@ -22,8 +22,8 @@
  */
 typedef struct stacklet_thread_s *stacklet_thread_handle;
 
-RPY_EXPORTED_FOR_TESTS stacklet_thread_handle stacklet_newthread(void);
-void stacklet_deletethread(stacklet_thread_handle thrd);
+RPY_EXTERN stacklet_thread_handle stacklet_newthread(void);
+RPY_EXTERN void stacklet_deletethread(stacklet_thread_handle thrd);
 
 
 /* The "run" function of a stacklet.  The first argument is the handle
@@ -35,7 +35,7 @@
 /* Call 'run(source, run_arg)' in a new stack.  See stacklet_switch()
  * for the return value.
  */
-RPY_EXPORTED_FOR_TESTS stacklet_handle stacklet_new(stacklet_thread_handle thrd,
+RPY_EXTERN stacklet_handle stacklet_new(stacklet_thread_handle thrd,
                              stacklet_run_fn run, void *run_arg);
 
 /* Switch to the target handle, resuming its stack.  This returns:
@@ -45,18 +45,19 @@
  * Don't call this with an already-used target, with EMPTY_STACKLET_HANDLE,
  * or with a stack handle from another thread (in multithreaded apps).
  */
-RPY_EXPORTED_FOR_TESTS stacklet_handle stacklet_switch(stacklet_handle target);
+RPY_EXTERN stacklet_handle stacklet_switch(stacklet_handle target);
 
 /* Delete a stack handle without resuming it at all.
  * (This works even if the stack handle is of a different thread)
  */
-void stacklet_destroy(stacklet_handle target);
+RPY_EXTERN void stacklet_destroy(stacklet_handle target);
 
 /* stacklet_handle _stacklet_switch_to_copy(stacklet_handle) --- later */
 
 /* Hack: translate a pointer into the stack of a stacklet into a pointer
  * to where it is really stored so far.  Only to access word-sized data.
  */
+RPY_EXTERN
 char **_stacklet_translate_pointer(stacklet_handle context, char **ptr);
 
 #endif /* _STACKLET_H_ */
diff --git a/rpython/translator/c/src/support.h b/rpython/translator/c/src/support.h
--- a/rpython/translator/c/src/support.h
+++ b/rpython/translator/c/src/support.h
@@ -27,12 +27,14 @@
 #  define RPyAssert(x, msg)                                             \
      if (!(x)) RPyAssertFailed(__FILE__, __LINE__, __FUNCTION__, msg)
 
+RPY_EXTERN
 void RPyAssertFailed(const char* filename, long lineno,
                      const char* function, const char *msg);
 #else
 #  define RPyAssert(x, msg)   /* nothing */
 #endif
 
+RPY_EXTERN
 void RPyAbort(void);
 
 #if defined(RPY_LL_ASSERT) || defined(RPY_SANDBOXED)
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
@@ -26,9 +26,9 @@
 
 #endif /* !_WIN32 */
 
-RPY_EXPORTED_FOR_TESTS void RPyGilAllocate(void);
-RPY_EXPORTED_FOR_TESTS long RPyGilYieldThread(void);
-RPY_EXPORTED_FOR_TESTS void RPyGilAcquire(void);
+RPY_EXTERN void RPyGilAllocate(void);
+RPY_EXTERN long RPyGilYieldThread(void);
+RPY_EXTERN void RPyGilAcquire(void);
 #define RPyGilRelease _RPyGilRelease
 #define RPyFetchFastGil _RPyFetchFastGil
 
@@ -38,7 +38,7 @@
 # define RPY_FASTGIL_LOCKED(x)   (x != 0)
 #endif
 
-extern long rpy_fastgil;
+RPY_EXTERN long rpy_fastgil;
 
 static inline void _RPyGilRelease(void) {
     assert(RPY_FASTGIL_LOCKED(rpy_fastgil));
diff --git a/rpython/translator/c/src/thread_gil.c b/rpython/translator/c/src/thread_gil.c
--- a/rpython/translator/c/src/thread_gil.c
+++ b/rpython/translator/c/src/thread_gil.c
@@ -162,7 +162,7 @@
 */
 
 #undef RPyGilRelease
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyGilRelease(void)
 {
     /* Releases the GIL in order to do an external function call.
@@ -173,7 +173,7 @@
 }
 
 #undef RPyFetchFastGil
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long *RPyFetchFastGil(void)
 {
     return _RPyFetchFastGil();
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,23 +12,23 @@
 } NRMUTEX, *PNRMUTEX;
 
 /* prototypes */
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadGetIdent(void);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadStart(void (*func)(void));
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int RPyThreadAcquireLock(struct RPyOpaque_ThreadLock *lock, int waitflag);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 RPyLockStatus RPyThreadAcquireLockTimed(struct RPyOpaque_ThreadLock *lock,
 					RPY_TIMEOUT_T timeout, int intr_flag);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyThreadReleaseLock(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadGetStackSize(void);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadSetStackSize(long);
 #endif
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,24 +59,24 @@
 
 /* prototypes */
 
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadGetIdent(void);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadStart(void (*func)(void));
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 int RPyThreadAcquireLock(struct RPyOpaque_ThreadLock *lock, int waitflag);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 RPyLockStatus RPyThreadAcquireLockTimed(struct RPyOpaque_ThreadLock *lock,
 					RPY_TIMEOUT_T timeout, int intr_flag);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyThreadReleaseLock(struct RPyOpaque_ThreadLock *lock);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadGetStackSize(void);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 long RPyThreadSetStackSize(long);
-RPY_EXPORTED_FOR_TESTS
+RPY_EXTERN
 void RPyThreadAfterFork(void);
diff --git a/rpython/translator/c/src/threadlocal.h b/rpython/translator/c/src/threadlocal.h
--- a/rpython/translator/c/src/threadlocal.h
+++ b/rpython/translator/c/src/threadlocal.h
@@ -2,6 +2,8 @@
 #ifndef _SRC_THREADLOCAL_H
 #define _SRC_THREADLOCAL_H
 
+#include <src/precommondefs.h>
+
 
 #ifdef _WIN32
 
@@ -38,7 +40,7 @@
 #define RPyThreadStaticTLS_Create(key) RPyThreadTLS_Create(key)
 #define RPyThreadStaticTLS_Get(key)    RPyThreadTLS_Get(key)
 #define RPyThreadStaticTLS_Set(key, value) RPyThreadTLS_Set(key, value)
-void RPyThreadTLS_Create(RPyThreadTLS *result);
+RPY_EXTERN void RPyThreadTLS_Create(RPyThreadTLS *result);
 
 #endif
 
diff --git a/rpython/translator/c/support.py b/rpython/translator/c/support.py
--- a/rpython/translator/c/support.py
+++ b/rpython/translator/c/support.py
@@ -32,21 +32,16 @@
 
 def forward_cdecl(ctype, cname, standalone, is_thread_local=False,
                   is_exported=False):
-    prefix = ""
-    if is_thread_local:
-        prefix = "__thread "
+    # 'standalone' ignored
     if is_exported:
         assert not is_thread_local
         prefix = "RPY_EXPORTED "
-    elif standalone:
-        prefix += "RPY_HIDDEN "
+    else:
+        prefix = "RPY_EXTERN "
+        if is_thread_local:
+            prefix += "__thread "
+    return prefix + cdecl(ctype, cname)
 
-    cdecl_str = prefix + cdecl(ctype, cname)
-    if standalone:
-        return 'extern ' + cdecl_str
-    else:
-        return cdecl_str
-    
 def somelettersfrom(s):
     upcase = [c for c in s if c.isupper()]
     if not upcase:
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
@@ -315,7 +315,7 @@
             d['link_files'] = [fn for fn in d['link_files']
                                   if not fn.endswith('.a')]
         d['compile_extra'] = d['compile_extra'] + (
-            '-DRPY_EXPORTED_FOR_TESTS=RPY_EXPORTED',)
+            '-DRPY_EXTERN=RPY_EXPORTED',)
         self = ExternalCompilationInfo(**d)
 
         lib = str(host.compile([], self, outputfilename=outputfilename,
diff --git a/rpython/translator/tool/test/test_cbuild.py b/rpython/translator/tool/test/test_cbuild.py
--- a/rpython/translator/tool/test/test_cbuild.py
+++ b/rpython/translator/tool/test/test_cbuild.py
@@ -74,7 +74,7 @@
     def test_make_shared_lib(self):
         eci = ExternalCompilationInfo(
             separate_module_sources = ['''
-            RPY_EXPORTED_FOR_TESTS int get()
+            RPY_EXTERN int get()
             {
                 return 42;
             }


More information about the pypy-commit mailing list