0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

When building with both Python 2 and Python 3 don't use RTLD_GLOBAL, so that

both may work.
This commit is contained in:
Bram Moolenaar
2010-08-09 22:06:13 +02:00
parent 82d1c33a8a
commit b61f95c31f
3 changed files with 79 additions and 60 deletions

View File

@@ -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 */
# endif
# 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*
# 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
# 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
/* 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)