- added support for visibility attribute for GCC 4.x for controlling export symbols
authorDamien Fouilleul <damienf@videolan.org>
Mon, 5 Feb 2007 14:58:40 +0000 (14:58 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Mon, 5 Feb 2007 14:58:40 +0000 (14:58 +0000)
configure.ac
include/vlc/vlc.h
include/vlc_common.h
include/vlc_modules_macros.h

index 6b9f2b9..49e46dd 100644 (file)
@@ -1011,6 +1011,26 @@ if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
     VLC_ADD_CFLAGS([i420_yuy2_mmx],[-fomit-frame-pointer])
 fi
 
+dnl Check for -fvisibility=hidden
+AC_CACHE_CHECK([if \$CC accepts -fvisibility=hidden],
+    [ac_cv_c_visibility_hidden],
+    [CFLAGS="${CFLAGS_save} -fvisibility=hidden"
+     AC_TRY_COMPILE([],,ac_cv_c_visibility_hidden=yes, ac_cv_c_visibility_hidden=no)])
+if test "${ac_cv_c_visibility_hidden}" != "no"; then
+    VLC_ADD_CFLAGS([libvlc],[-fvisibility=hidden])
+    VLC_ADD_CFLAGS([plugin],[-fvisibility=hidden])
+fi
+
+dnl Check for -fvisibility-inlines-hidden
+AC_CACHE_CHECK([if \$CC accepts -fvisibility-inlines-hidden],
+    [ac_cv_c_visibility_inlines_hidden],
+    [CFLAGS="${CFLAGS_save} -fvisibility-inlines-hidden"
+     AC_TRY_COMPILE([],,ac_cv_c_visibility_inlines_hidden=yes, ac_cv_c_visibility_inlines_hidden=no)])
+if test "${ac_cv_c_visibility_inlines_hidden}" != "no"; then
+    VLC_ADD_CFLAGS([libvlc],[-fvisibility-inlines-hidden])
+    VLC_ADD_CFLAGS([plugin],[-fvisibility-inlines-hidden])
+fi
+
 dnl Check for -mdynamic-no-pic
 AC_CACHE_CHECK([if \$CC accepts -mdynamic-no-pic],
     [ac_cv_c_dynamic_no_pic],
@@ -1089,7 +1109,7 @@ if test "${ac_cv_c_attribute_format}" != "no"; then
     AC_DEFINE(HAVE_ATTRIBUTE_FORMAT, 1, Support for __attribute__((format())) with function pointers)
 fi
 
-dnl Check for __attribute__(())
+dnl Check for __attribute__((packed))
 AC_CACHE_CHECK([for __attribute__((packed))],
   [ac_cv_c_attribute_packed],
   [ac_cv_c_attribute_packed=no
@@ -1099,6 +1119,16 @@ if test "${ac_cv_c_attribute_packed}" != "no"; then
   AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs)
 fi
 
+dnl Check for __attribute__((visibility()))
+AC_CACHE_CHECK([for __attribute__((visibility()))],
+  [ac_cv_c_attribute_visibility],
+  [ac_cv_c_attribute_visibility=no
+   AC_TRY_COMPILE(, [extern __attribute__((visibility("default"))) int foo(int);],
+                    [ac_cv_c_attribute_visibility=yes])])
+if test "${ac_cv_c_attribute_visibility}" != "no"; then
+  AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1, Support for __attribute__((visibility())) for exporting symbols)
+fi
+
 dnl
 dnl  Check the CPU
 dnl
index b19b389..a42a17d 100644 (file)
@@ -160,6 +160,8 @@ struct vlc_list_t
  *****************************************************************************/
 #if defined(WIN32) && defined(DLL_EXPORT)
 #  define VLC_PUBLIC_API extern __declspec(dllexport)
+#elif HAVE_ATTRIBUTE_VISIBILITY
+#  define VLC_PUBLIC_API extern __attribute__((visibility("default")))
 #else
 #  define VLC_PUBLIC_API extern
 #endif
index d587d54..1863b59 100644 (file)
@@ -480,6 +480,14 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *,      /* variable's object */
 #    define VLC_EXPORT( type, name, args ) __declspec(dllexport) type name args
 #    define VLC_INTERNAL( type, name, args ) type name args
 #  endif
+#elif HAVE_ATTRIBUTE_VISIBILITY
+#   ifdef __cplusplus
+#      define VLC_EXPORT( type, name, args ) extern "C" __attribute__((visibility("default"))) type name args
+#      define VLC_INTERNAL( type, name, args ) extern "C" __attribute__((visibility("hidden"))) type name args
+#   else
+#      define VLC_EXPORT( type, name, args ) __attribute__((visibility("default"))) type name args
+#      define VLC_INTERNAL( type, name, args ) __attribute__((visibility("hidden"))) type name args
+#   endif
 #else
 #  if !defined (__PLUGIN__) || defined (HAVE_SHARED_LIBVLC)
 #   ifdef __cplusplus
index b4c4988..39fdd26 100644 (file)
@@ -71,6 +71,9 @@
 #if defined( __PLUGIN__ ) && ( defined( WIN32 ) || defined( UNDER_CE ) )
 #   define DLL_SYMBOL              __declspec(dllexport)
 #   define CDECL_SYMBOL            __cdecl
+#elif HAVE_ATTRIBUTE_VISIBILITY
+#   define DLL_SYMBOL __attribute__((visibility("default")))
+#   define CDECL_SYMBOL
 #else
 #   define DLL_SYMBOL
 #   define CDECL_SYMBOL