Skip to content

bpo-36475: Make PyThread_exit_thread with _Py_NO_RETURN #13068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Include/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
#endif

#if defined(__clang__) || \
(defined(__GNUC__) && \
((__GNUC__ >= 3) || \
(__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
# define _Py_NO_RETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER)
# define _Py_NO_RETURN __declspec(noreturn)
#else
# define _Py_NO_RETURN
#endif

/* Defined in Python/pylifecycle.c */
PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);

Expand Down
14 changes: 14 additions & 0 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -829,4 +829,18 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler;
# define _Py_FORCE_UTF8_FS_ENCODING
#endif

/* Mark a function which cannot return. Example:

PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); */
#if defined(__clang__) || \
(defined(__GNUC__) && \
((__GNUC__ >= 3) || \
(__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
# define _Py_NO_RETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER)
# define _Py_NO_RETURN __declspec(noreturn)
#else
# define _Py_NO_RETURN
#endif

#endif /* Py_PYPORT_H */
2 changes: 1 addition & 1 deletion Include/pythread.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef enum PyLockStatus {

PyAPI_FUNC(void) PyThread_init_thread(void);
PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *);
PyAPI_FUNC(void) PyThread_exit_thread(void);
PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);

PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
Expand Down
1 change: 0 additions & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ exit_thread_if_finalizing(PyThreadState *tstate)
if (_Py_IsFinalizing() && !_Py_CURRENTLY_FINALIZING(tstate)) {
drop_gil(tstate);
PyThread_exit_thread();
Py_UNREACHABLE();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Python/thread_nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ PyThread_get_thread_ident(void)
return GetCurrentThreadId();
}

void
void _Py_NO_RETURN
PyThread_exit_thread(void)
{
dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
Expand Down
2 changes: 1 addition & 1 deletion Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ PyThread_get_thread_ident(void)
return (unsigned long) threadid;
}

void
void _Py_NO_RETURN
PyThread_exit_thread(void)
{
dprintf(("PyThread_exit_thread called\n"));
Expand Down