diff options
author | Andrea Canciani <ranma42@gmail.com> | 2012-08-01 18:48:30 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2012-08-02 15:53:55 +0200 |
commit | 2fdfba871ad0b7d786a85580802c9aa143be4f2c (patch) | |
tree | 628b605b6695704f7282c18f0c3efec5aefc924e | |
parent | 9240daf7d8feee0f7604a2ccfb905c78890d7b8b (diff) |
Add detection of visibility attribute at configuration time
On SunOS the linker does not support the visibility attribute.
Reported-by: Uli Schlachter <psychon@znc.in>
-rw-r--r-- | compiler/simpleops-compiler-types.h | 5 | ||||
-rw-r--r-- | m4/ax_c___attribute__visibility.m4 | 71 | ||||
-rw-r--r-- | m4/simpleops_compiler.m4 | 2 |
3 files changed, 77 insertions, 1 deletions
diff --git a/compiler/simpleops-compiler-types.h b/compiler/simpleops-compiler-types.h index 3507e42..7a6348c 100644 --- a/compiler/simpleops-compiler-types.h +++ b/compiler/simpleops-compiler-types.h @@ -143,7 +143,10 @@ typedef int simpleops_bool_t; #define _simpleops_import __declspec(dllimport) #define _simpleops_export __declspec(dllexport) #define simpleops_private -#elif defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +#elif defined(__GNUC__) && \ + (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) && \ + defined (SIMPLEOPS_HAVE_ATTRIBUTE_VISIBILITY_DEFAULT) && \ + defined (SIMPLEOPS_HAVE_ATTRIBUTE_VISIBILITY_HIDDEN) #define _simpleops_import extern #define _simpleops_export __attribute__((__visibility__("default"))) #define simpleops_private __attribute__((__visibility__("hidden"))) diff --git a/m4/ax_c___attribute__visibility.m4 b/m4/ax_c___attribute__visibility.m4 new file mode 100644 index 0000000..2f49bbc --- /dev/null +++ b/m4/ax_c___attribute__visibility.m4 @@ -0,0 +1,71 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_c___attribute__.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_C___ATTRIBUTE__VISIBILITY(VISIBILITY-TYPE) +# +# DESCRIPTION +# +# Provides a test for the compiler support of the +# __attribute__((__visibility__("VISIBILITY-TYPE"))) extension. +# Defines HAVE_ATTRIBUTE_VISIBILITY_<VISIBILITY_TYPE> if it is +# found. +# +# LICENSE +# +# Copyright (c) 2008 Stepan Kasal <skasal@redhat.com> +# Copyright (c) 2008 Christian Haggstrom +# Copyright (c) 2008 Ryan McCabe <ryan@numb.org> +# Copyright (c) 2011 Andrea Canciani <ranma42@gmail.com> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 11 + +AC_DEFUN([AX_C_ATTRIBUTE_VISIBILITY], [ + AC_CACHE_CHECK([for __attribute__((__visibility__("$1")))], [ax_cv_attribute_visibility_$1], + [AX_NODIFF_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +void foo (void); +void foo (void) { return; } + ]], [[foo ()]])], + [AC_LANG_PROGRAM( + [[ +void foo (void) __attribute__ ((__visibility__("$1"))); +void foo (void) { return; } + ]], [[foo ()]])], + [ax_cv_attribute_visibility_$1=yes], + [ax_cv_attribute_visibility_$1=no] + ) + ]) + if test "$ax_cv_attribute_visibility_$1" = "yes"; then + AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_ATTRIBUTE_VISIBILITY_$1]), 1, [Define to 1 if your compiler has __attribute__((__visibility__("$1"))).]) + fi +]) diff --git a/m4/simpleops_compiler.m4 b/m4/simpleops_compiler.m4 index 8ae12a5..65b8371 100644 --- a/m4/simpleops_compiler.m4 +++ b/m4/simpleops_compiler.m4 @@ -5,4 +5,6 @@ AC_DEFUN([SIMPLEOPS_CHECK_COMPILER], AX_C_ATTRIBUTE([const]) AX_C_ATTRIBUTE([noinline]) AX_C_ATTRIBUTE([pure]) + AX_C_ATTRIBUTE_VISIBILITY([default]) + AX_C_ATTRIBUTE_VISIBILITY([hidden]) ]) |