From 25fffb38ee50e7671cd4c12b5eca431a391ff8d5 Mon Sep 17 00:00:00 2001 From: John Marino Date: Sun, 5 Feb 2012 17:14:25 +0100 Subject: [PATCH] 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. --- sys/sys/cdefs.h | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 5b76100..a737c18 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. -- 1.7.7.2