Commit a1f69875 authored by Amaury Forgeot d'Arc's avatar Amaury Forgeot d'Arc

Merged revisions 78393 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78393 | amaury.forgeotdarc | 2010-02-24 00:19:39 +0100 (mer., 24 févr. 2010) | 2 lines

  #4852: Remove dead code in every thread implementation, unused for many years.
........
parent 9f435c5c
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#ifndef Py_PYTHREAD_H #ifndef Py_PYTHREAD_H
#define Py_PYTHREAD_H #define Py_PYTHREAD_H
#define NO_EXIT_PROG /* don't define PyThread_exit_prog() */
/* (the result is no use of signals on SGI) */
typedef void *PyThread_type_lock; typedef void *PyThread_type_lock;
typedef void *PyThread_type_sema; typedef void *PyThread_type_sema;
...@@ -15,7 +12,6 @@ extern "C" { ...@@ -15,7 +12,6 @@ extern "C" {
PyAPI_FUNC(void) PyThread_init_thread(void); PyAPI_FUNC(void) PyThread_init_thread(void);
PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
PyAPI_FUNC(void) PyThread_exit_thread(void); PyAPI_FUNC(void) PyThread_exit_thread(void);
PyAPI_FUNC(void) PyThread__PyThread_exit_thread(void);
PyAPI_FUNC(long) PyThread_get_thread_ident(void); PyAPI_FUNC(long) PyThread_get_thread_ident(void);
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
...@@ -28,11 +24,6 @@ PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); ...@@ -28,11 +24,6 @@ PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
PyAPI_FUNC(size_t) PyThread_get_stacksize(void); PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
PyAPI_FUNC(int) PyThread_set_stacksize(size_t); PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
#ifndef NO_EXIT_PROG
PyAPI_FUNC(void) PyThread_exit_prog(int);
PyAPI_FUNC(void) PyThread__PyThread_exit_prog(int);
#endif
/* Thread Local Storage (TLS) API */ /* Thread Local Storage (TLS) API */
PyAPI_FUNC(int) PyThread_create_key(void); PyAPI_FUNC(int) PyThread_create_key(void);
PyAPI_FUNC(void) PyThread_delete_key(int); PyAPI_FUNC(void) PyThread_delete_key(int);
......
...@@ -825,18 +825,6 @@ Raise a KeyboardInterrupt in the main thread.\n\ ...@@ -825,18 +825,6 @@ Raise a KeyboardInterrupt in the main thread.\n\
A subthread can use this function to interrupt the main thread." A subthread can use this function to interrupt the main thread."
); );
#ifndef NO_EXIT_PROG
static PyObject *
thread_PyThread_exit_prog(PyObject *self, PyObject *args)
{
int sts;
if (!PyArg_ParseTuple(args, "i:exit_prog", &sts))
return NULL;
Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */
for (;;) { } /* Should not be reached */
}
#endif
static lockobject *newlockobject(void); static lockobject *newlockobject(void);
static PyObject * static PyObject *
...@@ -970,10 +958,6 @@ static PyMethodDef thread_methods[] = { ...@@ -970,10 +958,6 @@ static PyMethodDef thread_methods[] = {
{"stack_size", (PyCFunction)thread_stack_size, {"stack_size", (PyCFunction)thread_stack_size,
METH_VARARGS, METH_VARARGS,
stack_size_doc}, stack_size_doc},
#ifndef NO_EXIT_PROG
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog,
METH_VARARGS},
#endif
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
......
...@@ -1168,7 +1168,6 @@ EXPORTS ...@@ -1168,7 +1168,6 @@ EXPORTS
"PyThread_delete_key" "PyThread_delete_key"
"PyThread_set_key_value" "PyThread_set_key_value"
"PyThread_get_key_value" "PyThread_get_key_value"
"PyThread__exit_thread"
; From python26_s.lib(gcmodule) ; From python26_s.lib(gcmodule)
; "initgc" ; "initgc"
......
...@@ -376,7 +376,6 @@ EXPORTS ...@@ -376,7 +376,6 @@ EXPORTS
PyThreadState_GetDict PyThreadState_GetDict
PyThreadState_New PyThreadState_New
PyThreadState_Swap PyThreadState_Swap
PyThread__exit_thread
PyThread_acquire_lock PyThread_acquire_lock
PyThread_allocate_lock PyThread_allocate_lock
PyThread_allocate_sema PyThread_allocate_sema
......
...@@ -50,58 +50,14 @@ PyThread_get_thread_ident(void) ...@@ -50,58 +50,14 @@ PyThread_get_thread_ident(void)
return (long) cthread_self(); return (long) cthread_self();
} }
static void
do_PyThread_exit_thread(int no_cleanup)
{
dprintf(("PyThread_exit_thread called\n"));
if (!initialized)
if (no_cleanup)
_exit(0);
else
exit(0);
cthread_exit(0);
}
void void
PyThread_exit_thread(void) PyThread_exit_thread(void)
{ {
do_PyThread_exit_thread(0); dprintf(("PyThread_exit_thread called\n"));
}
void
PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static
void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(status); cthread_exit(0);
else
exit(status);
if (no_cleanup)
_exit(status);
else
exit(status);
}
void
PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void
PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
} }
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
......
...@@ -29,53 +29,13 @@ PyThread_get_thread_ident(void) ...@@ -29,53 +29,13 @@ PyThread_get_thread_ident(void)
PyThread_init_thread(); PyThread_init_thread();
} }
static
void do_PyThread_exit_thread(int no_cleanup)
{
dprintf(("PyThread_exit_thread called\n"));
if (!initialized)
if (no_cleanup)
_exit(0);
else
exit(0);
}
void void
PyThread_exit_thread(void) PyThread_exit_thread(void)
{ {
do_PyThread_exit_thread(0); dprintf(("PyThread_exit_thread called\n"));
}
void
PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static
void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(status);
else
exit(status);
}
void
PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void
PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
} }
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
......
...@@ -47,50 +47,14 @@ long PyThread_get_thread_ident(void) ...@@ -47,50 +47,14 @@ long PyThread_get_thread_ident(void)
return tid.thread_id; return tid.thread_id;
} }
static void do_PyThread_exit_thread(int no_cleanup) void PyThread_exit_thread(void)
{ {
dprintf(("PyThread_exit_thread called\n")); dprintf(("PyThread_exit_thread called\n"));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(0);
else
exit(0);
lwp_destroy(SELF); lwp_destroy(SELF);
} }
void PyThread_exit_thread(void)
{
do_PyThread_exit_thread(0);
}
void PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
if (no_cleanup)
_exit(status);
else
exit(status);
pod_exit(status);
}
void PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
*/ */
......
...@@ -203,16 +203,6 @@ PyThread_exit_thread(void) ...@@ -203,16 +203,6 @@ PyThread_exit_thread(void)
#endif #endif
} }
#ifndef NO_EXIT_PROG
void
PyThread_exit_prog(int status)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
exit(status);
}
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. It has too be implemented as semaphores. * Lock support. It has too be implemented as semaphores.
* 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
......
...@@ -68,56 +68,16 @@ PyThread_get_thread_ident(void) ...@@ -68,56 +68,16 @@ PyThread_get_thread_ident(void)
#endif #endif
} }
static void void
do_PyThread_exit_thread(int no_cleanup) PyThread_exit_thread(void)
{ {
dprintf(("%ld: PyThread_exit_thread called\n", dprintf(("%ld: PyThread_exit_thread called\n",
PyThread_get_thread_ident())); PyThread_get_thread_ident()));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(0);
else
exit(0);
_endthread(); _endthread();
} }
void
PyThread_exit_thread(void)
{
do_PyThread_exit_thread(0);
}
void
PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void
do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
if (no_cleanup)
_exit(status);
else
exit(status);
}
void
PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void
PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. This is implemented with an event semaphore and critical * Lock support. This is implemented with an event semaphore and critical
* sections to make it behave more like a posix mutex than its OS/2 * sections to make it behave more like a posix mutex than its OS/2
......
...@@ -74,49 +74,14 @@ long PyThread_get_thread_ident(void) ...@@ -74,49 +74,14 @@ long PyThread_get_thread_ident(void)
return (long) *(long *) &threadid; return (long) *(long *) &threadid;
} }
static void do_PyThread_exit_thread(int no_cleanup) void PyThread_exit_thread(void)
{ {
dprintf(("PyThread_exit_thread called\n")); dprintf(("PyThread_exit_thread called\n"));
if (!initialized) { if (!initialized) {
if (no_cleanup) exit(0);
_exit(0);
else
exit(0);
} }
} }
void PyThread_exit_thread(void)
{
do_PyThread_exit_thread(0);
}
void PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
if (no_cleanup)
_exit(status);
else
exit(status);
}
void PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
*/ */
......
...@@ -225,55 +225,15 @@ PyThread_get_thread_ident(void) ...@@ -225,55 +225,15 @@ PyThread_get_thread_ident(void)
#endif #endif
} }
static void void
do_PyThread_exit_thread(int no_cleanup) PyThread_exit_thread(void)
{ {
dprintf(("PyThread_exit_thread called\n")); dprintf(("PyThread_exit_thread called\n"));
if (!initialized) { if (!initialized) {
if (no_cleanup) exit(0);
_exit(0);
else
exit(0);
} }
} }
void
PyThread_exit_thread(void)
{
do_PyThread_exit_thread(0);
}
void
PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void
do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
if (no_cleanup)
_exit(status);
else
exit(status);
}
void
PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void
PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
#ifdef USE_SEMAPHORES #ifdef USE_SEMAPHORES
/* /*
......
...@@ -17,9 +17,6 @@ static ulock_t wait_lock; /* lock used to wait for other threads */ ...@@ -17,9 +17,6 @@ static ulock_t wait_lock; /* lock used to wait for other threads */
static int waiting_for_threads; /* protected by count_lock */ static int waiting_for_threads; /* protected by count_lock */
static int nthreads; /* protected by count_lock */ static int nthreads; /* protected by count_lock */
static int exit_status; static int exit_status;
#ifndef NO_EXIT_PROG
static int do_exit; /* indicates that the program is to exit */
#endif
static int exiting; /* we're already exiting (for maybe_exit) */ static int exiting; /* we're already exiting (for maybe_exit) */
static pid_t my_pid; /* PID of main thread */ static pid_t my_pid; /* PID of main thread */
static struct pidlist { static struct pidlist {
...@@ -27,53 +24,11 @@ static struct pidlist { ...@@ -27,53 +24,11 @@ static struct pidlist {
pid_t child; pid_t child;
} pidlist[MAXPROC]; /* PIDs of other threads; protected by count_lock */ } pidlist[MAXPROC]; /* PIDs of other threads; protected by count_lock */
static int maxpidindex; /* # of PIDs in pidlist */ static int maxpidindex; /* # of PIDs in pidlist */
#ifndef NO_EXIT_PROG
/*
* 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 PyThread_exit_prog()) or whether we should continue on.
*/
static void exit_sig(void)
{
d2printf(("exit_sig called\n"));
if (exiting && getpid() == my_pid) {
d2printf(("already exiting\n"));
return;
}
if (do_exit) {
d2printf(("exiting in exit_sig\n"));
#ifdef Py_DEBUG
if ((thread_debug & 8) == 0)
thread_debug &= ~1; /* don't produce debug messages */
#endif
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 PyThread_exit_prog() was intended.
*/
static void maybe_exit(void)
{
dprintf(("maybe_exit called\n"));
if (exiting) {
dprintf(("already exiting\n"));
return;
}
PyThread_exit_prog(0);
}
#endif /* NO_EXIT_PROG */
/* /*
* Initialization. * Initialization.
*/ */
static void PyThread__init_thread(void) static void PyThread__init_thread(void)
{ {
#ifndef NO_EXIT_PROG
struct sigaction s;
#endif /* NO_EXIT_PROG */
#ifdef USE_DL #ifdef USE_DL
long addr, size; long addr, size;
#endif /* USE_DL */ #endif /* USE_DL */
...@@ -93,16 +48,6 @@ static void PyThread__init_thread(void) ...@@ -93,16 +48,6 @@ static void PyThread__init_thread(void)
if (usconfig(CONF_INITUSERS, 16) < 0) if (usconfig(CONF_INITUSERS, 16) < 0)
perror("usconfig - CONF_INITUSERS"); perror("usconfig - CONF_INITUSERS");
my_pid = getpid(); /* so that we know which is the main thread */ my_pid = getpid(); /* so that we know which is the main thread */
#ifndef NO_EXIT_PROG
atexit(maybe_exit);
s.sa_handler = exit_sig;
sigemptyset(&s.sa_mask);
/*sigaddset(&s.sa_mask, SIGUSR1);*/
s.sa_flags = 0;
sigaction(SIGUSR1, &s, 0);
if (prctl(PR_SETEXITSIG, SIGUSR1) < 0)
perror("prctl - PR_SETEXITSIG");
#endif /* NO_EXIT_PROG */
if (usconfig(CONF_ARENATYPE, US_SHAREDONLY) < 0) if (usconfig(CONF_ARENATYPE, US_SHAREDONLY) < 0)
perror("usconfig - CONF_ARENATYPE"); perror("usconfig - CONF_ARENATYPE");
usconfig(CONF_LOCKTYPE, US_DEBUG); /* XXX */ usconfig(CONF_LOCKTYPE, US_DEBUG); /* XXX */
...@@ -227,46 +172,24 @@ long PyThread_get_thread_ident(void) ...@@ -227,46 +172,24 @@ long PyThread_get_thread_ident(void)
return getpid(); return getpid();
} }
static void do_PyThread_exit_thread(int no_cleanup) void PyThread_exit_thread(void)
{ {
dprintf(("PyThread_exit_thread called\n")); dprintf(("PyThread_exit_thread called\n"));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(0);
else
exit(0);
if (ussetlock(count_lock) < 0) if (ussetlock(count_lock) < 0)
perror("ussetlock (count_lock)"); perror("ussetlock (count_lock)");
nthreads--; nthreads--;
if (getpid() == my_pid) { if (getpid() == my_pid) {
/* main thread; wait for other threads to exit */ /* main thread; wait for other threads to exit */
exiting = 1; exiting = 1;
#ifndef NO_EXIT_PROG
if (do_exit) {
int i;
/* notify other threads */
clean_threads();
if (nthreads >= 0) {
dprintf(("kill other threads\n"));
for (i = 0; i < maxpidindex; i++)
if (pidlist[i].child > 0)
(void) kill(pidlist[i].child,
SIGKILL);
_exit(exit_status);
}
}
#endif /* NO_EXIT_PROG */
waiting_for_threads = 1; waiting_for_threads = 1;
if (ussetlock(wait_lock) < 0) if (ussetlock(wait_lock) < 0)
perror("ussetlock (wait_lock)"); perror("ussetlock (wait_lock)");
for (;;) { for (;;) {
if (nthreads < 0) { if (nthreads < 0) {
dprintf(("really exit (%d)\n", exit_status)); dprintf(("really exit (%d)\n", exit_status));
if (no_cleanup) exit(exit_status);
_exit(exit_status);
else
exit(exit_status);
} }
if (usunsetlock(count_lock) < 0) if (usunsetlock(count_lock) < 0)
perror("usunsetlock (count_lock)"); perror("usunsetlock (count_lock)");
...@@ -283,50 +206,11 @@ static void do_PyThread_exit_thread(int no_cleanup) ...@@ -283,50 +206,11 @@ static void do_PyThread_exit_thread(int no_cleanup)
if (usunsetlock(wait_lock) < 0) if (usunsetlock(wait_lock) < 0)
perror("usunsetlock (wait_lock)"); perror("usunsetlock (wait_lock)");
} }
#ifndef NO_EXIT_PROG
else if (do_exit)
(void) kill(my_pid, SIGUSR1);
#endif /* NO_EXIT_PROG */
if (usunsetlock(count_lock) < 0) if (usunsetlock(count_lock) < 0)
perror("usunsetlock (count_lock)"); perror("usunsetlock (count_lock)");
_exit(0); _exit(0);
} }
void PyThread_exit_thread(void)
{
do_PyThread_exit_thread(0);
}
void PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized)
if (no_cleanup)
_exit(status);
else
exit(status);
do_exit = 1;
exit_status = status;
do_PyThread_exit_thread(no_cleanup);
}
void PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
}
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
*/ */
......
...@@ -64,58 +64,14 @@ PyThread_get_thread_ident(void) ...@@ -64,58 +64,14 @@ PyThread_get_thread_ident(void)
return thr_self(); return thr_self();
} }
static void
do_PyThread_exit_thread(int no_cleanup)
{
dprintf(("PyThread_exit_thread called\n"));
if (!initialized)
if (no_cleanup)
_exit(0);
else
exit(0);
thr_exit(0);
}
void void
PyThread_exit_thread(void) PyThread_exit_thread(void)
{ {
do_PyThread_exit_thread(0); dprintf(("PyThread_exit_thread called\n"));
}
void
PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void
do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(status); thr_exit(0);
else
exit(status);
if (no_cleanup)
_exit(status);
else
exit(status);
}
void
PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void
PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
} }
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. * Lock support.
......
...@@ -53,48 +53,13 @@ long PyThread_get_thread_ident(void) ...@@ -53,48 +53,13 @@ long PyThread_get_thread_ident(void)
return GetCurrentThreadId(); return GetCurrentThreadId();
} }
static void do_PyThread_exit_thread(int no_cleanup)
{
dprintf(("%ld: do_PyThread_exit_thread called\n", PyThread_get_thread_ident()));
if (!initialized)
if (no_cleanup)
exit(0); /* XXX - was _exit()!! */
else
exit(0);
_endthread();
}
void PyThread_exit_thread(void) void PyThread_exit_thread(void)
{ {
do_PyThread_exit_thread(0); dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
}
void PyThread__exit_thread(void)
{
do_PyThread_exit_thread(1);
}
#ifndef NO_EXIT_PROG
static void do_PyThread_exit_prog(int status, int no_cleanup)
{
dprintf(("PyThread_exit_prog(%d) called\n", status));
if (!initialized) if (!initialized)
if (no_cleanup) exit(0);
_exit(status); _endthread();
else
exit(status);
}
void PyThread_exit_prog(int status)
{
do_PyThread_exit_prog(status, 0);
}
void PyThread__exit_prog(int status)
{
do_PyThread_exit_prog(status, 1);
} }
#endif /* NO_EXIT_PROG */
/* /*
* Lock support. It has to be implemented using Mutexes, as * Lock support. It has to be implemented using Mutexes, as
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment