Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:53

0001 #ifndef Py_EXPORTS_H
0002 #define Py_EXPORTS_H
0003 
0004 /* Declarations for symbol visibility.
0005 
0006   PyAPI_FUNC(type): Declares a public Python API function and return type
0007   PyAPI_DATA(type): Declares public Python data and its type
0008   PyMODINIT_FUNC:   A Python module init function.  If these functions are
0009                     inside the Python core, they are private to the core.
0010                     If in an extension module, it may be declared with
0011                     external linkage depending on the platform.
0012 
0013   As a number of platforms support/require "__declspec(dllimport/dllexport)",
0014   we support a HAVE_DECLSPEC_DLL macro to save duplication.
0015 */
0016 
0017 /*
0018   All windows ports, except cygwin, are handled in PC/pyconfig.h.
0019 
0020   Cygwin is the only other autoconf platform requiring special
0021   linkage handling and it uses __declspec().
0022 */
0023 #if defined(__CYGWIN__)
0024 #       define HAVE_DECLSPEC_DLL
0025 #endif
0026 
0027 #if defined(_WIN32) || defined(__CYGWIN__)
0028     #if defined(Py_ENABLE_SHARED)
0029         #define Py_IMPORTED_SYMBOL __declspec(dllimport)
0030         #define Py_EXPORTED_SYMBOL __declspec(dllexport)
0031         #define Py_LOCAL_SYMBOL
0032     #else
0033         #define Py_IMPORTED_SYMBOL
0034         #define Py_EXPORTED_SYMBOL
0035         #define Py_LOCAL_SYMBOL
0036     #endif
0037 #else
0038 /*
0039  * If we only ever used gcc >= 5, we could use __has_attribute(visibility)
0040  * as a cross-platform way to determine if visibility is supported. However,
0041  * we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
0042  * have 4 < gcc < 5.
0043  */
0044     #ifndef __has_attribute
0045       #define __has_attribute(x) 0  // Compatibility with non-clang compilers.
0046     #endif
0047     #if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
0048         (defined(__clang__) && __has_attribute(visibility))
0049         #define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
0050         #define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
0051         #define Py_LOCAL_SYMBOL  __attribute__ ((visibility ("hidden")))
0052     #else
0053         #define Py_IMPORTED_SYMBOL
0054         #define Py_EXPORTED_SYMBOL
0055         #define Py_LOCAL_SYMBOL
0056     #endif
0057 #endif
0058 
0059 /* only get special linkage if built as shared or platform is Cygwin */
0060 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
0061 #       if defined(HAVE_DECLSPEC_DLL)
0062 #               if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
0063 #                       define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
0064 #                       define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
0065         /* module init functions inside the core need no external linkage */
0066         /* except for Cygwin to handle embedding */
0067 #                       if defined(__CYGWIN__)
0068 #                               define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
0069 #                       else /* __CYGWIN__ */
0070 #                               define PyMODINIT_FUNC PyObject*
0071 #                       endif /* __CYGWIN__ */
0072 #               else /* Py_BUILD_CORE */
0073         /* Building an extension module, or an embedded situation */
0074         /* public Python functions and data are imported */
0075         /* Under Cygwin, auto-import functions to prevent compilation */
0076         /* failures similar to those described at the bottom of 4.1: */
0077         /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
0078 #                       if !defined(__CYGWIN__)
0079 #                               define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
0080 #                       endif /* !__CYGWIN__ */
0081 #                       define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
0082         /* module init functions outside the core must be exported */
0083 #                       if defined(__cplusplus)
0084 #                               define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
0085 #                       else /* __cplusplus */
0086 #                               define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
0087 #                       endif /* __cplusplus */
0088 #               endif /* Py_BUILD_CORE */
0089 #       endif /* HAVE_DECLSPEC_DLL */
0090 #endif /* Py_ENABLE_SHARED */
0091 
0092 /* If no external linkage macros defined by now, create defaults */
0093 #ifndef PyAPI_FUNC
0094 #       define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
0095 #endif
0096 #ifndef PyAPI_DATA
0097 #       define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
0098 #endif
0099 #ifndef PyMODINIT_FUNC
0100 #       if defined(__cplusplus)
0101 #               define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
0102 #       else /* __cplusplus */
0103 #               define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
0104 #       endif /* __cplusplus */
0105 #endif
0106 
0107 
0108 #endif /* Py_EXPORTS_H */