@@ -379,19 +379,82 @@ extern int fsync(int fd);
379379extern double hypot (double , double );
380380#endif
381381
382- #ifndef __CYGWIN__
383- #ifndef DL_IMPORT /* declarations for DLL import */
384- #define DL_IMPORT (RTYPE ) RTYPE
385- #endif
386- #else /* __CYGWIN__ */
387- #ifdef USE_DL_IMPORT
388- #define DL_IMPORT (RTYPE ) __declspec(dllimport) RTYPE
389- #define DL_EXPORT (RTYPE ) __declspec(dllexport) RTYPE
390- #else /* !USE_DL_IMPORT */
391- #define DL_IMPORT (RTYPE ) __declspec(dllexport) RTYPE
392- #define DL_EXPORT (RTYPE ) __declspec(dllexport) RTYPE
393- #endif /* USE_DL_IMPORT */
394- #endif /* __CYGWIN__ */
382+ /* Declarations for symbol visibility.
383+
384+ PyAPI_FUNC(type): Declares a public Python API function and return type
385+ PyAPI_DATA(type): Declares public Python data and its type
386+ PyMODINIT_FUNC: A Python module init function. If these functions are
387+ inside the Python core, they are private to the core.
388+ If in an extension module, it may be declared with
389+ external linkage depending on the platform.
390+
391+ As a number of platforms support/require "__declspec(dllimport/dllexport)",
392+ we support a HAVE_DECLSPEC_DLL macro to save duplication.
393+ */
394+
395+ /*
396+ All windows ports, except cygwin, are handled in PC/pyconfig.h
397+ BeOS is only other autoconf platform requiring special linkage handling
398+ and both these use __declspec()
399+ */
400+ #if defined(__CYGWIN__ ) || defined(__BEOS__ )
401+ # define HAVE_DECLSPEC_DLL
402+ #endif
403+
404+ #if defined(Py_ENABLE_SHARED ) /* only get special linkage if built as shared */
405+ # if defined(HAVE_DECLSPEC_DLL )
406+ # ifdef Py_BUILD_CORE
407+ # define PyAPI_FUNC (RTYPE ) __declspec(dllexport) RTYPE
408+ # define PyAPI_DATA (RTYPE ) __declspec(dllexport) RTYPE
409+ /* module init functions inside the core need no external linkage */
410+ # define PyMODINIT_FUNC void
411+ # else /* Py_BUILD_CORE */
412+ /* Building an extension module, or an embedded situation */
413+ /* public Python functions and data are imported */
414+ # define PyAPI_FUNC (RTYPE ) __declspec(dllimport) RTYPE
415+ # define PyAPI_DATA (RTYPE ) __declspec(dllimport) RTYPE
416+ /* module init functions outside the core must be exported */
417+ # if defined(__cplusplus )
418+ # define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
419+ # else /* __cplusplus */
420+ # define PyMODINIT_FUNC __declspec(dllexport) void
421+ # endif /* __cplusplus */
422+ # endif /* Py_BUILD_CORE */
423+ # endif /* HAVE_DECLSPEC */
424+ #endif /* Py_ENABLE_SHARED */
425+
426+ /* If no external linkage macros defined by now, create defaults */
427+ #ifndef PyAPI_FUNC
428+ # define PyAPI_FUNC (RTYPE ) RTYPE
429+ #endif
430+ #ifndef PyAPI_DATA
431+ # define PyAPI_DATA (RTYPE ) RTYPE
432+ #endif
433+ #ifndef PyMODINIT_FUNC
434+ # if defined(__cplusplus )
435+ # define PyMODINIT_FUNC extern "C" void
436+ # else /* __cplusplus */
437+ # define PyMODINIT_FUNC void
438+ # endif /* __cplusplus */
439+ #endif
440+
441+ /* Deprecated DL_IMPORT and DL_EXPORT macros */
442+ #if defined(Py_ENABLE_SHARED ) && defined (HAVE_DECLSPEC_DLL )
443+ # if defined(Py_BUILD_CORE )
444+ # define DL_IMPORT (RTYPE ) __declspec(dllexport) RTYPE
445+ # define DL_EXPORT (RTYPE ) __declspec(dllexport) RTYPE
446+ # else
447+ # define DL_IMPORT (RTYPE ) __declspec(dllimport) RTYPE
448+ # define DL_EXPORT (RTYPE ) __declspec(dllexport) RTYPE
449+ # endif
450+ #endif
451+ #ifndef DL_EXPORT
452+ # define DL_EXPORT (RTYPE ) RTYPE
453+ #endif
454+ #ifndef DL_IMPORT
455+ # define DL_IMPORT (RTYPE ) RTYPE
456+ #endif
457+ /* End of deprecated DL_* macros */
395458
396459/* If the fd manipulation macros aren't defined,
397460 here is a set that should do the job */
@@ -458,15 +521,6 @@ typedef struct fd_set {
458521#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
459522#endif
460523
461- /*
462- * Rename some functions for the Borland compiler
463- */
464- #ifdef __BORLANDC__
465- # include <io.h>
466- # define _chsize chsize
467- # define _setmode setmode
468- #endif
469-
470524#ifdef __cplusplus
471525}
472526#endif
0 commit comments