[Freeswitch-svn] [commit] r12061 - in freeswitch/trunk: . libs/libteletone libs/libteletone/src src/include

FreeSWITCH SVN mikej at freeswitch.org
Mon Feb 16 10:17:01 PST 2009


Author: mikej
Date: Mon Feb 16 12:17:01 2009
New Revision: 12061

Log:
API visibility support (GCC/SUNCC) (FSCORE-264)

Modified:
   freeswitch/trunk/configure.in
   freeswitch/trunk/libs/libteletone/configure.in
   freeswitch/trunk/libs/libteletone/src/libteletone.h
   freeswitch/trunk/libs/libteletone/src/libteletone_detect.c
   freeswitch/trunk/libs/libteletone/src/libteletone_generate.c
   freeswitch/trunk/src/include/switch_platform.h

Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in	(original)
+++ freeswitch/trunk/configure.in	Mon Feb 16 12:17:01 2009
@@ -151,6 +151,76 @@
     fi
 fi
 
+#
+# gcc visibility cflag checks
+#
+AC_ARG_ENABLE([visibility],
+	[AS_HELP_STRING([--disable-visibility], [Disable or enable API visibility support (default: use if available)])],
+	[enable_visibility="${enableval}"],
+	[enable_visibility="detect"]
+)
+HAVE_VISIBILITY="no"
+
+if test "x${enable_visibility}" != "xno" ; then
+
+	case "${ax_cv_c_compiler_vendor}" in
+	gnu)
+		save_CFLAGS="${CFLAGS}"
+		CFLAGS="${CFLAGS} -fvisibility=hidden"
+		AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
+		AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM(
+				[int foo __attribute__ ((visibility("default")));],
+				[;]
+			)],
+
+			[AC_MSG_RESULT([yes])
+			 APR_ADDTO([SWITCH_AM_CFLAGS],   [-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
+			 APR_ADDTO([SWITCH_AM_CXXFLAGS], [-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
+			 HAVE_VISIBILITY="yes"],
+
+			[AC_MSG_RESULT([no])]
+		)
+		CFLAGS="${save_CFLAGS}"
+		;;
+
+	sun)
+		save_CFLAGS="${CFLAGS}"
+		CFLAGS="${CFLAGS} -xldscope=hidden"
+		AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
+		AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM(
+				[int foo __attribute__ ((visibility("default")));],
+				[;]
+			)],
+
+			[AC_MSG_RESULT([yes])
+			 APR_ADDTO([SWITCH_AM_CFLAGS],   [-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
+			 APR_ADDTO([SWITCH_AM_CXXFLAGS], [-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1])
+			 HAVE_VISIBILITY="yes"],
+
+			[AC_MSG_RESULT([no])]
+		)
+		CFLAGS="${save_CFLAGS}"
+		;;
+
+	*)
+		if test "x${enable_visibility}" = "xyes" ; then
+			AC_MSG_ERROR([Non-GNU / SUN compilers are currently unsupported])
+		else
+			AC_MSG_WARN([Non-GNU / SUN compilers are currently unsupported])
+		fi
+		;;
+	esac
+
+	#
+	# visibility explicitly requested but not supported by this compiler => error
+	#
+	if test "x${enable_visibility}" = "xyes" -a "x${HAVE_VISIBILITY}" = "xno" ; then
+		AC_MSG_ERROR([API visibility not supported by this compiler])
+	fi
+fi
+
 # Enable debugging (default: on)
 # (rename option if the default is changed)
 AC_ARG_ENABLE(debug,

Modified: freeswitch/trunk/libs/libteletone/configure.in
==============================================================================
--- freeswitch/trunk/libs/libteletone/configure.in	(original)
+++ freeswitch/trunk/libs/libteletone/configure.in	Mon Feb 16 12:17:01 2009
@@ -7,11 +7,16 @@
 AM_INIT_AUTOMAKE(libteletone,0.1)
 AC_CONFIG_SRCDIR([src])
 
+# disable checks
+m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
+
 # Checks for programs.
 AC_PROG_CC
 AC_PROG_MAKE_SET
 AC_PROG_LIBTOOL
 AC_PROG_INSTALL
+
 #  Optimize
 AC_ARG_ENABLE(optimization,
 [AC_HELP_STRING([--enable-optimization],[Set if you want us to add max optimising compiler flags])],[enable_optimizer="$enableval"],[enable_optimizer="no"])
@@ -64,6 +69,77 @@
                 new_AM_LDFLAGS=""
         ;;
 esac
+
+#
+# gcc visibility cflag checks
+#
+AC_ARG_ENABLE([visibility],
+	[AS_HELP_STRING([--disable-visibility], [Disable or enable API visibility support (default: use if available)])],
+	[enable_visibility="${enableval}"],
+	[enable_visibility="detect"]
+)
+HAVE_VISIBILITY="no"
+
+if test "x${enable_visibility}" != "xno" ; then
+
+	case "${ax_cv_c_compiler_vendor}" in
+	gnu)
+		save_CFLAGS="${CFLAGS}"
+		CFLAGS="${CFLAGS} -fvisibility=hidden"
+		AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
+		AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM(
+				[int foo __attribute__ ((visibility("default")));],
+				[;]
+			)],
+
+			[AC_MSG_RESULT([yes])
+			 new_AM_CFLAGS="${new_AM_CFLAGS} -fvisibility=hidden"
+			 AC_DEFINE([HAVE_VISIBILITY], [1], [GCC visibility support available])
+			 HAVE_VISIBILITY="yes"],
+
+			[AC_MSG_RESULT([no])]
+		)
+		CFLAGS="${save_CFLAGS}"
+		;;
+
+	sun)
+		save_CFLAGS="${CFLAGS}"
+		CFLAGS="${CFLAGS} -xldscope=hidden"
+		AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
+		AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM(
+				[int foo __attribute__ ((visibility("default")));],
+				[;]
+			)],
+
+			[AC_MSG_RESULT([yes])
+			 new_AM_CFLAGS="${new_AM_CFLAGS} -xldscope=hidden"
+			 AC_DEFINE([HAVE_VISIBILITY], [1], [SUNCC visibility support available])
+			 HAVE_VISIBILITY="yes"],
+
+			[AC_MSG_RESULT([no])]
+		)
+		CFLAGS="${save_CFLAGS}"
+		;;
+
+	*)
+		if test "x${enable_visibility}" = "xyes" ; then
+			AC_MSG_ERROR([Non-GNU / SUN compilers are currently unsupported])
+		else
+			AC_MSG_WARN([Non-GNU / SUN compilers are currently unsupported])
+		fi
+		;;
+	esac
+
+	#
+	# visibility explicitly requested but not supported by this compiler => error
+	#
+	if test "x${enable_visibility}" = "xyes" -a "x${HAVE_VISIBILITY}" = "xno" ; then
+		AC_MSG_ERROR([API visibility not supported by this compiler])
+	fi
+fi
+
 AC_SUBST(new_AM_CFLAGS)
 AC_SUBST(new_AM_LDFLAGS)
 

Modified: freeswitch/trunk/libs/libteletone/src/libteletone.h
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone.h	(original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone.h	Mon Feb 16 12:17:01 2009
@@ -110,6 +110,12 @@
 #define teletone_assert(expr) assert(expr)
 #endif
 
+#if (defined(__GNUC__) || defined(__SUNCC__)) && defined(HAVE_VISIBILITY)
+#define TELETONE_API __attribute__((visibility("default")))
+#else
+#define TELETONE_API
+#endif
+
 #include <libteletone_generate.h>
 #include <libteletone_detect.h>
 

Modified: freeswitch/trunk/libs/libteletone/src/libteletone_detect.c
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone_detect.c	(original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone_detect.c	Mon Feb 16 12:17:01 2009
@@ -116,7 +116,7 @@
 	goertzel_state->fac = tdesc->fac;
 }
 
-void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+TELETONE_API void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
 							  int16_t sample_buffer[],
 							  int samples)
 {
@@ -135,7 +135,7 @@
 
 #define teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac))
 
-void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate)
+TELETONE_API void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate)
 {
 	int i;
 	float theta;
@@ -169,7 +169,7 @@
 	dtmf_detect_state->mhit = 0;
 }
 
-void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map)
+TELETONE_API void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map)
 {
 	float theta = 0;
 	int x = 0;
@@ -209,7 +209,7 @@
 
 }
 
-int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
+TELETONE_API int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
 								int16_t sample_buffer[],
 								int samples)
 {
@@ -299,7 +299,7 @@
 }
 
 
-int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
 						  int16_t sample_buffer[],
 						  int samples)
 {
@@ -430,7 +430,7 @@
 }
 
 
-int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
+TELETONE_API int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
 					   char *buf,
 					   int max)
 {

Modified: freeswitch/trunk/libs/libteletone/src/libteletone_generate.c
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone_generate.c	(original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone_generate.c	Mon Feb 16 12:17:01 2009
@@ -99,7 +99,7 @@
 };
 
 
-int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
+TELETONE_API int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
 {
 	va_list ap;
 	int i = 0;
@@ -115,7 +115,7 @@
 	
 }
 
-int teletone_set_map(teletone_tone_map_t *map, ...)
+TELETONE_API int teletone_set_map(teletone_tone_map_t *map, ...)
 {
 	va_list ap;
 	int i = 0;
@@ -131,7 +131,7 @@
 	
 }
 
-int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
+TELETONE_API int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
 {
 	memset(ts, 0, sizeof(*ts));
 	ts->rate = 8000;
@@ -174,7 +174,7 @@
 	return 0;
 }
 
-int teletone_destroy_session(teletone_generation_session_t *ts)
+TELETONE_API int teletone_destroy_session(teletone_generation_session_t *ts)
 {
 	if (ts->buffer) {
 		free(ts->buffer);
@@ -203,7 +203,7 @@
 	return 0;
 }
 
-int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
+TELETONE_API int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
 {
 	/*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/
 	int i, c;
@@ -318,7 +318,7 @@
 	return (char *) memcpy (new, s, len);
 }
 
-int teletone_run(teletone_generation_session_t *ts, const char *cmd)
+TELETONE_API int teletone_run(teletone_generation_session_t *ts, const char *cmd)
 {
 	char *data = NULL, *cur = NULL, *end = NULL;
 	int var = 0, LOOPING = 0;

Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h	(original)
+++ freeswitch/trunk/src/include/switch_platform.h	Mon Feb 16 12:17:01 2009
@@ -164,11 +164,19 @@
 #define SWITCH_THREAD_FUNC  __stdcall
 #else //not win32
 #define O_BINARY 0
-#define SWITCH_DECLARE(type) type
-#define SWITCH_DECLARE_NONSTD(type) type
-#define SWITCH_MOD_DECLARE(type) type
+#if (defined(__GNUC__) || defined(__SUNCC__)) && defined(SWITCH_API_VISIBILITY)
+#define SWITCH_DECLARE(type)		__attribute__((visibility("default"))) type
+#define SWITCH_DECLARE_NONSTD(type)	__attribute__((visibility("default"))) type
+#define SWITCH_DECLARE_DATA		__attribute__((visibility("default")))
+#define SWITCH_MOD_DECLARE(type)	__attribute__((visibility("default"))) type
+#define SWITCH_MOD_DECLARE_DATA		__attribute__((visibility("default")))
+#else
+#define SWITCH_DECLARE(type)		type
+#define SWITCH_DECLARE_NONSTD(type)	type
 #define SWITCH_DECLARE_DATA
+#define SWITCH_MOD_DECLARE(type)	type
 #define SWITCH_MOD_DECLARE_DATA
+#endif
 #define SWITCH_THREAD_FUNC
 #endif
 #define SWITCH_DECLARE_CONSTRUCTOR SWITCH_DECLARE_DATA



More information about the Freeswitch-svn mailing list