diff options
author | Arnd Bergmann <arnd@arndb.de> | 2020-10-19 09:35:39 +0200 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2020-10-28 14:55:36 +0100 |
commit | caabdd0f59a9771ed095efe3ad5a08867b976ab2 (patch) | |
tree | 3e588a89ccaddec4fce4a183b3e9ccaa7c60fc51 /include/linux/ctype.h | |
parent | f44ca0871b7a98b075560711d48849914a102221 (diff) |
ctype.h: remove duplicate isdigit() helper
gcc warns a few thousand times about the isdigit() shadow:
include/linux/ctype.h:26:19: warning: declaration of 'isdigit' shadows a built-in function [-Wshadow]
As there is already a compiler builtin, just use that, and make
it clear we do that by defining a macro. Unfortunately, clang
does not have the isdigit() builtin, so this has to be conditional.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/linux/ctype.h')
-rw-r--r-- | include/linux/ctype.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/ctype.h b/include/linux/ctype.h index 363b004426db..bc95aef2219c 100644 --- a/include/linux/ctype.h +++ b/include/linux/ctype.h @@ -2,6 +2,8 @@ #ifndef _LINUX_CTYPE_H #define _LINUX_CTYPE_H +#include <linux/compiler.h> + /* * NOTE! This ctype does not handle EOF like the standard C * library is required to. @@ -23,10 +25,6 @@ extern const unsigned char _ctype[]; #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) #define iscntrl(c) ((__ismask(c)&(_C)) != 0) -static inline int isdigit(int c) -{ - return '0' <= c && c <= '9'; -} #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) #define islower(c) ((__ismask(c)&(_L)) != 0) #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) @@ -39,6 +37,15 @@ static inline int isdigit(int c) #define isascii(c) (((unsigned char)(c))<=0x7f) #define toascii(c) (((unsigned char)(c))&0x7f) +#if __has_builtin(__builtin_isdigit) +#define isdigit(c) __builtin_isdigit(c) +#else +static inline int isdigit(int c) +{ + return '0' <= c && c <= '9'; +} +#endif + static inline unsigned char __tolower(unsigned char c) { if (isupper(c)) |