Hi Bruno,
On AIX 7.3 (cfarm119) you can see the following warning:
$ gnulib-tool --create-testdir --dir testdir1 thrd
$ cd testdir1 && ./configure && make
[...]
depbase=`echo thrd.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -D_THREAD_SAFE -g
-O2 -MT thrd.o -MD -MP -MF $depbase.Tpo -c -o thrd.o thrd.c &&\
mv -f $depbase.Tpo $depbase.Po
thrd.c: In function 'rpl_thrd_create':
thrd.c:116:51: warning: passing argument 2 of 'thrd_create' from
incompatible pointer type [-Wincompatible-pointer-types]
116 | thrd_create ((thrd_t *) &main_arg->t.tid, thrd_main_func,
main_arg);
| ^~~~~~~~~~~~~~
| |
| void * (*)(void *)
In file included from ./threads.h:43,
from thrd.c:22:
/usr/include/threads.h:100:39: note: expected 'thrd_start_t' {aka 'int
(*)(void *)'} but argument is of type 'void * (*)(void *)'
100 | thrd_create(thrd_t *thr, thrd_start_t func,void *arg);
| ~~~~~~~~~~~~~^~~~
Since this becomes an error by default in newer versions of GCC than are
on this machine (GCC 14, IIRC), I think it should be fixed.
The issue is on AIX ≤ 7.2, thrd_start_t is defined to the wrong
type. The static 'thrd_main_func' wrapper uses that type to call the
system's thrd_create. However, on AIX 7.3 this type was fixed. We still
need to compile this file though since thrd_join does not store the exit
code.
How about the attached patch to fix it? Maybe you can think of a cleaner
way to do it without the function cast.
Collin
>From 47cbc846b6b082ce5741fda20690a04f47c2e098 Mon Sep 17 00:00:00 2001
Message-ID: <47cbc846b6b082ce5741fda20690a04f47c2e098.1753212997.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Tue, 22 Jul 2025 12:36:04 -0700
Subject: [PATCH] thrd: Fix -Wincompatible-pointer-types on AIX 7.3.
* lib/thrd.c (SYSTEM_THRD_START_T): Define macro.
(rpl_thrd_create): Use it when calling the system's thrd_create
function.
---
ChangeLog | 7 +++++++
lib/thrd.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ac20d475da..37e2ff9ec7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-07-22 Collin Funk <[email protected]>
+
+ thrd: Fix -Wincompatible-pointer-types on AIX 7.3.
+ * lib/thrd.c (SYSTEM_THRD_START_T): Define macro.
+ (rpl_thrd_create): Use it when calling the system's thrd_create
+ function.
+
2025-07-22 Paul Eggert <[email protected]>
mkdir-p: ENOENT/ENOTDIR safety and consistency
diff --git a/lib/thrd.c b/lib/thrd.c
index ea7f0f5397..18e3e3e4a1 100644
--- a/lib/thrd.c
+++ b/lib/thrd.c
@@ -30,6 +30,14 @@
# undef thrd_t
+/* On AIX 7.3 we have to cast to the system's thrd_start_t type before calling
+ the system's thrd_create function. */
+# if !defined thrd_start_t
+# define SYSTEM_THRD_START_T(func) ((int (*) (void *)) func)
+# else
+# define SYSTEM_THRD_START_T(func) (func)
+# endif
+
/* AIX 7.1..7.2 defines thrd_start_t incorrectly, namely as
'void * (*) (void *)' instead of 'int (*) (void *)'.
As a consequence, its thrd_join function never stores an exit code.
@@ -112,8 +120,8 @@ rpl_thrd_create (rpl_thrd_t *threadp, thrd_start_t mainfunc, void *arg)
main_arg->a.arg = arg;
main_arg->t.detached = 0;
{
- int err =
- thrd_create ((thrd_t *) &main_arg->t.tid, thrd_main_func, main_arg);
+ int err = thrd_create ((thrd_t *) &main_arg->t.tid,
+ SYSTEM_THRD_START_T (thrd_main_func), main_arg);
if (err == thrd_success)
*threadp = &main_arg->t;
else
--
2.50.1