mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-05-13 15:13:36 +00:00
thrd: Avoid conversion between different function pointer types.
Reported by Collin Funk in <https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00170.html>. * m4/thrd.m4 (gl_FUNC_THRD_JOIN): Define BROKEN_THRD_START_T or BROKEN_THRD_JOIN. Don't define BROKEN_THRD_START_T_OR_JOIN. * lib/thrd.c (thrd_main_func): Define with the right return type, depending on BROKEN_THRD_START_T.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2025-07-23 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
thrd: Avoid conversion between different function pointer types.
|
||||
Reported by Collin Funk in
|
||||
<https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00170.html>.
|
||||
* m4/thrd.m4 (gl_FUNC_THRD_JOIN): Define BROKEN_THRD_START_T or
|
||||
BROKEN_THRD_JOIN. Don't define BROKEN_THRD_START_T_OR_JOIN.
|
||||
* lib/thrd.c (thrd_main_func): Define with the right return type,
|
||||
depending on BROKEN_THRD_START_T.
|
||||
|
||||
2025-07-22 Collin Funk <collin.funk1@gmail.com>
|
||||
Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
|
||||
13
lib/thrd.c
13
lib/thrd.c
@@ -26,7 +26,7 @@
|
||||
#if HAVE_THREADS_H
|
||||
/* Provide workarounds. */
|
||||
|
||||
# if BROKEN_THRD_START_T_OR_JOIN
|
||||
# if BROKEN_THRD_START_T || BROKEN_THRD_JOIN
|
||||
|
||||
# undef thrd_t
|
||||
|
||||
@@ -70,7 +70,12 @@ typedef union
|
||||
}
|
||||
main_arg_t;
|
||||
|
||||
static void *
|
||||
static
|
||||
# if BROKEN_THRD_START_T
|
||||
void *
|
||||
# else /* BROKEN_THRD_JOIN */
|
||||
int
|
||||
# endif
|
||||
thrd_main_func (void *pmarg)
|
||||
{
|
||||
/* Unpack the object that combines mainfunc and arg. */
|
||||
@@ -91,7 +96,11 @@ thrd_main_func (void *pmarg)
|
||||
/* Clean up the thread, like thrd_join would do. */
|
||||
free (&main_arg->t);
|
||||
}
|
||||
# if BROKEN_THRD_START_T
|
||||
return NULL;
|
||||
# else /* BROKEN_THRD_JOIN */
|
||||
return 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
m4/thrd.m4
11
m4/thrd.m4
@@ -1,5 +1,5 @@
|
||||
# thrd.m4
|
||||
# serial 6
|
||||
# serial 7
|
||||
dnl Copyright (C) 2019-2025 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
@@ -39,8 +39,13 @@ AC_DEFUN([gl_FUNC_THRD_JOIN],
|
||||
REPLACE_THRD_EQUAL=1
|
||||
REPLACE_THRD_EXIT=1
|
||||
REPLACE_THRD_JOIN=1
|
||||
AC_DEFINE([BROKEN_THRD_START_T_OR_JOIN], [1],
|
||||
[Define if the thrd_start_t type is not as described in ISO C 11 or if thrd_join discards the thread's exit code.])
|
||||
if test $BROKEN_THRD_START_T = 1; then
|
||||
AC_DEFINE([BROKEN_THRD_START_T], [1],
|
||||
[Define if the thrd_start_t type is not as described in ISO C 11.])
|
||||
else
|
||||
AC_DEFINE([BROKEN_THRD_JOIN], [1],
|
||||
[Define if thrd_start_t is OK but thrd_join discards the thread's exit code.])
|
||||
fi
|
||||
dnl The thrd_exit replacement relies on pthread_exit, which on AIX is in
|
||||
dnl libpthread.
|
||||
LIBSTDTHREAD="$LIBSTDTHREAD $LIBPTHREAD"
|
||||
|
||||
Reference in New Issue
Block a user