diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/dynload_os2.c | 42 | ||||
-rw-r--r-- | Python/dynload_shlib.c | 36 | ||||
-rw-r--r-- | Python/formatter_unicode.c | 3 | ||||
-rw-r--r-- | Python/importdl.h | 5 | ||||
-rw-r--r-- | Python/importlib.h | 210 | ||||
-rw-r--r-- | Python/thread.c | 4 | ||||
-rw-r--r-- | Python/thread_os2.h | 267 |
7 files changed, 122 insertions, 445 deletions
diff --git a/Python/dynload_os2.c b/Python/dynload_os2.c deleted file mode 100644 index 0e1b907..0000000 --- a/Python/dynload_os2.c +++ /dev/null @@ -1,42 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#define INCL_DOSERRORS -#define INCL_DOSMODULEMGR -#include <os2.h> - -#include "Python.h" -#include "importdl.h" - - -const char *_PyImport_DynLoadFiletab[] = {".pyd", ".dll", NULL}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - APIRET rc; - HMODULE hDLL; - char failreason[256]; - char funcname[258]; - - rc = DosLoadModule(failreason, - sizeof(failreason), - pathname, - &hDLL); - - if (rc != NO_ERROR) { - char errBuf[256]; - PyOS_snprintf(errBuf, sizeof(errBuf), - "DLL load failed, rc = %d: %.200s", - rc, failreason); - PyErr_SetString(PyExc_ImportError, errBuf); - return NULL; - } - - PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname); - rc = DosQueryProcAddr(hDLL, 0L, funcname, &p); - if (rc != NO_ERROR) - p = NULL; /* Signify Failure to Acquire Entrypoint */ - return p; -} diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 0ca65c7..46fed6e 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -18,10 +18,6 @@ #ifdef HAVE_DLFCN_H #include <dlfcn.h> -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include "dlfcn.h" -#endif #endif #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) @@ -40,10 +36,6 @@ const char *_PyImport_DynLoadFiletab[] = { #ifdef __CYGWIN__ ".dll", #else /* !__CYGWIN__ */ -#if defined(PYOS_OS2) && defined(PYCC_GCC) - ".pyd", - ".dll", -#else /* !(defined(PYOS_OS2) && defined(PYCC_GCC)) */ #ifdef __VMS ".exe", ".EXE", @@ -52,7 +44,6 @@ const char *_PyImport_DynLoadFiletab[] = { ".abi" PYTHON_ABI_STRING ".so", ".so", #endif /* __VMS */ -#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */ #endif /* __CYGWIN__ */ NULL, }; @@ -111,9 +102,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, } } -#if !(defined(PYOS_OS2) && defined(PYCC_GCC)) dlopenflags = PyThreadState_GET()->interp->dlopenflags; -#endif #ifdef __VMS /* VMS currently don't allow a pathname, use a logical name instead */ @@ -129,19 +118,30 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, handle = dlopen(pathname, dlopenflags); if (handle == NULL) { - PyObject *mod_name = NULL; - PyObject *path = NULL; - PyObject *error_ob = NULL; + PyObject *mod_name; + PyObject *path; + PyObject *error_ob; const char *error = dlerror(); if (error == NULL) error = "unknown dlopen() error"; error_ob = PyUnicode_FromString(error); - path = PyUnicode_FromString(pathname); + if (error_ob == NULL) + return NULL; mod_name = PyUnicode_FromString(shortname); + if (mod_name == NULL) { + Py_DECREF(error_ob); + return NULL; + } + path = PyUnicode_FromString(pathname); + if (path == NULL) { + Py_DECREF(error_ob); + Py_DECREF(mod_name); + return NULL; + } PyErr_SetImportError(error_ob, mod_name, path); - Py_XDECREF(error_ob); - Py_XDECREF(path); - Py_XDECREF(mod_name); + Py_DECREF(error_ob); + Py_DECREF(mod_name); + Py_DECREF(path); return NULL; } if (fp != NULL && nhandles < 128) diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index aa62502..0ce9862 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -757,7 +757,8 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format, goto done; } - if (format->width == -1 && format->precision == -1) { + if ((format->width == -1 || format->width <= len) + && (format->precision == -1 || format->precision >= len)) { /* Fast path */ return _PyUnicodeWriter_WriteStr(writer, value); } diff --git a/Python/importdl.h b/Python/importdl.h index 6b9cf75..6a51a91 100644 --- a/Python/importdl.h +++ b/Python/importdl.h @@ -18,13 +18,8 @@ extern PyObject *_PyImport_LoadDynamicModule(PyObject *name, PyObject *pathname, #include <windows.h> typedef FARPROC dl_funcptr; #else -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -#include <os2def.h> -typedef int (* APIENTRY dl_funcptr)(); -#else typedef void (*dl_funcptr)(void); #endif -#endif #ifdef __cplusplus diff --git a/Python/importlib.h b/Python/importlib.h index 9d3b4dc..59486d6 100644 --- a/Python/importlib.h +++ b/Python/importlib.h @@ -4102,87 +4102,82 @@ unsigned char _Py_M__importlib[] = { 12,1,23,1,6,1,4,4,35,3,40,2,117,10,0,0, 0,95,95,105,109,112,111,114,116,95,95,99,2,0,0,0, 0,0,0,0,14,0,0,0,13,0,0,0,67,0,0,0, - 115,196,2,0,0,124,1,0,97,0,0,124,0,0,97,1, + 115,141,2,0,0,124,1,0,97,0,0,124,0,0,97,1, 0,116,1,0,106,2,0,106,3,0,114,33,0,116,4,0, 97,5,0,110,6,0,116,6,0,97,5,0,120,47,0,116, 0,0,116,1,0,102,2,0,68,93,33,0,125,2,0,116, 7,0,124,2,0,100,1,0,131,2,0,115,52,0,116,8, 0,124,2,0,95,9,0,113,52,0,113,52,0,87,116,1, - 0,106,10,0,116,11,0,25,125,3,0,120,76,0,100,28, + 0,106,10,0,116,11,0,25,125,3,0,120,76,0,100,25, 0,68,93,68,0,125,4,0,124,4,0,116,1,0,106,10, 0,107,7,0,114,148,0,116,8,0,106,12,0,124,4,0, 131,1,0,125,5,0,110,13,0,116,1,0,106,10,0,124, 4,0,25,125,5,0,116,13,0,124,3,0,124,4,0,124, 5,0,131,3,0,1,113,109,0,87,100,6,0,100,7,0, 103,1,0,102,2,0,100,8,0,100,9,0,100,7,0,103, - 2,0,102,2,0,100,10,0,100,9,0,100,7,0,103,2, - 0,102,2,0,102,3,0,125,6,0,120,189,0,124,6,0, - 68,93,169,0,92,2,0,125,7,0,125,8,0,116,14,0, - 100,11,0,100,12,0,132,0,0,124,8,0,68,131,1,0, - 131,1,0,115,23,1,116,15,0,130,1,0,124,8,0,100, - 13,0,25,125,9,0,124,7,0,116,1,0,106,10,0,107, - 6,0,114,65,1,116,1,0,106,10,0,124,7,0,25,125, - 10,0,80,113,236,0,121,60,0,116,8,0,106,12,0,124, - 7,0,131,1,0,125,10,0,124,7,0,100,10,0,107,2, - 0,114,123,1,100,14,0,116,1,0,106,16,0,107,6,0, - 114,123,1,124,8,0,100,15,0,25,125,9,0,110,0,0, - 80,87,113,236,0,4,116,17,0,107,10,0,114,148,1,1, - 1,1,119,236,0,89,113,236,0,88,113,236,0,87,116,17, - 0,100,16,0,131,1,0,130,1,0,121,19,0,116,8,0, - 106,12,0,100,17,0,131,1,0,125,11,0,87,110,24,0, - 4,116,17,0,107,10,0,114,210,1,1,1,1,100,27,0, - 125,11,0,89,110,1,0,88,116,8,0,106,12,0,100,18, - 0,131,1,0,125,12,0,124,7,0,100,8,0,107,2,0, - 114,16,2,116,8,0,106,12,0,100,19,0,131,1,0,125, - 13,0,116,13,0,124,3,0,100,20,0,124,13,0,131,3, - 0,1,110,0,0,116,13,0,124,3,0,100,21,0,124,10, - 0,131,3,0,1,116,13,0,124,3,0,100,17,0,124,11, - 0,131,3,0,1,116,13,0,124,3,0,100,18,0,124,12, - 0,131,3,0,1,116,13,0,124,3,0,100,22,0,124,9, - 0,131,3,0,1,116,13,0,124,3,0,100,23,0,116,19, - 0,124,8,0,131,1,0,131,3,0,1,116,13,0,124,3, - 0,100,24,0,116,20,0,131,0,0,131,3,0,1,116,21, - 0,106,22,0,116,0,0,106,23,0,131,0,0,131,1,0, - 1,124,7,0,100,8,0,107,2,0,114,192,2,116,24,0, - 106,25,0,100,25,0,131,1,0,1,100,26,0,116,21,0, - 107,6,0,114,192,2,100,29,0,116,27,0,95,28,0,113, - 192,2,110,0,0,100,27,0,83,40,30,0,0,0,117,250, - 0,0,0,83,101,116,117,112,32,105,109,112,111,114,116,108, - 105,98,32,98,121,32,105,109,112,111,114,116,105,110,103,32, - 110,101,101,100,101,100,32,98,117,105,108,116,45,105,110,32, - 109,111,100,117,108,101,115,32,97,110,100,32,105,110,106,101, - 99,116,105,110,103,32,116,104,101,109,10,32,32,32,32,105, - 110,116,111,32,116,104,101,32,103,108,111,98,97,108,32,110, - 97,109,101,115,112,97,99,101,46,10,10,32,32,32,32,65, - 115,32,115,121,115,32,105,115,32,110,101,101,100,101,100,32, - 102,111,114,32,115,121,115,46,109,111,100,117,108,101,115,32, - 97,99,99,101,115,115,32,97,110,100,32,95,105,109,112,32, - 105,115,32,110,101,101,100,101,100,32,116,111,32,108,111,97, - 100,32,98,117,105,108,116,45,105,110,10,32,32,32,32,109, - 111,100,117,108,101,115,44,32,116,104,111,115,101,32,116,119, - 111,32,109,111,100,117,108,101,115,32,109,117,115,116,32,98, - 101,32,101,120,112,108,105,99,105,116,108,121,32,112,97,115, - 115,101,100,32,105,110,46,10,10,32,32,32,32,117,10,0, - 0,0,95,95,108,111,97,100,101,114,95,95,117,3,0,0, - 0,95,105,111,117,9,0,0,0,95,119,97,114,110,105,110, - 103,115,117,8,0,0,0,98,117,105,108,116,105,110,115,117, - 7,0,0,0,109,97,114,115,104,97,108,117,5,0,0,0, - 112,111,115,105,120,117,1,0,0,0,47,117,2,0,0,0, - 110,116,117,1,0,0,0,92,117,3,0,0,0,111,115,50, - 99,1,0,0,0,0,0,0,0,2,0,0,0,3,0,0, - 0,115,0,0,0,115,33,0,0,0,124,0,0,93,23,0, - 125,1,0,116,0,0,124,1,0,131,1,0,100,0,0,107, - 2,0,86,1,113,3,0,100,1,0,83,40,2,0,0,0, - 105,1,0,0,0,78,40,1,0,0,0,117,3,0,0,0, - 108,101,110,40,2,0,0,0,117,2,0,0,0,46,48,117, - 3,0,0,0,115,101,112,40,0,0,0,0,40,0,0,0, - 0,117,29,0,0,0,60,102,114,111,122,101,110,32,105,109, - 112,111,114,116,108,105,98,46,95,98,111,111,116,115,116,114, - 97,112,62,117,9,0,0,0,60,103,101,110,101,120,112,114, - 62,179,6,0,0,115,2,0,0,0,6,0,117,25,0,0, - 0,95,115,101,116,117,112,46,60,108,111,99,97,108,115,62, - 46,60,103,101,110,101,120,112,114,62,105,0,0,0,0,117, - 7,0,0,0,69,77,88,32,71,67,67,105,1,0,0,0, + 2,0,102,2,0,102,2,0,125,6,0,120,149,0,124,6, + 0,68,93,129,0,92,2,0,125,7,0,125,8,0,116,14, + 0,100,10,0,100,11,0,132,0,0,124,8,0,68,131,1, + 0,131,1,0,115,8,1,116,15,0,130,1,0,124,8,0, + 100,12,0,25,125,9,0,124,7,0,116,1,0,106,10,0, + 107,6,0,114,50,1,116,1,0,106,10,0,124,7,0,25, + 125,10,0,80,113,221,0,121,20,0,116,8,0,106,12,0, + 124,7,0,131,1,0,125,10,0,80,87,113,221,0,4,116, + 16,0,107,10,0,114,93,1,1,1,1,119,221,0,89,113, + 221,0,88,113,221,0,87,116,16,0,100,13,0,131,1,0, + 130,1,0,121,19,0,116,8,0,106,12,0,100,14,0,131, + 1,0,125,11,0,87,110,24,0,4,116,16,0,107,10,0, + 114,155,1,1,1,1,100,24,0,125,11,0,89,110,1,0, + 88,116,8,0,106,12,0,100,15,0,131,1,0,125,12,0, + 124,7,0,100,8,0,107,2,0,114,217,1,116,8,0,106, + 12,0,100,16,0,131,1,0,125,13,0,116,13,0,124,3, + 0,100,17,0,124,13,0,131,3,0,1,110,0,0,116,13, + 0,124,3,0,100,18,0,124,10,0,131,3,0,1,116,13, + 0,124,3,0,100,14,0,124,11,0,131,3,0,1,116,13, + 0,124,3,0,100,15,0,124,12,0,131,3,0,1,116,13, + 0,124,3,0,100,19,0,124,9,0,131,3,0,1,116,13, + 0,124,3,0,100,20,0,116,18,0,124,8,0,131,1,0, + 131,3,0,1,116,13,0,124,3,0,100,21,0,116,19,0, + 131,0,0,131,3,0,1,116,20,0,106,21,0,116,0,0, + 106,22,0,131,0,0,131,1,0,1,124,7,0,100,8,0, + 107,2,0,114,137,2,116,23,0,106,24,0,100,22,0,131, + 1,0,1,100,23,0,116,20,0,107,6,0,114,137,2,100, + 26,0,116,26,0,95,27,0,113,137,2,110,0,0,100,24, + 0,83,40,27,0,0,0,117,250,0,0,0,83,101,116,117, + 112,32,105,109,112,111,114,116,108,105,98,32,98,121,32,105, + 109,112,111,114,116,105,110,103,32,110,101,101,100,101,100,32, + 98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,115, + 32,97,110,100,32,105,110,106,101,99,116,105,110,103,32,116, + 104,101,109,10,32,32,32,32,105,110,116,111,32,116,104,101, + 32,103,108,111,98,97,108,32,110,97,109,101,115,112,97,99, + 101,46,10,10,32,32,32,32,65,115,32,115,121,115,32,105, + 115,32,110,101,101,100,101,100,32,102,111,114,32,115,121,115, + 46,109,111,100,117,108,101,115,32,97,99,99,101,115,115,32, + 97,110,100,32,95,105,109,112,32,105,115,32,110,101,101,100, + 101,100,32,116,111,32,108,111,97,100,32,98,117,105,108,116, + 45,105,110,10,32,32,32,32,109,111,100,117,108,101,115,44, + 32,116,104,111,115,101,32,116,119,111,32,109,111,100,117,108, + 101,115,32,109,117,115,116,32,98,101,32,101,120,112,108,105, + 99,105,116,108,121,32,112,97,115,115,101,100,32,105,110,46, + 10,10,32,32,32,32,117,10,0,0,0,95,95,108,111,97, + 100,101,114,95,95,117,3,0,0,0,95,105,111,117,9,0, + 0,0,95,119,97,114,110,105,110,103,115,117,8,0,0,0, + 98,117,105,108,116,105,110,115,117,7,0,0,0,109,97,114, + 115,104,97,108,117,5,0,0,0,112,111,115,105,120,117,1, + 0,0,0,47,117,2,0,0,0,110,116,117,1,0,0,0, + 92,99,1,0,0,0,0,0,0,0,2,0,0,0,3,0, + 0,0,115,0,0,0,115,33,0,0,0,124,0,0,93,23, + 0,125,1,0,116,0,0,124,1,0,131,1,0,100,0,0, + 107,2,0,86,1,113,3,0,100,1,0,83,40,2,0,0, + 0,105,1,0,0,0,78,40,1,0,0,0,117,3,0,0, + 0,108,101,110,40,2,0,0,0,117,2,0,0,0,46,48, + 117,3,0,0,0,115,101,112,40,0,0,0,0,40,0,0, + 0,0,117,29,0,0,0,60,102,114,111,122,101,110,32,105, + 109,112,111,114,116,108,105,98,46,95,98,111,111,116,115,116, + 114,97,112,62,117,9,0,0,0,60,103,101,110,101,120,112, + 114,62,179,6,0,0,115,2,0,0,0,6,0,117,25,0, + 0,0,95,115,101,116,117,112,46,60,108,111,99,97,108,115, + 62,46,60,103,101,110,101,120,112,114,62,105,0,0,0,0, 117,30,0,0,0,105,109,112,111,114,116,108,105,98,32,114, 101,113,117,105,114,101,115,32,112,111,115,105,120,32,111,114, 32,110,116,117,7,0,0,0,95,116,104,114,101,97,100,117, @@ -4196,7 +4191,7 @@ unsigned char _Py_M__importlib[] = { 78,40,4,0,0,0,117,3,0,0,0,95,105,111,117,9, 0,0,0,95,119,97,114,110,105,110,103,115,117,8,0,0, 0,98,117,105,108,116,105,110,115,117,7,0,0,0,109,97, - 114,115,104,97,108,84,40,29,0,0,0,117,4,0,0,0, + 114,115,104,97,108,84,40,28,0,0,0,117,4,0,0,0, 95,105,109,112,117,3,0,0,0,115,121,115,117,5,0,0, 0,102,108,97,103,115,117,8,0,0,0,111,112,116,105,109, 105,122,101,117,27,0,0,0,79,80,84,73,77,73,90,69, @@ -4212,41 +4207,40 @@ unsigned char _Py_M__importlib[] = { 0,0,108,111,97,100,95,109,111,100,117,108,101,117,7,0, 0,0,115,101,116,97,116,116,114,117,3,0,0,0,97,108, 108,117,14,0,0,0,65,115,115,101,114,116,105,111,110,69, - 114,114,111,114,117,7,0,0,0,118,101,114,115,105,111,110, - 117,11,0,0,0,73,109,112,111,114,116,69,114,114,111,114, - 117,4,0,0,0,78,111,110,101,117,3,0,0,0,115,101, - 116,117,16,0,0,0,95,109,97,107,101,95,114,101,108,97, - 120,95,99,97,115,101,117,18,0,0,0,69,88,84,69,78, - 83,73,79,78,95,83,85,70,70,73,88,69,83,117,6,0, - 0,0,101,120,116,101,110,100,117,18,0,0,0,101,120,116, - 101,110,115,105,111,110,95,115,117,102,102,105,120,101,115,117, - 15,0,0,0,83,79,85,82,67,69,95,83,85,70,70,73, - 88,69,83,117,6,0,0,0,97,112,112,101,110,100,117,4, - 0,0,0,84,114,117,101,117,21,0,0,0,87,105,110,100, - 111,119,115,82,101,103,105,115,116,114,121,70,105,110,100,101, - 114,117,11,0,0,0,68,69,66,85,71,95,66,85,73,76, - 68,40,14,0,0,0,117,10,0,0,0,115,121,115,95,109, - 111,100,117,108,101,117,11,0,0,0,95,105,109,112,95,109, - 111,100,117,108,101,117,6,0,0,0,109,111,100,117,108,101, - 117,11,0,0,0,115,101,108,102,95,109,111,100,117,108,101, - 117,12,0,0,0,98,117,105,108,116,105,110,95,110,97,109, - 101,117,14,0,0,0,98,117,105,108,116,105,110,95,109,111, - 100,117,108,101,117,10,0,0,0,111,115,95,100,101,116,97, - 105,108,115,117,10,0,0,0,98,117,105,108,116,105,110,95, - 111,115,117,15,0,0,0,112,97,116,104,95,115,101,112,97, - 114,97,116,111,114,115,117,8,0,0,0,112,97,116,104,95, - 115,101,112,117,9,0,0,0,111,115,95,109,111,100,117,108, - 101,117,13,0,0,0,116,104,114,101,97,100,95,109,111,100, - 117,108,101,117,14,0,0,0,119,101,97,107,114,101,102,95, - 109,111,100,117,108,101,117,13,0,0,0,119,105,110,114,101, - 103,95,109,111,100,117,108,101,40,0,0,0,0,40,0,0, - 0,0,117,29,0,0,0,60,102,114,111,122,101,110,32,105, - 109,112,111,114,116,108,105,98,46,95,98,111,111,116,115,116, - 114,97,112,62,117,6,0,0,0,95,115,101,116,117,112,147, - 6,0,0,115,96,0,0,0,0,9,6,1,6,2,12,1, - 9,2,6,2,19,1,15,1,16,2,13,1,13,1,15,1, - 18,2,13,1,20,2,48,1,19,2,31,1,10,1,15,1, - 13,1,4,2,3,1,15,2,27,1,13,1,5,1,13,1, + 114,114,111,114,117,11,0,0,0,73,109,112,111,114,116,69, + 114,114,111,114,117,4,0,0,0,78,111,110,101,117,3,0, + 0,0,115,101,116,117,16,0,0,0,95,109,97,107,101,95, + 114,101,108,97,120,95,99,97,115,101,117,18,0,0,0,69, + 88,84,69,78,83,73,79,78,95,83,85,70,70,73,88,69, + 83,117,6,0,0,0,101,120,116,101,110,100,117,18,0,0, + 0,101,120,116,101,110,115,105,111,110,95,115,117,102,102,105, + 120,101,115,117,15,0,0,0,83,79,85,82,67,69,95,83, + 85,70,70,73,88,69,83,117,6,0,0,0,97,112,112,101, + 110,100,117,4,0,0,0,84,114,117,101,117,21,0,0,0, + 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, + 105,110,100,101,114,117,11,0,0,0,68,69,66,85,71,95, + 66,85,73,76,68,40,14,0,0,0,117,10,0,0,0,115, + 121,115,95,109,111,100,117,108,101,117,11,0,0,0,95,105, + 109,112,95,109,111,100,117,108,101,117,6,0,0,0,109,111, + 100,117,108,101,117,11,0,0,0,115,101,108,102,95,109,111, + 100,117,108,101,117,12,0,0,0,98,117,105,108,116,105,110, + 95,110,97,109,101,117,14,0,0,0,98,117,105,108,116,105, + 110,95,109,111,100,117,108,101,117,10,0,0,0,111,115,95, + 100,101,116,97,105,108,115,117,10,0,0,0,98,117,105,108, + 116,105,110,95,111,115,117,15,0,0,0,112,97,116,104,95, + 115,101,112,97,114,97,116,111,114,115,117,8,0,0,0,112, + 97,116,104,95,115,101,112,117,9,0,0,0,111,115,95,109, + 111,100,117,108,101,117,13,0,0,0,116,104,114,101,97,100, + 95,109,111,100,117,108,101,117,14,0,0,0,119,101,97,107, + 114,101,102,95,109,111,100,117,108,101,117,13,0,0,0,119, + 105,110,114,101,103,95,109,111,100,117,108,101,40,0,0,0, + 0,40,0,0,0,0,117,29,0,0,0,60,102,114,111,122, + 101,110,32,105,109,112,111,114,116,108,105,98,46,95,98,111, + 111,116,115,116,114,97,112,62,117,6,0,0,0,95,115,101, + 116,117,112,147,6,0,0,115,92,0,0,0,0,9,6,1, + 6,2,12,1,9,2,6,2,19,1,15,1,16,2,13,1, + 13,1,15,1,18,2,13,1,20,2,33,1,19,2,31,1, + 10,1,15,1,13,1,4,2,3,1,15,1,5,1,13,1, 12,2,12,2,3,1,19,1,13,2,11,1,15,2,12,1, 15,1,19,2,16,1,16,1,16,1,16,1,22,2,19,1, 19,1,12,1,13,1,12,1,117,6,0,0,0,95,115,101, @@ -4286,7 +4280,7 @@ unsigned char _Py_M__importlib[] = { 40,0,0,0,0,40,0,0,0,0,117,29,0,0,0,60, 102,114,111,122,101,110,32,105,109,112,111,114,116,108,105,98, 46,95,98,111,111,116,115,116,114,97,112,62,117,8,0,0, - 0,95,105,110,115,116,97,108,108,221,6,0,0,115,16,0, + 0,95,105,110,115,116,97,108,108,218,6,0,0,115,16,0, 0,0,0,2,13,1,9,1,28,1,16,1,16,1,15,1, 19,1,117,8,0,0,0,95,105,110,115,116,97,108,108,78, 40,3,0,0,0,117,3,0,0,0,119,105,110,117,6,0, @@ -4389,5 +4383,5 @@ unsigned char _Py_M__importlib[] = { 18,12,11,12,11,12,17,19,57,19,54,19,50,19,82,22, 134,19,29,25,46,25,25,6,3,19,45,19,55,19,18,19, 89,19,125,19,13,12,9,12,17,12,17,6,2,12,50,12, - 13,18,24,12,34,12,15,12,11,24,36,12,74, + 13,18,24,12,34,12,15,12,11,24,36,12,71, }; diff --git a/Python/thread.c b/Python/thread.c index e55d342..25ab16e 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -91,10 +91,6 @@ static size_t _pythread_stacksize = 0; #include "thread_nt.h" #endif -#ifdef OS2_THREADS -#define PYTHREAD_NAME "os2" -#include "thread_os2.h" -#endif /* #ifdef FOOBAR_THREADS diff --git a/Python/thread_os2.h b/Python/thread_os2.h deleted file mode 100644 index 1b264b5..0000000 --- a/Python/thread_os2.h +++ /dev/null @@ -1,267 +0,0 @@ -/* This code implemented by cvale@netcom.com */ - -#define INCL_DOSPROCESS -#define INCL_DOSSEMAPHORES -#include "os2.h" -#include "limits.h" - -#include "process.h" - -#if defined(PYCC_GCC) -#include <sys/builtin.h> -#include <sys/fmutex.h> -#else -long PyThread_get_thread_ident(void); -#endif - -/* default thread stack size of 64kB */ -#if !defined(THREAD_STACK_SIZE) -#define THREAD_STACK_SIZE 0x10000 -#endif - -#define OS2_STACKSIZE(x) (x ? x : THREAD_STACK_SIZE) - -/* - * Initialization of the C package, should not be needed. - */ -static void -PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - int thread_id; - - thread_id = _beginthread(func, - NULL, - OS2_STACKSIZE(_pythread_stacksize), - arg); - - if (thread_id == -1) { - dprintf(("_beginthread failed. return %ld\n", errno)); - } - - return thread_id; -} - -long -PyThread_get_thread_ident(void) -{ -#if !defined(PYCC_GCC) - PPIB pib; - PTIB tib; -#endif - - if (!initialized) - PyThread_init_thread(); - -#if defined(PYCC_GCC) - return _gettid(); -#else - DosGetInfoBlocks(&tib, &pib); - return tib->tib_ptib2->tib2_ultid; -#endif -} - -void -PyThread_exit_thread(void) -{ - dprintf(("%ld: PyThread_exit_thread called\n", - PyThread_get_thread_ident())); - if (!initialized) - exit(0); - _endthread(); -} - -/* - * Lock support. This is implemented with an event semaphore and critical - * sections to make it behave more like a posix mutex than its OS/2 - * counterparts. - */ - -typedef struct os2_lock_t { - int is_set; - HEV changed; -} *type_os2_lock; - -PyThread_type_lock -PyThread_allocate_lock(void) -{ -#if defined(PYCC_GCC) - _fmutex *sem = malloc(sizeof(_fmutex)); - if (!initialized) - PyThread_init_thread(); - dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", - PyThread_get_thread_ident(), - (long)sem)); - if (_fmutex_create(sem, 0)) { - free(sem); - sem = NULL; - } - return (PyThread_type_lock)sem; -#else - APIRET rc; - type_os2_lock lock = (type_os2_lock)malloc(sizeof(struct os2_lock_t)); - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock->is_set = 0; - - DosCreateEventSem(NULL, &lock->changed, 0, 0); - - dprintf(("%ld: PyThread_allocate_lock() -> %p\n", - PyThread_get_thread_ident(), - lock->changed)); - - return (PyThread_type_lock)lock; -#endif -} - -void -PyThread_free_lock(PyThread_type_lock aLock) -{ -#if !defined(PYCC_GCC) - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_free_lock(%p) called\n", - PyThread_get_thread_ident(),aLock)); - -#if defined(PYCC_GCC) - if (aLock) { - _fmutex_close((_fmutex *)aLock); - free((_fmutex *)aLock); - } -#else - DosCloseEventSem(lock->changed); - free(aLock); -#endif -} - -/* - * Return 1 on success if the lock was acquired - * - * and 0 if the lock was not acquired. - */ -int -PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) -{ -#if !defined(PYCC_GCC) - int done = 0; - ULONG count; - PID pid = 0; - TID tid = 0; - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", - PyThread_get_thread_ident(), - aLock, - waitflag)); - -#if defined(PYCC_GCC) - /* always successful if the lock doesn't exist */ - if (aLock && - _fmutex_request((_fmutex *)aLock, waitflag ? 0 : _FMR_NOWAIT)) - return 0; -#else - while (!done) { - /* if the lock is currently set, we have to wait for - * the state to change - */ - if (lock->is_set) { - if (!waitflag) - return 0; - DosWaitEventSem(lock->changed, SEM_INDEFINITE_WAIT); - } - - /* enter a critical section and try to get the semaphore. If - * it is still locked, we will try again. - */ - if (DosEnterCritSec()) - return 0; - - if (!lock->is_set) { - lock->is_set = 1; - DosResetEventSem(lock->changed, &count); - done = 1; - } - - DosExitCritSec(); - } -#endif - - return 1; -} - -void -PyThread_release_lock(PyThread_type_lock aLock) -{ -#if !defined(PYCC_GCC) - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_release_lock(%p) called\n", - PyThread_get_thread_ident(), - aLock)); - -#if defined(PYCC_GCC) - if (aLock) - _fmutex_release((_fmutex *)aLock); -#else - if (!lock->is_set) { - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", - PyThread_get_thread_ident(), - aLock, - GetLastError())); - return; - } - - if (DosEnterCritSec()) { - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", - PyThread_get_thread_ident(), - aLock, - GetLastError())); - return; - } - - lock->is_set = 0; - DosPostEventSem(lock->changed); - - DosExitCritSec(); -#endif -} - -/* minimum/maximum thread stack sizes supported */ -#define THREAD_MIN_STACKSIZE 0x8000 /* 32kB */ -#define THREAD_MAX_STACKSIZE 0x2000000 /* 32MB */ - -/* set the thread stack size. - * Return 0 if size is valid, -1 otherwise. - */ -static int -_pythread_os2_set_stacksize(size_t size) -{ - /* set to default */ - if (size == 0) { - _pythread_stacksize = 0; - return 0; - } - - /* valid range? */ - if (size >= THREAD_MIN_STACKSIZE && size < THREAD_MAX_STACKSIZE) { - _pythread_stacksize = size; - return 0; - } - - return -1; -} - -#define THREAD_SET_STACKSIZE(x) _pythread_os2_set_stacksize(x) |