aboutsummaryrefslogtreecommitdiff
path: root/argp
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-07-21 14:12:01 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-17 16:12:10 -0300
commit35cdd59852251b2e69b3311ab1e22fccdb5e1a18 (patch)
treed683e2a3f1af295d259688effca8f8f1e09224ec /argp
parented63857295eb3d48e9114ae4c697f65d5d83635a (diff)
downloadglibc-35cdd59852251b2e69b3311ab1e22fccdb5e1a18.zip
glibc-35cdd59852251b2e69b3311ab1e22fccdb5e1a18.tar.gz
glibc-35cdd59852251b2e69b3311ab1e22fccdb5e1a18.tar.bz2
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.
Diffstat (limited to 'argp')
-rw-r--r--argp/argp-xinl.c34
-rw-r--r--argp/argp.h10
2 files changed, 26 insertions, 18 deletions
diff --git a/argp/argp-xinl.c b/argp/argp-xinl.c
index 4bd4671..e9d6544 100644
--- a/argp/argp-xinl.c
+++ b/argp/argp-xinl.c
@@ -25,19 +25,31 @@
# include <features.h>
#endif
-#ifndef __USE_EXTERN_INLINES
-# define __USE_EXTERN_INLINES 1
-#endif
-#define ARGP_EI
-#undef __OPTIMIZE__
-#define __OPTIMIZE__ 1
#include <argp.h>
-/* 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 efae2a6..99d3b4d 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;