From patchwork Thu Oct 15 12:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 40727 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 556E83857821; Thu, 15 Oct 2020 12:27:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 556E83857821 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1602764821; bh=GL7UqOTA112NEKGh92yRcIZvjW8a8ckDoB1mUJ4lmTk=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TBOJA4kOXvt7fA8QAxiL/k3WGYzScqPcGe0X2x2a2np0ftO+ie3LnmLSMYD2/CzeK ie25NUTStCn5eILxq6fup5RZPavGGmM/QE4eYfG9xorWxzSn1p+9UfSBqdnUlYZPOM XjF7Y8fxhUSVK4CYXusQmWRe47SjZ8U5DYAdUjhs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by sourceware.org (Postfix) with ESMTPS id 294C33857C62 for ; Thu, 15 Oct 2020 12:26:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 294C33857C62 Received: by mail-pj1-x1044.google.com with SMTP id ds1so1745920pjb.5 for ; Thu, 15 Oct 2020 05:26:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=GL7UqOTA112NEKGh92yRcIZvjW8a8ckDoB1mUJ4lmTk=; b=oiF2UZkWMEjmg2PTRBi6F9kEZzGfQrA4lOF9G9RVZeMt5M9LHb663/raUogHmz0naT MlS2AIXxHZuujVFu/+Mn0IDOLUL7ADV6sDhPh9kTAz6pwHMreb9RxE9MTQmSX1LLqlcu m//bHqofHXTIJe5wz6hNLJV5DIwA8jZrHmSmK+lEhRUYiQ8mD8eVkMnK+ISQHoP/Nzs8 IsEhWOBemLQE0SYWIk1mGLGvEnAXa1MqQPDZXdnFqSfAEPYzKqDfYZNxozpEfRQvnobb Oo4NKuqmH+oH3awC9pKx44voOdEA8zyuNvEM1BKZ2EhLChID+zNR0sakM8acuV6mYbso aGGA== X-Gm-Message-State: AOAM5316t6wT8NpcY4PzaCA6oVNLu27gikZmgI5lmWr9qtZB+eMrXbVo 0uwbPT0LF5gOSqnmdGizqJ/hIkTBXSI= X-Google-Smtp-Source: ABdhPJymW2+BTqhE3ElErUTpCMJt5/hlIsW3FA4+QoGRCkpWER74bcc9GXf8K5fDKtoPWVBCUySeHA== X-Received: by 2002:a17:902:704b:b029:d3:eca2:d221 with SMTP id h11-20020a170902704bb02900d3eca2d221mr2210329plt.74.1602764817001; Thu, 15 Oct 2020 05:26:57 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id c15sm3185854pgg.77.2020.10.15.05.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 05:26:56 -0700 (PDT) Received: by gnu-cfl-2.localdomain (Postfix, from userid 1000) id B339F1A021A; Thu, 15 Oct 2020 05:26:53 -0700 (PDT) Date: Thu, 15 Oct 2020 05:26:53 -0700 To: Dave Martin Subject: [PATCH] Deprecate SIGSTKSZ/MINSIGSTKSZ with _SC_SIGSTKSZ_SOURCE Message-ID: <20201015122653.GA319424@gmail.com> References: <20201010121935.3263605-1-hjl.tools@gmail.com> <20201014174659.GL32292@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201014174659.GL32292@arm.com> X-Spam-Status: No, score=-3041.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: GNU C Library , Joseph Myers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On Wed, Oct 14, 2020 at 06:47:01PM +0100, Dave Martin wrote: > > +#ifndef _SIGNAL_H > > +# error "Never include directly; use instead." > > +#endif > > + > > +#if __USE_SC_SIGSTKSZ > > +# include > > + > > +/* 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(-) 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..c3e17e2251 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 +__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