diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2019-10-15 07:26:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-15 07:26:12 (GMT) |
commit | 0b60f64e4343913b4931dc27379d9808e5b78fe1 (patch) | |
tree | 197eeeff16c9146b5040bed69d1e0d95c5fdc87b /Include/exports.h | |
parent | 4d202281c128e2026e78fc5f4cc752b1dafbf3ad (diff) | |
download | cpython-0b60f64e4343913b4931dc27379d9808e5b78fe1.zip cpython-0b60f64e4343913b4931dc27379d9808e5b78fe1.tar.gz cpython-0b60f64e4343913b4931dc27379d9808e5b78fe1.tar.bz2 |
bpo-11410: Standardize and use symbol visibility attributes across POSIX and Windows. (GH-16347)
Diffstat (limited to 'Include/exports.h')
-rw-r--r-- | Include/exports.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Include/exports.h b/Include/exports.h new file mode 100644 index 0000000..fc1a5c5 --- /dev/null +++ b/Include/exports.h @@ -0,0 +1,30 @@ +#ifndef Py_EXPORTS_H +#define Py_EXPORTS_H + +#if defined(_WIN32) || defined(__CYGWIN__) + #define Py_IMPORTED_SYMBOL __declspec(dllimport) + #define Py_EXPORTED_SYMBOL __declspec(dllexport) + #define Py_LOCAL_SYMBOL +#else +/* + * If we only ever used gcc >= 5, we could use __has_attribute(visibility) + * as a cross-platform way to determine if visibility is supported. However, + * we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions + * have 4 < gcc < 5. + */ + #ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. + #endif + #if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\ + (defined(__clang__) && __has_attribute(visibility)) + #define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default"))) + #define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default"))) + #define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden"))) + #else + #define Py_IMPORTED_SYMBOL + #define Py_EXPORTED_SYMBOL + #define Py_LOCAL_SYMBOL + #endif +#endif + +#endif /* Py_EXPORTS_H */ |