From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id DB3793877417; Mon, 2 Aug 2021 14:47:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB3793877417 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] libc: Fix compilation for new sig2str/str2sig implementation X-Act-Checkin: newlib-cygwin X-Git-Author: Christoph Muellner X-Git-Refname: refs/heads/master X-Git-Oldrev: 5970bbded8bfd417861c78cc077444764aa2fe93 X-Git-Newrev: 15c53a34bc944346fde129700a020647095b1b7d Message-Id: <20210802144717.DB3793877417@sourceware.org> Date: Mon, 2 Aug 2021 14:47:17 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2021 14:47:18 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=15c53a34bc944346fde129700a020647095b1b7d commit 15c53a34bc944346fde129700a020647095b1b7d Author: Christoph Muellner Date: Mon Aug 2 16:00:58 2021 +0200 libc: Fix compilation for new sig2str/str2sig implementation A recent patch introduced new code for sig2str/str2sig. This code does not properly exclude code that requires SIGRTMIN/SIGRTMAX to be defined and triggers the following compile error: newlib/libc/signal/sig2str.c:199:8: error: 'SIGRTMIN' undeclared newlib/libc/signal/sig2str.c:200:29: error: 'SIGRTMAX' undeclared Let's add the missing guards. Fixes: 2b50ec0cd205 ("libc: Fix compilation for new sig2str/str2sig implementation") Signed-off-by: Christoph Muellner Diff: --- newlib/libc/signal/sig2str.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c index 940a5eab9..d3be1ba68 100644 --- a/newlib/libc/signal/sig2str.c +++ b/newlib/libc/signal/sig2str.c @@ -194,6 +194,7 @@ sig2str(int signum, char *str) { const sig_name_and_num *sptr; +#if defined (SIGRTMIN) && defined (SIGRTMAX) /* If signum falls in lower half of the real time signals range, define * the saved str value as "RTMIN+n" according to the Issue 8 standard */ if ((SIGRTMIN + 1) <= signum && @@ -209,6 +210,7 @@ sig2str(int signum, char *str) sprintf(str, "RTMAX-%d", (SIGRTMAX - signum)); return 0; } +#endif /* Otherwise, search for signal matching signum in sig_array. If found, * save its string value in str. */ @@ -231,6 +233,7 @@ str2sig(const char *restrict str, int *restrict pnum) const sig_name_and_num *sptr; unsigned long is_valid_decimal; +#if defined (SIGRTMIN) && defined (SIGRTMAX) /* i686 Cygwin only supports one RT signal. For this case, skip checks * for "RTMIN+n" and "RTMAX-m". */ if (SIGRTMIN != SIGRTMAX) { @@ -269,6 +272,7 @@ str2sig(const char *restrict str, int *restrict pnum) return -1; } } +#endif /*If str is a valid signal name, save its corresponding number in pnum. */ for (sptr = sig_array; sptr < &sig_array[NUM_OF_SIGS]; sptr++) { @@ -289,9 +293,10 @@ str2sig(const char *restrict str, int *restrict pnum) /* If str is a representation of a decimal value, save its integer value * in pnum. */ if (1 <= is_valid_decimal && - is_valid_decimal <= SIGRTMAX) { + is_valid_decimal <= (NSIG - 1)) { *pnum = is_valid_decimal; return 0; } + return -1; }