Deprecate SIGSTKSZ/MINSIGSTKSZ with _SC_SIGSTKSZ_SOURCE
Commit Message
On Wed, Oct 14, 2020 at 06:47:01PM +0100, Dave Martin wrote:
> > +#ifndef _SIGNAL_H
> > +# error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
> > +#endif
> > +
> > +#if __USE_SC_SIGSTKSZ
> > +# include <unistd.h>
> > +
> > +/* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
> > +# undef SIGSTKSZ
> > +# define SIGSTKSZ sysconf (_SC_SIGSTKSZ)
> > +
> > +/* Minimum stack size for a signal handler: SIGSTKSZ. */
> > +# undef MINSIGSTKSZ
> > +# define MINSIGSTKSZ SIGSTKSZ
> > +#endif
>
> To help raise awareness, is it worth adding deprecation warnings on
> these?
>
> Could we still consider them deprecated even with _SC_SIGSTKSZ_SOURCE?
> Ideally they should be (or even removed), since even if these values are
> "correct", using them is still a potential portability problem when
> building for other library stacks.
>
> I think the rule ought to be to use these only if _SC_SIGSTKSZ /
> _SC_MINSIGSTKSZ aren't available, and with the caveat that the values
> may be wrong -- similar to the situation with PAGESIZE.
>
>
> It could be worth making this feature test macro more general and
> harvesting any other broken legacy macros we're aware of (such as
> PAGESIZE, but there are probably others). Probably out of scope for
> this patch, though.
>
Here is the followup patch to deprecate SIGSTKSZ and MINSIGSTKSZ.
H.J.
----
When _SC_SIGSTKSZ_SOURCE is defined, deprecate SIGSTKSZ and MINSIGSTKSZ:
tst-minsigstksz-5.c:46:3: warning: ‘MINSIGSTKSZ_is_deprecated’ is deprecated: Use sysconf (_SC_MINSIGSTKSZ) instead [-Wdeprecated-declarations]
35 | MINSIGSTKSZ_is_deprecated (void)
---
sysdeps/unix/sysv/linux/Makefile | 6 ++++--
sysdeps/unix/sysv/linux/bits/sigstksz.h | 18 ++++++++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
Comments
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.
@@ -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)
@@ -23,11 +23,25 @@
#if __USE_SC_SIGSTKSZ
# include <unistd.h>
+__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);
+}
+
/* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */
# undef SIGSTKSZ
-# define SIGSTKSZ sysconf (_SC_SIGSTKSZ)
+# define SIGSTKSZ SIGSTKSZ_is_deprecated ()
/* Minimum stack size for a signal handler: SIGSTKSZ. */
# undef MINSIGSTKSZ
-# define MINSIGSTKSZ SIGSTKSZ
+# define MINSIGSTKSZ MINSIGSTKSZ_is_deprecated ()
#endif