Eric Gallager wrote:
> Hi, I'm writing about gnulib's documentation for psignal:
> https://www.gnu.org/software/gnulib//manual/html_node/psignal.html
> One thing I'm not seeing mentioned in it is how the first argument can
> sometimes have different types. While POSIX says the first type should
> be int, on my macOS system, it's unsigned int. Libiberty changed its
> type from unsigned int to int in 2007:
> https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ae452ed134d3de34c430ecd901484a57482d581b

Indeed. I'm adding the doc update below.

> I'm not quite sure what the best way to handle this possible
> portability difference would be. Perhaps the gnulib manual could
> suggest something?

Gnulib does not support this function, because it's rarely used:
The typical place to invoke it would be inside a signal handler.
But you can't invoke it in a signal handler, since it is not
async-signal safe.
<https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04_03>

What to do in your package, depends on your portability requirements.
- If you need to provide the function where it does not exist, do so.
- If you need to declare the function where the declaration is missing,
  include <siginfo.h>.
- The difference in the first argument type is not a problem, if you don't
  cast the function to a function pointer.

Bruno


2024-08-27  Bruno Haible  <br...@clisp.org>

        doc: Update about psignal.
        Reported by Eric Gallager <eg...@gwmail.gwu.edu> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2024-08/msg00177.html>.
        * doc/posix-functions/psignal.texi: Mention the Solaris problem and the
        first parameter type.

diff --git a/doc/posix-functions/psignal.texi b/doc/posix-functions/psignal.texi
index 12b0a46bb5..4ff2a37ab4 100644
--- a/doc/posix-functions/psignal.texi
+++ b/doc/posix-functions/psignal.texi
@@ -14,5 +14,13 @@
 @itemize
 @item
 This function is missing on some platforms:
-Minix 3.1.8, HP-UX 11, Cygwin 1.7.9, mingw, MSVC 14, Android 4.1.
+Minix 3.1.8, HP-UX 11, Cygwin 1.7.9, mingw, MSVC 14, Android API level 16.
+@item
+This function is declared in @code{<siginfo.h>}, not @code{<signal.h>},
+on some platforms:
+Solaris 11.3.
+@item
+The first parameter is of type @code{unsigned int}, not @code{int},
+on some platforms:
+macOS 13, FreeBSD 10.4, NetBSD 5.1, OpenBSD 7.5.
 @end itemize




Reply via email to