[PATCH] Make SIG2STR_MAX usable in #if

Mingye Wang <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAD66C+bisTo5xtQ+-M5C+Tc+7vV3HvLK9PdX5gn8wjfMeY-FJw@mail.gmail.com>
On Mon, Jun 19, 2023 at 5:00 PM Corinna Vinschen <[email protected]> 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
0802d3650565f4192a931beb9676276480df8fb3.patch.txt (text/plain, 1.1 KB)
From 0802d3650565f4192a931beb9676276480df8fb3 Mon Sep 17 00:00:00 2001
From: Mingye Wang <[email protected]>
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 *);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.