FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

#4852: Remove dead code in every thread implementation, unused for ma… · python/cpython@adfc80b · GitHub

/ cpython Public

Commit adfc80b

Browse files
committed
#4852: Remove dead code in every thread implementation, unused for many years.
1 parent f20f9c2 commit adfc80b

16 files changed

Lines changed: 28 additions & 575 deletions

‎Include/pythread.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#ifndef Py_PYTHREAD_H
33
#define Py_PYTHREAD_H
44

5-
#define NO_EXIT_PROG /* don't define PyThread_exit_prog() */
6-
/* (the result is no use of signals on SGI) */
7-
85
typedef void *PyThread_type_lock;
96
typedef void *PyThread_type_sema;
107

@@ -15,7 +12,6 @@ extern "C" {
1512
PyAPI_FUNC(void) PyThread_init_thread(void);
1613
PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
1714
PyAPI_FUNC(void) PyThread_exit_thread(void);
18-
PyAPI_FUNC(void) PyThread__PyThread_exit_thread(void);
1915
PyAPI_FUNC(long) PyThread_get_thread_ident(void);
2016

2117
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
@@ -28,11 +24,6 @@ PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
2824
PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
2925
PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
3026

31-
#ifndef NO_EXIT_PROG
32-
PyAPI_FUNC(void) PyThread_exit_prog(int);
33-
PyAPI_FUNC(void) PyThread__PyThread_exit_prog(int);
34-
#endif
35-
3627
/* Thread Local Storage (TLS) API */
3728
PyAPI_FUNC(int) PyThread_create_key(void);
3829
PyAPI_FUNC(void) PyThread_delete_key(int);

‎Modules/threadmodule.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,6 @@ Raise a KeyboardInterrupt in the main thread.\n\
558558
A subthread can use this function to interrupt the main thread."
559559
);
560560

561-
#ifndef NO_EXIT_PROG
562-
static PyObject *
563-
thread_PyThread_exit_prog(PyObject *self, PyObject *args)
564-
{
565-
int sts;
566-
if (!PyArg_ParseTuple(args, "i:exit_prog", &sts))
567-
return NULL;
568-
Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */
569-
for (;;) { } /* Should not be reached */
570-
}
571-
#endif
572-
573561
static lockobject *newlockobject(void);
574562

575563
static PyObject *
@@ -703,10 +691,6 @@ static PyMethodDef thread_methods[] = {
703691
{"stack_size", (PyCFunction)thread_stack_size,
704692
METH_VARARGS,
705693
stack_size_doc},
706-
#ifndef NO_EXIT_PROG
707-
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog,
708-
METH_VARARGS},
709-
#endif
710694
{NULL, NULL} /* sentinel */
711695
};
712696

‎PC/os2emx/python27.def‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,6 @@ EXPORTS
11601160
"PyThread_delete_key"
11611161
"PyThread_set_key_value"
11621162
"PyThread_get_key_value"
1163-
"PyThread__exit_thread"
11641163

11651164
; From python27_s.lib(gcmodule)
11661165
; "initgc"

‎PC/os2vacpp/python.def‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ EXPORTS
368368
PyThreadState_GetDict
369369
PyThreadState_New
370370
PyThreadState_Swap
371-
PyThread__exit_thread
372371
PyThread_acquire_lock
373372
PyThread_allocate_lock
374373
PyThread_allocate_sema

‎Python/thread_atheos.h‎

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -128,62 +128,21 @@ long PyThread_get_thread_ident(void)
128128
}
129129

130130

131-
static void do_PyThread_exit_thread(int no_cleanup)
131+
void PyThread_exit_thread(void)
132132
{
133133
dprintf(("PyThread_exit_thread called\n"));
134134

135135
/* Thread-safe way to read a variable without a mutex: */
136136
if (atomic_add(&thread_count, 0) == 0) {
137137
/* No threads around, so exit main(). */
138-
if (no_cleanup)
139-
_exit(0);
140-
else
141-
exit(0);
138+
exit(0);
142139
} else {
143140
/* We're a thread */
144141
exit_thread(0);
145142
}
146143
}
147144

148145

