Skip to content

Commit

Permalink
Mark win32's pthread_exit() as NORETURN
Browse files Browse the repository at this point in the history
The pthread_exit() function is not expected to return. Ever. On Windows,
we call ExitThread() whose documentation claims: "Ends the calling
thread", i.e. there is no condition in which this function simply
returns: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682659

While at it, fix the return type to be void, as per
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html

Pointed out by Jeff King, helped by Stefan Naewe, Junio Hamano &
Johannes Sixt.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Mar 2, 2016
1 parent 326e5bc commit 296d673
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compat/win32/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern int win32_pthread_join(pthread_t *thread, void **value_ptr);
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
extern pthread_t pthread_self(void);

static inline int pthread_exit(void *ret)
static inline void NORETURN pthread_exit(void *ret)
{
ExitThread((DWORD)ret);
}
Expand Down

0 comments on commit 296d673

Please sign in to comment.