+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>
#if HAVE_THREADS_H
/* Provide workarounds. */
-# if BROKEN_THRD_START_T_OR_JOIN
+# if BROKEN_THRD_START_T || BROKEN_THRD_JOIN
# undef thrd_t
}
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. */
/* 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
}
}
# 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,
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"