summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2002-07-19 06:55:41 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2002-07-19 06:55:41 (GMT)
commit8235ea1c3a5c57c9279668b5bff3d5f021ceb2d5 (patch)
treeaaab09a7c61fc66bc25bb19cc885692bd0e8e121 /Include
parentb88169819c301dc77fc2f240c1641acf0b8cf5af (diff)
downloadcpython-8235ea1c3a5c57c9279668b5bff3d5f021ceb2d5.zip
cpython-8235ea1c3a5c57c9279668b5bff3d5f021ceb2d5.tar.gz
cpython-8235ea1c3a5c57c9279668b5bff3d5f021ceb2d5.tar.bz2
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Diffstat (limited to 'Include')
-rw-r--r--Include/import.h34
-rw-r--r--Include/pyport.h98
2 files changed, 93 insertions, 39 deletions
diff --git a/Include/import.h b/Include/import.h
index f90dd20..3f6157d 100644
--- a/Include/import.h
+++ b/Include/import.h
@@ -7,32 +7,32 @@
extern "C" {
#endif
-DL_IMPORT(long) PyImport_GetMagicNumber(void);
-DL_IMPORT(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co);
-DL_IMPORT(PyObject *) PyImport_ExecCodeModuleEx(
+PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
+PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co);
+PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
char *name, PyObject *co, char *pathname);
-DL_IMPORT(PyObject *) PyImport_GetModuleDict(void);
-DL_IMPORT(PyObject *) PyImport_AddModule(char *name);
-DL_IMPORT(PyObject *) PyImport_ImportModule(char *name);
-DL_IMPORT(PyObject *) PyImport_ImportModuleEx(
+PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
+PyAPI_FUNC(PyObject *) PyImport_AddModule(char *name);
+PyAPI_FUNC(PyObject *) PyImport_ImportModule(char *name);
+PyAPI_FUNC(PyObject *) PyImport_ImportModuleEx(
char *name, PyObject *globals, PyObject *locals, PyObject *fromlist);
-DL_IMPORT(PyObject *) PyImport_Import(PyObject *name);
-DL_IMPORT(PyObject *) PyImport_ReloadModule(PyObject *m);
-DL_IMPORT(void) PyImport_Cleanup(void);
-DL_IMPORT(int) PyImport_ImportFrozenModule(char *);
+PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
+PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
+PyAPI_FUNC(void) PyImport_Cleanup(void);
+PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
-extern DL_IMPORT(PyObject *)_PyImport_FindExtension(char *, char *);
-extern DL_IMPORT(PyObject *)_PyImport_FixupExtension(char *, char *);
+extern PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *);
+extern PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *);
struct _inittab {
char *name;
void (*initfunc)(void);
};
-extern DL_IMPORT(struct _inittab *) PyImport_Inittab;
+extern PyAPI_DATA(struct _inittab *) PyImport_Inittab;
-extern DL_IMPORT(int) PyImport_AppendInittab(char *name, void (*initfunc)(void));
-extern DL_IMPORT(int) PyImport_ExtendInittab(struct _inittab *newtab);
+extern PyAPI_FUNC(int) PyImport_AppendInittab(char *name, void (*initfunc)(void));
+extern PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
struct _frozen {
char *name;
@@ -43,7 +43,7 @@ struct _frozen {
/* Embedding apps may change this pointer to point to their favorite
collection of frozen modules: */
-extern DL_IMPORT(struct _frozen *) PyImport_FrozenModules;
+extern PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
#ifdef __cplusplus
}
diff --git a/Include/pyport.h b/Include/pyport.h
index 3f0923f..c362ca0 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -379,19 +379,82 @@ extern int fsync(int fd);
extern double hypot(double, double);
#endif
-#ifndef __CYGWIN__
-#ifndef DL_IMPORT /* declarations for DLL import */
-#define DL_IMPORT(RTYPE) RTYPE
-#endif
-#else /* __CYGWIN__ */
-#ifdef USE_DL_IMPORT
-#define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
-#define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
-#else /* !USE_DL_IMPORT */
-#define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
-#define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
-#endif /* USE_DL_IMPORT */
-#endif /* __CYGWIN__ */
+/* Declarations for symbol visibility.
+
+ PyAPI_FUNC(type): Declares a public Python API function and return type
+ PyAPI_DATA(type): Declares public Python data and its type
+ PyMODINIT_FUNC: A Python module init function. If these functions are
+ inside the Python core, they are private to the core.
+ If in an extension module, it may be declared with
+ external linkage depending on the platform.
+
+ As a number of platforms support/require "__declspec(dllimport/dllexport)",
+ we support a HAVE_DECLSPEC_DLL macro to save duplication.
+*/
+
+/*
+All windows ports, except cygwin, are handled in PC/pyconfig.h
+BeOS is only other autoconf platform requiring special linkage handling
+and both these use __declspec()
+*/
+#if defined(__CYGWIN__) || defined(__BEOS__)
+# define HAVE_DECLSPEC_DLL
+#endif
+
+#if defined(Py_ENABLE_SHARED) /* only get special linkage if built as shared */
+# if defined(HAVE_DECLSPEC_DLL)
+# ifdef Py_BUILD_CORE
+# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
+# define PyAPI_DATA(RTYPE) __declspec(dllexport) RTYPE
+ /* module init functions inside the core need no external linkage */
+# define PyMODINIT_FUNC void
+# else /* Py_BUILD_CORE */
+ /* Building an extension module, or an embedded situation */
+ /* public Python functions and data are imported */
+# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
+# define PyAPI_DATA(RTYPE) __declspec(dllimport) RTYPE
+ /* module init functions outside the core must be exported */
+# if defined(__cplusplus)
+# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
+# else /* __cplusplus */
+# define PyMODINIT_FUNC __declspec(dllexport) void
+# endif /* __cplusplus */
+# endif /* Py_BUILD_CORE */
+# endif /* HAVE_DECLSPEC */
+#endif /* Py_ENABLE_SHARED */
+
+/* If no external linkage macros defined by now, create defaults */
+#ifndef PyAPI_FUNC
+# define PyAPI_FUNC(RTYPE) RTYPE
+#endif
+#ifndef PyAPI_DATA
+# define PyAPI_DATA(RTYPE) RTYPE
+#endif
+#ifndef PyMODINIT_FUNC
+# if defined(__cplusplus)
+# define PyMODINIT_FUNC extern "C" void
+# else /* __cplusplus */
+# define PyMODINIT_FUNC void
+# endif /* __cplusplus */
+#endif
+
+/* Deprecated DL_IMPORT and DL_EXPORT macros */
+#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL)
+# if defined(Py_BUILD_CORE)
+# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
+# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
+# else
+# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
+# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
+# endif
+#endif
+#ifndef DL_EXPORT
+# define DL_EXPORT(RTYPE) RTYPE
+#endif
+#ifndef DL_IMPORT
+# define DL_IMPORT(RTYPE) RTYPE
+#endif
+/* End of deprecated DL_* macros */
/* If the fd manipulation macros aren't defined,
here is a set that should do the job */
@@ -458,15 +521,6 @@ typedef struct fd_set {
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
#endif
-/*
- * Rename some functions for the Borland compiler
- */
-#ifdef __BORLANDC__
-# include <io.h>
-# define _chsize chsize
-# define _setmode setmode
-#endif
-
#ifdef __cplusplus
}
#endif