[PATCH] Make SIG2STR_MAX usable in #if

Mingye Wang arthur200126@gmail.com
Wed Jun 21 01:22:00 GMT 2023


On Mon, Jun 19, 2023 at 5:00 PM Corinna Vinschen <vinschen@redhat.com> wrote:
>
> We could redefine SIG2STR_MAX as static values (still dependent on
> __SIZEOF_INT__) and prepend the sizeof expressions as comments.
>
> Do you want to provide a patch?

I guess? See the attached file for an attempt.

Uh, what license am I supposed to say I am releasing this patch under?

Sincerely,
Mingye
-------------- next part --------------
From 0802d3650565f4192a931beb9676276480df8fb3 Mon Sep 17 00:00:00 2001
From: Mingye Wang <arthur200126@gmail.com>
Date: Wed, 21 Jun 2023 09:16:06 +0800
Subject: [PATCH] Make SIG2STR_MAX usable in #if

The language accepted for POSIX issue 8 requires that SIG2STR_MAX be usable in #if, which we currently break with sizeof. Use static values instead.
---
 newlib/libc/include/sys/signal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h
index 8dc5fb9c34..18fee63691 100644
--- a/newlib/libc/include/sys/signal.h
+++ b/newlib/libc/include/sys/signal.h
@@ -245,9 +245,9 @@ int sigqueue (pid_t, int, const union sigval);
 /* POSIX Issue 8 adds sig2str() and str2sig() */
 
 #if __SIZEOF_INT__ >= 4
-#define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("4294967295") - 1)
+#define SIG2STR_MAX 21	/* (sizeof("RTMAX+") + sizeof("4294967295") - 1) */
 #else
-#define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("65535") - 1)
+#define SIG2STR_MAX 17	/* (sizeof("RTMAX+") + sizeof("65535") - 1) */
 #endif
 
 int sig2str(int, char *);


More information about the Newlib mailing list