bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pselect: Fix compilation error in C++ mode on AIX 7


From: Bruno Haible
Subject: pselect: Fix compilation error in C++ mode on AIX 7
Date: Sun, 26 Dec 2021 12:58:28 +0100

In a testdir on AIX 7, with xlc and xlC, I'm seeing this compilation error:

source='../../gltests/test-sys_select-c++.cc' object='test-sys_select-c++.o' 
libtool=no  DEPDIR=.deps depmode=xlc /bin/sh ../../build-aux/depcomp  xlC -q64 
-qthreaded -qtls -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..   
-DGNULIB_STRICT_CHECKING=1  -DIN_GNULIB_TESTS=1  -I. -I../../gltests  -I.. 
-I../../gltests/..  -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix64/include -D_THREAD_SAFE  -g -c -o test-sys_select-c++.o 
../../gltests/test-sys_select-c++.cc
"../gllib/sys/select.h", line 763.1: 1540-0258 (S) A return value of type "int 
(*)(int, fd_set * restrict, fd_set * restrict, fd_set * restrict, const 
timespec * restrict, const sigset_t * restrict)" cannot be initialized with an 
expression of type "extern "C" int (int, void * restrict, void * restrict, void 
* restrict, const timespec * restrict, const sigset_t * restrict)".
make: 1254-004 The error code from the last command is 1.

The problem is the declaration of 'pselect', which is POSIX compliant

extern int pselect(int, fd_set *__restrict__, fd_set *__restrict__, fd_set 
*__restrict__, const struct timespec *__restrict__, const sigset_t 
*__restrict__);

if _ALL_SOURCE is not defined, but looks like this if _ALL_SOURCE is defined:

extern int pselect(int, void *__restrict__, void *__restrict__, void 
*__restrict__, const struct timespec *__restrict__, const sigset_t 
*__restrict__);


2021-12-26  Bruno Haible  <bruno@clisp.org>

        pselect: Fix compilation error in C++ mode on AIX 7.
        * lib/sys_select.in.h (pselect): Use _GL_CXXALIAS_SYS_CAST instead of
        _GL_CXXALIAS_SYS.
        * doc/posix-functions/pselect.texi: Mention the AIX problem.

diff --git a/doc/posix-functions/pselect.texi b/doc/posix-functions/pselect.texi
index ce26c1688..83323e5c5 100644
--- a/doc/posix-functions/pselect.texi
+++ b/doc/posix-functions/pselect.texi
@@ -20,6 +20,9 @@ FreeBSD 8.2.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+This function has a slightly incompatible declaration on some platforms:
+AIX 7.1 (when @code{_ALL_SOURCE} is defined).
+@item
 When the @var{sigmask} argument is nonnull on platforms that do not
 natively support this function, race conditions are possible when its
 gnulib implementation temporarily modifies the signal mask, and the
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 910bea5d1..e95e7e77c 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -279,9 +279,13 @@ _GL_FUNCDECL_SYS (pselect, int,
                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
                    struct timespec const *restrict, const sigset_t *restrict));
 #  endif
-_GL_CXXALIAS_SYS (pselect, int,
-                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
-                   struct timespec const *restrict, const sigset_t *restrict));
+/* Need to cast, because on AIX 7, the second, third, fourth argument may be
+                        void *restrict,   void *restrict,   void *restrict.  */
+_GL_CXXALIAS_SYS_CAST (pselect, int,
+                       (int,
+                        fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                        struct timespec const *restrict,
+                        const sigset_t *restrict));
 # endif
 _GL_CXXALIASWARN (pselect);
 #elif defined GNULIB_POSIXCHECK






reply via email to

[Prev in Thread] Current Thread [Next in Thread]