From ccec2ca875ca7894d745cbed5f7b1ee07894eb8a Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 22 Sep 2011 20:05:40 +0000 Subject: [PATCH] use correct gcc attribute on OS X for weak linkage; reformat overly-wide comment git-svn-id: svn+ssh://jackaudio.org/trunk/jack@4539 0c269be4-1314-0410-8aa9-9f06e86f4224 --- jack/weakjack.h | 40 +++++++++++++++++++++++++++++----------- jack/weakmacros.h | 8 +++++++- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/jack/weakjack.h b/jack/weakjack.h index 2fe3d5c..cd68b4d 100644 --- a/jack/weakjack.h +++ b/jack/weakjack.h @@ -22,16 +22,28 @@ /** * @defgroup WeakLinkage managing support for newer/older versions of JACK - * @{ One challenge faced by developers is that of taking advantage of new features introduced in new versions of [ JACK ] while still - * supporting older versions of the system. Normally, if an application uses a new feature in a library/API, it is unable to run on - * earlier versions of the library/API that do not support that feature. Such applications would either fail to launch or crash when - * an attempt to use the feature was made. This problem cane be solved using weakly-linked symbols. + * @{ One challenge faced by developers is that of taking + * advantage of new features introduced in new versions + * of [ JACK ] while still supporting older versions of + * the system. Normally, if an application uses a new + * feature in a library/API, it is unable to run on + * earlier versions of the library/API that do not + * support that feature. Such applications would either + * fail to launch or crash when an attempt to use the + * feature was made. This problem cane be solved using + * weakly-linked symbols. * - * When a symbol in a framework is defined as weakly linked, the symbol does not have to be present at runtime for a process to - * continue running. The static linker identifies a weakly linked symbol as such in any code module that references the symbol. The - * dynamic linker uses this same information at runtime to determine whether a process can continue running. If a weakly linked symbol - * is not present in the framework, the code module can continue to run as long as it does not reference the symbol. However, if the - * symbol is present, the code can use it normally. + * When a symbol in a framework is defined as weakly + * linked, the symbol does not have to be present at + * runtime for a process to continue running. The static + * linker identifies a weakly linked symbol as such in + * any code module that references the symbol. The + * dynamic linker uses this same information at runtime + * to determine whether a process can continue + * running. If a weakly linked symbol is not present in + * the framework, the code module can continue to run as + * long as it does not reference the symbol. However, if + * the symbol is present, the code can use it normally. * * (adapted from: http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) * @@ -73,6 +85,12 @@ * */ +#ifdef __APPLE__ +#define WEAK_ATTRIBUTE weak_import +#else +#define WEAK_ATTRIBUTE __weak__ +#endif + #ifndef JACK_OPTIONAL_WEAK_EXPORT /* JACK_OPTIONAL_WEAK_EXPORT needs to be a macro which expands into a compiler directive. If non-null, the directive @@ -81,7 +99,7 @@ require linker arguments for the client as well. */ #ifdef __GNUC__ -#define JACK_OPTIONAL_WEAK_EXPORT __attribute__((__weak__)) +#define JACK_OPTIONAL_WEAK_EXPORT __attribute__((WEAK_ATTRIBUTE)) #else /* Add other things here for non-gcc platforms */ #endif @@ -96,7 +114,7 @@ linker arguments for the client as well. */ #ifdef __GNUC__ -#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__weak__,__deprecated__)) +#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((WEAK_ATTRIBUTE,__deprecated__)) #else /* Add other things here for non-gcc platforms */ #endif diff --git a/jack/weakmacros.h b/jack/weakmacros.h index 3db19d3..1fe34e2 100644 --- a/jack/weakmacros.h +++ b/jack/weakmacros.h @@ -32,6 +32,12 @@ * before jack.h. *************************************************************/ +#ifdef __APPLE__ +#define WEAK_ATTRIBUTE weak_import +#else +#define WEAK_ATTRIBUTE __weak__ +#endif + #ifndef JACK_WEAK_EXPORT #ifdef __GNUC__ /* JACK_WEAK_EXPORT needs to be a macro which @@ -40,7 +46,7 @@ the symbol it used with. For this to work full may require linker arguments in the client as well. */ -#define JACK_WEAK_EXPORT __attribute__((weak)) +#define JACK_WEAK_EXPORT __attribute__((WEAK_ATTRIBUTE)) #else /* Add other things here for non-gcc platforms */ #endif