149-
void PyThread_exit_thread(void)
150-
{
151-
do_PyThread_exit_thread(0);
152-
}
153-
154-
155-
void PyThread__exit_thread(void)
156-
{
157-
do_PyThread_exit_thread(1);
158-
}
159-
160-
161-
#ifndef NO_EXIT_PROG
162-
static void do_PyThread_exit_prog(int status, int no_cleanup)
163-
{
164-
dprintf(("PyThread_exit_prog(%d) called\n", status));
165-
166-
/* No need to do anything, the threads get torn down if main()exits. */
167-
if (no_cleanup)
168-
_exit(status);
169-
else
170-
exit(status);
171-
}
172-
173-
174-
void PyThread_exit_prog(int status)
175-
{
176-
do_PyThread_exit_prog(status, 0);
177-
}
178-
179-
180-
void PyThread__exit_prog(int status)
181-
{
182-
do_PyThread_exit_prog(status, 1);
183-
}
184-
#endif /* NO_EXIT_PROG */
185-
186-
187146
/*
188147
* Lock support.
189148
*

‎Python/thread_beos.h‎

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ long PyThread_get_thread_ident( void )
144144
return ( tid != B_NAME_NOT_FOUND ? tid : -1 );
145145
}
146146

147-
static void do_PyThread_exit_thread( int no_cleanup )
147+
void PyThread_exit_thread( void )
148148
{
149149
int32 threads;
150150

@@ -155,52 +155,13 @@ static void do_PyThread_exit_thread( int no_cleanup )
155155

156156
if( threads == 0 ) {
157157
/* No threads around, so exit main(). */
158-
if( no_cleanup ) {
159-
_exit(0);
160-
} else {
161-
exit(0);
162-
}
158+
exit(0);
163159
} else {
164160
/* Oh, we're a thread, let's try to exit gracefully... */
165161
exit_thread( B_NO_ERROR );
166162
}
167163
}
168164

169-
void PyThread_exit_thread( void )
170-
{
171-
do_PyThread_exit_thread(0);
172-
}
173-
174-
void PyThread__exit_thread( void )
175-
{
176-
do_PyThread_exit_thread(1);
177-
}
178-
179-
#ifndef NO_EXIT_PROG
180-
static void do_PyThread_exit_prog( int status, int no_cleanup )
181-
{
182-
dprintf(("PyThread_exit_prog(%d) called\n", status));
183-
184-
/* No need to do anything, the threads get torn down if main() exits. */
185-
186-
if (no_cleanup) {
187-
_exit(status);
188-
} else {
189-
exit(status);
190-
}
191-
}
192-
193-
void PyThread_exit_prog( int status )
194-
{
195-
do_PyThread_exit_prog(status, 0);
196-
}
197-
198-
void PyThread__exit_prog( int status )
199-
{
200-
do_PyThread_exit_prog(status, 1);
201-
}
202-
#endif /* NO_EXIT_PROG */
203-
204165
/* ----------------------------------------------------------------------
205166
* Lock support.
206167
*/

‎Python/thread_cthread.h‎

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -50,58 +50,14 @@ PyThread_get_thread_ident(void)
5050
return (long) cthread_self();
5151
}
5252

53-
static void
54-
do_PyThread_exit_thread(int no_cleanup)
55-
{
56-
dprintf(("PyThread_exit_thread called\n"));
57-
if (!initialized)
58-
if (no_cleanup)
59-
_exit(0);
60-
else
61-
exit(0);
62-
cthread_exit(0);
63-
}
64-
6553
void
6654
PyThread_exit_thread(void)
6755
{
68-
do_PyThread_exit_thread(0);
69-
}
70-
71-
void
72-
PyThread__exit_thread(void)
73-
{
74-
do_PyThread_exit_thread(1);
75-
}
76-
77-
#ifndef NO_EXIT_PROG
78-
static
79-
void do_PyThread_exit_prog(int status, int no_cleanup)
80-
{
81-
dprintf(("PyThread_exit_prog(%d) called\n", status));
56+
dprintf(("PyThread_exit_thread called\n"));
8257
if (!initialized)
83-
if (no_cleanup)
84-
_exit(status);
85-
else
86-
exit(status);
87-
if (no_cleanup)
88-
_exit(status);
89-
else
90-
exit(status);
91-
}
92-
93-
void
94-
PyThread_exit_prog(int status)
95-
{
96-
do_PyThread_exit_prog(status, 0);
97-
}
98-
99-
void
100-
PyThread__exit_prog(int status)
101-
{
102-
do_PyThread_exit_prog(status, 1);
58+
exit(0);
59+
cthread_exit(0);
10360
}
104-
#endif /* NO_EXIT_PROG */
10561

10662
/*
10763
* Lock support.

‎Python/thread_foobar.h‎

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,13 @@ PyThread_get_thread_ident(void)
2929
PyThread_init_thread();
3030
}
3131

32-
static
33-
void do_PyThread_exit_thread(int no_cleanup)
34-
{
35-
dprintf(("PyThread_exit_thread called\n"));
36-
if (!initialized)
37-
if (no_cleanup)
38-
_exit(0);
39-
else
40-
exit(0);
41-
}
42-
4332
void
4433
PyThread_exit_thread(void)
4534
{
46-
do_PyThread_exit_thread(0);
47-
}
48-
49-
void
50-
PyThread__exit_thread(void)
51-
{
52-
do_PyThread_exit_thread(1);
53-
}
54-
55-
#ifndef NO_EXIT_PROG
56-
static
57-
void do_PyThread_exit_prog(int status, int no_cleanup)
58-
{
59-
dprintf(("PyThread_exit_prog(%d) called\n", status));
35+
dprintf(("PyThread_exit_thread called\n"));
6036
if (!initialized)
61-
if (no_cleanup)
62-
_exit(status);
63-
else
64-
exit(status);
65-
}
66-
67-
void
68-
PyThread_exit_prog(int status)
69-
{
70-
do_PyThread_exit_prog(status, 0);
71-
}
72-
73-
void
74-
PyThread__exit_prog(int status)
75-
{
76-
do_PyThread_exit_prog(status, 1);
37+
exit(0);
7738
}
78-
#endif /* NO_EXIT_PROG */
7939

8040
/*
8141
* Lock support.

‎Python/thread_lwp.h‎

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,50 +47,14 @@ long PyThread_get_thread_ident(void)
4747
return tid.thread_id;
4848
}
4949

50-
static void do_PyThread_exit_thread(int no_cleanup)
50+
void PyThread_exit_thread(void)
5151
{
5252
dprintf(("PyThread_exit_thread called\n"));
5353
if (!initialized)
54-
if (no_cleanup)
55-
_exit(0);
56-
else
57-
exit(0);
54+
exit(0);
5855
lwp_destroy(SELF);
5956
}
6057

61-
void PyThread_exit_thread(void)
62-
{
63-
do_PyThread_exit_thread(0);
64-
}
65-
66-
void PyThread__exit_thread(void)
67-
{
68-
do_PyThread_exit_thread(1);
69-
}
70-
71-
#ifndef NO_EXIT_PROG
72-
static void do_PyThread_exit_prog(int status, int no_cleanup)
73-
{
74-
dprintf(("PyThread_exit_prog(%d) called\n", status));
75-
if (!initialized)
76-
if (no_cleanup)
77-
_exit(status);
78-
else
79-
exit(status);
80-
pod_exit(status);
81-
}
82-
83-
void PyThread_exit_prog(int status)
84-
{
85-
do_PyThread_exit_prog(status, 0);
86-
}
87-
88-
void PyThread__exit_prog(int status)
89-
{
90-
do_PyThread_exit_prog(status, 1);
91-
}
92-
#endif /* NO_EXIT_PROG */
93-
9458
/*
9559
* Lock support.
9660
*/

‎Python/thread_nt.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,6 @@ PyThread_exit_thread(void)
203203
#endif
204204
}
205205

206-
#ifndef NO_EXIT_PROG
207-
void
208-
PyThread_exit_prog(int status)
209-
{
210-
dprintf(("PyThread_exit_prog(%d) called\n", status));
211-
if (!initialized)
212-
exit(status);
213-
}
214-
#endif /* NO_EXIT_PROG */
215-
216206
/*
217207
* Lock support. It has too be implemented as semaphores.
218208
* I [Dag] tried to implement it with mutex but I could find a way to

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL