[PATCH 7/7] Set symbol visibility attribute to hide internal symbols

Keith Packard keithp at keithp.com
Wed Nov 20 11:56:01 PST 2013


Expose only the official API.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 configure.ac    | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/xshmfence.h | 16 +++++++++-------
 xshmfence.pc.in |  2 +-
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0c8a325..4c6c333 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,49 @@ AC_SUBST([PTHREAD_LIBS])
 AM_CONDITIONAL([FUTEX], [test x"$FUTEX" = xyes])
 AM_CONDITIONAL([PTHREAD], [test x"$PTHREAD" = xyes])
 
+PKG_CHECK_MODULES(XPROTO, xproto)
+
+AC_SUBST([XPROTO_CFLAGS])
+
+CFLAGS="$CFLAGS $XPROTO_CFLAGS"
+
+AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
+				[SYMBOL_VISIBILITY=$enableval],
+				[SYMBOL_VISIBILITY=auto])
+
+dnl ==================================================================
+dnl symbol visibility
+symbol_visibility=
+have_visibility=disabled
+if test x$SYMBOL_VISIBILITY != xno; then
+    AC_MSG_CHECKING(for symbol visibility support)
+    if test x$GCC = xyes; then
+	VISIBILITY_CFLAGS="-fvisibility=hidden"
+    else
+	if test x$SUNCC = xyes; then
+	    VISIBILITY_CFLAGS="-xldscope=hidden"
+	else
+	    have_visibility=no
+	fi
+    fi
+    if test x$have_visibility != xno; then
+	AC_TRY_COMPILE(
+	    [#include <X11/Xfuncproto.h>
+	     extern _X_HIDDEN int hidden_int;
+	     extern _X_EXPORT int public_int;
+	     extern _X_HIDDEN int hidden_int_func(void);
+	     extern _X_EXPORT int public_int_func(void);],
+	    [],
+	    have_visibility=yes,
+	    have_visibility=no)
+    fi
+    AC_MSG_RESULT([$have_visibility])
+    if test x$have_visibility != xno; then
+	symbol_visibility=$VISIBILITY_CFLAGS
+	CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
+    fi
+fi
+
 AC_ARG_WITH(shared-memory-dir, AS_HELP_STRING([--with-shared-memory-dir=PATH], [Path to directory in a world-writable temporary directory for anonymous shared memory (default: auto)]),
 [],
 [with_shared_memory_dir=yes])
diff --git a/src/xshmfence.h b/src/xshmfence.h
index bbdbb53..27d1b82 100644
--- a/src/xshmfence.h
+++ b/src/xshmfence.h
@@ -23,29 +23,31 @@
 #ifndef _XSHMFENCE_H_
 #define _XSHMFENCE_H_
 
+#include <X11/Xfuncproto.h>
+
 #define HAVE_STRUCT_XSHMFENCE   1
 
 struct xshmfence;
 
-int
+_X_EXPORT int 
 xshmfence_trigger(struct xshmfence *f);
 
-int
+_X_EXPORT int
 xshmfence_await(struct xshmfence *f);
 
-int
+_X_EXPORT int
 xshmfence_query(struct xshmfence *f);
 
-void
+_X_EXPORT void
 xshmfence_reset(struct xshmfence *f);
 
-int
+_X_EXPORT int
 xshmfence_alloc_shm(void);
 
-struct xshmfence *
+_X_EXPORT struct xshmfence *
 xshmfence_map_shm(int fd);
 
-void
+_X_EXPORT void
 xshmfence_unmap_shm(struct xshmfence *f);
 
 #endif /* _XSHMFENCE_H_ */
diff --git a/xshmfence.pc.in b/xshmfence.pc.in
index 579af0b..a139fab 100644
--- a/xshmfence.pc.in
+++ b/xshmfence.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: xshmfence
 Description: The X Shared Memory Fence Library
 Version: @PACKAGE_VERSION@
-Cflags: -I${includedir}
+Cflags: -I${includedir} @XPROTO_CFLAGS@
 Libs: -L${libdir} -lxshmfence
 Libs.private: @PTHREAD_LIBS@
-- 
1.8.4.2



More information about the xorg-devel mailing list