#ifndef _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) */
#ifndef Py_PROTO
#endif
#endif
-typedef void *type_lock;
-typedef void *type_sema;
+typedef void *PyThread_type_lock;
+typedef void *PyThread_type_sema;
#ifdef __cplusplus
extern "C" {
#endif
-/* Macros defining new names for all these symbols */
-/* BeOS note: We have exit_thread(), and no legacy code to
- * 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_init_thread Py_PROTO((void));
+DL_IMPORT(int) PyThread_start_new_thread Py_PROTO((void (*)(void *), void *));
DL_IMPORT(void) PyThread_exit_thread Py_PROTO((void));
-DL_IMPORT(void) PyThread__exit_thread Py_PROTO((void));
-#endif
-DL_IMPORT(long) get_thread_ident Py_PROTO((void));
+DL_IMPORT(void) PyThread__PyThread_exit_thread Py_PROTO((void));
+DL_IMPORT(long) PyThread_get_thread_ident Py_PROTO((void));
-DL_IMPORT(type_lock) allocate_lock Py_PROTO((void));
-DL_IMPORT(void) free_lock Py_PROTO((type_lock));
-DL_IMPORT(int) acquire_lock Py_PROTO((type_lock, int));
+DL_IMPORT(PyThread_type_lock) PyThread_allocate_lock Py_PROTO((void));
+DL_IMPORT(void) PyThread_free_lock Py_PROTO((PyThread_type_lock));
+DL_IMPORT(int) PyThread_acquire_lock Py_PROTO((PyThread_type_lock, int));
#define WAIT_LOCK 1
#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(void) free_sema Py_PROTO((type_sema));
-DL_IMPORT(int) down_sema Py_PROTO((type_sema, int));
+DL_IMPORT(PyThread_type_sema) PyThread_allocate_sema Py_PROTO((int));
+DL_IMPORT(void) PyThread_free_sema Py_PROTO((PyThread_type_sema));
+DL_IMPORT(int) PyThread_down_sema Py_PROTO((PyThread_type_sema, int));
#define WAIT_SEMA 1
#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
-DL_IMPORT(void) exit_prog Py_PROTO((int));
-DL_IMPORT(void) _exit_prog Py_PROTO((int));
+DL_IMPORT(void) PyThread_exit_prog Py_PROTO((int));
+DL_IMPORT(void) PyThread__PyThread_exit_prog Py_PROTO((int));
#endif
-DL_IMPORT(int) create_key Py_PROTO((void));
-DL_IMPORT(void) delete_key Py_PROTO((int));
-DL_IMPORT(int) set_key_value Py_PROTO((int, void *));
-DL_IMPORT(void *) get_key_value Py_PROTO((int));
+DL_IMPORT(int) PyThread_create_key Py_PROTO((void));
+DL_IMPORT(void) PyThread_delete_key Py_PROTO((int));
+DL_IMPORT(int) PyThread_set_key_value Py_PROTO((int, void *));
+DL_IMPORT(void *) PyThread_get_key_value Py_PROTO((int));
#ifdef __cplusplus
}
*/
-static type_lock tcl_lock = 0;
+static PyThread_type_lock tcl_lock = 0;
static PyThreadState *tcl_tstate = NULL;
#define ENTER_TCL \
{ 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 \
- 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 \
Py_END_ALLOW_THREADS
#define LEAVE_OVERLAP_TCL \
- tcl_tstate = NULL; release_lock(tcl_lock); }
+ tcl_tstate = NULL; PyThread_release_lock(tcl_lock); }
#define ENTER_PYTHON \
{ 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 \
{ PyThreadState *tstate = PyEval_SaveThread(); \
- acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
+ PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
#else
#ifdef WITH_THREAD
Py_BEGIN_ALLOW_THREADS
- acquire_lock(tcl_lock, 1);
+ PyThread_acquire_lock(tcl_lock, 1);
tcl_tstate = tstate;
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
tcl_tstate = NULL;
- release_lock(tcl_lock);
+ PyThread_release_lock(tcl_lock);
if (result == 0)
Sleep(20);
Py_END_ALLOW_THREADS
#endif
#if defined(WITH_THREAD) || defined(MS_WINDOWS)
Py_BEGIN_ALLOW_THREADS
- acquire_lock(tcl_lock, 1);
+ PyThread_acquire_lock(tcl_lock, 1);
tcl_tstate = event_tstate;
result = Tcl_DoOneEvent(TCL_DONT_WAIT);
tcl_tstate = NULL;
- release_lock(tcl_lock);
+ PyThread_release_lock(tcl_lock);
if (result == 0)
Sleep(20);
Py_END_ALLOW_THREADS
Tkapp_Type.ob_type = &PyType_Type;
#ifdef WITH_THREAD
- tcl_lock = allocate_lock();
+ tcl_lock = PyThread_allocate_lock();
#endif
m = Py_InitModule("_tkinter", moduleMethods);
DB *di_bsddb;
int di_size; /* -1 means recompute */
#ifdef WITH_THREAD
- type_lock di_lock;
+ PyThread_type_lock di_lock;
#endif
} bsddbobject;
dp->di_size = -1;
#ifdef WITH_THREAD
- dp->di_lock = allocate_lock();
+ dp->di_lock = PyThread_allocate_lock();
if (dp->di_lock == NULL) {
PyErr_SetString(BsddbError, "can't allocate lock");
Py_DECREF(dp);
dp->di_size = -1;
#ifdef WITH_THREAD
- dp->di_lock = allocate_lock();
+ dp->di_lock = PyThread_allocate_lock();
if (dp->di_lock == NULL) {
PyErr_SetString(BsddbError, "can't allocate lock");
Py_DECREF(dp);
dp->di_size = -1;
#ifdef WITH_THREAD
- dp->di_lock = allocate_lock();
+ dp->di_lock = PyThread_allocate_lock();
if (dp->di_lock == NULL) {
PyErr_SetString(BsddbError, "can't allocate lock");
Py_DECREF(dp);
{
#ifdef WITH_THREAD
if (dp->di_lock) {
- acquire_lock(dp->di_lock, 0);
- release_lock(dp->di_lock);
- free_lock(dp->di_lock);
+ PyThread_acquire_lock(dp->di_lock, 0);
+ PyThread_release_lock(dp->di_lock);
+ PyThread_free_lock(dp->di_lock);
dp->di_lock = NULL;
}
#endif
}
#ifdef WITH_THREAD
-#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS acquire_lock(_dp->di_lock,1);
-#define BSDDB_END_SAVE(_dp) release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
+#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(_dp->di_lock,1);
+#define BSDDB_END_SAVE(_dp) PyThread_release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
#else
#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS
#define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS
if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
return NULL;
#ifdef WITH_THREAD
- if (get_thread_ident() != main_thread) {
+ if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,
"signal only works in main thread");
return NULL;
int i;
#ifdef WITH_THREAD
- main_thread = get_thread_ident();
+ main_thread = PyThread_get_thread_ident();
main_pid = getpid();
#endif
if (!is_tripped)
return 0;
#ifdef WITH_THREAD
- if (get_thread_ident() != main_thread)
+ if (PyThread_get_thread_ident() != main_thread)
return 0;
#endif
if (!(f = PyEval_GetFrame()))
{
if (Handlers[SIGINT].tripped) {
#ifdef WITH_THREAD
- if (get_thread_ident() != main_thread)
+ if (PyThread_get_thread_ident() != main_thread)
return 0;
#endif
Handlers[SIGINT].tripped = 0;
PyOS_AfterFork()
{
#ifdef WITH_THREAD
- main_thread = get_thread_ident();
+ main_thread = PyThread_get_thread_ident();
main_pid = getpid();
#endif
}
/* Lock to allow python interpreter to continue, but only allow one
thread to be in gethostbyname */
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
-type_lock gethostbyname_lock;
+PyThread_type_lock gethostbyname_lock;
#endif
hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
#else /* not HAVE_GETHOSTBYNAME_R */
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- acquire_lock(gethostbyname_lock,1);
+ PyThread_acquire_lock(gethostbyname_lock,1);
#endif
hp = gethostbyname(name);
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- release_lock(gethostbyname_lock);
+ PyThread_release_lock(gethostbyname_lock);
#endif
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
#else /* not HAVE_GETHOSTBYNAME_R */
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- acquire_lock(gethostbyname_lock,1);
+ PyThread_acquire_lock(gethostbyname_lock,1);
#endif
h = gethostbyname(name);
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- release_lock(gethostbyname_lock);
+ PyThread_release_lock(gethostbyname_lock);
#endif
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
&hp_allocated, buf, buf_len, &errnop);
#else /* not HAVE_GETHOSTBYNAME_R */
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- acquire_lock(gethostbyname_lock,1);
+ PyThread_acquire_lock(gethostbyname_lock,1);
#endif
h = gethostbyaddr((char *)&addr.sin_addr,
sizeof(addr.sin_addr),
AF_INET);
#if defined(WITH_THREAD) && !defined(MS_WINDOWS)
- release_lock(gethostbyname_lock);
+ PyThread_release_lock(gethostbyname_lock);
#endif
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
/* Initialize gethostbyname lock */
#if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
- gethostbyname_lock = allocate_lock();
+ gethostbyname_lock = PyThread_allocate_lock();
#endif
}
#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 RET_STDWIN release_lock(StdwinLock); Py_BLOCK_THREADS
-#define END_STDWIN release_lock(StdwinLock); Py_END_ALLOW_THREADS
+#define BGN_STDWIN Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(StdwinLock, 1);
+#define RET_STDWIN PyThread_release_lock(StdwinLock); Py_BLOCK_THREADS
+#define END_STDWIN PyThread_release_lock(StdwinLock); Py_END_ALLOW_THREADS
#else
PyDict_SetItemString(d, "error", StdwinError) != 0)
return;
#ifdef WITH_THREAD
- StdwinLock = allocate_lock();
+ StdwinLock = PyThread_allocate_lock();
#endif
}
typedef struct {
PyObject_HEAD
- type_lock lock_lock;
+ PyThread_type_lock lock_lock;
} lockobject;
staticforward PyTypeObject Locktype;
self = PyObject_NEW(lockobject, &Locktype);
if (self == NULL)
return NULL;
- self->lock_lock = allocate_lock();
+ self->lock_lock = PyThread_allocate_lock();
if (self->lock_lock == NULL) {
PyMem_DEL(self);
self = NULL;
lockobject *self;
{
/* Unlock the lock so it's safe to free it */
- acquire_lock(self->lock_lock, 0);
- release_lock(self->lock_lock);
+ PyThread_acquire_lock(self->lock_lock, 0);
+ PyThread_release_lock(self->lock_lock);
- free_lock(self->lock_lock);
+ PyThread_free_lock(self->lock_lock);
PyMem_DEL(self);
}
static PyObject *
-lock_acquire_lock(self, args)
+lock_PyThread_acquire_lock(self, args)
lockobject *self;
PyObject *args;
{
i = 1;
Py_BEGIN_ALLOW_THREADS
- i = acquire_lock(self->lock_lock, i);
+ i = PyThread_acquire_lock(self->lock_lock, i);
Py_END_ALLOW_THREADS
if (args == NULL) {
static char acquire_doc[] =
"acquire([wait]) -> None or Boolean\n\
-(acquire_lock() is an obsolete synonym)\n\
+(PyThread_acquire_lock() is an obsolete synonym)\n\
\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\
The blocking operation is not interruptible.";
static PyObject *
-lock_release_lock(self, args)
+lock_PyThread_release_lock(self, args)
lockobject *self;
PyObject *args;
{
return NULL;
/* Sanity check: the lock must be locked */
- if (acquire_lock(self->lock_lock, 0)) {
- release_lock(self->lock_lock);
+ if (PyThread_acquire_lock(self->lock_lock, 0)) {
+ PyThread_release_lock(self->lock_lock);
PyErr_SetString(ThreadError, "release unlocked lock");
return NULL;
}
- release_lock(self->lock_lock);
+ PyThread_release_lock(self->lock_lock);
Py_INCREF(Py_None);
return Py_None;
}
static char release_doc[] =
"release()\n\
-(release_lock() is an obsolete synonym)\n\
+(PyThread_release_lock() is an obsolete synonym)\n\
\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\
if (!PyArg_NoArgs(args))
return NULL;
- if (acquire_lock(self->lock_lock, 0)) {
- release_lock(self->lock_lock);
+ if (PyThread_acquire_lock(self->lock_lock, 0)) {
+ PyThread_release_lock(self->lock_lock);
return PyInt_FromLong(0L);
}
return PyInt_FromLong(1L);
Return whether the lock is in the locked state.";
static PyMethodDef lock_methods[] = {
- {"acquire_lock", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
- {"acquire", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
- {"release_lock", (PyCFunction)lock_release_lock, 0, release_doc},
- {"release", (PyCFunction)lock_release_lock, 0, release_doc},
+ {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
+ {"acquire", (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
+ {"release_lock", (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
+ {"release", (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
{"locked_lock", (PyCFunction)lock_locked_lock, 0, locked_doc},
{"locked", (PyCFunction)lock_locked_lock, 0, locked_doc},
{NULL, NULL} /* sentinel */
PyThreadState_Clear(tstate);
PyEval_ReleaseThread(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();
-#else
- exit_thread();
-#endif
}
static PyObject *
-thread_start_new_thread(self, fargs)
+thread_PyThread_start_new_thread(self, fargs)
PyObject *self; /* Not used */
PyObject *fargs;
{
Py_INCREF(args);
Py_XINCREF(keyw);
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");
Py_DECREF(func);
Py_DECREF(args);
SystemExit.";
static PyObject *
-thread_exit_thread(self, args)
+thread_PyThread_exit_thread(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
static char exit_doc[] =
"exit()\n\
-(exit_thread() is an obsolete synonym)\n\
+(PyThread_exit_thread() is an obsolete synonym)\n\
\n\
This is synonymous to ``raise SystemExit''. It will cause the current\n\
thread to exit silently unless the exception is caught.";
#ifndef NO_EXIT_PROG
static PyObject *
-thread_exit_prog(self, args)
+thread_PyThread_exit_prog(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
int sts;
if (!PyArg_Parse(args, "i", &sts))
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 */
}
#endif
static PyObject *
-thread_allocate_lock(self, args)
+thread_PyThread_allocate_lock(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
long ident;
if (!PyArg_NoArgs(args))
return NULL;
- ident = get_thread_ident();
+ ident = PyThread_get_thread_ident();
if (ident == -1) {
PyErr_SetString(ThreadError, "no current thread ident");
return NULL;
A thread's identity may be reused for another thread after it exits.";
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", (PyCFunction)thread_start_new_thread, 1,
+ {"start_new", (PyCFunction)thread_PyThread_start_new_thread, 1,
start_new_doc},
- {"allocate_lock", (PyCFunction)thread_allocate_lock, 0,
+ {"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, 0,
allocate_doc},
- {"allocate", (PyCFunction)thread_allocate_lock, 0,
+ {"allocate", (PyCFunction)thread_PyThread_allocate_lock, 0,
allocate_doc},
- {"exit_thread", (PyCFunction)thread_exit_thread, 0,
+ {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, 0,
exit_doc},
- {"exit", (PyCFunction)thread_exit_thread, 0,
+ {"exit", (PyCFunction)thread_PyThread_exit_thread, 0,
exit_doc},
{"get_ident", (PyCFunction)thread_get_ident, 0,
get_ident_doc},
#ifndef NO_EXIT_PROG
- {"exit_prog", (PyCFunction)thread_exit_prog},
+ {"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
#endif
{NULL, NULL} /* sentinel */
};
static char lock_doc[] =
"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\
acquire() -- lock the lock, possibly blocking until it can be obtained\n\
release() -- unlock of the lock\n\
PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
/* Initialize the C thread library */
- init_thread();
+ PyThread_init_thread();
}
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;
void
if (interpreter_lock)
return;
_PyThread_Started = 1;
- interpreter_lock = allocate_lock();
- acquire_lock(interpreter_lock, 1);
- main_thread = get_thread_ident();
+ interpreter_lock = PyThread_allocate_lock();
+ PyThread_acquire_lock(interpreter_lock, 1);
+ main_thread = PyThread_get_thread_ident();
}
void
PyEval_AcquireLock()
{
- acquire_lock(interpreter_lock, 1);
+ PyThread_acquire_lock(interpreter_lock, 1);
}
void
PyEval_ReleaseLock()
{
- release_lock(interpreter_lock);
+ PyThread_release_lock(interpreter_lock);
}
void
{
if (tstate == NULL)
Py_FatalError("PyEval_AcquireThread: NULL new thread state");
- acquire_lock(interpreter_lock, 1);
+ PyThread_acquire_lock(interpreter_lock, 1);
if (PyThreadState_Swap(tstate) != NULL)
Py_FatalError(
"PyEval_AcquireThread: non-NULL old thread state");
Py_FatalError("PyEval_ReleaseThread: NULL thread state");
if (PyThreadState_Swap(NULL) != tstate)
Py_FatalError("PyEval_ReleaseThread: wrong thread state");
- release_lock(interpreter_lock);
+ PyThread_release_lock(interpreter_lock);
}
#endif
Py_FatalError("PyEval_SaveThread: NULL tstate");
#ifdef WITH_THREAD
if (interpreter_lock)
- release_lock(interpreter_lock);
+ PyThread_release_lock(interpreter_lock);
#endif
return tstate;
}
#ifdef WITH_THREAD
if (interpreter_lock) {
int err = errno;
- acquire_lock(interpreter_lock, 1);
+ PyThread_acquire_lock(interpreter_lock, 1);
errno = err;
}
#endif
{
static int busy = 0;
#ifdef WITH_THREAD
- if (main_thread && get_thread_ident() != main_thread)
+ if (main_thread && PyThread_get_thread_ident() != main_thread)
return 0;
#endif
if (busy)
if (PyThreadState_Swap(NULL) != tstate)
Py_FatalError("ceval: tstate mix-up");
- release_lock(interpreter_lock);
+ PyThread_release_lock(interpreter_lock);
/* Other threads may run now */
- acquire_lock(interpreter_lock, 1);
+ PyThread_acquire_lock(interpreter_lock, 1);
if (PyThreadState_Swap(tstate) != NULL)
Py_FatalError("ceval: orphan tstate");
}
#include "pythread.h"
-static type_lock import_lock = 0;
+static PyThread_type_lock import_lock = 0;
static long import_lock_thread = -1;
static int import_lock_level = 0;
static void
lock_import()
{
- long me = get_thread_ident();
+ long me = PyThread_get_thread_ident();
if (me == -1)
return; /* Too bad */
if (import_lock == NULL)
- import_lock = allocate_lock();
+ import_lock = PyThread_allocate_lock();
if (import_lock_thread == me) {
import_lock_level++;
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();
- acquire_lock(import_lock, 1);
+ PyThread_acquire_lock(import_lock, 1);
PyEval_RestoreThread(tstate);
}
import_lock_thread = me;
static void
unlock_import()
{
- long me = get_thread_ident();
+ long me = PyThread_get_thread_ident();
if (me == -1)
return; /* Too bad */
if (import_lock_thread != me)
import_lock_level--;
if (import_lock_level == 0) {
import_lock_thread = -1;
- release_lock(import_lock);
+ PyThread_release_lock(import_lock);
}
}
#ifdef WITH_THREAD
#include "pythread.h"
-static type_lock beos_dyn_lock;
+static PyThread_type_lock beos_dyn_lock;
#endif
static PyObject *beos_dyn_images = NULL;
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
char *p = getenv("THREADDEBUG");
if (initialized)
return;
initialized = 1;
- dprintf(("init_thread called\n"));
- _init_thread();
+ dprintf(("PyThread_init_thread called\n"));
+ PyThread__init_thread();
}
#ifdef SGI_THREADS
/* ----------------------------------------------------------------------
* Initialization.
*/
-static void _init_thread( void )
+static void PyThread__init_thread( void )
{
/* Do nothing. */
return;
char name[B_OS_NAME_LENGTH];
int32 this_thread;
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
/* We are so very thread-safe... */
this_thread = atomic_add( &thread_count, 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;
- dprintf(("exit_thread called\n"));
+ dprintf(("PyThread_exit_thread called\n"));
/* Thread-safe way to read a variable without a mutex: */
threads = atomic_add( &thread_count, 0 );
void PyThread_exit_thread( void )
{
- do_exit_thread(0);
+ do_PyThread_exit_thread(0);
}
void PyThread__exit_thread( void )
{
- do_exit_thread(1);
+ do_PyThread_exit_thread(1);
}
#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. */
void PyThread_exit_prog( int status )
{
- do_exit_prog(status, 0);
+ do_PyThread_exit_prog(status, 0);
}
void PyThread__exit_prog( int status )
{
- do_exit_prog(status, 1);
+ do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
static int32 lock_count = 0;
-type_lock PyThread_allocate_lock( void )
+PyThread_type_lock PyThread_allocate_lock( void )
{
benaphore_t *lock;
status_t retval;
char name[B_OS_NAME_LENGTH];
int32 this_lock;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
lock = (benaphore_t *)malloc( sizeof( benaphore_t ) );
if( lock == NULL ) {
/* TODO: that's bad, raise MemoryError */
- return (type_lock)NULL;
+ return (PyThread_type_lock)NULL;
}
this_lock = atomic_add( &lock_count, 1 );
retval = benaphore_create( name, lock );
if( retval != EOK ) {
/* TODO: that's bad, raise an exception */
- return (type_lock)NULL;
+ return (PyThread_type_lock)NULL;
}
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock));
+ return (PyThread_type_lock) lock;
}
-void PyThread_free_lock( type_lock lock )
+void PyThread_free_lock( PyThread_type_lock lock )
{
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 );
if( retval != EOK ) {
}
}
-int PyThread_acquire_lock( type_lock lock, int waitflag )
+int PyThread_acquire_lock( PyThread_type_lock lock, int waitflag )
{
int success;
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 ) {
retval = benaphore_lock( (benaphore_t *)lock );
/* 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;
}
-void PyThread_release_lock( type_lock lock )
+void PyThread_release_lock( PyThread_type_lock lock )
{
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 );
if( retval != EOK ) {
* I'll do it anyway, you never know when it might be handy, and it's
* easy...
*/
-type_sema PyThread_allocate_sema( int value )
+PyThread_type_sema PyThread_allocate_sema( int value )
{
sem_id sema;
- dprintf(("allocate_sema called\n"));
+ dprintf(("PyThread_allocate_sema called\n"));
sema = create_sem( value, "python semaphore" );
if( sema < B_NO_ERROR ) {
return 0;
}
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema));
+ return (PyThread_type_sema) sema;
}
-void PyThread_free_sema( type_sema sema )
+void PyThread_free_sema( PyThread_type_sema sema )
{
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 );
if( retval != B_NO_ERROR ) {
}
}
-int PyThread_down_sema( type_sema sema, int waitflag )
+int PyThread_down_sema( PyThread_type_sema sema, int waitflag )
{
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 ) {
retval = acquire_sem( (sem_id)sema );
return 0;
}
- dprintf(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return -1;
}
-void PyThread_up_sema( type_sema sema )
+void PyThread_up_sema( PyThread_type_sema sema )
{
status_t retval;
- dprintf(("up_sema(%lx)\n", (long) sema));
+ dprintf(("PyThread_up_sema(%lx)\n", (long) sema));
retval = release_sem( (sem_id)sema );
if( retval != B_NO_ERROR ) {
/*
* Initialization.
*/
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
cthread_init();
}
/*
* 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 */
/* C_THREADS implemented properly */
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
/* looks like solaris detaches the thread to never rejoin
* so well do it here
*/
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
if (!initialized)
- init_thread();
+ PyThread_init_thread();
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 (no_cleanup)
_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
-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 (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 */
/*
* Lock support.
*/
-type_lock allocate_lock _P0()
+PyThread_type_lock PyThread_allocate_lock _P0()
{
mutex_t lock;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
lock = mutex_alloc();
if (mutex_init(lock)) {
free((void *) lock);
lock = 0;
}
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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);
}
-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;
- dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
+ dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
if (waitflag) { /* blocking */
mutex_lock(lock);
success = TRUE;
} else { /* non blocking */
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;
}
-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);
}
* 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;
- dprintf(("allocate_sema called\n"));
+ dprintf(("PyThread_allocate_sema called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
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));
}
/*
* Initialization.
*/
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
}
/*
* 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 */
/* C_THREADS implemented properly */
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
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 (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
-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 (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 */
/*
* 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)
- init_thread();
+ PyThread_init_thread();
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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;
- dprintf(("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) called\n", (long)lock, waitflag));
+ dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, 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.
*/
-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)
- init_thread();
+ PyThread_init_thread();
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
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));
}
/*
* Initialization.
*/
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
lwp_setstkcache(STACKSIZE, NSTACKS);
}
*/
-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;
int success;
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
success = lwp_create(&tid, func, MINPRIO, 0, lwp_newstk(), 1, arg);
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
thread_t tid;
if (!initialized)
- init_thread();
+ PyThread_init_thread();
if (lwp_self(&tid) < 0)
return -1;
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 (no_cleanup)
_exit(0);
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
-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 (no_cleanup)
_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 */
/*
* Lock support.
*/
-type_lock allocate_lock _P0()
+PyThread_type_lock PyThread_allocate_lock _P0()
{
struct lock *lock;
extern char *malloc();
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
lock = (struct lock *) malloc(sizeof(struct lock));
lock->lock_locked = 0;
(void) mon_create(&lock->lock_monitor);
(void) cv_create(&lock->lock_condvar, lock->lock_monitor);
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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);
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;
- dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
+ dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
success = 0;
(void) mon_enter(((struct lock *) lock)->lock_monitor);
}
cv_broadcast(((struct lock *) lock)->lock_condvar);
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;
}
-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);
((struct lock *) lock)->lock_locked = 0;
cv_broadcast(((struct lock *) lock)->lock_condvar);
/*
* Semaphore support.
*/
-type_sema allocate_sema _P1(value, int value)
+PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
{
- type_sema sema = 0;
- dprintf(("allocate_sema called\n"));
+ PyThread_type_sema sema = 0;
+ dprintf(("PyThread_allocate_sema called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
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));
}
#include <limits.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
/*
* Initialization of the C package, should not be needed.
*/
-static void _init_thread(void)
+static void PyThread__init_thread(void)
{
}
/*
* Thread support.
*/
-int start_new_thread(void (*func)(void *), void *arg)
+int PyThread_start_new_thread(void (*func)(void *), void *arg)
{
long rv;
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)
- init_thread();
+ PyThread_init_thread();
rv = _beginthread(func, 0, arg); /* use default stack size */
if (rv != -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 the thread Id instead of an handle. The Id is said to uniquely identify the
* thread in the system
*/
-long get_thread_ident(void)
+long PyThread_get_thread_ident(void)
{
if (!initialized)
- init_thread();
+ PyThread_init_thread();
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 (no_cleanup)
_exit(0);
_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
-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 (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 */
* 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.
*/
-type_lock allocate_lock(void)
+PyThread_type_lock PyThread_allocate_lock(void)
{
HANDLE aLock;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
aLock = CreateSemaphore(NULL, /* Security attributes */
1, /* Initial value */
NULL);
/* 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);
}
* and 0 if the lock was not acquired. This means a 0 is returned
* 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;
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));
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;
}
-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(
(HANDLE) aLock, /* Handle of semaphore */
1, /* increment count by one */
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.
*/
-type_sema allocate_sema(int value)
+PyThread_type_sema PyThread_allocate_sema(int value)
{
HANDLE aSemaphore;
- dprintf(("%ld: allocate_sema called\n", get_thread_ident()));
+ dprintf(("%ld: PyThread_allocate_sema called\n", PyThread_get_thread_ident()));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
aSemaphore = CreateSemaphore( NULL, /* Security attributes */
value, /* Initial value */
INT_MAX, /* Maximum value */
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);
}
/*
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;
- 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);
- 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;
}
-void up_sema(type_sema aSemaphore)
+void PyThread_up_sema(PyThread_type_sema aSemaphore)
{
ReleaseSemaphore(
(HANDLE) aSemaphore, /* Handle of semaphore */
1, /* increment count by one */
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));
}
#include "process.h"
-long get_thread_ident(void);
+long PyThread_get_thread_ident(void);
/*
* Initialization of the C package, should not be needed.
*/
-static void _init_thread(void)
+static void PyThread__init_thread(void)
{
}
/*
* Thread support.
*/
-int start_new_thread(void (*func)(void *), void *arg)
+int PyThread_start_new_thread(void (*func)(void *), void *arg)
{
int aThread;
int success = 1;
return success;
}
-long get_thread_ident(void)
+long PyThread_get_thread_ident(void)
{
PPIB pib;
PTIB tib;
if (!initialized)
- init_thread();
+ PyThread_init_thread();
DosGetInfoBlocks(&tib,&pib);
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 (no_cleanup)
_exit(0);
_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
-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 (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 */
* 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.
*/
-type_lock allocate_lock(void)
+PyThread_type_lock PyThread_allocate_lock(void)
{
HMTX aLock;
APIRET rc;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
DosCreateMutexSem(NULL, /* Sem name */
&aLock, /* the semaphone */
0, /* shared ? */
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);
}
* and 0 if the lock was not acquired. This means a 0 is returned
* 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;
ULONG rc, count;
PID pid = 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));
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;
} else {
rc = DosRequestMutexSem((HMTX) aLock,
}
}
- 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;
}
-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 ) {
- 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.
*/
-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;
}
-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));
}
{
}
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
/* DO AN INIT BY STARTING THE THREAD */
static int dummy = 0;
#else /* !_HAVE_BSDI */
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
#if defined(_AIX) && defined(__GNUC__)
pthread_init();
*/
-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;
int success;
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
success = pthread_create(&th,
#if defined(PY_PTHREAD_D4)
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
volatile pthread_t threadid;
if (!initialized)
- init_thread();
+ PyThread_init_thread();
/* Jump through some hoops for Alpha OSF/1 */
threadid = pthread_self();
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 (no_cleanup)
_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
-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 (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 */
/*
* Lock support.
*/
-type_lock allocate_lock _P0()
+PyThread_type_lock PyThread_allocate_lock _P0()
{
pthread_lock *lock;
int status, error = 0;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
lock = (pthread_lock *) malloc(sizeof(pthread_lock));
memset((void *)lock, '\0', sizeof(pthread_lock));
}
}
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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;
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 );
CHECK_STATUS("pthread_mutex_destroy");
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;
pthread_lock *thelock = (pthread_lock *)lock;
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 );
CHECK_STATUS("pthread_mutex_lock[1]");
success = 1;
}
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;
}
-void release_lock _P1(lock, type_lock lock)
+void PyThread_release_lock _P1(lock, PyThread_type_lock lock)
{
pthread_lock *thelock = (pthread_lock *)lock;
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 );
CHECK_STATUS("pthread_mutex_lock[3]");
int value;
};
-type_sema allocate_sema _P1(value, int value)
+PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
{
struct semaphore *sema;
int status, error = 0;
- dprintf(("allocate_sema called\n"));
+ dprintf(("PyThread_allocate_sema called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
sema = (struct semaphore *) malloc(sizeof(struct semaphore));
if (sema != NULL) {
sema = NULL;
}
}
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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;
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);
CHECK_STATUS("pthread_cond_destroy");
status = pthread_mutex_destroy(&thesema->mutex);
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;
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);
CHECK_STATUS("pthread_mutex_lock");
if (waitflag) {
success = 0;
status = pthread_mutex_unlock(&thesema->mutex);
CHECK_STATUS("pthread_mutex_unlock");
- dprintf(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
return success;
}
-void up_sema _P1(sema, type_sema sema)
+void PyThread_up_sema _P1(sema, PyThread_type_sema sema)
{
int status, error = 0;
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);
CHECK_STATUS("pthread_mutex_lock");
thesema->value++;
/*
* This routine is called as a signal handler when another thread
* 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()
{
if ((thread_debug & 8) == 0)
thread_debug &= ~1; /* don't produce debug messages */
#endif
- exit_thread();
+ PyThread_exit_thread();
}
}
/*
* 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()
{
dprintf(("already exiting\n"));
return;
}
- exit_prog(0);
+ PyThread_exit_prog(0);
}
#endif /* NO_EXIT_PROG */
/*
* Initialization.
*/
-static void _init_thread _P0()
+static void PyThread__init_thread _P0()
{
#ifndef NO_EXIT_PROG
struct sigaction s;
}
}
-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
long addr, size;
int success = 0; /* init not needed when SOLARIS_THREADS and */
/* C_THREADS implemented properly */
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
switch (ussetlock(count_lock)) {
case 0: return 0;
case -1: perror("ussetlock (count_lock)");
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
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 (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
-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 (no_cleanup)
_exit(status);
exit(status);
do_exit = 1;
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 */
/*
* Lock support.
*/
-type_lock allocate_lock _P0()
+PyThread_type_lock PyThread_allocate_lock _P0()
{
ulock_t lock;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
if ((lock = usnewlock(shared_arena)) == NULL)
perror("usnewlock");
(void) usinitlock(lock);
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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);
}
-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;
- 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 */
if (waitflag)
success = ussetlock((ulock_t) lock);
success = uscsetlock((ulock_t) lock, 1); /* Try it once */
if (success < 0)
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;
}
-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)
perror("usunsetlock");
}
/*
* Semaphore support.
*/
-type_sema allocate_sema _P1(value, int value)
+PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
{
usema_t *sema;
- dprintf(("allocate_sema called\n"));
+ dprintf(("PyThread_allocate_sema called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
if ((sema = usnewsema(shared_arena, value)) == NULL)
perror("usnewsema");
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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);
}
-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;
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
if (waitflag)
success = uspsema((usema_t *) sema);
else
success = uscpsema((usema_t *) sema);
if (success < 0)
perror(waitflag ? "uspsema" : "uscpsema");
- dprintf(("down_sema(%lx) return\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx) return\n", (long) sema));
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)
perror("usvsema");
}
static struct key *keyhead = NULL;
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)
{
struct key *p;
- long id = get_thread_ident();
+ long id = PyThread_get_thread_ident();
for (p = keyhead; p != NULL; p = p->next) {
if (p->id == id && p->key == key)
return p;
p->id = id;
p->key = key;
p->value = value;
- acquire_lock(keymutex, 1);
+ PyThread_acquire_lock(keymutex, 1);
p->next = keyhead;
keyhead = p;
- release_lock(keymutex);
+ PyThread_release_lock(keymutex);
}
return p;
}
-int create_key _P0()
+int PyThread_create_key _P0()
{
if (keymutex == NULL)
- keymutex = allocate_lock();
+ keymutex = PyThread_allocate_lock();
return ++nkeys;
}
-void delete_key _P1(key, int key)
+void PyThread_delete_key _P1(key, int key)
{
struct key *p, **q;
- acquire_lock(keymutex, 1);
+ PyThread_acquire_lock(keymutex, 1);
q = &keyhead;
while ((p = *q) != NULL) {
if (p->key == key) {
else
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);
if (p == NULL)
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);
if (p == NULL)
/*
* Initialization.
*/
-static void _init_thread _P0()
+static void PyThread__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)
{
struct func_arg *funcarg;
int success = 0; /* init not needed when SOLARIS_THREADS and */
/* C_THREADS implemented properly */
- dprintf(("start_new_thread called\n"));
+ dprintf(("PyThread_start_new_thread called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
funcarg = (struct func_arg *) malloc(sizeof(struct func_arg));
funcarg->func = func;
funcarg->arg = arg;
return success < 0 ? 0 : 1;
}
-long get_thread_ident _P0()
+long PyThread_get_thread_ident _P0()
{
if (!initialized)
- init_thread();
+ PyThread_init_thread();
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 (no_cleanup)
_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
-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 (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 */
/*
* Lock support.
*/
-type_lock allocate_lock _P0()
+PyThread_type_lock PyThread_allocate_lock _P0()
{
mutex_t *lock;
- dprintf(("allocate_lock called\n"));
+ dprintf(("PyThread_allocate_lock called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
lock = (mutex_t *) malloc(sizeof(mutex_t));
if (mutex_init(lock, USYNC_THREAD, 0)) {
free((void *) lock);
lock = 0;
}
- dprintf(("allocate_lock() -> %lx\n", (long)lock));
- return (type_lock) lock;
+ dprintf(("PyThread_allocate_lock() -> %lx\n", (long)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);
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;
- dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
+ dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
if (waitflag)
success = mutex_lock((mutex_t *) lock);
else
perror(waitflag ? "mutex_lock" : "mutex_trylock");
else
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;
}
-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))
perror("mutex_unlock");
}
/*
* Semaphore support.
*/
-type_sema allocate_sema _P1(value, int value)
+PyThread_type_sema PyThread_allocate_sema _P1(value, int value)
{
sema_t *sema;
- dprintf(("allocate_sema called\n"));
+ dprintf(("PyThread_allocate_sema called\n"));
if (!initialized)
- init_thread();
+ PyThread_init_thread();
sema = (sema_t *) malloc(sizeof(sema_t));
if (sema_init(sema, value, USYNC_THREAD, 0)) {
free((void *) sema);
sema = 0;
}
- dprintf(("allocate_sema() -> %lx\n", (long) sema));
- return (type_sema) sema;
+ dprintf(("PyThread_allocate_sema() -> %lx\n", (long) 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))
perror("sema_destroy");
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;
- dprintf(("down_sema(%lx) called\n", (long) sema));
+ dprintf(("PyThread_down_sema(%lx) called\n", (long) sema));
if (waitflag)
success = sema_wait((sema_t *) sema);
else
}
else
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;
}
-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))
perror("sema_post");
}