From: Mika Lindqvist Date: Thu, 28 Apr 2016 19:48:15 +0000 (+0300) Subject: Add support for internal attribute X-Git-Tag: 1.9.9-b1~694^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5913691d83d4716e2463803a3dc6e169ac29a96;p=thirdparty%2Fzlib-ng.git Add support for internal attribute The advantage of this over hidden is for example that the compiler can safely assume that pointers to functions declared internal can never be passed externally. This allows the compiler to consider optimizations otherwise impossible. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d8318082d..b7935c0b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,7 @@ check_include_file(unistd.h Z_HAVE_UNISTD_H) check_include_file(stdarg.h Z_HAVE_STDARG_H) # -# Check if we can hide zlib internal symbols that are linked between separate source files +# Check if we can hide zlib internal symbols that are linked between separate source files using hidden # check_c_source_compiles( "#define ZLIB_INTERNAL __attribute__((visibility (\"hidden\"))) @@ -186,6 +186,21 @@ if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN) add_definitions(-DHAVE_HIDDEN) endif() +# +# Check if we can hide zlib internal symbols that are linked between separate source files using internal +# +check_c_source_compiles( + "#define ZLIB_INTERNAL __attribute__((visibility (\"internal\"))) + int ZLIB_INTERNAL foo; + int main() + { + return 0; + }" + HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "not supported") +if(HAVE_ATTRIBUTE_VISIBILITY_INTERNAL) + add_definitions(-DHAVE_INTERNAL) +endif() + # # check for __builtin_ctzl() support in the compiler #