mirror of git://sourceware.org/git/glibc.git
argp: Expand argp_usage, _option_is_short, and _option_is_end
The argp code uses macro redefinitions to avoid duplicating static inline implementations for argp_usage, _option_is_short, and _option_is_end. However, this causes build issues with clang, as some function prototypes are redefined to add the hidden attribute with libc_hidden_proto. To avoid extensive changes to internal headers, just expand the function implementations and avoid the macro redefine tricks. Reviewed-by: Collin Funk <collin.funk1@gmail.com>
This commit is contained in:
parent
36b4c553e6
commit
110ec4954e
|
|
@ -25,19 +25,35 @@
|
||||||
# include <features.h>
|
# include <features.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __USE_EXTERN_INLINES
|
|
||||||
# define __USE_EXTERN_INLINES 1
|
|
||||||
#endif
|
|
||||||
#define ARGP_EI
|
|
||||||
#undef __OPTIMIZE__
|
|
||||||
#define __OPTIMIZE__ 1
|
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
|
|
||||||
/* Add weak aliases. */
|
#ifdef _LIBC
|
||||||
#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)
|
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_short, _option_is_short)
|
||||||
|
|
||||||
|
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)
|
weak_alias (__option_is_end, _option_is_end)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
10
argp/argp.h
10
argp/argp.h
|
|
@ -518,17 +518,13 @@ extern void *__argp_input (const struct argp *__restrict __argp,
|
||||||
# define __option_is_end _option_is_end
|
# define __option_is_end _option_is_end
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef ARGP_EI
|
__extern_inline void
|
||||||
# define ARGP_EI __extern_inline
|
|
||||||
# endif
|
|
||||||
|
|
||||||
ARGP_EI void
|
|
||||||
__argp_usage (const struct argp_state *__state)
|
__argp_usage (const struct argp_state *__state)
|
||||||
{
|
{
|
||||||
__argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
|
__argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARGP_EI int
|
__extern_inline int
|
||||||
__NTH (__option_is_short (const struct argp_option *__opt))
|
__NTH (__option_is_short (const struct argp_option *__opt))
|
||||||
{
|
{
|
||||||
if (__opt->flags & OPTION_DOC)
|
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))
|
__NTH (__option_is_end (const struct argp_option *__opt))
|
||||||
{
|
{
|
||||||
return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
|
return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue