diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-24 02:36:52 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-24 02:36:52 +0000 |
commit | 53fc98d09198a2058aa933c8848921ecd211861f (patch) | |
tree | df0b55c7ccaf36240cba24ebaa815af670149222 | |
parent | 28f03eec2826b61adc58e545a642d3d14163cf91 (diff) | |
download | xine-lib-53fc98d09198a2058aa933c8848921ecd211861f.tar.gz xine-lib-53fc98d09198a2058aa933c8848921ecd211861f.tar.bz2 |
Improve tests for visibility attribute support; Mach-O supports default visibility but not protected (as the default is actually kinda like protected), thanks to Matt Messier in bug #1686194 for pointing me at that.
CVS patchset: 8744
CVS date: 2007/03/24 02:36:52
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | m4/attributes.m4 | 39 | ||||
-rw-r--r-- | src/xine-utils/attributes.h | 4 |
3 files changed, 29 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac index ce672cf46..8dc2e6cda 100644 --- a/configure.ac +++ b/configure.ac @@ -2139,14 +2139,20 @@ dnl --------------------------------------------- CC_ATTRIBUTE_ALIGNED -CC_ATTRIBUTE_VISIBILITY([ +CC_ATTRIBUTE_VISIBILITY([protected], [visibility_export="protected"], + [CC_ATTRIBUTE_VISIBILITY([default], [visibility_export="default"])] +) + +if test "x$visibility_export" != "x"; then CC_FLAG_VISIBILITY([ AC_DEFINE([EXPORTED], [__attribute__((visibility("default")))], [Mark a symbol as being exported if visibility is changed]) VISIBILITY_FLAG="-fvisibility=hidden" ], [AC_DEFINE([EXPORTED], [], [Dummy mark as being exported]) - ])], [AC_DEFINE([EXPORTED], [], [Dummy mark as being exported]) -]) + ]) +else + AC_DEFINE([EXPORTED], [], [Dummy mark as being exported]) +fi AC_SUBST([VISIBILITY_FLAG]) diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 2d52cebc4..1901cc2c8 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -136,28 +136,23 @@ AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ - AC_REQUIRE([CC_CHECK_WERROR]) - ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_CACHE_CHECK([if compiler supports __attribute__((visibility("...")))], - [cc_cv_attribute_visibility], - [AC_COMPILE_IFELSE([ - void __attribute__((visibility("internal"))) internal_function() { } - void __attribute__((visibility("hidden"))) hidden_function() { } - void __attribute__((visibility("default"))) external_function() { } - ], - [cc_cv_attribute_visibility=yes], - [cc_cv_attribute_visibility=no]) - ]) - CFLAGS="$ac_save_CFLAGS" - - if test "x$cc_cv_attribute_visibility" = "xyes"; then - AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attribute]) - $1 - else - true - $2 - fi + AC_REQUIRE([CC_CHECK_WERROR]) + AC_CACHE_CHECK([if $CC supports __attribute__((visibility("$1")))], + AS_TR_SH([cc_cv_attribute_visibility_$1]), + [ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $cc_cv_werror" + AC_COMPILE_IFELSE([void __attribute__((visibility("$1"))) $1_function() { }], + [eval "AS_TR_SH([cc_cv_attribute_visibility_$1])='yes'"], + [eval "AS_TR_SH([cc_cv_attribute_visibility_$1])='no'"]) + CFLAGS="$ac_save_CFLAGS" + ]) + + if eval test [x$]AS_TR_SH([cc_cv_attribute_visibility_$1]); then + AC_DEFINE(AS_TR_CPP([SUPPORT_ATTRIBUTE_VISIBILITY_$1]), 1, [Define this if the compiler supports __attribute__((visibility("$1")))]) + ifelse([$2], , [:], [$2]) + else + ifelse([$3], , [:], [$3]) + fi ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 0328493aa..4d22226ac 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -47,8 +47,10 @@ #endif /* Export protected only for libxine functions */ -#if defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY) +#if defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED) # define XINE_PROTECTED __attribute__((visibility("protected"))) +#elif defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT) +# define XINE_PROTECTED __attribute__((visibility("default"))) #else # define XINE_PROTECTED #endif |