diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-07-01 12:21:02 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-07-01 19:21:39 +0000 |
commit | 27d320112e451b0d4568d422c6576fba366a59b6 (patch) | |
tree | f837ba640ba574d0dda947826e0702ef58bbf214 /ws_symbol_export.h | |
parent | 2211813e2190007b42e4385e06c5d10959f74e75 (diff) |
Pick up stuff from GLib to hide symbols with Sun C.
Note why we don't use G_GNUC_INTERNAL, but duplicate what GLib does, and
don't use G_HAVE_GNUC_VISIBILITY to determine whether we can use
__attribute__ ((visibility (...))).
Change-Id: I0b8d40f40d04e821352522320626173806787214
Reviewed-on: https://code.wireshark.org/review/2753
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ws_symbol_export.h')
-rw-r--r-- | ws_symbol_export.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/ws_symbol_export.h b/ws_symbol_export.h index ed49ba80ae..c3804755a6 100644 --- a/ws_symbol_export.h +++ b/ws_symbol_export.h @@ -47,6 +47,29 @@ #ifndef SYMBOL_EXPORT_H #define SYMBOL_EXPORT_H +/* + * NOTE: G_HAVE_GNUC_VISIBILITY is defined only if all of + * + * __attribute__ ((visibility ("hidden"))) + * + * __attribute__ ((visibility ("internal"))) + * + * __attribute__ ((visibility ("protected"))) + * + * __attribute__ ((visibility ("default"))) + * + * are supported, and at least some versions of GCC from Apple support + * "default" and "hidden" but not "internal" or "protected", so it + * shouldn't be used to determine whether "hidden" or "default" is + * supported. + * + * This also means that we shouldn't use G_GNUC_INTERNAL instead of + * WS_DLL_LOCAL, as GLib uses G_HAVE_GNUC_VISIBILITY to determine + * whether to use __attribute__ ((visibility ("hidden"))) for + * G_GNUC_INTERNAL, and that will not use it even with compilers + * that support it. + */ + /* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */ #if defined _WIN32 || defined __CYGWIN__ /* Compiling for Windows, so we use the Windows DLL declarations. */ @@ -121,10 +144,22 @@ #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden"))) #else /* ! __GNUC__ >= 4 */ /* - * We have no way to control visibility. + * We have no way to make stuff not explicitly marked as + * visible invisible outside a library, but we might have + * a way to make stuff explicitly marked as local invisible + * outside the library. + * + * This was lifted from GLib; see above for why we don't use + * G_GNUC_INTERNAL. */ #define WS_DLL_PUBLIC_DEF - #define WS_DLL_LOCAL + #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) + #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden"))) + #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) + #define WS_DLL_LOCAL __hidden + #else /* not Sun C with "hidden" support */ + #define WS_DLL_LOCAL + #endif #endif /* __GNUC__ >= 4 */ #endif |