diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-08-09 22:06:13 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-08-09 22:06:13 +0200 |
commit | b61f95c31f37ae3c5daef6596b55e4b9dec62eb8 (patch) | |
tree | 26d5793388a89a80bcddd30cb72ab16e7a2d5809 /src/if_python.c | |
parent | 82d1c33a8ab759aeca7efb462ecca66c8fa0ac96 (diff) | |
download | vim-git-b61f95c31f37ae3c5daef6596b55e4b9dec62eb8.tar.gz |
When building with both Python 2 and Python 3 don't use RTLD_GLOBAL, so that
both may work.
Diffstat (limited to 'src/if_python.c')
-rw-r--r-- | src/if_python.c | 52 |
1 files changed, 30 insertions, 22 deletions
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 <dlfcn.h> +# 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 <dlfcn.h> -# 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. */ @@ -354,6 +361,7 @@ python_runtime_link_init(char *libname, int verbose) return FAIL; } #endif +#endif if (hinstPython) return OK; |