diff mbox series

V2 [PATCH] Deprecate SIGSTKSZ/MINSIGSTKSZ with _SC_SIGSTKSZ_SOURCE

Message ID CAMe9rOo3FdwJV8fa=KcHa6VSqNexzgiiF2NS1uq=ay+bzMHpOw@mail.gmail.com
State New
Headers show
Series V2 [PATCH] Deprecate SIGSTKSZ/MINSIGSTKSZ with _SC_SIGSTKSZ_SOURCE | expand

Commit Message

H.J. Lu Oct. 15, 2020, 9:22 p.m. UTC
On Thu, Oct 15, 2020 at 12:59 PM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Thu, 15 Oct 2020, H.J. Lu via Libc-alpha wrote:
>
> > +__attribute_deprecated_msg__ ("Use sysconf (_SC_SIGSTKSZ) instead")
> > +__extern_always_inline long
> > +SIGSTKSZ_is_deprecated (void)
> > +{
> > +  return sysconf (_SC_SIGSTKSZ);
> > +}
> > +
> > +__attribute_deprecated_msg__ ("Use sysconf (_SC_MINSIGSTKSZ) instead")
> > +__extern_always_inline long
> > +MINSIGSTKSZ_is_deprecated (void)
> > +{
> > +  return sysconf (_SC_SIGSTKSZ);
> > +}
>
> Those function names should start with '__' rather than claiming the names
> SIGSTKSZ_is_deprecated and MINSIGSTKSZ_is_deprecated from the user's
> namespace.
>

Like this?

Comments

Joseph Myers Oct. 16, 2020, 12:57 a.m. UTC | #1
On Thu, 15 Oct 2020, H.J. Lu via Libc-alpha wrote:

> > Those function names should start with '__' rather than claiming the names
> > SIGSTKSZ_is_deprecated and MINSIGSTKSZ_is_deprecated from the user's
> > namespace.
> >
> 
> Like this?

Yes (this is not a review of this patch, but, if we do want such a 
deprecation, the function names used in this patch are now appropriate).
diff mbox series

Patch

From a9b02d82571c0b0e0a5d4b46f0683a5341046bdf Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 15 Oct 2020 05:21:28 -0700
Subject: [PATCH] Deprecate SIGSTKSZ/MINSIGSTKSZ with _SC_SIGSTKSZ_SOURCE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When _SC_SIGSTKSZ_SOURCE is defined, deprecate SIGSTKSZ and MINSIGSTKSZ:

tst-minsigstksz-5.c: In function ‘do_test’:
tst-minsigstksz-5.c:46:3: warning: ‘__MINSIGSTKSZ’ is deprecated: Use sysconf (_SC_MINSIGSTKSZ) instead of MINSIGSTKSZ [-Wdeprecated-declarations]
   46 |   void *stack_bottom = stack_buffer + (stack_buffer_size + MINSIGSTKSZ) / 2;
      |   ^~~~
In file included from ../signal/signal.h:315,
                 from ../include/signal.h:2,
                 from tst-minsigstksz-5.c:19:
../sysdeps/unix/sysv/linux/bits/sigstksz.h:35:1: note: declared here
   35 | __MINSIGSTKSZ (void)
      | ^~~~~~~~~~~~~
---
 sysdeps/unix/sysv/linux/Makefile        |  6 ++++--
 sysdeps/unix/sysv/linux/bits/sigstksz.h | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index b51a02a6e6..5576c729ae 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -189,9 +189,11 @@  sysdep_headers += sys/timex.h bits/timex.h
 sysdep_routines += ntp_gettime ntp_gettimex
 endif
 
+CFLAGS-SIGSTKSZ += -D_SC_SIGSTKSZ_SOURCE -Wno-error=deprecated-declarations
+
 ifeq ($(subdir),signal)
 # Compile tst-minsigstksz-5.c with _SC_SIGSTKSZ_SOURCE.
-CFLAGS-tst-minsigstksz-5.c += -D_SC_SIGSTKSZ_SOURCE
+CFLAGS-tst-minsigstksz-5.c += $(CFLAGS-SIGSTKSZ)
 
 tests-special += $(objpfx)tst-signal-numbers.out
 # Depending on signal.o* is a hack.  What we actually want is a dependency
@@ -233,7 +235,7 @@  endif
 
 ifeq ($(subdir),support)
 # Compile xsigstack.c with _SC_SIGSTKSZ_SOURCE.
-CFLAGS-xsigstack.c += -D_SC_SIGSTKSZ_SOURCE
+CFLAGS-xsigstack.c += $(CFLAGS-SIGSTKSZ)
 endif
 
 ifeq ($(subdir),termios)
diff --git a/sysdeps/unix/sysv/linux/bits/sigstksz.h b/sysdeps/unix/sysv/linux/bits/sigstksz.h
index cd5b3cc895..b90a614de6 100644
--- a/sysdeps/unix/sysv/linux/bits/sigstksz.h
+++ b/sysdeps/unix/sysv/linux/bits/sigstksz.h
@@ -23,11 +23,25 @@ 
 #if __USE_SC_SIGSTKSZ
 # include <unistd.h>
 
+__attribute_deprecated_msg__ ("Use sysconf (_SC_SIGSTKSZ) instead of SIGSTKSZ")
+__extern_always_inline long
+__SIGSTKSZ (void)
+{
+  return sysconf (_SC_SIGSTKSZ);
+}
+
+__attribute_deprecated_msg__ ("Use sysconf (_SC_MINSIGSTKSZ) instead of MINSIGSTKSZ")
+__extern_always_inline long
+__MINSIGSTKSZ (void)
+{
+  return sysconf (_SC_SIGSTKSZ);
+}
+
 /* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ).  */
 # undef SIGSTKSZ
-# define SIGSTKSZ sysconf (_SC_SIGSTKSZ)
+# define SIGSTKSZ __SIGSTKSZ ()
 
 /* Minimum stack size for a signal handler: SIGSTKSZ.  */
 # undef MINSIGSTKSZ
-# define MINSIGSTKSZ SIGSTKSZ
+# define MINSIGSTKSZ __MINSIGSTKSZ ()
 #endif
-- 
2.26.2