bpo-36475: Make PyThread_exit_thread with _Py_NO_RETURN (GH-13068) · python/cpython@c664b34 (original) (raw)
6 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,17 +21,6 @@ PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **); | ||
21 | 21 | PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *); |
22 | 22 | #endif |
23 | 23 | |
24 | -#if defined(__clang__) | | |
25 | - (defined(__GNUC__) && \ | |
26 | - ((__GNUC__ >= 3) | | |
27 | - (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))) | |
28 | -# define _Py_NO_RETURN __attribute__((__noreturn__)) | |
29 | -#elif defined(_MSC_VER) | |
30 | -# define _Py_NO_RETURN __declspec(noreturn) | |
31 | -#else | |
32 | -# define _Py_NO_RETURN | |
33 | -#endif | |
34 | - | |
35 | 24 | /* Defined in Python/pylifecycle.c */ |
36 | 25 | PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message); |
37 | 26 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -829,4 +829,18 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; | ||
829 | 829 | # define _Py_FORCE_UTF8_FS_ENCODING |
830 | 830 | #endif |
831 | 831 | |
832 | +/* Mark a function which cannot return. Example: | |
833 | + | |
834 | + PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); */ | |
835 | +#if defined(__clang__) | | |
836 | + (defined(__GNUC__) && \ | |
837 | + ((__GNUC__ >= 3) | | |
838 | + (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))) | |
839 | +# define _Py_NO_RETURN __attribute__((__noreturn__)) | |
840 | +#elif defined(_MSC_VER) | |
841 | +# define _Py_NO_RETURN __declspec(noreturn) | |
842 | +#else | |
843 | +# define _Py_NO_RETURN | |
844 | +#endif | |
845 | + | |
832 | 846 | #endif /* Py_PYPORT_H */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -23,7 +23,7 @@ typedef enum PyLockStatus { | ||
23 | 23 | |
24 | 24 | PyAPI_FUNC(void) PyThread_init_thread(void); |
25 | 25 | PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *); |
26 | -PyAPI_FUNC(void) PyThread_exit_thread(void); | |
26 | +PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); | |
27 | 27 | PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void); |
28 | 28 | |
29 | 29 | PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -211,7 +211,6 @@ exit_thread_if_finalizing(PyThreadState *tstate) | ||
211 | 211 | if (_Py_IsFinalizing() && !_Py_CURRENTLY_FINALIZING(tstate)) { |
212 | 212 | drop_gil(tstate); |
213 | 213 | PyThread_exit_thread(); |
214 | -Py_UNREACHABLE(); | |
215 | 214 | } |
216 | 215 | } |
217 | 216 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -227,7 +227,7 @@ PyThread_get_thread_ident(void) | ||
227 | 227 | return GetCurrentThreadId(); |
228 | 228 | } |
229 | 229 | |
230 | -void | |
230 | +void _Py_NO_RETURN | |
231 | 231 | PyThread_exit_thread(void) |
232 | 232 | { |
233 | 233 | dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident())); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -302,7 +302,7 @@ PyThread_get_thread_ident(void) | ||
302 | 302 | return (unsigned long) threadid; |
303 | 303 | } |
304 | 304 | |
305 | -void | |
305 | +void _Py_NO_RETURN | |
306 | 306 | PyThread_exit_thread(void) |
307 | 307 | { |
308 | 308 | dprintf(("PyThread_exit_thread called\n")); |