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

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12061 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-02-16 18:17:01 +00:00
parent 104c99ea85
commit ffe2ad4bbd
6 changed files with 175 additions and 15 deletions

View File

@ -151,6 +151,76 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
fi fi
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) # Enable debugging (default: on)
# (rename option if the default is changed) # (rename option if the default is changed)
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,

View File

@ -7,11 +7,16 @@ AC_CONFIG_AUX_DIR(build)
AM_INIT_AUTOMAKE(libteletone,0.1) AM_INIT_AUTOMAKE(libteletone,0.1)
AC_CONFIG_SRCDIR([src]) AC_CONFIG_SRCDIR([src])
# disable checks
m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_PROG_INSTALL AC_PROG_INSTALL
# Optimize # Optimize
AC_ARG_ENABLE(optimization, 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"]) [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 @@ case "$host" in
new_AM_LDFLAGS="" new_AM_LDFLAGS=""
;; ;;
esac 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_CFLAGS)
AC_SUBST(new_AM_LDFLAGS) AC_SUBST(new_AM_LDFLAGS)

View File

@ -110,6 +110,12 @@ typedef __int16 int16_t;
#define teletone_assert(expr) assert(expr) #define teletone_assert(expr) assert(expr)
#endif #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_generate.h>
#include <libteletone_detect.h> #include <libteletone_detect.h>

View File

@ -116,7 +116,7 @@ static void goertzel_init(teletone_goertzel_state_t *goertzel_state, teletone_de
goertzel_state->fac = tdesc->fac; 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[], int16_t sample_buffer[],
int samples) int samples)
{ {
@ -135,7 +135,7 @@ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
#define teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)) #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; int i;
float theta; float theta;
@ -169,7 +169,7 @@ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state,
dtmf_detect_state->mhit = 0; 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; float theta = 0;
int x = 0; int x = 0;
@ -209,7 +209,7 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
} }
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[], int16_t sample_buffer[],
int samples) int samples)
{ {
@ -299,7 +299,7 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
} }
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[], int16_t sample_buffer[],
int samples) int samples)
{ {
@ -430,7 +430,7 @@ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
} }
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, char *buf,
int max) int max)
{ {

View File

@ -99,7 +99,7 @@ int16_t TELETONE_SINES[SINE_TABLE_MAX] = {
}; };
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; va_list ap;
int i = 0; int i = 0;
@ -115,7 +115,7 @@ int teletone_set_tone(teletone_generation_session_t *ts, int index, ...)
} }
int teletone_set_map(teletone_tone_map_t *map, ...) TELETONE_API int teletone_set_map(teletone_tone_map_t *map, ...)
{ {
va_list ap; va_list ap;
int i = 0; int i = 0;
@ -131,7 +131,7 @@ int teletone_set_map(teletone_tone_map_t *map, ...)
} }
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)); memset(ts, 0, sizeof(*ts));
ts->rate = 8000; ts->rate = 8000;
@ -174,7 +174,7 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
return 0; 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) { if (ts->buffer) {
free(ts->buffer); free(ts->buffer);
@ -203,7 +203,7 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need)
return 0; 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;*/ /*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/
int i, c; int i, c;
@ -318,7 +318,7 @@ static char *my_strdup (const char *s)
return (char *) memcpy (new, s, len); 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; char *data = NULL, *cur = NULL, *end = NULL;
int var = 0, LOOPING = 0; int var = 0, LOOPING = 0;

View File

@ -164,11 +164,19 @@ typedef int gid_t;
#define SWITCH_THREAD_FUNC __stdcall #define SWITCH_THREAD_FUNC __stdcall
#else //not win32 #else //not win32
#define O_BINARY 0 #define O_BINARY 0
#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(type) type
#define SWITCH_DECLARE_NONSTD(type) type #define SWITCH_DECLARE_NONSTD(type) type
#define SWITCH_MOD_DECLARE(type) type
#define SWITCH_DECLARE_DATA #define SWITCH_DECLARE_DATA
#define SWITCH_MOD_DECLARE(type) type
#define SWITCH_MOD_DECLARE_DATA #define SWITCH_MOD_DECLARE_DATA
#endif
#define SWITCH_THREAD_FUNC #define SWITCH_THREAD_FUNC
#endif #endif
#define SWITCH_DECLARE_CONSTRUCTOR SWITCH_DECLARE_DATA #define SWITCH_DECLARE_CONSTRUCTOR SWITCH_DECLARE_DATA