Change all kernel C-type macros into static inline functions.
The current kernel C-type macros might obscurely hide the fact that the input argument might be used multiple times. This breaks code like: isalpha(*ptr++) Use static inline functions instead of macros to fix this. Reviewed by: kib @ Differential Revision: https://reviews.freebsd.org/D19694 MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
df422cb404
commit
d7c5dccd66
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345499
@ -41,19 +41,65 @@
|
|||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
||||||
#define isspace(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
|
static __inline int
|
||||||
#define isascii(c) (((c) & ~0x7f) == 0)
|
isspace(int c)
|
||||||
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
{
|
||||||
#define islower(c) ((c) >= 'a' && (c) <= 'z')
|
return (c == ' ' || (c >= '\t' && c <= '\r'));
|
||||||
#define isalpha(c) (isupper(c) || islower(c))
|
}
|
||||||
#define isdigit(c) ((c) >= '0' && (c) <= '9')
|
|
||||||
#define isxdigit(c) (isdigit(c) \
|
|
||||||
|| ((c) >= 'A' && (c) <= 'F') \
|
|
||||||
|| ((c) >= 'a' && (c) <= 'f'))
|
|
||||||
#define isprint(c) ((c) >= ' ' && (c) <= '~')
|
|
||||||
|
|
||||||
#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
|
static __inline int
|
||||||
#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
|
isascii(int c)
|
||||||
|
{
|
||||||
|
return ((c & ~0x7f) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
isupper(int c)
|
||||||
|
{
|
||||||
|
return (c >= 'A' && c <= 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
islower(int c)
|
||||||
|
{
|
||||||
|
return (c >= 'a' && c <= 'z');
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
isalpha(int c)
|
||||||
|
{
|
||||||
|
return (isupper(c) || islower(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
isdigit(int c)
|
||||||
|
{
|
||||||
|
return (c >= '0' && c <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
isxdigit(int c)
|
||||||
|
{
|
||||||
|
return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
isprint(int c)
|
||||||
|
{
|
||||||
|
return (c >= ' ' && c <= '~');
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
toupper(int c)
|
||||||
|
{
|
||||||
|
return (c - 0x20 * ((c >= 'a') && (c <= 'z')));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
tolower(int c)
|
||||||
|
{
|
||||||
|
return (c + 0x20 * ((c >= 'A') && (c <= 'Z')));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* !_SYS_CTYPE_H_ */
|
#endif /* !_SYS_CTYPE_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user