Use ALWAYS_INLINE for ctype inlines.

This commit is contained in:
Andreas Kling 2018-10-31 15:53:11 +01:00
parent 71c9b09e8c
commit 2fdc7c2c60
Notes: sideshowbarker 2024-07-19 18:35:51 +09:00
2 changed files with 15 additions and 6 deletions

View file

@ -1,35 +1,42 @@
#pragma once
inline int isascii(int ch)
#include <sys/cdefs.h>
ALWAYS_INLINE int isascii(int ch)
{
return (ch & ~0x7f) == 0;
}
inline int isspace(int ch)
ALWAYS_INLINE int isspace(int ch)
{
return ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' == '\v';
}
inline int islower(int c)
ALWAYS_INLINE int islower(int c)
{
return c >= 'a' && c <= 'z';
}
inline int isupper(int c)
ALWAYS_INLINE int isupper(int c)
{
return c >= 'A' && c <= 'Z';
}
inline int tolower(int c)
ALWAYS_INLINE int tolower(int c)
{
if (isupper(c))
return c | 0x20;
return c;
}
inline int toupper(int c)
ALWAYS_INLINE int toupper(int c)
{
if (islower(c))
return c & ~0x20;
return c;
}
ALWAYS_INLINE int isdigit(int c)
{
return c >= '0' && c <= '9';
}

View file

@ -1,5 +1,7 @@
#pragma once
#define ALWAYS_INLINE inline __attribute__ ((always_inline))
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }