From b61f95c31f37ae3c5daef6596b55e4b9dec62eb8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 9 Aug 2010 22:06:13 +0200 Subject: When building with both Python 2 and Python 3 don't use RTLD_GLOBAL, so that both may work. --- src/if_python.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'src/if_python.c') diff --git a/src/if_python.c b/src/if_python.c index c7c67a81e..8a28f8bd4 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -93,32 +93,38 @@ struct PyMethodDef { Py_ssize_t a; }; # define PY_CAN_RECURSE #endif -#if defined(DYNAMIC_PYTHON) || defined(PROTO) -# ifndef DYNAMIC_PYTHON -# define HINSTANCE long_u /* for generating prototypes */ +# if defined(DYNAMIC_PYTHON) || defined(PROTO) +# ifndef DYNAMIC_PYTHON +# define HINSTANCE long_u /* for generating prototypes */ +# endif + +# ifndef WIN3264 +# include +# define FARPROC void* +# define HINSTANCE void* +# ifdef FEAT_PYTHON3 + /* Don't use RTLD_GLOBAL, it may cause a crash if both :python and :py3 are + * used. But without it importing may fail, e.g., for termios. */ +# define load_dll(n) dlopen((n), RTLD_LAZY) +# else +# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) +# endif +# define close_dll dlclose +# define symbol_from_dll dlsym +# else +# define load_dll LoadLibrary +# define close_dll FreeLibrary +# define symbol_from_dll GetProcAddress # endif -#ifndef WIN3264 -# include -# define FARPROC void* -# define HINSTANCE void* -# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) -# define close_dll dlclose -# define symbol_from_dll dlsym -#else -# define load_dll LoadLibrary -# define close_dll FreeLibrary -# define symbol_from_dll GetProcAddress -#endif - /* This makes if_python.c compile without warnings against Python 2.5 * on Win32 and Win64. */ -#undef PyRun_SimpleString -#undef PyArg_Parse -#undef PyArg_ParseTuple -#undef Py_BuildValue -#undef Py_InitModule4 -#undef Py_InitModule4_64 +# undef PyRun_SimpleString +# undef PyArg_Parse +# undef PyArg_ParseTuple +# undef Py_BuildValue +# undef Py_InitModule4 +# undef Py_InitModule4_64 /* * Wrapper defines @@ -345,6 +351,7 @@ python_runtime_link_init(char *libname, int verbose) { int i; +#if 0 /* this should be OK now that we don't use RTLD_GLOBAL */ #if defined(UNIX) && defined(FEAT_PYTHON3) /* Can't have Python and Python3 loaded at the same time, it may cause a * crash. */ @@ -353,6 +360,7 @@ python_runtime_link_init(char *libname, int verbose) EMSG(_("E999: Python: Cannot use :py and :py3 in one session")); return FAIL; } +#endif #endif if (hinstPython) -- cgit v1.2.1