diff --git a/src/duk_features.h.in b/src/duk_features.h.in index b027ef15..c3db4044 100644 --- a/src/duk_features.h.in +++ b/src/duk_features.h.in @@ -1897,6 +1897,98 @@ typedef FILE duk_file; #define DUK_UNLIKELY(x) (x) #endif +/* + * Symbol visibility macros + */ + +/* XXX: add support for at least clang */ +/* XXX: user override for these? user override for just using the default visibility macros? */ + +#if defined(DUK_F_GCC_VERSION) +#if (DUK_F_GCC_VERSION >= 40000) +#define DUK_F_GCC_SYMBOL_VISIBILITY +#endif +#endif +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__GNUC__)) +/* MSVC, also MinGW on Windows. */ +#define DUK_F_MSVC_SYMBOL_VISIBILITY +#endif + +/* FIXME: separate macros for functions and data may be necessary. */ + +#if defined(DUK_F_GCC_SYMBOL_VISIBILITY) +/* GCC 4+ visibility */ +#if defined(DUK_SINGLE_FILE) +#define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern +#define DUK_EXTERNAL __attribute__ ((visibility("default"))) +#define DUK_INTERNAL_DECL static +#define DUK_INTERNAL static +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#else /* DUK_SINGLE_FILE */ +#define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern +#define DUK_EXTERNAL __attribute__ ((visibility("default"))) +#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern +#define DUK_INTERNAL __attribute__ ((visibility("hidden"))) +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#endif +#elif defined(DUK_F_MSVC_SYMBOL_VISIBILITY) +/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're + * compiling Duktape or the application. + */ +#if defined(DUK_SINGLE_FILE) +#if defined(DUK_COMPILING_DUKTAPE) +#define DUK_EXTERNAL_DECL extern __declspec(dllexport) +#define DUK_EXTERNAL __declspec(dllexport) +#define DUK_INTERNAL_DECL static +#define DUK_INTERNAL static +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#else +#define DUK_EXTERNAL_DECL extern __declspec(dllimport) +#define DUK_EXTERNAL should_not_happen +#define DUK_INTERNAL_DECL static +#define DUK_INTERNAL static +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#endif /* DUK_COMPILING_DUKTAPE */ +#else /* DUK_SINGLE_FILE */ +#if defined(DUK_COMPILING_DUKTAPE) +#define DUK_EXTERNAL_DECL extern __declspec(dllexport) +#define DUK_EXTERNAL __declspec(dllexport) +#define DUK_INTERNAL_DECL extern +#define DUK_INTERNAL /*empty*/ +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#else +#define DUK_EXTERNAL_DECL extern __declspec(dllexport) +#define DUK_EXTERNAL should_not_happen +#define DUK_INTERNAL_DECL extern +#define DUK_INTERNAL /*empty*/ +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#endif /* DUK_COMPILING_DUKTAPE */ +#endif /* DUK_SINGLE_FILE */ +#else +/* Default visibility */ +#if defined(DUK_SINGLE_FILE) +#define DUK_EXTERNAL_DECL extern +#define DUK_EXTERNAL /*empty*/ +#define DUK_INTERNAL_DECL static +#define DUK_INTERNAL static +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#else /* DUK_SINGLE_FILE */ +#define DUK_EXTERNAL_DECL extern +#define DUK_EXTERNAL /*empty*/ +#define DUK_INTERNAL_DECL extern +#define DUK_INTERNAL /*empty*/ +#define DUK_LOCAL_DECL static +#define DUK_LOCAL static +#endif +#endif + /* * __FILE__, __LINE__, __func__ are wrapped. Especially __func__ is a * problem because it is not available even in some compilers which try