]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
API visibility support (GCC/SUNCC) (FSCORE-264)
authorMichael Jerris <mike@jerris.com>
Mon, 16 Feb 2009 18:17:01 +0000 (18:17 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 16 Feb 2009 18:17:01 +0000 (18:17 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12061 d0543943-73ff-0310-b7d9-9358b9ac24b2

configure.in
libs/libteletone/configure.in
libs/libteletone/src/libteletone.h
libs/libteletone/src/libteletone_detect.c
libs/libteletone/src/libteletone_generate.c
src/include/switch_platform.h

index 66f2f1d66472cc1d8e348b62844651eeb2ce8f35..1dea4b4fc4f22010f4f7528c1e7b8b7323e1971b 100644 (file)
@@ -151,6 +151,76 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
     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,
index 3d7fa121674d8e705b0d3127fd566906041b9462..20019df2e5a6676c86dcfad329bdff70738076d7 100755 (executable)
@@ -7,11 +7,16 @@ AC_CONFIG_AUX_DIR(build)
 AM_INIT_AUTOMAKE(libteletone,0.1)\r
 AC_CONFIG_SRCDIR([src])\r
 \r
+# disable checks\r
+m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])\r
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])\r
+\r
 # Checks for programs.\r
 AC_PROG_CC\r
 AC_PROG_MAKE_SET\r
 AC_PROG_LIBTOOL\r
 AC_PROG_INSTALL\r
+\r
 #  Optimize\r
 AC_ARG_ENABLE(optimization,\r
 [AC_HELP_STRING([--enable-optimization],[Set if you want us to add max optimising compiler flags])],[enable_optimizer="$enableval"],[enable_optimizer="no"])\r
@@ -64,6 +69,77 @@ case "$host" in
                 new_AM_LDFLAGS=""\r
         ;;\r
 esac\r
+\r
+#\r
+# gcc visibility cflag checks\r
+#\r
+AC_ARG_ENABLE([visibility],\r
+       [AS_HELP_STRING([--disable-visibility], [Disable or enable API visibility support (default: use if available)])],\r
+       [enable_visibility="${enableval}"],\r
+       [enable_visibility="detect"]\r
+)\r
+HAVE_VISIBILITY="no"\r
+\r
+if test "x${enable_visibility}" != "xno" ; then\r
+\r
+       case "${ax_cv_c_compiler_vendor}" in\r
+       gnu)\r
+               save_CFLAGS="${CFLAGS}"\r
+               CFLAGS="${CFLAGS} -fvisibility=hidden"\r
+               AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])\r
+               AC_COMPILE_IFELSE(\r
+                       [AC_LANG_PROGRAM(\r
+                               [int foo __attribute__ ((visibility("default")));],\r
+                               [;]\r
+                       )],\r
+\r
+                       [AC_MSG_RESULT([yes])\r
+                        new_AM_CFLAGS="${new_AM_CFLAGS} -fvisibility=hidden"\r
+                        AC_DEFINE([HAVE_VISIBILITY], [1], [GCC visibility support available])\r
+                        HAVE_VISIBILITY="yes"],\r
+\r
+                       [AC_MSG_RESULT([no])]\r
+               )\r
+               CFLAGS="${save_CFLAGS}"\r
+               ;;\r
+\r
+       sun)\r
+               save_CFLAGS="${CFLAGS}"\r
+               CFLAGS="${CFLAGS} -xldscope=hidden"\r
+               AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])\r
+               AC_COMPILE_IFELSE(\r
+                       [AC_LANG_PROGRAM(\r
+                               [int foo __attribute__ ((visibility("default")));],\r
+                               [;]\r
+                       )],\r
+\r
+                       [AC_MSG_RESULT([yes])\r
+                        new_AM_CFLAGS="${new_AM_CFLAGS} -xldscope=hidden"\r
+                        AC_DEFINE([HAVE_VISIBILITY], [1], [SUNCC visibility support available])\r
+                        HAVE_VISIBILITY="yes"],\r
+\r
+                       [AC_MSG_RESULT([no])]\r
+               )\r
+               CFLAGS="${save_CFLAGS}"\r
+               ;;\r
+\r
+       *)\r
+               if test "x${enable_visibility}" = "xyes" ; then\r
+                       AC_MSG_ERROR([Non-GNU / SUN compilers are currently unsupported])\r
+               else\r
+                       AC_MSG_WARN([Non-GNU / SUN compilers are currently unsupported])\r
+               fi\r
+               ;;\r
+       esac\r
+\r
+       #\r
+       # visibility explicitly requested but not supported by this compiler => error\r
+       #\r
+       if test "x${enable_visibility}" = "xyes" -a "x${HAVE_VISIBILITY}" = "xno" ; then\r
+               AC_MSG_ERROR([API visibility not supported by this compiler])\r
+       fi\r
+fi\r
+\r
 AC_SUBST(new_AM_CFLAGS)\r
 AC_SUBST(new_AM_LDFLAGS)\r
 \r
index 9bb7f6aba1e4b8fcedfc7525abaa31f91a56df1d..24685e2f2d1ec0314a7d6063ccbaa2efd96d39f5 100644 (file)
@@ -110,6 +110,12 @@ typedef __int16 int16_t;
 #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>
 
index b44e3096b1b35c2d1d2faabb11022d854f13023c..1274e3e059957e6cf7cb248b8f5b9cbe14d698de 100644 (file)
@@ -116,7 +116,7 @@ static void goertzel_init(teletone_goertzel_state_t *goertzel_state, teletone_de
        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 @@ 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))
 
-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 @@ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state,
        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 @@ 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[],
                                                                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[],
                                                  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,
                                           int max)
 {
index dea04b839f9e85c817b89de59b5b57e72622777e..f869cbc0a52094144b19e29010b46f20633b9e00 100644 (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;
        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;
        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));
        ts->rate = 8000;
@@ -174,7 +174,7 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
        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 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need)
        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 @@ static char *my_strdup (const char *s)
        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;
index 4faad97cf2a905e75fbca9b92ea8966892a497f7..b9eff657fb85fc871eda23050d32a3f2c829ed1b 100644 (file)
@@ -164,11 +164,19 @@ typedef int gid_t;
 #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