From: John Marino Date: Sun, 5 Feb 2012 16:14:25 +0000 (+0100) Subject: cdefs: Rework and augment visibility attributes X-Git-Tag: v3.4.0rc~1283 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/25fffb38ee50e7671cd4c12b5eca431a391ff8d5 cdefs: Rework and augment visibility attributes One macro based on GCC visibility functions was already defined, __exported. However, it was marked as available for all GCC versions when it fact it was introduced with gcc 4.0. There was no macro for hidden visibility attributes, so the macros __dso_hidden and __dso_public were borrowed from NetBSD. __dso_public is an alias for __exported. The definition for all three macros were made on the condition that the gcc version used is 4.0 or later. --- diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 5b761008d5..a737c18887 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -41,12 +41,6 @@ #ifndef _SYS_CDEFS_H_ #define _SYS_CDEFS_H_ -#if defined(__GNUC__) -#define __exported __attribute__((__visibility__("default"))) -#else -#define __exported -#endif - #if defined(__cplusplus) #define __BEGIN_DECLS extern "C" { #define __END_DECLS } @@ -299,6 +293,16 @@ #define __ARRAY_ZERO #endif +#if __GNUC_PREREQ__(4, 0) +#define __exported __attribute__((__visibility__("default"))) +#define __dso_public __attribute__((__visibility__("default"))) +#define __dso_hidden __attribute__((__visibility__("hidden"))) +#else +#define __exported +#define __dso_public +#define __dso_hidden +#endif + /* * A convenient constructor macro, GCC 4.3.0 added priority support to * constructors, provide a compatible interface for both.