From e2d63b1fea0ab7d985503cd1b44b0ea85c96506c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 15 Sep 2009 02:48:17 +0000 Subject: [PATCH] Enable -fvisibility=hidden on Linux. This will prevent further symbol clashes, and makes the shared libraries 10 to 20 percent smaller. We should enable this on other platforms, too, if we can guarantee they'll use gcc 4.0 or later and the platform supports it. --- Makefile | 2 +- code/cgame/cg_main.c | 2 +- code/cgame/cg_syscalls.c | 2 +- code/game/g_main.c | 2 +- code/game/g_syscalls.c | 2 +- code/q3_ui/ui_main.c | 2 +- code/qcommon/q_shared.h | 10 ++++++++++ code/ui/ui_main.c | 2 +- code/ui/ui_syscalls.c | 2 +- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0a3efc55..d190f6d3 100644 --- a/Makefile +++ b/Makefile @@ -304,7 +304,7 @@ ifeq ($(PLATFORM),linux) endif SHLIBEXT=so - SHLIBCFLAGS=-fPIC + SHLIBCFLAGS=-fPIC -fvisibility=hidden SHLIBLDFLAGS=-shared $(LDFLAGS) THREAD_LIBS=-lpthread diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 15a5539b..b5670c5e 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -43,7 +43,7 @@ This is the only way control passes into the module. This must be the very first function compiled into the .q3vm file ================ */ -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { switch ( command ) { case CG_INIT: diff --git a/code/cgame/cg_syscalls.c b/code/cgame/cg_syscalls.c index cdc10601..83606acd 100644 --- a/code/cgame/cg_syscalls.c +++ b/code/cgame/cg_syscalls.c @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1; -void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { +Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { syscall = syscallptr; } diff --git a/code/game/g_main.c b/code/game/g_main.c index cd176d31..5073fe0b 100644 --- a/code/game/g_main.c +++ b/code/game/g_main.c @@ -198,7 +198,7 @@ This is the only way control passes into the module. This must be the very first function compiled into the .q3vm file ================ */ -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { switch ( command ) { case GAME_INIT: G_InitGame( arg0, arg1, arg2 ); diff --git a/code/game/g_syscalls.c b/code/game/g_syscalls.c index 59d89bde..1868d0ac 100644 --- a/code/game/g_syscalls.c +++ b/code/game/g_syscalls.c @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1; -void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { +Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { syscall = syscallptr; } diff --git a/code/q3_ui/ui_main.c b/code/q3_ui/ui_main.c index 2b10db0e..8ec498df 100644 --- a/code/q3_ui/ui_main.c +++ b/code/q3_ui/ui_main.c @@ -40,7 +40,7 @@ This is the only way control passes into the module. This must be the very first function compiled into the .qvm file ================ */ -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { switch ( command ) { case UI_GETAPIVERSION: return UI_API_VERSION; diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 99edd69b..19db09ce 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -81,6 +81,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #endif +#if (defined _MSC_VER) +#define Q_EXPORT __declspec(dllexport) +#elif (defined __SUNPRO_C) +#define Q_EXPORT __global +#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun)) +#define Q_EXPORT __attribute__((visibility("default"))) +#else +#define Q_EXPORT +#endif + /********************************************************************** VM Considerations diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c index 2fccf16a..6c9fb6e1 100644 --- a/code/ui/ui_main.c +++ b/code/ui/ui_main.c @@ -164,7 +164,7 @@ void _UI_KeyEvent( int key, qboolean down ); void _UI_MouseEvent( int dx, int dy ); void _UI_Refresh( int realtime ); qboolean _UI_IsFullscreen( void ); -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { switch ( command ) { case UI_GETAPIVERSION: return UI_API_VERSION; diff --git a/code/ui/ui_syscalls.c b/code/ui/ui_syscalls.c index 9048a951..5b3ab45f 100644 --- a/code/ui/ui_syscalls.c +++ b/code/ui/ui_syscalls.c @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1; -void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { +Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) { syscall = syscallptr; }