mirror of
https://github.com/python/cpython.git
synced 2025-09-03 23:41:18 +00:00
OS/2 EMX port changes (Python part of patch #450267):
Python/ dynload_shlib.c // EMX port emulates dlopen() etc. for DL extensions import.c // changes to support 8.3 DLL name limit (VACPP+EMX) // and case sensitive import semantics importdl.h thread_os2.h
This commit is contained in:
parent
c487439aa7
commit
d940054ad4
4 changed files with 140 additions and 3 deletions
|
@ -7,8 +7,12 @@
|
|||
|
||||
#include "process.h"
|
||||
|
||||
#if defined(PYCC_GCC)
|
||||
#include <sys/builtin.h>
|
||||
#include <sys/fmutex.h>
|
||||
#else
|
||||
long PyThread_get_thread_ident(void);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialization of the C package, should not be needed.
|
||||
|
@ -41,14 +45,20 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
|
|||
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
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -103,7 +113,7 @@ PyThread__exit_prog(int status)
|
|||
/*
|
||||
* 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.
|
||||
* counterparts.
|
||||
*/
|
||||
|
||||
typedef struct os2_lock_t {
|
||||
|
@ -114,6 +124,19 @@ typedef struct os2_lock_t {
|
|||
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));
|
||||
|
||||
|
@ -130,16 +153,27 @@ PyThread_allocate_lock(void)
|
|||
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
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,15 +184,22 @@ PyThread_free_lock(PyThread_type_lock aLock)
|
|||
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) {
|
||||
|
@ -182,15 +223,23 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
|||
|
||||
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()));
|
||||
|
@ -208,4 +257,5 @@ void PyThread_release_lock(PyThread_type_lock aLock)
|
|||
DosPostEventSem(lock->changed);
|
||||
|
||||
DosExitCritSec();
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue