]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add support for internal attribute
authorMika Lindqvist <postmaster@raasu.org>
Thu, 28 Apr 2016 19:48:15 +0000 (22:48 +0300)
committerMika Lindqvist <postmaster@raasu.org>
Mon, 13 Feb 2017 10:42:03 +0000 (12:42 +0200)
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.

CMakeLists.txt

index d8318082dbfc014d171cad499e6302cc3ded4d9f..b7935c0b273b7b862ddec640ecdc217448a2f2ed 100644 (file)
@@ -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
 #