From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.129.74]) by sourceware.org (Postfix) with ESMTPS id C68913857C6F for ; Thu, 5 May 2022 15:43:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C68913857C6F Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-mDPwr-C9O5urfSP90XHgCQ-1; Thu, 05 May 2022 11:43:18 -0400 X-MC-Unique: mDPwr-C9O5urfSP90XHgCQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36A9C83396E; Thu, 5 May 2022 15:43:18 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DEDE40CF8F5; Thu, 5 May 2022 15:43:17 +0000 (UTC) From: Florian Weimer To: Andreas Schwab Cc: Florian Weimer via Libc-alpha Subject: Re: [PATCH v4 2/3] Linux: Implement a useful version of _startup_fatal References: <71808d9fc272aa3cfb78c905dd5aedd39bb903f6.1651762968.git.fweimer@redhat.com> <87ilqk6ltk.fsf@igel.home> Date: Thu, 05 May 2022 17:43:15 +0200 In-Reply-To: <87ilqk6ltk.fsf@igel.home> (Andreas Schwab's message of "Thu, 05 May 2022 17:28:07 +0200") Message-ID: <87bkwcm1d8.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 05 May 2022 15:43:22 -0000 * Andreas Schwab: > On Mai 05 2022, Florian Weimer via Libc-alpha wrote: > >> +/* Avoid a run-time invocation of strlen. */ >> +#define _startup_fatal(message) = \ >> + do = \ >> + { = \ >> + size_t __message_length =3D __builtin_strlen (message); = \ >> + if (! __builtin_constant_p (__message_length)) = \ >> + { = \ >> + extern void _startup_fatal_not_constant (void); = \ >> + _startup_fatal_not_constant (); = \ >> + } = \ > > I think that could use _Static_assert. It only works for simple cases, not for arguments that require constant progagation: libc-tls.c: In function =E2=80=98__libc_setup_tls=E2=80=99: ../sysdeps/unix/sysv/linux/startup.h:29:23: error: expression in static ass= ertion is not constant 29 | _Static_assert (__builtin_constant_p (__message_length), = \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks, Florian