mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Thanks to Chris Herborth, the thread primitives now have proper Py*
names in the source code (they already had those for the linker, through some smart macros; but the source still had the old, un-Py names).
This commit is contained in:
parent
14f53a7757
commit
65d5b5763c
20 changed files with 507 additions and 548 deletions
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _THREAD_H_included
|
#ifndef _THREAD_H_included
|
||||||
#define _THREAD_H_included
|
#define _THREAD_H_included
|
||||||
|
|
||||||
#define NO_EXIT_PROG /* don't define exit_prog() */
|
#define NO_EXIT_PROG /* don't define PyThread_exit_prog() */
|
||||||
/* (the result is no use of signals on SGI) */
|
/* (the result is no use of signals on SGI) */
|
||||||
|
|
||||||
#ifndef Py_PROTO
|
#ifndef Py_PROTO
|
||||||
|
@ -12,76 +12,42 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void *type_lock;
|
typedef void *PyThread_type_lock;
|
||||||
typedef void *type_sema;
|
typedef void *PyThread_type_sema;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macros defining new names for all these symbols */
|
DL_IMPORT(void) PyThread_init_thread Py_PROTO((void));
|
||||||
/* BeOS note: We have exit_thread(), and no legacy code to
|
DL_IMPORT(int) PyThread_start_new_thread Py_PROTO((void (*)(void *), void *));
|
||||||
* support, so we won't allow exit_thread and _exit_thread
|
|
||||||
* in here. Actually, I think these #defines should vanish;
|
|
||||||
* aren't they cheesy in the face of the Great Renaming? [cjh]
|
|
||||||
*/
|
|
||||||
#define init_thread PyThread_init_thread
|
|
||||||
#define start_new_thread PyThread_start_new_thread
|
|
||||||
#ifndef __BEOS__
|
|
||||||
#define exit_thread PyThread_exit_thread
|
|
||||||
#define _exit_thread PyThread__exit_thread
|
|
||||||
#endif
|
|
||||||
#define get_thread_ident PyThread_get_thread_ident
|
|
||||||
#define allocate_lock PyThread_allocate_lock
|
|
||||||
#define free_lock PyThread_free_lock
|
|
||||||
#define acquire_lock PyThread_acquire_lock
|
|
||||||
#define release_lock PyThread_release_lock
|
|
||||||
#define allocate_sema PyThread_allocate_sema
|
|
||||||
#define free_sema PyThread_free_sema
|
|
||||||
#define down_sema PyThread_down_sema
|
|
||||||
#define up_sema PyThread_up_sema
|
|
||||||
#define exit_prog PyThread_exit_prog
|
|
||||||
#define _exit_prog PyThread__exit_prog
|
|
||||||
#define create_key PyThread_create_key
|
|
||||||
#define delete_key PyThread_delete_key
|
|
||||||
#define get_key_value PyThread_get_key_value
|
|
||||||
#define set_key_value PyThread_set_key_value
|
|
||||||
|
|
||||||
|
|
||||||
DL_IMPORT(void) init_thread Py_PROTO((void));
|
|
||||||
DL_IMPORT(int) start_new_thread Py_PROTO((void (*)(void *), void *));
|
|
||||||
#ifndef __BEOS__
|
|
||||||
DL_IMPORT(void) exit_thread Py_PROTO((void));
|
|
||||||
DL_IMPORT(void) _exit_thread Py_PROTO((void));
|
|
||||||
#else
|
|
||||||
DL_IMPORT(void) PyThread_exit_thread Py_PROTO((void));
|
DL_IMPORT(void) PyThread_exit_thread Py_PROTO((void));
|
||||||
DL_IMPORT(void) PyThread__exit_thread Py_PROTO((void));
|
DL_IMPORT(void) PyThread__PyThread_exit_thread Py_PROTO((void));
|
||||||
#endif
|
DL_IMPORT(long) PyThread_get_thread_ident Py_PROTO((void));
|
||||||
DL_IMPORT(long) get_thread_ident Py_PROTO((void));
|
|
||||||
|
|
||||||
DL_IMPORT(type_lock) allocate_lock Py_PROTO((void));
|
DL_IMPORT(PyThread_type_lock) PyThread_allocate_lock Py_PROTO((void));
|
||||||
DL_IMPORT(void) free_lock Py_PROTO((type_lock));
|
DL_IMPORT(void) PyThread_free_lock Py_PROTO((PyThread_type_lock));
|
||||||
DL_IMPORT(int) acquire_lock Py_PROTO((type_lock, int));
|
DL_IMPORT(int) PyThread_acquire_lock Py_PROTO((PyThread_type_lock, int));
|
||||||
#define WAIT_LOCK 1
|
#define WAIT_LOCK 1
|
||||||
#define NOWAIT_LOCK 0
|
#define NOWAIT_LOCK 0
|
||||||
DL_IMPORT(void) release_lock Py_PROTO((type_lock));
|
DL_IMPORT(void) PyThread_release_lock Py_PROTO((PyThread_type_lock));
|
||||||
|
|
||||||
DL_IMPORT(type_sema) allocate_sema Py_PROTO((int));
|
DL_IMPORT(PyThread_type_sema) PyThread_allocate_sema Py_PROTO((int));
|
||||||
DL_IMPORT(void) free_sema Py_PROTO((type_sema));
|
DL_IMPORT(void) PyThread_free_sema Py_PROTO((PyThread_type_sema));
|
||||||
DL_IMPORT(int) down_sema Py_PROTO((type_sema, int));
|
DL_IMPORT(int) PyThread_down_sema Py_PROTO((PyThread_type_sema, int));
|
||||||
#define WAIT_SEMA 1
|
#define WAIT_SEMA 1
|
||||||
#define NOWAIT_SEMA 0
|
#define NOWAIT_SEMA 0
|
||||||
DL_IMPORT(void) up_sema Py_PROTO((type_sema));
|
DL_IMPORT(void) PyThread_up_sema Py_PROTO((PyThread_type_sema));
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
DL_IMPORT(void) exit_prog Py_PROTO((int));
|
DL_IMPORT(void) PyThread_exit_prog Py_PROTO((int));
|
||||||
DL_IMPORT(void) _exit_prog Py_PROTO((int));
|
DL_IMPORT(void) PyThread__PyThread_exit_prog Py_PROTO((int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DL_IMPORT(int) create_key Py_PROTO((void));
|
DL_IMPORT(int) PyThread_create_key Py_PROTO((void));
|
||||||
DL_IMPORT(void) delete_key Py_PROTO((int));
|
DL_IMPORT(void) PyThread_delete_key Py_PROTO((int));
|
||||||
DL_IMPORT(int) set_key_value Py_PROTO((int, void *));
|
DL_IMPORT(int) PyThread_set_key_value Py_PROTO((int, void *));
|
||||||
DL_IMPORT(void *) get_key_value Py_PROTO((int));
|
DL_IMPORT(void *) PyThread_get_key_value Py_PROTO((int));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,29 +171,29 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static type_lock tcl_lock = 0;
|
static PyThread_type_lock tcl_lock = 0;
|
||||||
static PyThreadState *tcl_tstate = NULL;
|
static PyThreadState *tcl_tstate = NULL;
|
||||||
|
|
||||||
#define ENTER_TCL \
|
#define ENTER_TCL \
|
||||||
{ PyThreadState *tstate = PyThreadState_Get(); Py_BEGIN_ALLOW_THREADS \
|
{ PyThreadState *tstate = PyThreadState_Get(); Py_BEGIN_ALLOW_THREADS \
|
||||||
acquire_lock(tcl_lock, 1); tcl_tstate = tstate;
|
PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate;
|
||||||
|
|
||||||
#define LEAVE_TCL \
|
#define LEAVE_TCL \
|
||||||
tcl_tstate = NULL; release_lock(tcl_lock); Py_END_ALLOW_THREADS}
|
tcl_tstate = NULL; PyThread_release_lock(tcl_lock); Py_END_ALLOW_THREADS}
|
||||||
|
|
||||||
#define ENTER_OVERLAP \
|
#define ENTER_OVERLAP \
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
#define LEAVE_OVERLAP_TCL \
|
#define LEAVE_OVERLAP_TCL \
|
||||||
tcl_tstate = NULL; release_lock(tcl_lock); }
|
tcl_tstate = NULL; PyThread_release_lock(tcl_lock); }
|
||||||
|
|
||||||
#define ENTER_PYTHON \
|
#define ENTER_PYTHON \
|
||||||
{ PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \
|
{ PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \
|
||||||
release_lock(tcl_lock); PyEval_RestoreThread((tstate)); }
|
PyThread_release_lock(tcl_lock); PyEval_RestoreThread((tstate)); }
|
||||||
|
|
||||||
#define LEAVE_PYTHON \
|
#define LEAVE_PYTHON \
|
||||||
{ PyThreadState *tstate = PyEval_SaveThread(); \
|
{ PyThreadState *tstate = PyEval_SaveThread(); \
|
||||||
acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
|
PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -1679,11 +1679,11 @@ Tkapp_MainLoop(self, args)
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
acquire_lock(tcl_lock, 1);
|
PyThread_acquire_lock(tcl_lock, 1);
|
||||||
tcl_tstate = tstate;
|
tcl_tstate = tstate;
|
||||||
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
|
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
|
||||||
tcl_tstate = NULL;
|
tcl_tstate = NULL;
|
||||||
release_lock(tcl_lock);
|
PyThread_release_lock(tcl_lock);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
Sleep(20);
|
Sleep(20);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
@ -1921,13 +1921,13 @@ EventHook()
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_THREAD) || defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) || defined(MS_WINDOWS)
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
acquire_lock(tcl_lock, 1);
|
PyThread_acquire_lock(tcl_lock, 1);
|
||||||
tcl_tstate = event_tstate;
|
tcl_tstate = event_tstate;
|
||||||
|
|
||||||
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
|
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
|
||||||
|
|
||||||
tcl_tstate = NULL;
|
tcl_tstate = NULL;
|
||||||
release_lock(tcl_lock);
|
PyThread_release_lock(tcl_lock);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
Sleep(20);
|
Sleep(20);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
@ -2014,7 +2014,7 @@ init_tkinter()
|
||||||
Tkapp_Type.ob_type = &PyType_Type;
|
Tkapp_Type.ob_type = &PyType_Type;
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
tcl_lock = allocate_lock();
|
tcl_lock = PyThread_allocate_lock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m = Py_InitModule("_tkinter", moduleMethods);
|
m = Py_InitModule("_tkinter", moduleMethods);
|
||||||
|
|
|
@ -57,7 +57,7 @@ typedef struct {
|
||||||
DB *di_bsddb;
|
DB *di_bsddb;
|
||||||
int di_size; /* -1 means recompute */
|
int di_size; /* -1 means recompute */
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
type_lock di_lock;
|
PyThread_type_lock di_lock;
|
||||||
#endif
|
#endif
|
||||||
} bsddbobject;
|
} bsddbobject;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ newdbhashobject(file, flags, mode,
|
||||||
|
|
||||||
dp->di_size = -1;
|
dp->di_size = -1;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
dp->di_lock = allocate_lock();
|
dp->di_lock = PyThread_allocate_lock();
|
||||||
if (dp->di_lock == NULL) {
|
if (dp->di_lock == NULL) {
|
||||||
PyErr_SetString(BsddbError, "can't allocate lock");
|
PyErr_SetString(BsddbError, "can't allocate lock");
|
||||||
Py_DECREF(dp);
|
Py_DECREF(dp);
|
||||||
|
@ -169,7 +169,7 @@ newdbbtobject(file, flags, mode,
|
||||||
|
|
||||||
dp->di_size = -1;
|
dp->di_size = -1;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
dp->di_lock = allocate_lock();
|
dp->di_lock = PyThread_allocate_lock();
|
||||||
if (dp->di_lock == NULL) {
|
if (dp->di_lock == NULL) {
|
||||||
PyErr_SetString(BsddbError, "can't allocate lock");
|
PyErr_SetString(BsddbError, "can't allocate lock");
|
||||||
Py_DECREF(dp);
|
Py_DECREF(dp);
|
||||||
|
@ -225,7 +225,7 @@ newdbrnobject(file, flags, mode,
|
||||||
|
|
||||||
dp->di_size = -1;
|
dp->di_size = -1;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
dp->di_lock = allocate_lock();
|
dp->di_lock = PyThread_allocate_lock();
|
||||||
if (dp->di_lock == NULL) {
|
if (dp->di_lock == NULL) {
|
||||||
PyErr_SetString(BsddbError, "can't allocate lock");
|
PyErr_SetString(BsddbError, "can't allocate lock");
|
||||||
Py_DECREF(dp);
|
Py_DECREF(dp);
|
||||||
|
@ -242,9 +242,9 @@ bsddb_dealloc(dp)
|
||||||
{
|
{
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (dp->di_lock) {
|
if (dp->di_lock) {
|
||||||
acquire_lock(dp->di_lock, 0);
|
PyThread_acquire_lock(dp->di_lock, 0);
|
||||||
release_lock(dp->di_lock);
|
PyThread_release_lock(dp->di_lock);
|
||||||
free_lock(dp->di_lock);
|
PyThread_free_lock(dp->di_lock);
|
||||||
dp->di_lock = NULL;
|
dp->di_lock = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -262,8 +262,8 @@ bsddb_dealloc(dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS acquire_lock(_dp->di_lock,1);
|
#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(_dp->di_lock,1);
|
||||||
#define BSDDB_END_SAVE(_dp) release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
|
#define BSDDB_END_SAVE(_dp) PyThread_release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
|
||||||
#else
|
#else
|
||||||
#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS
|
#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS
|
||||||
#define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS
|
#define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS
|
||||||
|
|
|
@ -221,7 +221,7 @@ signal_signal(self, args)
|
||||||
if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
|
if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (get_thread_ident() != main_thread) {
|
if (PyThread_get_thread_ident() != main_thread) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"signal only works in main thread");
|
"signal only works in main thread");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -346,7 +346,7 @@ initsignal()
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
main_thread = get_thread_ident();
|
main_thread = PyThread_get_thread_ident();
|
||||||
main_pid = getpid();
|
main_pid = getpid();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ PyErr_CheckSignals()
|
||||||
if (!is_tripped)
|
if (!is_tripped)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (get_thread_ident() != main_thread)
|
if (PyThread_get_thread_ident() != main_thread)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
if (!(f = PyEval_GetFrame()))
|
if (!(f = PyEval_GetFrame()))
|
||||||
|
@ -676,7 +676,7 @@ PyOS_InterruptOccurred()
|
||||||
{
|
{
|
||||||
if (Handlers[SIGINT].tripped) {
|
if (Handlers[SIGINT].tripped) {
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (get_thread_ident() != main_thread)
|
if (PyThread_get_thread_ident() != main_thread)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
Handlers[SIGINT].tripped = 0;
|
Handlers[SIGINT].tripped = 0;
|
||||||
|
@ -689,7 +689,7 @@ void
|
||||||
PyOS_AfterFork()
|
PyOS_AfterFork()
|
||||||
{
|
{
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
main_thread = get_thread_ident();
|
main_thread = PyThread_get_thread_ident();
|
||||||
main_pid = getpid();
|
main_pid = getpid();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ BUILD_FUNC_DEF_4(PySocketSock_New,int,fd, int,family, int,type, int,proto)
|
||||||
/* Lock to allow python interpreter to continue, but only allow one
|
/* Lock to allow python interpreter to continue, but only allow one
|
||||||
thread to be in gethostbyname */
|
thread to be in gethostbyname */
|
||||||
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
|
||||||
type_lock gethostbyname_lock;
|
PyThread_type_lock gethostbyname_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,11 +358,11 @@ BUILD_FUNC_DEF_2(setipaddr, char*,name, struct sockaddr_in *,addr_ret)
|
||||||
hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
|
hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
|
||||||
#else /* not HAVE_GETHOSTBYNAME_R */
|
#else /* not HAVE_GETHOSTBYNAME_R */
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
acquire_lock(gethostbyname_lock,1);
|
PyThread_acquire_lock(gethostbyname_lock,1);
|
||||||
#endif
|
#endif
|
||||||
hp = gethostbyname(name);
|
hp = gethostbyname(name);
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
release_lock(gethostbyname_lock);
|
PyThread_release_lock(gethostbyname_lock);
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_GETHOSTBYNAME_R */
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
@ -1417,11 +1417,11 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname_ex,PyObject *,self, PyObject *,args)
|
||||||
h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
|
h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
|
||||||
#else /* not HAVE_GETHOSTBYNAME_R */
|
#else /* not HAVE_GETHOSTBYNAME_R */
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
acquire_lock(gethostbyname_lock,1);
|
PyThread_acquire_lock(gethostbyname_lock,1);
|
||||||
#endif
|
#endif
|
||||||
h = gethostbyname(name);
|
h = gethostbyname(name);
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
release_lock(gethostbyname_lock);
|
PyThread_release_lock(gethostbyname_lock);
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_GETHOSTBYNAME_R */
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
@ -1463,13 +1463,13 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyaddr,PyObject *,self, PyObject *, args)
|
||||||
&hp_allocated, buf, buf_len, &errnop);
|
&hp_allocated, buf, buf_len, &errnop);
|
||||||
#else /* not HAVE_GETHOSTBYNAME_R */
|
#else /* not HAVE_GETHOSTBYNAME_R */
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
acquire_lock(gethostbyname_lock,1);
|
PyThread_acquire_lock(gethostbyname_lock,1);
|
||||||
#endif
|
#endif
|
||||||
h = gethostbyaddr((char *)&addr.sin_addr,
|
h = gethostbyaddr((char *)&addr.sin_addr,
|
||||||
sizeof(addr.sin_addr),
|
sizeof(addr.sin_addr),
|
||||||
AF_INET);
|
AF_INET);
|
||||||
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
|
||||||
release_lock(gethostbyname_lock);
|
PyThread_release_lock(gethostbyname_lock);
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_GETHOSTBYNAME_R */
|
#endif /* HAVE_GETHOSTBYNAME_R */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
@ -2188,6 +2188,6 @@ initsocket()
|
||||||
|
|
||||||
/* Initialize gethostbyname lock */
|
/* Initialize gethostbyname lock */
|
||||||
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
|
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
|
||||||
gethostbyname_lock = allocate_lock();
|
gethostbyname_lock = PyThread_allocate_lock();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,11 +87,11 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include "pythread.h"
|
#include "pythread.h"
|
||||||
|
|
||||||
static type_lock StdwinLock; /* Lock held when interpreter not locked */
|
static PyThread_type_lock StdwinLock; /* Lock held when interpreter not locked */
|
||||||
|
|
||||||
#define BGN_STDWIN Py_BEGIN_ALLOW_THREADS acquire_lock(StdwinLock, 1);
|
#define BGN_STDWIN Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(StdwinLock, 1);
|
||||||
#define RET_STDWIN release_lock(StdwinLock); Py_BLOCK_THREADS
|
#define RET_STDWIN PyThread_release_lock(StdwinLock); Py_BLOCK_THREADS
|
||||||
#define END_STDWIN release_lock(StdwinLock); Py_END_ALLOW_THREADS
|
#define END_STDWIN PyThread_release_lock(StdwinLock); Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -2659,6 +2659,6 @@ initstdwin()
|
||||||
PyDict_SetItemString(d, "error", StdwinError) != 0)
|
PyDict_SetItemString(d, "error", StdwinError) != 0)
|
||||||
return;
|
return;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
StdwinLock = allocate_lock();
|
StdwinLock = PyThread_allocate_lock();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ static PyObject *ThreadError;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
type_lock lock_lock;
|
PyThread_type_lock lock_lock;
|
||||||
} lockobject;
|
} lockobject;
|
||||||
|
|
||||||
staticforward PyTypeObject Locktype;
|
staticforward PyTypeObject Locktype;
|
||||||
|
@ -61,7 +61,7 @@ newlockobject()
|
||||||
self = PyObject_NEW(lockobject, &Locktype);
|
self = PyObject_NEW(lockobject, &Locktype);
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
self->lock_lock = allocate_lock();
|
self->lock_lock = PyThread_allocate_lock();
|
||||||
if (self->lock_lock == NULL) {
|
if (self->lock_lock == NULL) {
|
||||||
PyMem_DEL(self);
|
PyMem_DEL(self);
|
||||||
self = NULL;
|
self = NULL;
|
||||||
|
@ -75,15 +75,15 @@ lock_dealloc(self)
|
||||||
lockobject *self;
|
lockobject *self;
|
||||||
{
|
{
|
||||||
/* Unlock the lock so it's safe to free it */
|
/* Unlock the lock so it's safe to free it */
|
||||||
acquire_lock(self->lock_lock, 0);
|
PyThread_acquire_lock(self->lock_lock, 0);
|
||||||
release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
|
|
||||||
free_lock(self->lock_lock);
|
PyThread_free_lock(self->lock_lock);
|
||||||
PyMem_DEL(self);
|
PyMem_DEL(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
lock_acquire_lock(self, args)
|
lock_PyThread_acquire_lock(self, args)
|
||||||
lockobject *self;
|
lockobject *self;
|
||||||
PyObject *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ lock_acquire_lock(self, args)
|
||||||
i = 1;
|
i = 1;
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
i = acquire_lock(self->lock_lock, i);
|
i = PyThread_acquire_lock(self->lock_lock, i);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
|
@ -110,7 +110,7 @@ lock_acquire_lock(self, args)
|
||||||
|
|
||||||
static char acquire_doc[] =
|
static char acquire_doc[] =
|
||||||
"acquire([wait]) -> None or Boolean\n\
|
"acquire([wait]) -> None or Boolean\n\
|
||||||
(acquire_lock() is an obsolete synonym)\n\
|
(PyThread_acquire_lock() is an obsolete synonym)\n\
|
||||||
\n\
|
\n\
|
||||||
Lock the lock. Without argument, this blocks if the lock is already\n\
|
Lock the lock. Without argument, this blocks if the lock is already\n\
|
||||||
locked (even by the same thread), waiting for another thread to release\n\
|
locked (even by the same thread), waiting for another thread to release\n\
|
||||||
|
@ -120,7 +120,7 @@ and the return value reflects whether the lock is acquired.\n\
|
||||||
The blocking operation is not interruptible.";
|
The blocking operation is not interruptible.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
lock_release_lock(self, args)
|
lock_PyThread_release_lock(self, args)
|
||||||
lockobject *self;
|
lockobject *self;
|
||||||
PyObject *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
|
@ -128,20 +128,20 @@ lock_release_lock(self, args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Sanity check: the lock must be locked */
|
/* Sanity check: the lock must be locked */
|
||||||
if (acquire_lock(self->lock_lock, 0)) {
|
if (PyThread_acquire_lock(self->lock_lock, 0)) {
|
||||||
release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
PyErr_SetString(ThreadError, "release unlocked lock");
|
PyErr_SetString(ThreadError, "release unlocked lock");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char release_doc[] =
|
static char release_doc[] =
|
||||||
"release()\n\
|
"release()\n\
|
||||||
(release_lock() is an obsolete synonym)\n\
|
(PyThread_release_lock() is an obsolete synonym)\n\
|
||||||
\n\
|
\n\
|
||||||
Release the lock, allowing another thread that is blocked waiting for\n\
|
Release the lock, allowing another thread that is blocked waiting for\n\
|
||||||
the lock to acquire the lock. The lock must be in the locked state,\n\
|
the lock to acquire the lock. The lock must be in the locked state,\n\
|
||||||
|
@ -155,8 +155,8 @@ lock_locked_lock(self, args)
|
||||||
if (!PyArg_NoArgs(args))
|
if (!PyArg_NoArgs(args))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (acquire_lock(self->lock_lock, 0)) {
|
if (PyThread_acquire_lock(self->lock_lock, 0)) {
|
||||||
release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
return PyInt_FromLong(0L);
|
return PyInt_FromLong(0L);
|
||||||
}
|
}
|
||||||
return PyInt_FromLong(1L);
|
return PyInt_FromLong(1L);
|
||||||
|
@ -169,10 +169,10 @@ static char locked_doc[] =
|
||||||
Return whether the lock is in the locked state.";
|
Return whether the lock is in the locked state.";
|
||||||
|
|
||||||
static PyMethodDef lock_methods[] = {
|
static PyMethodDef lock_methods[] = {
|
||||||
{"acquire_lock", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
|
{"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
|
||||||
{"acquire", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
|
{"acquire", (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
|
||||||
{"release_lock", (PyCFunction)lock_release_lock, 0, release_doc},
|
{"release_lock", (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
|
||||||
{"release", (PyCFunction)lock_release_lock, 0, release_doc},
|
{"release", (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
|
||||||
{"locked_lock", (PyCFunction)lock_locked_lock, 0, locked_doc},
|
{"locked_lock", (PyCFunction)lock_locked_lock, 0, locked_doc},
|
||||||
{"locked", (PyCFunction)lock_locked_lock, 0, locked_doc},
|
{"locked", (PyCFunction)lock_locked_lock, 0, locked_doc},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
|
@ -240,18 +240,11 @@ t_bootstrap(boot_raw)
|
||||||
PyThreadState_Clear(tstate);
|
PyThreadState_Clear(tstate);
|
||||||
PyEval_ReleaseThread(tstate);
|
PyEval_ReleaseThread(tstate);
|
||||||
PyThreadState_Delete(tstate);
|
PyThreadState_Delete(tstate);
|
||||||
#ifdef __BEOS__
|
|
||||||
/* Dunno if this will cause problems with other ports; the BeOS thread
|
|
||||||
* support features only 100% renamed functions. [cjh]
|
|
||||||
*/
|
|
||||||
PyThread_exit_thread();
|
PyThread_exit_thread();
|
||||||
#else
|
|
||||||
exit_thread();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
thread_start_new_thread(self, fargs)
|
thread_PyThread_start_new_thread(self, fargs)
|
||||||
PyObject *self; /* Not used */
|
PyObject *self; /* Not used */
|
||||||
PyObject *fargs;
|
PyObject *fargs;
|
||||||
{
|
{
|
||||||
|
@ -286,7 +279,7 @@ thread_start_new_thread(self, fargs)
|
||||||
Py_INCREF(args);
|
Py_INCREF(args);
|
||||||
Py_XINCREF(keyw);
|
Py_XINCREF(keyw);
|
||||||
PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
|
PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
|
||||||
if (!start_new_thread(t_bootstrap, (void*) boot)) {
|
if (!PyThread_start_new_thread(t_bootstrap, (void*) boot)) {
|
||||||
PyErr_SetString(ThreadError, "can't start new thread\n");
|
PyErr_SetString(ThreadError, "can't start new thread\n");
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
@ -310,7 +303,7 @@ unhandled exception; a stack trace will be printed unless the exception is\n\
|
||||||
SystemExit.";
|
SystemExit.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
thread_exit_thread(self, args)
|
thread_PyThread_exit_thread(self, args)
|
||||||
PyObject *self; /* Not used */
|
PyObject *self; /* Not used */
|
||||||
PyObject *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
|
@ -322,27 +315,27 @@ thread_exit_thread(self, args)
|
||||||
|
|
||||||
static char exit_doc[] =
|
static char exit_doc[] =
|
||||||
"exit()\n\
|
"exit()\n\
|
||||||
(exit_thread() is an obsolete synonym)\n\
|
(PyThread_exit_thread() is an obsolete synonym)\n\
|
||||||
\n\
|
\n\
|
||||||
This is synonymous to ``raise SystemExit''. It will cause the current\n\
|
This is synonymous to ``raise SystemExit''. It will cause the current\n\
|
||||||
thread to exit silently unless the exception is caught.";
|
thread to exit silently unless the exception is caught.";
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static PyObject *
|
static PyObject *
|
||||||
thread_exit_prog(self, args)
|
thread_PyThread_exit_prog(self, args)
|
||||||
PyObject *self; /* Not used */
|
PyObject *self; /* Not used */
|
||||||
PyObject *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
int sts;
|
int sts;
|
||||||
if (!PyArg_Parse(args, "i", &sts))
|
if (!PyArg_Parse(args, "i", &sts))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_Exit(sts); /* Calls exit_prog(sts) or _exit_prog(sts) */
|
Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */
|
||||||
for (;;) { } /* Should not be reached */
|
for (;;) { } /* Should not be reached */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
thread_allocate_lock(self, args)
|
thread_PyThread_allocate_lock(self, args)
|
||||||
PyObject *self; /* Not used */
|
PyObject *self; /* Not used */
|
||||||
PyObject *args;
|
PyObject *args;
|
||||||
{
|
{
|
||||||
|
@ -365,7 +358,7 @@ thread_get_ident(self, args)
|
||||||
long ident;
|
long ident;
|
||||||
if (!PyArg_NoArgs(args))
|
if (!PyArg_NoArgs(args))
|
||||||
return NULL;
|
return NULL;
|
||||||
ident = get_thread_ident();
|
ident = PyThread_get_thread_ident();
|
||||||
if (ident == -1) {
|
if (ident == -1) {
|
||||||
PyErr_SetString(ThreadError, "no current thread ident");
|
PyErr_SetString(ThreadError, "no current thread ident");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -385,22 +378,22 @@ be relied upon, and the number should be seen purely as a magic cookie.\n\
|
||||||
A thread's identity may be reused for another thread after it exits.";
|
A thread's identity may be reused for another thread after it exits.";
|
||||||
|
|
||||||
static PyMethodDef thread_methods[] = {
|
static PyMethodDef thread_methods[] = {
|
||||||
{"start_new_thread", (PyCFunction)thread_start_new_thread, 1,
|
{"start_new_thread", (PyCFunction)thread_PyThread_start_new_thread, 1,
|
||||||
start_new_doc},
|
start_new_doc},
|
||||||
{"start_new", (PyCFunction)thread_start_new_thread, 1,
|
{"start_new", (PyCFunction)thread_PyThread_start_new_thread, 1,
|
||||||
start_new_doc},
|
start_new_doc},
|
||||||
{"allocate_lock", (PyCFunction)thread_allocate_lock, 0,
|
{"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, 0,
|
||||||
allocate_doc},
|
allocate_doc},
|
||||||
{"allocate", (PyCFunction)thread_allocate_lock, 0,
|
{"allocate", (PyCFunction)thread_PyThread_allocate_lock, 0,
|
||||||
allocate_doc},
|
allocate_doc},
|
||||||
{"exit_thread", (PyCFunction)thread_exit_thread, 0,
|
{"exit_thread", (PyCFunction)thread_PyThread_exit_thread, 0,
|
||||||
exit_doc},
|
exit_doc},
|
||||||
{"exit", (PyCFunction)thread_exit_thread, 0,
|
{"exit", (PyCFunction)thread_PyThread_exit_thread, 0,
|
||||||
exit_doc},
|
exit_doc},
|
||||||
{"get_ident", (PyCFunction)thread_get_ident, 0,
|
{"get_ident", (PyCFunction)thread_get_ident, 0,
|
||||||
get_ident_doc},
|
get_ident_doc},
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
{"exit_prog", (PyCFunction)thread_exit_prog},
|
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -414,7 +407,7 @@ The 'threading' module provides a more convenient interface.";
|
||||||
|
|
||||||
static char lock_doc[] =
|
static char lock_doc[] =
|
||||||
"A lock object is a synchronization primitive. To create a lock,\n\
|
"A lock object is a synchronization primitive. To create a lock,\n\
|
||||||
call the allocate_lock() function. Methods are:\n\
|
call the PyThread_allocate_lock() function. Methods are:\n\
|
||||||
\n\
|
\n\
|
||||||
acquire() -- lock the lock, possibly blocking until it can be obtained\n\
|
acquire() -- lock the lock, possibly blocking until it can be obtained\n\
|
||||||
release() -- unlock of the lock\n\
|
release() -- unlock of the lock\n\
|
||||||
|
@ -441,5 +434,5 @@ initthread()
|
||||||
PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
|
PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
|
||||||
|
|
||||||
/* Initialize the C thread library */
|
/* Initialize the C thread library */
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ static long dxp[256];
|
||||||
|
|
||||||
extern int _PyThread_Started; /* Flag for Py_Exit */
|
extern int _PyThread_Started; /* Flag for Py_Exit */
|
||||||
|
|
||||||
static type_lock interpreter_lock = 0;
|
static PyThread_type_lock interpreter_lock = 0;
|
||||||
static long main_thread = 0;
|
static long main_thread = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -122,21 +122,21 @@ PyEval_InitThreads()
|
||||||
if (interpreter_lock)
|
if (interpreter_lock)
|
||||||
return;
|
return;
|
||||||
_PyThread_Started = 1;
|
_PyThread_Started = 1;
|
||||||
interpreter_lock = allocate_lock();
|
interpreter_lock = PyThread_allocate_lock();
|
||||||
acquire_lock(interpreter_lock, 1);
|
PyThread_acquire_lock(interpreter_lock, 1);
|
||||||
main_thread = get_thread_ident();
|
main_thread = PyThread_get_thread_ident();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyEval_AcquireLock()
|
PyEval_AcquireLock()
|
||||||
{
|
{
|
||||||
acquire_lock(interpreter_lock, 1);
|
PyThread_acquire_lock(interpreter_lock, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyEval_ReleaseLock()
|
PyEval_ReleaseLock()
|
||||||
{
|
{
|
||||||
release_lock(interpreter_lock);
|
PyThread_release_lock(interpreter_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -145,7 +145,7 @@ PyEval_AcquireThread(tstate)
|
||||||
{
|
{
|
||||||
if (tstate == NULL)
|
if (tstate == NULL)
|
||||||
Py_FatalError("PyEval_AcquireThread: NULL new thread state");
|
Py_FatalError("PyEval_AcquireThread: NULL new thread state");
|
||||||
acquire_lock(interpreter_lock, 1);
|
PyThread_acquire_lock(interpreter_lock, 1);
|
||||||
if (PyThreadState_Swap(tstate) != NULL)
|
if (PyThreadState_Swap(tstate) != NULL)
|
||||||
Py_FatalError(
|
Py_FatalError(
|
||||||
"PyEval_AcquireThread: non-NULL old thread state");
|
"PyEval_AcquireThread: non-NULL old thread state");
|
||||||
|
@ -159,7 +159,7 @@ PyEval_ReleaseThread(tstate)
|
||||||
Py_FatalError("PyEval_ReleaseThread: NULL thread state");
|
Py_FatalError("PyEval_ReleaseThread: NULL thread state");
|
||||||
if (PyThreadState_Swap(NULL) != tstate)
|
if (PyThreadState_Swap(NULL) != tstate)
|
||||||
Py_FatalError("PyEval_ReleaseThread: wrong thread state");
|
Py_FatalError("PyEval_ReleaseThread: wrong thread state");
|
||||||
release_lock(interpreter_lock);
|
PyThread_release_lock(interpreter_lock);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ PyEval_SaveThread()
|
||||||
Py_FatalError("PyEval_SaveThread: NULL tstate");
|
Py_FatalError("PyEval_SaveThread: NULL tstate");
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (interpreter_lock)
|
if (interpreter_lock)
|
||||||
release_lock(interpreter_lock);
|
PyThread_release_lock(interpreter_lock);
|
||||||
#endif
|
#endif
|
||||||
return tstate;
|
return tstate;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ PyEval_RestoreThread(tstate)
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (interpreter_lock) {
|
if (interpreter_lock) {
|
||||||
int err = errno;
|
int err = errno;
|
||||||
acquire_lock(interpreter_lock, 1);
|
PyThread_acquire_lock(interpreter_lock, 1);
|
||||||
errno = err;
|
errno = err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -269,7 +269,7 @@ Py_MakePendingCalls()
|
||||||
{
|
{
|
||||||
static int busy = 0;
|
static int busy = 0;
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
if (main_thread && get_thread_ident() != main_thread)
|
if (main_thread && PyThread_get_thread_ident() != main_thread)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
if (busy)
|
if (busy)
|
||||||
|
@ -622,11 +622,11 @@ eval_code2(co, globals, locals,
|
||||||
|
|
||||||
if (PyThreadState_Swap(NULL) != tstate)
|
if (PyThreadState_Swap(NULL) != tstate)
|
||||||
Py_FatalError("ceval: tstate mix-up");
|
Py_FatalError("ceval: tstate mix-up");
|
||||||
release_lock(interpreter_lock);
|
PyThread_release_lock(interpreter_lock);
|
||||||
|
|
||||||
/* Other threads may run now */
|
/* Other threads may run now */
|
||||||
|
|
||||||
acquire_lock(interpreter_lock, 1);
|
PyThread_acquire_lock(interpreter_lock, 1);
|
||||||
if (PyThreadState_Swap(tstate) != NULL)
|
if (PyThreadState_Swap(tstate) != NULL)
|
||||||
Py_FatalError("ceval: orphan tstate");
|
Py_FatalError("ceval: orphan tstate");
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,25 +121,25 @@ _PyImport_Fini()
|
||||||
|
|
||||||
#include "pythread.h"
|
#include "pythread.h"
|
||||||
|
|
||||||
static type_lock import_lock = 0;
|
static PyThread_type_lock import_lock = 0;
|
||||||
static long import_lock_thread = -1;
|
static long import_lock_thread = -1;
|
||||||
static int import_lock_level = 0;
|
static int import_lock_level = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lock_import()
|
lock_import()
|
||||||
{
|
{
|
||||||
long me = get_thread_ident();
|
long me = PyThread_get_thread_ident();
|
||||||
if (me == -1)
|
if (me == -1)
|
||||||
return; /* Too bad */
|
return; /* Too bad */
|
||||||
if (import_lock == NULL)
|
if (import_lock == NULL)
|
||||||
import_lock = allocate_lock();
|
import_lock = PyThread_allocate_lock();
|
||||||
if (import_lock_thread == me) {
|
if (import_lock_thread == me) {
|
||||||
import_lock_level++;
|
import_lock_level++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (import_lock_thread != -1 || !acquire_lock(import_lock, 0)) {
|
if (import_lock_thread != -1 || !PyThread_acquire_lock(import_lock, 0)) {
|
||||||
PyThreadState *tstate = PyEval_SaveThread();
|
PyThreadState *tstate = PyEval_SaveThread();
|
||||||
acquire_lock(import_lock, 1);
|
PyThread_acquire_lock(import_lock, 1);
|
||||||
PyEval_RestoreThread(tstate);
|
PyEval_RestoreThread(tstate);
|
||||||
}
|
}
|
||||||
import_lock_thread = me;
|
import_lock_thread = me;
|
||||||
|
@ -149,7 +149,7 @@ lock_import()
|
||||||
static void
|
static void
|
||||||
unlock_import()
|
unlock_import()
|
||||||
{
|
{
|
||||||
long me = get_thread_ident();
|
long me = PyThread_get_thread_ident();
|
||||||
if (me == -1)
|
if (me == -1)
|
||||||
return; /* Too bad */
|
return; /* Too bad */
|
||||||
if (import_lock_thread != me)
|
if (import_lock_thread != me)
|
||||||
|
@ -157,7 +157,7 @@ unlock_import()
|
||||||
import_lock_level--;
|
import_lock_level--;
|
||||||
if (import_lock_level == 0) {
|
if (import_lock_level == 0) {
|
||||||
import_lock_thread = -1;
|
import_lock_thread = -1;
|
||||||
release_lock(import_lock);
|
PyThread_release_lock(import_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ typedef void (*dl_funcptr)(void);
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
#include "pythread.h"
|
#include "pythread.h"
|
||||||
static type_lock beos_dyn_lock;
|
static PyThread_type_lock beos_dyn_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject *beos_dyn_images = NULL;
|
static PyObject *beos_dyn_images = NULL;
|
||||||
|
|
|
@ -109,9 +109,9 @@ static int thread_debug = 0;
|
||||||
|
|
||||||
static int initialized;
|
static int initialized;
|
||||||
|
|
||||||
static void _init_thread(); /* Forward */
|
static void PyThread__init_thread(); /* Forward */
|
||||||
|
|
||||||
void init_thread _P0()
|
void PyThread_init_thread _P0()
|
||||||
{
|
{
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
char *p = getenv("THREADDEBUG");
|
char *p = getenv("THREADDEBUG");
|
||||||
|
@ -126,8 +126,8 @@ void init_thread _P0()
|
||||||
if (initialized)
|
if (initialized)
|
||||||
return;
|
return;
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
dprintf(("init_thread called\n"));
|
dprintf(("PyThread_init_thread called\n"));
|
||||||
_init_thread();
|
PyThread__init_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SGI_THREADS
|
#ifdef SGI_THREADS
|
||||||
|
|
|
@ -129,7 +129,7 @@ static status_t benaphore_unlock( benaphore_t *ben )
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread( void )
|
static void PyThread__init_thread( void )
|
||||||
{
|
{
|
||||||
/* Do nothing. */
|
/* Do nothing. */
|
||||||
return;
|
return;
|
||||||
|
@ -151,7 +151,7 @@ int PyThread_start_new_thread( void (*func)(void *), void *arg )
|
||||||
char name[B_OS_NAME_LENGTH];
|
char name[B_OS_NAME_LENGTH];
|
||||||
int32 this_thread;
|
int32 this_thread;
|
||||||
|
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
|
|
||||||
/* We are so very thread-safe... */
|
/* We are so very thread-safe... */
|
||||||
this_thread = atomic_add( &thread_count, 1 );
|
this_thread = atomic_add( &thread_count, 1 );
|
||||||
|
@ -175,11 +175,11 @@ long PyThread_get_thread_ident( void )
|
||||||
return ( tid != B_NAME_NOT_FOUND ? tid : -1 );
|
return ( tid != B_NAME_NOT_FOUND ? tid : -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread( int no_cleanup )
|
static void do_PyThread_exit_thread( int no_cleanup )
|
||||||
{
|
{
|
||||||
int32 threads;
|
int32 threads;
|
||||||
|
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
|
|
||||||
/* Thread-safe way to read a variable without a mutex: */
|
/* Thread-safe way to read a variable without a mutex: */
|
||||||
threads = atomic_add( &thread_count, 0 );
|
threads = atomic_add( &thread_count, 0 );
|
||||||
|
@ -199,18 +199,18 @@ static void do_exit_thread( int no_cleanup )
|
||||||
|
|
||||||
void PyThread_exit_thread( void )
|
void PyThread_exit_thread( void )
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread__exit_thread( void )
|
void PyThread__exit_thread( void )
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog( int status, int no_cleanup )
|
static void do_PyThread_exit_prog( int status, int no_cleanup )
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
|
|
||||||
/* No need to do anything, the threads get torn down if main() exits. */
|
/* No need to do anything, the threads get torn down if main() exits. */
|
||||||
|
|
||||||
|
@ -223,12 +223,12 @@ static void do_exit_prog( int status, int no_cleanup )
|
||||||
|
|
||||||
void PyThread_exit_prog( int status )
|
void PyThread_exit_prog( int status )
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread__exit_prog( int status )
|
void PyThread__exit_prog( int status )
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
|
@ -238,19 +238,19 @@ void PyThread__exit_prog( int status )
|
||||||
|
|
||||||
static int32 lock_count = 0;
|
static int32 lock_count = 0;
|
||||||
|
|
||||||
type_lock PyThread_allocate_lock( void )
|
PyThread_type_lock PyThread_allocate_lock( void )
|
||||||
{
|
{
|
||||||
benaphore_t *lock;
|
benaphore_t *lock;
|
||||||
status_t retval;
|
status_t retval;
|
||||||
char name[B_OS_NAME_LENGTH];
|
char name[B_OS_NAME_LENGTH];
|
||||||
int32 this_lock;
|
int32 this_lock;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
|
|
||||||
lock = (benaphore_t *)malloc( sizeof( benaphore_t ) );
|
lock = (benaphore_t *)malloc( sizeof( benaphore_t ) );
|
||||||
if( lock == NULL ) {
|
if( lock == NULL ) {
|
||||||
/* TODO: that's bad, raise MemoryError */
|
/* TODO: that's bad, raise MemoryError */
|
||||||
return (type_lock)NULL;
|
return (PyThread_type_lock)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this_lock = atomic_add( &lock_count, 1 );
|
this_lock = atomic_add( &lock_count, 1 );
|
||||||
|
@ -259,18 +259,18 @@ type_lock PyThread_allocate_lock( void )
|
||||||
retval = benaphore_create( name, lock );
|
retval = benaphore_create( name, lock );
|
||||||
if( retval != EOK ) {
|
if( retval != EOK ) {
|
||||||
/* TODO: that's bad, raise an exception */
|
/* TODO: that's bad, raise an exception */
|
||||||
return (type_lock)NULL;
|
return (PyThread_type_lock)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_free_lock( type_lock lock )
|
void PyThread_free_lock( PyThread_type_lock lock )
|
||||||
{
|
{
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
|
|
||||||
retval = benaphore_destroy( (benaphore_t *)lock );
|
retval = benaphore_destroy( (benaphore_t *)lock );
|
||||||
if( retval != EOK ) {
|
if( retval != EOK ) {
|
||||||
|
@ -279,12 +279,12 @@ void PyThread_free_lock( type_lock lock )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PyThread_acquire_lock( type_lock lock, int waitflag )
|
int PyThread_acquire_lock( PyThread_type_lock lock, int waitflag )
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
|
|
||||||
if( waitflag ) {
|
if( waitflag ) {
|
||||||
retval = benaphore_lock( (benaphore_t *)lock );
|
retval = benaphore_lock( (benaphore_t *)lock );
|
||||||
|
@ -300,15 +300,15 @@ int PyThread_acquire_lock( type_lock lock, int waitflag )
|
||||||
/* TODO: that's bad, raise an exception */
|
/* TODO: that's bad, raise an exception */
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_release_lock( type_lock lock )
|
void PyThread_release_lock( PyThread_type_lock lock )
|
||||||
{
|
{
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
|
|
||||||
retval = benaphore_unlock( (benaphore_t *)lock );
|
retval = benaphore_unlock( (benaphore_t *)lock );
|
||||||
if( retval != EOK ) {
|
if( retval != EOK ) {
|
||||||
|
@ -324,11 +324,11 @@ void PyThread_release_lock( type_lock lock )
|
||||||
* I'll do it anyway, you never know when it might be handy, and it's
|
* I'll do it anyway, you never know when it might be handy, and it's
|
||||||
* easy...
|
* easy...
|
||||||
*/
|
*/
|
||||||
type_sema PyThread_allocate_sema( int value )
|
PyThread_type_sema PyThread_allocate_sema( int value )
|
||||||
{
|
{
|
||||||
sem_id sema;
|
sem_id sema;
|
||||||
|
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
|
|
||||||
sema = create_sem( value, "python semaphore" );
|
sema = create_sem( value, "python semaphore" );
|
||||||
if( sema < B_NO_ERROR ) {
|
if( sema < B_NO_ERROR ) {
|
||||||
|
@ -336,15 +336,15 @@ type_sema PyThread_allocate_sema( int value )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_free_sema( type_sema sema )
|
void PyThread_free_sema( PyThread_type_sema sema )
|
||||||
{
|
{
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
|
|
||||||
retval = delete_sem( (sem_id)sema );
|
retval = delete_sem( (sem_id)sema );
|
||||||
if( retval != B_NO_ERROR ) {
|
if( retval != B_NO_ERROR ) {
|
||||||
|
@ -353,11 +353,11 @@ void PyThread_free_sema( type_sema sema )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PyThread_down_sema( type_sema sema, int waitflag )
|
int PyThread_down_sema( PyThread_type_sema sema, int waitflag )
|
||||||
{
|
{
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
||||||
|
|
||||||
if( waitflag ) {
|
if( waitflag ) {
|
||||||
retval = acquire_sem( (sem_id)sema );
|
retval = acquire_sem( (sem_id)sema );
|
||||||
|
@ -370,15 +370,15 @@ int PyThread_down_sema( type_sema sema, int waitflag )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_up_sema( type_sema sema )
|
void PyThread_up_sema( PyThread_type_sema sema )
|
||||||
{
|
{
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
|
|
||||||
retval = release_sem( (sem_id)sema );
|
retval = release_sem( (sem_id)sema );
|
||||||
if( retval != B_NO_ERROR ) {
|
if( retval != B_NO_ERROR ) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
cthread_init();
|
cthread_init();
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,14 @@ static void _init_thread _P0()
|
||||||
/*
|
/*
|
||||||
* Thread support.
|
* Thread support.
|
||||||
*/
|
*/
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
||||||
/* C_THREADS implemented properly */
|
/* C_THREADS implemented properly */
|
||||||
|
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
/* looks like solaris detaches the thread to never rejoin
|
/* looks like solaris detaches the thread to never rejoin
|
||||||
* so well do it here
|
* so well do it here
|
||||||
*/
|
*/
|
||||||
|
@ -58,16 +58,16 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
return (long) cthread_self();
|
return (long) cthread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -76,20 +76,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
cthread_exit(0);
|
cthread_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -101,27 +101,27 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
mutex_t lock;
|
mutex_t lock;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
lock = mutex_alloc();
|
lock = mutex_alloc();
|
||||||
if (mutex_init(lock)) {
|
if (mutex_init(lock)) {
|
||||||
|
@ -129,34 +129,34 @@ type_lock allocate_lock _P0()
|
||||||
free((void *) lock);
|
free((void *) lock);
|
||||||
lock = 0;
|
lock = 0;
|
||||||
}
|
}
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
mutex_free(lock);
|
mutex_free(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success = FALSE;
|
int success = FALSE;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
if (waitflag) { /* blocking */
|
if (waitflag) { /* blocking */
|
||||||
mutex_lock(lock);
|
mutex_lock(lock);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
} else { /* non blocking */
|
} else { /* non blocking */
|
||||||
success = mutex_try_lock(lock);
|
success = mutex_try_lock(lock);
|
||||||
}
|
}
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
mutex_unlock((mutex_t )lock);
|
mutex_unlock((mutex_t )lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,30 +174,30 @@ void release_lock _P1(lock, type_lock lock)
|
||||||
* semaphore using a condition.
|
* semaphore using a condition.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
char *sema = 0;
|
char *sema = 0;
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,33 +32,33 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread support.
|
* Thread support.
|
||||||
*/
|
*/
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
||||||
/* C_THREADS implemented properly */
|
/* C_THREADS implemented properly */
|
||||||
|
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -66,20 +66,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -87,76 +87,76 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct lock {
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
lwp_setstkcache(STACKSIZE, NSTACKS);
|
lwp_setstkcache(STACKSIZE, NSTACKS);
|
||||||
}
|
}
|
||||||
|
@ -56,30 +56,30 @@ static void _init_thread _P0()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
thread_t tid;
|
thread_t tid;
|
||||||
int success;
|
int success;
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
success = lwp_create(&tid, func, MINPRIO, 0, lwp_newstk(), 1, arg);
|
success = lwp_create(&tid, func, MINPRIO, 0, lwp_newstk(), 1, arg);
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
thread_t tid;
|
thread_t tid;
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
if (lwp_self(&tid) < 0)
|
if (lwp_self(&tid) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return tid.thread_id;
|
return tid.thread_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -88,20 +88,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
lwp_destroy(SELF);
|
lwp_destroy(SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -110,49 +110,49 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
pod_exit(status);
|
pod_exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
struct lock *lock;
|
struct lock *lock;
|
||||||
extern char *malloc();
|
extern char *malloc();
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
lock = (struct lock *) malloc(sizeof(struct lock));
|
lock = (struct lock *) malloc(sizeof(struct lock));
|
||||||
lock->lock_locked = 0;
|
lock->lock_locked = 0;
|
||||||
(void) mon_create(&lock->lock_monitor);
|
(void) mon_create(&lock->lock_monitor);
|
||||||
(void) cv_create(&lock->lock_condvar, lock->lock_monitor);
|
(void) cv_create(&lock->lock_condvar, lock->lock_monitor);
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
mon_destroy(((struct lock *) lock)->lock_monitor);
|
mon_destroy(((struct lock *) lock)->lock_monitor);
|
||||||
free((char *) lock);
|
free((char *) lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
success = 0;
|
success = 0;
|
||||||
|
|
||||||
(void) mon_enter(((struct lock *) lock)->lock_monitor);
|
(void) mon_enter(((struct lock *) lock)->lock_monitor);
|
||||||
|
@ -165,13 +165,13 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
||||||
}
|
}
|
||||||
cv_broadcast(((struct lock *) lock)->lock_condvar);
|
cv_broadcast(((struct lock *) lock)->lock_condvar);
|
||||||
mon_exit(((struct lock *) lock)->lock_monitor);
|
mon_exit(((struct lock *) lock)->lock_monitor);
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
(void) mon_enter(((struct lock *) lock)->lock_monitor);
|
(void) mon_enter(((struct lock *) lock)->lock_monitor);
|
||||||
((struct lock *) lock)->lock_locked = 0;
|
((struct lock *) lock)->lock_locked = 0;
|
||||||
cv_broadcast(((struct lock *) lock)->lock_condvar);
|
cv_broadcast(((struct lock *) lock)->lock_condvar);
|
||||||
|
@ -181,30 +181,30 @@ void release_lock _P1(lock, type_lock lock)
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
type_sema sema = 0;
|
PyThread_type_sema sema = 0;
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
long get_thread_ident(void);
|
long PyThread_get_thread_ident(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change all headers to pure ANSI as no one will use K&R style on an
|
* Change all headers to pure ANSI as no one will use K&R style on an
|
||||||
|
@ -45,27 +45,27 @@ long get_thread_ident(void);
|
||||||
/*
|
/*
|
||||||
* Initialization of the C package, should not be needed.
|
* Initialization of the C package, should not be needed.
|
||||||
*/
|
*/
|
||||||
static void _init_thread(void)
|
static void PyThread__init_thread(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread support.
|
* Thread support.
|
||||||
*/
|
*/
|
||||||
int start_new_thread(void (*func)(void *), void *arg)
|
int PyThread_start_new_thread(void (*func)(void *), void *arg)
|
||||||
{
|
{
|
||||||
long rv;
|
long rv;
|
||||||
int success = 0;
|
int success = 0;
|
||||||
|
|
||||||
dprintf(("%ld: start_new_thread called\n", get_thread_ident()));
|
dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident()));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
rv = _beginthread(func, 0, arg); /* use default stack size */
|
rv = _beginthread(func, 0, arg); /* use default stack size */
|
||||||
|
|
||||||
if (rv != -1) {
|
if (rv != -1) {
|
||||||
success = 1;
|
success = 1;
|
||||||
dprintf(("%ld: start_new_thread succeeded: %ld\n", get_thread_ident(), aThreadId));
|
dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), aThreadId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -75,17 +75,17 @@ int start_new_thread(void (*func)(void *), void *arg)
|
||||||
* Return the thread Id instead of an handle. The Id is said to uniquely identify the
|
* Return the thread Id instead of an handle. The Id is said to uniquely identify the
|
||||||
* thread in the system
|
* thread in the system
|
||||||
*/
|
*/
|
||||||
long get_thread_ident(void)
|
long PyThread_get_thread_ident(void)
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread(int no_cleanup)
|
static void do_PyThread_exit_thread(int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: exit_thread called\n", get_thread_ident()));
|
dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -94,20 +94,20 @@ static void do_exit_thread(int no_cleanup)
|
||||||
_endthread();
|
_endthread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread(void)
|
void PyThread_exit_thread(void)
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread(void)
|
void PyThread__exit_thread(void)
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog(int status, int no_cleanup)
|
static void do_PyThread_exit_prog(int status, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -115,14 +115,14 @@ static void do_exit_prog(int status, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog(int status)
|
void PyThread_exit_prog(int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(int status)
|
void PyThread__exit_prog _P1(int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
|
@ -131,13 +131,13 @@ void _exit_prog _P1(int status)
|
||||||
* I [Dag] tried to implement it with mutex but I could find a way to
|
* I [Dag] tried to implement it with mutex but I could find a way to
|
||||||
* tell whether a thread already own the lock or not.
|
* tell whether a thread already own the lock or not.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock(void)
|
PyThread_type_lock PyThread_allocate_lock(void)
|
||||||
{
|
{
|
||||||
HANDLE aLock;
|
HANDLE aLock;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
aLock = CreateSemaphore(NULL, /* Security attributes */
|
aLock = CreateSemaphore(NULL, /* Security attributes */
|
||||||
1, /* Initial value */
|
1, /* Initial value */
|
||||||
|
@ -145,14 +145,14 @@ type_lock allocate_lock(void)
|
||||||
NULL);
|
NULL);
|
||||||
/* Name of semaphore */
|
/* Name of semaphore */
|
||||||
|
|
||||||
dprintf(("%ld: allocate_lock() -> %lx\n", get_thread_ident(), (long)aLock));
|
dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock));
|
||||||
|
|
||||||
return (type_lock) aLock;
|
return (PyThread_type_lock) aLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock(type_lock aLock)
|
void PyThread_free_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: free_lock(%lx) called\n", get_thread_ident(),(long)aLock));
|
dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
|
||||||
|
|
||||||
CloseHandle((HANDLE) aLock);
|
CloseHandle((HANDLE) aLock);
|
||||||
}
|
}
|
||||||
|
@ -163,12 +163,12 @@ void free_lock(type_lock aLock)
|
||||||
* and 0 if the lock was not acquired. This means a 0 is returned
|
* and 0 if the lock was not acquired. This means a 0 is returned
|
||||||
* if the lock has already been acquired by this thread!
|
* if the lock has already been acquired by this thread!
|
||||||
*/
|
*/
|
||||||
int acquire_lock(type_lock aLock, int waitflag)
|
int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
{
|
{
|
||||||
int success = 1;
|
int success = 1;
|
||||||
DWORD waitResult;
|
DWORD waitResult;
|
||||||
|
|
||||||
dprintf(("%ld: acquire_lock(%lx, %d) called\n", get_thread_ident(),(long)aLock, waitflag));
|
dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag));
|
||||||
|
|
||||||
waitResult = WaitForSingleObject((HANDLE) aLock, (waitflag == 1 ? INFINITE : 0));
|
waitResult = WaitForSingleObject((HANDLE) aLock, (waitflag == 1 ? INFINITE : 0));
|
||||||
|
|
||||||
|
@ -176,48 +176,48 @@ int acquire_lock(type_lock aLock, int waitflag)
|
||||||
success = 0; /* We failed */
|
success = 0; /* We failed */
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("%ld: acquire_lock(%lx, %d) -> %d\n", get_thread_ident(),(long)aLock, waitflag, success));
|
dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success));
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock(type_lock aLock)
|
void PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: release_lock(%lx) called\n", get_thread_ident(),(long)aLock));
|
dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
|
||||||
|
|
||||||
if (!ReleaseSemaphore(
|
if (!ReleaseSemaphore(
|
||||||
(HANDLE) aLock, /* Handle of semaphore */
|
(HANDLE) aLock, /* Handle of semaphore */
|
||||||
1, /* increment count by one */
|
1, /* increment count by one */
|
||||||
NULL)) /* not interested in previous count */
|
NULL)) /* not interested in previous count */
|
||||||
{
|
{
|
||||||
dprintf(("%ld: Could not release_lock(%lx) error: %l\n", get_thread_ident(), (long)aLock, GetLastError()));
|
dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema(int value)
|
PyThread_type_sema PyThread_allocate_sema(int value)
|
||||||
{
|
{
|
||||||
HANDLE aSemaphore;
|
HANDLE aSemaphore;
|
||||||
|
|
||||||
dprintf(("%ld: allocate_sema called\n", get_thread_ident()));
|
dprintf(("%ld: PyThread_allocate_sema called\n", PyThread_get_thread_ident()));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
aSemaphore = CreateSemaphore( NULL, /* Security attributes */
|
aSemaphore = CreateSemaphore( NULL, /* Security attributes */
|
||||||
value, /* Initial value */
|
value, /* Initial value */
|
||||||
INT_MAX, /* Maximum value */
|
INT_MAX, /* Maximum value */
|
||||||
NULL); /* Name of semaphore */
|
NULL); /* Name of semaphore */
|
||||||
|
|
||||||
dprintf(("%ld: allocate_sema() -> %lx\n", get_thread_ident(), (long)aSemaphore));
|
dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore));
|
||||||
|
|
||||||
return (type_sema) aSemaphore;
|
return (PyThread_type_sema) aSemaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema(type_sema aSemaphore)
|
void PyThread_free_sema(PyThread_type_sema aSemaphore)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: free_sema(%lx) called\n", get_thread_ident(), (long)aSemaphore));
|
dprintf(("%ld: PyThread_free_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore));
|
||||||
|
|
||||||
CloseHandle((HANDLE) aSemaphore);
|
CloseHandle((HANDLE) aSemaphore);
|
||||||
}
|
}
|
||||||
|
@ -225,24 +225,24 @@ void free_sema(type_sema aSemaphore)
|
||||||
/*
|
/*
|
||||||
XXX must do something about waitflag
|
XXX must do something about waitflag
|
||||||
*/
|
*/
|
||||||
int down_sema(type_sema aSemaphore, int waitflag)
|
int PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag)
|
||||||
{
|
{
|
||||||
DWORD waitResult;
|
DWORD waitResult;
|
||||||
|
|
||||||
dprintf(("%ld: down_sema(%lx) called\n", get_thread_ident(), (long)aSemaphore));
|
dprintf(("%ld: PyThread_down_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore));
|
||||||
|
|
||||||
waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
|
waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
|
||||||
|
|
||||||
dprintf(("%ld: down_sema(%lx) return: %l\n", get_thread_ident(),(long) aSemaphore, waitResult));
|
dprintf(("%ld: PyThread_down_sema(%lx) return: %l\n", PyThread_get_thread_ident(),(long) aSemaphore, waitResult));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema(type_sema aSemaphore)
|
void PyThread_up_sema(PyThread_type_sema aSemaphore)
|
||||||
{
|
{
|
||||||
ReleaseSemaphore(
|
ReleaseSemaphore(
|
||||||
(HANDLE) aSemaphore, /* Handle of semaphore */
|
(HANDLE) aSemaphore, /* Handle of semaphore */
|
||||||
1, /* increment count by one */
|
1, /* increment count by one */
|
||||||
NULL); /* not interested in previous count */
|
NULL); /* not interested in previous count */
|
||||||
|
|
||||||
dprintf(("%ld: up_sema(%lx)\n", get_thread_ident(), (long)aSemaphore));
|
dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,20 +38,20 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
|
|
||||||
long get_thread_ident(void);
|
long PyThread_get_thread_ident(void);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialization of the C package, should not be needed.
|
* Initialization of the C package, should not be needed.
|
||||||
*/
|
*/
|
||||||
static void _init_thread(void)
|
static void PyThread__init_thread(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread support.
|
* Thread support.
|
||||||
*/
|
*/
|
||||||
int start_new_thread(void (*func)(void *), void *arg)
|
int PyThread_start_new_thread(void (*func)(void *), void *arg)
|
||||||
{
|
{
|
||||||
int aThread;
|
int aThread;
|
||||||
int success = 1;
|
int success = 1;
|
||||||
|
@ -67,21 +67,21 @@ int start_new_thread(void (*func)(void *), void *arg)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident(void)
|
long PyThread_get_thread_ident(void)
|
||||||
{
|
{
|
||||||
PPIB pib;
|
PPIB pib;
|
||||||
PTIB tib;
|
PTIB tib;
|
||||||
|
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
DosGetInfoBlocks(&tib,&pib);
|
DosGetInfoBlocks(&tib,&pib);
|
||||||
return tib->tib_ptib2->tib2_ultid;
|
return tib->tib_ptib2->tib2_ultid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread(int no_cleanup)
|
static void do_PyThread_exit_thread(int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: exit_thread called\n", get_thread_ident()));
|
dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -90,20 +90,20 @@ static void do_exit_thread(int no_cleanup)
|
||||||
_endthread();
|
_endthread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread(void)
|
void PyThread_exit_thread(void)
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread(void)
|
void PyThread__exit_thread(void)
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog(int status, int no_cleanup)
|
static void do_PyThread_exit_prog(int status, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -111,14 +111,14 @@ static void do_exit_prog(int status, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog(int status)
|
void PyThread_exit_prog(int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(int status)
|
void PyThread__exit_prog _P1(int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
|
@ -127,28 +127,28 @@ void _exit_prog _P1(int status)
|
||||||
* I [Dag] tried to implement it with mutex but I could find a way to
|
* I [Dag] tried to implement it with mutex but I could find a way to
|
||||||
* tell whether a thread already own the lock or not.
|
* tell whether a thread already own the lock or not.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock(void)
|
PyThread_type_lock PyThread_allocate_lock(void)
|
||||||
{
|
{
|
||||||
HMTX aLock;
|
HMTX aLock;
|
||||||
APIRET rc;
|
APIRET rc;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
DosCreateMutexSem(NULL, /* Sem name */
|
DosCreateMutexSem(NULL, /* Sem name */
|
||||||
&aLock, /* the semaphone */
|
&aLock, /* the semaphone */
|
||||||
0, /* shared ? */
|
0, /* shared ? */
|
||||||
0); /* initial state */
|
0); /* initial state */
|
||||||
|
|
||||||
dprintf(("%ld: allocate_lock() -> %lx\n", get_thread_ident(), (long)aLock));
|
dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock));
|
||||||
|
|
||||||
return (type_lock) aLock;
|
return (PyThread_type_lock) aLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock(type_lock aLock)
|
void PyThread_free_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: free_lock(%lx) called\n", get_thread_ident(),(long)aLock));
|
dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
|
||||||
|
|
||||||
DosCloseMutexSem((HMTX)aLock);
|
DosCloseMutexSem((HMTX)aLock);
|
||||||
}
|
}
|
||||||
|
@ -159,18 +159,18 @@ void free_lock(type_lock aLock)
|
||||||
* and 0 if the lock was not acquired. This means a 0 is returned
|
* and 0 if the lock was not acquired. This means a 0 is returned
|
||||||
* if the lock has already been acquired by this thread!
|
* if the lock has already been acquired by this thread!
|
||||||
*/
|
*/
|
||||||
int acquire_lock(type_lock aLock, int waitflag)
|
int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
{
|
{
|
||||||
int success = 1;
|
int success = 1;
|
||||||
ULONG rc, count;
|
ULONG rc, count;
|
||||||
PID pid = 0;
|
PID pid = 0;
|
||||||
TID tid = 0;
|
TID tid = 0;
|
||||||
|
|
||||||
dprintf(("%ld: acquire_lock(%lx, %d) called\n", get_thread_ident(),
|
dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),
|
||||||
(long)aLock, waitflag));
|
(long)aLock, waitflag));
|
||||||
|
|
||||||
DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count);
|
DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count);
|
||||||
if( tid == get_thread_ident() ) { /* if we own this lock */
|
if( tid == PyThread_get_thread_ident() ) { /* if we own this lock */
|
||||||
success = 0;
|
success = 0;
|
||||||
} else {
|
} else {
|
||||||
rc = DosRequestMutexSem((HMTX) aLock,
|
rc = DosRequestMutexSem((HMTX) aLock,
|
||||||
|
@ -181,41 +181,41 @@ int acquire_lock(type_lock aLock, int waitflag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("%ld: acquire_lock(%lx, %d) -> %d\n",
|
dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n",
|
||||||
get_thread_ident(),(long)aLock, waitflag, success));
|
PyThread_get_thread_ident(),(long)aLock, waitflag, success));
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock(type_lock aLock)
|
void PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: release_lock(%lx) called\n", get_thread_ident(),(long)aLock));
|
dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock));
|
||||||
|
|
||||||
if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) {
|
if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) {
|
||||||
dprintf(("%ld: Could not release_lock(%lx) error: %l\n",
|
dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n",
|
||||||
get_thread_ident(), (long)aLock, GetLastError()));
|
PyThread_get_thread_ident(), (long)aLock, GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema(int value)
|
PyThread_type_sema PyThread_allocate_sema(int value)
|
||||||
{
|
{
|
||||||
return (type_sema) 0;
|
return (PyThread_type_sema) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema(type_sema aSemaphore)
|
void PyThread_free_sema(PyThread_type_sema aSemaphore)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema(type_sema aSemaphore, int waitflag)
|
int PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema(type_sema aSemaphore)
|
void PyThread_up_sema(PyThread_type_sema aSemaphore)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: up_sema(%lx)\n", get_thread_ident(), (long)aSemaphore));
|
dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ static void _noop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
/* DO AN INIT BY STARTING THE THREAD */
|
/* DO AN INIT BY STARTING THE THREAD */
|
||||||
static int dummy = 0;
|
static int dummy = 0;
|
||||||
|
@ -136,7 +136,7 @@ static void _init_thread _P0()
|
||||||
|
|
||||||
#else /* !_HAVE_BSDI */
|
#else /* !_HAVE_BSDI */
|
||||||
|
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
#if defined(_AIX) && defined(__GNUC__)
|
#if defined(_AIX) && defined(__GNUC__)
|
||||||
pthread_init();
|
pthread_init();
|
||||||
|
@ -150,13 +150,13 @@ static void _init_thread _P0()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
pthread_t th;
|
pthread_t th;
|
||||||
int success;
|
int success;
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
success = pthread_create(&th,
|
success = pthread_create(&th,
|
||||||
#if defined(PY_PTHREAD_D4)
|
#if defined(PY_PTHREAD_D4)
|
||||||
|
@ -188,19 +188,19 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
volatile pthread_t threadid;
|
volatile pthread_t threadid;
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
/* Jump through some hoops for Alpha OSF/1 */
|
/* Jump through some hoops for Alpha OSF/1 */
|
||||||
threadid = pthread_self();
|
threadid = pthread_self();
|
||||||
return (long) *(long *) &threadid;
|
return (long) *(long *) &threadid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -209,20 +209,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -230,28 +230,28 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
pthread_lock *lock;
|
pthread_lock *lock;
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
lock = (pthread_lock *) malloc(sizeof(pthread_lock));
|
lock = (pthread_lock *) malloc(sizeof(pthread_lock));
|
||||||
memset((void *)lock, '\0', sizeof(pthread_lock));
|
memset((void *)lock, '\0', sizeof(pthread_lock));
|
||||||
|
@ -272,16 +272,16 @@ type_lock allocate_lock _P0()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
pthread_lock *thelock = (pthread_lock *)lock;
|
pthread_lock *thelock = (pthread_lock *)lock;
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
|
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
|
|
||||||
status = pthread_mutex_destroy( &thelock->mut );
|
status = pthread_mutex_destroy( &thelock->mut );
|
||||||
CHECK_STATUS("pthread_mutex_destroy");
|
CHECK_STATUS("pthread_mutex_destroy");
|
||||||
|
@ -292,13 +292,13 @@ void free_lock _P1(lock, type_lock lock)
|
||||||
free((void *)thelock);
|
free((void *)thelock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
pthread_lock *thelock = (pthread_lock *)lock;
|
pthread_lock *thelock = (pthread_lock *)lock;
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
|
|
||||||
status = pthread_mutex_lock( &thelock->mut );
|
status = pthread_mutex_lock( &thelock->mut );
|
||||||
CHECK_STATUS("pthread_mutex_lock[1]");
|
CHECK_STATUS("pthread_mutex_lock[1]");
|
||||||
|
@ -325,16 +325,16 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
||||||
success = 1;
|
success = 1;
|
||||||
}
|
}
|
||||||
if (error) success = 0;
|
if (error) success = 0;
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
pthread_lock *thelock = (pthread_lock *)lock;
|
pthread_lock *thelock = (pthread_lock *)lock;
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
|
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
|
|
||||||
status = pthread_mutex_lock( &thelock->mut );
|
status = pthread_mutex_lock( &thelock->mut );
|
||||||
CHECK_STATUS("pthread_mutex_lock[3]");
|
CHECK_STATUS("pthread_mutex_lock[3]");
|
||||||
|
@ -359,14 +359,14 @@ struct semaphore {
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
struct semaphore *sema;
|
struct semaphore *sema;
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
|
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
sema = (struct semaphore *) malloc(sizeof(struct semaphore));
|
sema = (struct semaphore *) malloc(sizeof(struct semaphore));
|
||||||
if (sema != NULL) {
|
if (sema != NULL) {
|
||||||
|
@ -382,16 +382,16 @@ type_sema allocate_sema _P1(value, int value)
|
||||||
sema = NULL;
|
sema = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
struct semaphore *thesema = (struct semaphore *) sema;
|
struct semaphore *thesema = (struct semaphore *) sema;
|
||||||
|
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
status = pthread_cond_destroy(&thesema->cond);
|
status = pthread_cond_destroy(&thesema->cond);
|
||||||
CHECK_STATUS("pthread_cond_destroy");
|
CHECK_STATUS("pthread_cond_destroy");
|
||||||
status = pthread_mutex_destroy(&thesema->mutex);
|
status = pthread_mutex_destroy(&thesema->mutex);
|
||||||
|
@ -399,12 +399,12 @@ void free_sema _P1(sema, type_sema sema)
|
||||||
free((void *) thesema);
|
free((void *) thesema);
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int status, error = 0, success;
|
int status, error = 0, success;
|
||||||
struct semaphore *thesema = (struct semaphore *) sema;
|
struct semaphore *thesema = (struct semaphore *) sema;
|
||||||
|
|
||||||
dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
|
||||||
status = pthread_mutex_lock(&thesema->mutex);
|
status = pthread_mutex_lock(&thesema->mutex);
|
||||||
CHECK_STATUS("pthread_mutex_lock");
|
CHECK_STATUS("pthread_mutex_lock");
|
||||||
if (waitflag) {
|
if (waitflag) {
|
||||||
|
@ -424,16 +424,16 @@ int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
||||||
success = 0;
|
success = 0;
|
||||||
status = pthread_mutex_unlock(&thesema->mutex);
|
status = pthread_mutex_unlock(&thesema->mutex);
|
||||||
CHECK_STATUS("pthread_mutex_unlock");
|
CHECK_STATUS("pthread_mutex_unlock");
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
int status, error = 0;
|
int status, error = 0;
|
||||||
struct semaphore *thesema = (struct semaphore *) sema;
|
struct semaphore *thesema = (struct semaphore *) sema;
|
||||||
|
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
status = pthread_mutex_lock(&thesema->mutex);
|
status = pthread_mutex_lock(&thesema->mutex);
|
||||||
CHECK_STATUS("pthread_mutex_lock");
|
CHECK_STATUS("pthread_mutex_lock");
|
||||||
thesema->value++;
|
thesema->value++;
|
||||||
|
|
|
@ -66,7 +66,7 @@ static int maxpidindex; /* # of PIDs in pidlist */
|
||||||
/*
|
/*
|
||||||
* This routine is called as a signal handler when another thread
|
* This routine is called as a signal handler when another thread
|
||||||
* exits. When that happens, we must see whether we have to exit as
|
* exits. When that happens, we must see whether we have to exit as
|
||||||
* well (because of an exit_prog()) or whether we should continue on.
|
* well (because of an PyThread_exit_prog()) or whether we should continue on.
|
||||||
*/
|
*/
|
||||||
static void exit_sig _P0()
|
static void exit_sig _P0()
|
||||||
{
|
{
|
||||||
|
@ -81,13 +81,13 @@ static void exit_sig _P0()
|
||||||
if ((thread_debug & 8) == 0)
|
if ((thread_debug & 8) == 0)
|
||||||
thread_debug &= ~1; /* don't produce debug messages */
|
thread_debug &= ~1; /* don't produce debug messages */
|
||||||
#endif
|
#endif
|
||||||
exit_thread();
|
PyThread_exit_thread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine is called when a process calls exit(). If that wasn't
|
* This routine is called when a process calls exit(). If that wasn't
|
||||||
* done from the library, we do as if an exit_prog() was intended.
|
* done from the library, we do as if an PyThread_exit_prog() was intended.
|
||||||
*/
|
*/
|
||||||
static void maybe_exit _P0()
|
static void maybe_exit _P0()
|
||||||
{
|
{
|
||||||
|
@ -96,14 +96,14 @@ static void maybe_exit _P0()
|
||||||
dprintf(("already exiting\n"));
|
dprintf(("already exiting\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exit_prog(0);
|
PyThread_exit_prog(0);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
struct sigaction s;
|
struct sigaction s;
|
||||||
|
@ -198,7 +198,7 @@ static void clean_threads _P0()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
#ifdef USE_DL
|
#ifdef USE_DL
|
||||||
long addr, size;
|
long addr, size;
|
||||||
|
@ -207,9 +207,9 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
||||||
/* C_THREADS implemented properly */
|
/* C_THREADS implemented properly */
|
||||||
|
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
switch (ussetlock(count_lock)) {
|
switch (ussetlock(count_lock)) {
|
||||||
case 0: return 0;
|
case 0: return 0;
|
||||||
case -1: perror("ussetlock (count_lock)");
|
case -1: perror("ussetlock (count_lock)");
|
||||||
|
@ -256,14 +256,14 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
return getpid();
|
return getpid();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -326,20 +326,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -347,49 +347,49 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
do_exit = 1;
|
do_exit = 1;
|
||||||
exit_status = status;
|
exit_status = status;
|
||||||
do_exit_thread(no_cleanup);
|
do_PyThread_exit_thread(no_cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
ulock_t lock;
|
ulock_t lock;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
if ((lock = usnewlock(shared_arena)) == NULL)
|
if ((lock = usnewlock(shared_arena)) == NULL)
|
||||||
perror("usnewlock");
|
perror("usnewlock");
|
||||||
(void) usinitlock(lock);
|
(void) usinitlock(lock);
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
usfreelock((ulock_t) lock, shared_arena);
|
usfreelock((ulock_t) lock, shared_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
errno = 0; /* clear it just in case */
|
errno = 0; /* clear it just in case */
|
||||||
if (waitflag)
|
if (waitflag)
|
||||||
success = ussetlock((ulock_t) lock);
|
success = ussetlock((ulock_t) lock);
|
||||||
|
@ -397,13 +397,13 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
||||||
success = uscsetlock((ulock_t) lock, 1); /* Try it once */
|
success = uscsetlock((ulock_t) lock, 1); /* Try it once */
|
||||||
if (success < 0)
|
if (success < 0)
|
||||||
perror(waitflag ? "ussetlock" : "uscsetlock");
|
perror(waitflag ? "ussetlock" : "uscsetlock");
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
if (usunsetlock((ulock_t) lock) < 0)
|
if (usunsetlock((ulock_t) lock) < 0)
|
||||||
perror("usunsetlock");
|
perror("usunsetlock");
|
||||||
}
|
}
|
||||||
|
@ -411,43 +411,43 @@ void release_lock _P1(lock, type_lock lock)
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
usema_t *sema;
|
usema_t *sema;
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
if ((sema = usnewsema(shared_arena, value)) == NULL)
|
if ((sema = usnewsema(shared_arena, value)) == NULL)
|
||||||
perror("usnewsema");
|
perror("usnewsema");
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
usfreesema((usema_t *) sema, shared_arena);
|
usfreesema((usema_t *) sema, shared_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("down_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
|
||||||
if (waitflag)
|
if (waitflag)
|
||||||
success = uspsema((usema_t *) sema);
|
success = uspsema((usema_t *) sema);
|
||||||
else
|
else
|
||||||
success = uscpsema((usema_t *) sema);
|
success = uscpsema((usema_t *) sema);
|
||||||
if (success < 0)
|
if (success < 0)
|
||||||
perror(waitflag ? "uspsema" : "uscpsema");
|
perror(waitflag ? "uspsema" : "uscpsema");
|
||||||
dprintf(("down_sema(%lx) return\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
if (usvsema((usema_t *) sema) < 0)
|
if (usvsema((usema_t *) sema) < 0)
|
||||||
perror("usvsema");
|
perror("usvsema");
|
||||||
}
|
}
|
||||||
|
@ -465,12 +465,12 @@ struct key {
|
||||||
|
|
||||||
static struct key *keyhead = NULL;
|
static struct key *keyhead = NULL;
|
||||||
static int nkeys = 0;
|
static int nkeys = 0;
|
||||||
static type_lock keymutex = NULL;
|
static PyThread_type_lock keymutex = NULL;
|
||||||
|
|
||||||
static struct key *find_key _P2(key, int key, value, void *value)
|
static struct key *find_key _P2(key, int key, value, void *value)
|
||||||
{
|
{
|
||||||
struct key *p;
|
struct key *p;
|
||||||
long id = get_thread_ident();
|
long id = PyThread_get_thread_ident();
|
||||||
for (p = keyhead; p != NULL; p = p->next) {
|
for (p = keyhead; p != NULL; p = p->next) {
|
||||||
if (p->id == id && p->key == key)
|
if (p->id == id && p->key == key)
|
||||||
return p;
|
return p;
|
||||||
|
@ -482,25 +482,25 @@ static struct key *find_key _P2(key, int key, value, void *value)
|
||||||
p->id = id;
|
p->id = id;
|
||||||
p->key = key;
|
p->key = key;
|
||||||
p->value = value;
|
p->value = value;
|
||||||
acquire_lock(keymutex, 1);
|
PyThread_acquire_lock(keymutex, 1);
|
||||||
p->next = keyhead;
|
p->next = keyhead;
|
||||||
keyhead = p;
|
keyhead = p;
|
||||||
release_lock(keymutex);
|
PyThread_release_lock(keymutex);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int create_key _P0()
|
int PyThread_create_key _P0()
|
||||||
{
|
{
|
||||||
if (keymutex == NULL)
|
if (keymutex == NULL)
|
||||||
keymutex = allocate_lock();
|
keymutex = PyThread_allocate_lock();
|
||||||
return ++nkeys;
|
return ++nkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_key _P1(key, int key)
|
void PyThread_delete_key _P1(key, int key)
|
||||||
{
|
{
|
||||||
struct key *p, **q;
|
struct key *p, **q;
|
||||||
acquire_lock(keymutex, 1);
|
PyThread_acquire_lock(keymutex, 1);
|
||||||
q = &keyhead;
|
q = &keyhead;
|
||||||
while ((p = *q) != NULL) {
|
while ((p = *q) != NULL) {
|
||||||
if (p->key == key) {
|
if (p->key == key) {
|
||||||
|
@ -511,10 +511,10 @@ void delete_key _P1(key, int key)
|
||||||
else
|
else
|
||||||
q = &p->next;
|
q = &p->next;
|
||||||
}
|
}
|
||||||
release_lock(keymutex);
|
PyThread_release_lock(keymutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_key_value _P2(key, int key, value, void *value)
|
int PyThread_set_key_value _P2(key, int key, value, void *value)
|
||||||
{
|
{
|
||||||
struct key *p = find_key(key, value);
|
struct key *p = find_key(key, value);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
|
@ -523,7 +523,7 @@ int set_key_value _P2(key, int key, value, void *value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *get_key_value _P1(key, int key)
|
void *PyThread_get_key_value _P1(key, int key)
|
||||||
{
|
{
|
||||||
struct key *p = find_key(key, NULL);
|
struct key *p = find_key(key, NULL);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
|
|
|
@ -40,7 +40,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
/*
|
/*
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*/
|
*/
|
||||||
static void _init_thread _P0()
|
static void PyThread__init_thread _P0()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,15 +65,15 @@ static void *new_func _P1(funcarg, void *funcarg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
{
|
{
|
||||||
struct func_arg *funcarg;
|
struct func_arg *funcarg;
|
||||||
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
||||||
/* C_THREADS implemented properly */
|
/* C_THREADS implemented properly */
|
||||||
|
|
||||||
dprintf(("start_new_thread called\n"));
|
dprintf(("PyThread_start_new_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
funcarg = (struct func_arg *) malloc(sizeof(struct func_arg));
|
funcarg = (struct func_arg *) malloc(sizeof(struct func_arg));
|
||||||
funcarg->func = func;
|
funcarg->func = func;
|
||||||
funcarg->arg = arg;
|
funcarg->arg = arg;
|
||||||
|
@ -85,16 +85,16 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
|
||||||
return success < 0 ? 0 : 1;
|
return success < 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_thread_ident _P0()
|
long PyThread_get_thread_ident _P0()
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
return thr_self();
|
return thr_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_thread called\n"));
|
dprintf(("PyThread_exit_thread called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -103,20 +103,20 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
|
||||||
thr_exit(0);
|
thr_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_thread _P0()
|
void PyThread_exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_thread _P0()
|
void PyThread__exit_thread _P0()
|
||||||
{
|
{
|
||||||
do_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
if (no_cleanup)
|
if (no_cleanup)
|
||||||
_exit(status);
|
_exit(status);
|
||||||
|
@ -128,27 +128,27 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_prog _P1(status, int status)
|
void PyThread_exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit_prog _P1(status, int status)
|
void PyThread__exit_prog _P1(status, int status)
|
||||||
{
|
{
|
||||||
do_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
#endif /* NO_EXIT_PROG */
|
#endif /* NO_EXIT_PROG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock support.
|
* Lock support.
|
||||||
*/
|
*/
|
||||||
type_lock allocate_lock _P0()
|
PyThread_type_lock PyThread_allocate_lock _P0()
|
||||||
{
|
{
|
||||||
mutex_t *lock;
|
mutex_t *lock;
|
||||||
|
|
||||||
dprintf(("allocate_lock called\n"));
|
dprintf(("PyThread_allocate_lock called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
lock = (mutex_t *) malloc(sizeof(mutex_t));
|
lock = (mutex_t *) malloc(sizeof(mutex_t));
|
||||||
if (mutex_init(lock, USYNC_THREAD, 0)) {
|
if (mutex_init(lock, USYNC_THREAD, 0)) {
|
||||||
|
@ -156,22 +156,22 @@ type_lock allocate_lock _P0()
|
||||||
free((void *) lock);
|
free((void *) lock);
|
||||||
lock = 0;
|
lock = 0;
|
||||||
}
|
}
|
||||||
dprintf(("allocate_lock() -> %lx\n", (long)lock));
|
dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
|
||||||
return (type_lock) lock;
|
return (PyThread_type_lock) lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_lock _P1(lock, type_lock lock)
|
void PyThread_free_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("free_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_free_lock(%lx) called\n", (long)lock));
|
||||||
mutex_destroy((mutex_t *) lock);
|
mutex_destroy((mutex_t *) lock);
|
||||||
free((void *) lock);
|
free((void *) lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
|
||||||
if (waitflag)
|
if (waitflag)
|
||||||
success = mutex_lock((mutex_t *) lock);
|
success = mutex_lock((mutex_t *) lock);
|
||||||
else
|
else
|
||||||
|
@ -180,13 +180,13 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
|
||||||
perror(waitflag ? "mutex_lock" : "mutex_trylock");
|
perror(waitflag ? "mutex_lock" : "mutex_trylock");
|
||||||
else
|
else
|
||||||
success = !success; /* solaris does it the other way round */
|
success = !success; /* solaris does it the other way round */
|
||||||
dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_lock _P1(lock, type_lock lock)
|
void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
|
||||||
{
|
{
|
||||||
dprintf(("release_lock(%lx) called\n", (long)lock));
|
dprintf(("PyThread_release_lock(%lx) called\n", (long)lock));
|
||||||
if (mutex_unlock((mutex_t *) lock))
|
if (mutex_unlock((mutex_t *) lock))
|
||||||
perror("mutex_unlock");
|
perror("mutex_unlock");
|
||||||
}
|
}
|
||||||
|
@ -194,12 +194,12 @@ void release_lock _P1(lock, type_lock lock)
|
||||||
/*
|
/*
|
||||||
* Semaphore support.
|
* Semaphore support.
|
||||||
*/
|
*/
|
||||||
type_sema allocate_sema _P1(value, int value)
|
PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
|
||||||
{
|
{
|
||||||
sema_t *sema;
|
sema_t *sema;
|
||||||
dprintf(("allocate_sema called\n"));
|
dprintf(("PyThread_allocate_sema called\n"));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
sema = (sema_t *) malloc(sizeof(sema_t));
|
sema = (sema_t *) malloc(sizeof(sema_t));
|
||||||
if (sema_init(sema, value, USYNC_THREAD, 0)) {
|
if (sema_init(sema, value, USYNC_THREAD, 0)) {
|
||||||
|
@ -207,23 +207,23 @@ type_sema allocate_sema _P1(value, int value)
|
||||||
free((void *) sema);
|
free((void *) sema);
|
||||||
sema = 0;
|
sema = 0;
|
||||||
}
|
}
|
||||||
dprintf(("allocate_sema() -> %lx\n", (long) sema));
|
dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
|
||||||
return (type_sema) sema;
|
return (PyThread_type_sema) sema;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_sema _P1(sema, type_sema sema)
|
void PyThread_free_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("free_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_free_sema(%lx) called\n", (long) sema));
|
||||||
if (sema_destroy((sema_t *) sema))
|
if (sema_destroy((sema_t *) sema))
|
||||||
perror("sema_destroy");
|
perror("sema_destroy");
|
||||||
free((void *) sema);
|
free((void *) sema);
|
||||||
}
|
}
|
||||||
|
|
||||||
int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag)
|
||||||
{
|
{
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
dprintf(("down_sema(%lx) called\n", (long) sema));
|
dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
|
||||||
if (waitflag)
|
if (waitflag)
|
||||||
success = sema_wait((sema_t *) sema);
|
success = sema_wait((sema_t *) sema);
|
||||||
else
|
else
|
||||||
|
@ -236,13 +236,13 @@ int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = !success;
|
success = !success;
|
||||||
dprintf(("down_sema(%lx) return %d\n", (long) sema, success));
|
dprintf(("PyThread_down_sema(%lx) return %d\n", (long) sema, success));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void up_sema _P1(sema, type_sema sema)
|
void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
|
||||||
{
|
{
|
||||||
dprintf(("up_sema(%lx)\n", (long) sema));
|
dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
|
||||||
if (sema_post((sema_t *) sema))
|
if (sema_post((sema_t *) sema))
|
||||||
perror("sema_post");
|
perror("sema_post");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue