* lib/threads.in.h (thrd_exit): Consider REPLACE_THRD_EXIT.
* lib/thrd.c (rpl_thrd_exit): New function.
* m4/threads_h.m4 (gl_THREADS_H_DEFAULTS): Initialize REPLACE_THRD_EXIT.
* m4/thrd.m4 (gl_FUNC_THRD_JOIN): Set also REPLACE_THRD_EXIT and adjust
LIBSTDTHREAD.
* modules/threads-h (Makefile.am): Substitute REPLACE_THRD_EXIT.
* doc/posix-functions/thrd_exit.texi: Mention the AIX thrd_join problem
also here.
+2023-08-18 Bruno Haible <bruno@clisp.org>
+
+ thrd: On AIX 7.1 and 7.2, override also thrd_exit.
+ * lib/threads.in.h (thrd_exit): Consider REPLACE_THRD_EXIT.
+ * lib/thrd.c (rpl_thrd_exit): New function.
+ * m4/threads_h.m4 (gl_THREADS_H_DEFAULTS): Initialize REPLACE_THRD_EXIT.
+ * m4/thrd.m4 (gl_FUNC_THRD_JOIN): Set also REPLACE_THRD_EXIT and adjust
+ LIBSTDTHREAD.
+ * modules/threads-h (Makefile.am): Substitute REPLACE_THRD_EXIT.
+ * doc/posix-functions/thrd_exit.texi: Mention the AIX thrd_join problem
+ also here.
+
2023-08-18 Bruno Haible <bruno@clisp.org>
aligned_alloc: Fix test failure on AIX 7.3 with ibm-clang.
@item
This function is missing on many platforms:
glibc 2.27, macOS 11.1, FreeBSD 9.3, NetBSD 8.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
+@item
+The exit code provided to this function is discarded on some platforms:
+AIX 7.2.
@end itemize
Portability problems not fixed by Gnulib:
}
}
+_Noreturn void
+rpl_thrd_exit (int exitcode)
+{
+ rpl_thrd_t t = rpl_thrd_current ();
+
+ /* Store the exitcode, for use by thrd_join(). */
+ t->exitcode = exitcode;
+ if (t->detached)
+ {
+ /* Clean up the thread, like thrd_join would do. */
+ free (t);
+ }
+ pthread_exit (NULL);
+}
+
# endif
# if BROKEN_THRD_JOIN
#endif
#if @GNULIB_THRD@
-# if !@HAVE_THREADS_H@
+# if @REPLACE_THRD_EXIT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define thrd_exit rpl_thrd_exit
+# endif
+_GL_FUNCDECL_RPL (thrd_exit, _Noreturn void, (int));
+_GL_CXXALIAS_RPL (thrd_exit, void, (int));
+# else
+# if !@HAVE_THREADS_H@
_GL_FUNCDECL_SYS (thrd_exit, _Noreturn void, (int));
-# endif
+# endif
/* Need to cast because of AIX with xlclang++. */
_GL_CXXALIAS_SYS_CAST (thrd_exit, void, (int));
+# endif
_GL_CXXALIASWARN (thrd_exit);
#elif defined GNULIB_POSIXCHECK
# undef thrd_exit
-# thrd.m4 serial 1
+# thrd.m4 serial 2
dnl Copyright (C) 2019-2023 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_CURRENT=1
REPLACE_THRD_DETACH=1
REPLACE_THRD_EQUAL=1
+ REPLACE_THRD_EXIT=1
REPLACE_THRD_JOIN=1
AC_DEFINE([BROKEN_THRD_START_T], [1],
[Define if the thrd_start_t type is not as described in ISO C 11.])
+ dnl The thrd_exit replacement relies on pthread_exit, which on AIX is in
+ dnl libpthread.
+ LIBSTDTHREAD="$LIBSTDTHREAD $LIBPTHREAD"
fi
dnl On Solaris 11.4, thrd_join crashes when the second argument is NULL.
-# threads_h.m4 serial 10
+# threads_h.m4 serial 10.1
dnl Copyright (C) 2019-2023 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_CURRENT=0; AC_SUBST([REPLACE_THRD_CURRENT])
REPLACE_THRD_DETACH=0; AC_SUBST([REPLACE_THRD_DETACH])
REPLACE_THRD_EQUAL=0; AC_SUBST([REPLACE_THRD_EQUAL])
+ REPLACE_THRD_EXIT=0; AC_SUBST([REPLACE_THRD_EXIT])
REPLACE_THRD_JOIN=0; AC_SUBST([REPLACE_THRD_JOIN])
])
-e 's|@''REPLACE_THRD_CURRENT''@|$(REPLACE_THRD_CURRENT)|g' \
-e 's|@''REPLACE_THRD_DETACH''@|$(REPLACE_THRD_DETACH)|g' \
-e 's|@''REPLACE_THRD_EQUAL''@|$(REPLACE_THRD_EQUAL)|g' \
+ -e 's|@''REPLACE_THRD_EXIT''@|$(REPLACE_THRD_EXIT)|g' \
-e 's|@''REPLACE_THRD_JOIN''@|$(REPLACE_THRD_JOIN)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _Noreturn/r $(_NORETURN_H)' \