From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 71DB4388455F; Thu, 28 Sep 2023 17:50:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71DB4388455F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695923401; bh=Z1icg8edBvNO8rcnyolskTbn811NxIPohUfnpH/Jk+Y=; h=From:To:Subject:Date:From; b=gpkHx+XNiXAijSdDdv0VHpUxf1e0wxkQA/HbpicWhepez7xUvwavcIwG3q8xCUeh9 ViFdYpBOnrnO/SK3z1RvfOAksW3kL8kIQHnZ8/7FcMI6m1WkUak+tevMy5vVWaaIY/ KxHRU7RcHrKpcD9SfCoNj3w6RKEYQvb7VlMqSGTs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] argp: Expand argp_usage, _option_is_short, and _option_is_end X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: c9730cb3e225d070f29626c22a3e15553163837f X-Git-Newrev: bf7ac8d7a812c9f6be104aa48ae8f5744260e2db Message-Id: <20230928175001.71DB4388455F@sourceware.org> Date: Thu, 28 Sep 2023 17:50:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bf7ac8d7a812c9f6be104aa48ae8f5744260e2db commit bf7ac8d7a812c9f6be104aa48ae8f5744260e2db Author: Adhemerval Zanella Date: Thu Jul 21 14:12:01 2022 -0300 argp: Expand argp_usage, _option_is_short, and _option_is_end The argp code uses some clever macro redefine to avoid need to duplicate the optimized static inline implementations for argp_usage, _option_is_short, and _option_is_end. This however leads to some build issues with clang, since some function prototypes are redefined to add the hidden attribute with libc_hidden_proto. To avoid extensive changes on internal headers, just expand the function implementations and avoid the macro redefine tricks. Diff: --- argp/argp-xinl.c | 34 +++++++++++++++++++++++----------- argp/argp.h | 10 +++------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/argp/argp-xinl.c b/argp/argp-xinl.c index b7cd70cc51..ae41d3bdb4 100644 --- a/argp/argp-xinl.c +++ b/argp/argp-xinl.c @@ -25,19 +25,31 @@ # include #endif -#ifndef __USE_EXTERN_INLINES -# define __USE_EXTERN_INLINES 1 -#endif -#define ARGP_EI -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 #include -/* Add weak aliases. */ -#if _LIBC - 0 && defined (weak_alias) - +void +__argp_usage (const struct argp_state *__state) +{ + __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); +} weak_alias (__argp_usage, argp_usage) + +int +__option_is_short (const struct argp_option *__opt) +{ + if (__opt->flags & OPTION_DOC) + return 0; + else + { + int __key = __opt->key; + return __key > 0 && __key <= UCHAR_MAX && isprint (__key); + } +} weak_alias (__option_is_short, _option_is_short) -weak_alias (__option_is_end, _option_is_end) -#endif +int +__option_is_end (const struct argp_option *__opt) +{ + return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; +} +weak_alias (__option_is_end, _option_is_end) diff --git a/argp/argp.h b/argp/argp.h index 77d696c65d..b899a53bd8 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -518,17 +518,13 @@ extern void *__argp_input (const struct argp *__restrict __argp, # define __option_is_end _option_is_end # endif -# ifndef ARGP_EI -# define ARGP_EI __extern_inline -# endif - -ARGP_EI void +__extern_inline void __argp_usage (const struct argp_state *__state) { __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); } -ARGP_EI int +__extern_inline int __NTH (__option_is_short (const struct argp_option *__opt)) { if (__opt->flags & OPTION_DOC) @@ -540,7 +536,7 @@ __NTH (__option_is_short (const struct argp_option *__opt)) } } -ARGP_EI int +__extern_inline int __NTH (__option_is_end (const struct argp_option *__opt)) { return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;