/* ISO C Runtime Library Copyright (c) 1983-2022 Green Hills Software, Inc. This program is the property of Green Hills Software, Inc. Its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ /* ANSI C requires these functions, and allows them to also be macros. ANSI C++ requires them to be only functions, but allows them to be inline. This implementation works as follows: 1. In C, all functions are prototyped unconditionally. In C++, all functions are prototyped unless __CALL_CTYPE_FUNCTIONS__ 2. If defined __CALL_CTYPE_FUNCTIONS__, only prototypes are provided for the functions and the rest of the file is skipped. No macros will be defined and no inline functions will be declared. 3. Inline versions of all functions are declared with hidden names. (In C89, this depends on the Green Hills C __inline feature.) 4. In C++, inline versions of the functions are declared which invoke the inline versions with hidden names. 5. In C, macros are define'd which invoke the inline versions with hidden names. To take the address of isspace, first use #undef isspace to remove the macro, then take the address of isspace. 6. In all cases, these functions are safe: a. Arguments with side-effects are always evaluated once. b. Out of range arguments always return false. 7. With --saferc=1 macros do NOT invoke inline functions because that is an extension. Rather, macros are expanded into expressions if they are safe and function calls if the expression is not safe. */ #ifndef _GHS_CTYPE_H #ifdef __ghs__ #pragma ghs startnomisra #if !defined(__GHS_INST_PRO_EPI_IN_C_HEADERS) #pragma ghs instrument_prologue_epilogue push off #endif #endif #define _GHS_CTYPE_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #if !defined(__Inline_keyword_) # define __need_to_undef_inline_keyword # if defined(__cplusplus) # define __Inline_keyword_ inline # elif (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && \ !defined(__GNUC__) /* Don't use "inline" prior to C99. */ # if defined(__ONLY_STANDARD_KEYWORDS_IN_C) /* MISRA 2004 1.1 and MISRA 2012 R1.2 also remove extension keywords like * "__inline", so there is no way to define an inline function. */ # define __No_inline_functions # else # define __Inline_keyword_ __inline # endif # else /* In C99 (with or without MISRA checking) and GNU C, "inline" is allowed. */ # define __Inline_keyword_ static inline # endif /* __cplusplus, __STDC__, etc. */ #endif /* __Inline_keyword_ */ #if defined(__GHS_GENERATE_FEE) && defined(__ghs__) #pragma ghs entry_exit_history push on #endif /* Prototypes are required in ANSI always. Prototypes are needed in C++ when inline versions are not used. */ #if defined(__CALL_CTYPE_FUNCTIONS__) || !defined(__cplusplus) int isalnum (int); int isalpha (int); int isblank (int); int iscntrl (int); int isdigit (int); int isgraph (int); int islower (int); int isprint (int); int ispunct (int); int isspace (int); int isupper (int); int isxdigit(int); int tolower (int); int toupper (int); #if (!defined(__STDC__) || __STDC__==0) && !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) /* deprecated */ int isascii (int); int toascii (int); #endif /* non-ANSI C functions */ #endif /* defined(__CALL_CTYPE_FUNCTIONS__) || !defined(__cplusplus) */ #if defined(__GHS_GENERATE_FEE) && defined(__ghs__) #pragma ghs entry_exit_history pop #endif #ifndef __CALL_CTYPE_FUNCTIONS__ #define __INRANGE(c,l,h) ((((unsigned)(c) - (unsigned)(l))) <= \ (((unsigned)(h) - (unsigned)(l)))) #if defined(__mips) # define _OR_ | /* SLTIU is shorter than BLT/NOP */ #else # define _OR_ || #endif /* __mips */ #if defined(__No_inline_functions) /* anything that requires evaluation of __Ch__ more than once is a function call. Only simple cases are generated inline in C89. */ #define __ISALPHA(__Ch__) (__INRANGE(((unsigned)(__Ch__)|0x20),'a','z')) #define __ISALNUM(__Ch__) ((isalnum)(__Ch__)) #define __ISBLANK(__Ch__) ((isblank)(__Ch__)) #define __ISCNTRL(__Ch__) ((iscntrl)(__Ch__)) #define __ISDIGIT(__Ch__) (__INRANGE(__Ch__,'0','9')) #define __ISGRAPH(__Ch__) (__INRANGE(__Ch__,0x21,0x7e)) #define __ISLOWER(__Ch__) (__INRANGE(__Ch__,'a','z')) #define __ISPRINT(__Ch__) (__INRANGE(__Ch__,0x20,0x7e)) #define __ISPUNCT(__Ch__) ((ispunct)(__Ch__)) #define __ISSPACE(__Ch__) ((isspace)(__Ch__)) #define __ISUPPER(__Ch__) (__INRANGE(__Ch__,'A','Z')) #define __ISXDIGIT(__Ch__)((isxdigit)(__Ch__)) #define __TOLOWER(__Ch__) ((tolower)(__Ch__)) #define __TOUPPER(__Ch__) ((toupper)(__Ch__)) #else __Inline_keyword_ int __ISALPHA(int __Ch__) { return __INRANGE((__Ch__|0x20),'a','z'); } __Inline_keyword_ int __ISALNUM(int __Ch__) { return __INRANGE((__Ch__|0x20),'a','z') _OR_ __INRANGE(__Ch__,'0','9'); } __Inline_keyword_ int __ISBLANK(int __Ch__) { return (__Ch__=='\t') _OR_ (__Ch__==' '); } __Inline_keyword_ int __ISCNTRL(int __Ch__) { return (((unsigned) __Ch__)<=0x1f) _OR_ (__Ch__==0x7f); } __Inline_keyword_ int __ISDIGIT(int __Ch__) { return __INRANGE(__Ch__,'0','9'); } __Inline_keyword_ int __ISGRAPH(int __Ch__) { return __INRANGE(__Ch__,0x21,0x7e); } __Inline_keyword_ int __ISLOWER(int __Ch__) { return __INRANGE(__Ch__,'a','z'); } __Inline_keyword_ int __ISPRINT(int __Ch__) { return __INRANGE(__Ch__,0x20,0x7e); } __Inline_keyword_ int __ISPUNCT(int __Ch__) { return __INRANGE(__Ch__,'!','/') _OR_ __INRANGE(__Ch__,':','@') _OR_ __INRANGE(__Ch__,'[','`') _OR_ __INRANGE(__Ch__,'{','~'); } __Inline_keyword_ int __ISSPACE(int __Ch__) { return (__Ch__==0x20) _OR_ __INRANGE(__Ch__,'\t','\r'); } __Inline_keyword_ int __ISUPPER(int __Ch__) { return __INRANGE(__Ch__,'A','Z'); } __Inline_keyword_ int __ISXDIGIT(int __Ch__) { return __INRANGE(__Ch__,'0','9') _OR_ __INRANGE((__Ch__|0x20),'a','f'); } __Inline_keyword_ int __TOLOWER(int __Ch__) { return __Ch__ + (__INRANGE(__Ch__,'A','Z')<<5); /*return __INRANGE(__Ch__,'A','Z') ? 'a'+(__Ch__-'A') : __Ch__;*/ } __Inline_keyword_ int __TOUPPER(int __Ch__) { return __Ch__ - (__INRANGE(__Ch__,'a','z')<<5); /*return __INRANGE(__Ch__,'a','z') ? 'A'+(__Ch__-'a') : __Ch__;*/ } #if (!defined(__STDC__) || __STDC__==0) && !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) /* deprecated */ __Inline_keyword_ int __ISASCII(int __Ch__) { return ((unsigned) __Ch__)<=0x7f; } __Inline_keyword_ int __TOASCII(int __Ch__) { return __Ch__&0x7f; } #endif /* non-ANSI C functions */ #if defined(_STD_BEGIN) && defined(__cplusplus) && !defined(_Isspace)/* used by our C++ libs */ inline int _Isspace (int __Ch__) { return __ISSPACE(__Ch__); } #endif #undef __INRANGE #endif /* defined(__ONLY_STANDARD_KEYWORDS_IN_C) */ #if defined(__cplusplus) inline int isalnum (int __Ch__) { return __ISALNUM(__Ch__); } inline int isalpha (int __Ch__) { return __ISALPHA(__Ch__); } inline int isblank (int __Ch__) { return __ISBLANK(__Ch__); } inline int iscntrl (int __Ch__) { return __ISCNTRL(__Ch__); } inline int isdigit (int __Ch__) { return __ISDIGIT(__Ch__); } inline int isgraph (int __Ch__) { return __ISGRAPH(__Ch__); } inline int islower (int __Ch__) { return __ISLOWER(__Ch__); } inline int isprint (int __Ch__) { return __ISPRINT(__Ch__); } inline int ispunct (int __Ch__) { return __ISPUNCT(__Ch__); } inline int isspace (int __Ch__) { return __ISSPACE(__Ch__); } inline int isupper (int __Ch__) { return __ISUPPER(__Ch__); } inline int isxdigit(int __Ch__) { return __ISXDIGIT(__Ch__); } inline int tolower (int __Ch__) { return __TOLOWER(__Ch__); } inline int toupper (int __Ch__) { return __TOUPPER(__Ch__); } #if (!defined(__STDC__) || __STDC__==0) && !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) /* deprecated */ inline int isascii (int __Ch__) { return __ISASCII(__Ch__); } inline int toascii (int __Ch__) { return __TOASCII(__Ch__); } #endif /* non-ANSI C functions */ #else /* __cplusplus */ # define isalnum(c) __ISALNUM(c) # define isalpha(c) __ISALPHA(c) # define isblank(c) __ISBLANK(c) # define iscntrl(c) __ISCNTRL(c) # define isdigit(c) __ISDIGIT(c) # define isgraph(c) __ISGRAPH(c) # define islower(c) __ISLOWER(c) # define isprint(c) __ISPRINT(c) # define ispunct(c) __ISPUNCT(c) # define isspace(c) __ISSPACE(c) # define isupper(c) __ISUPPER(c) # define isxdigit(c) __ISXDIGIT(c) # define tolower(c) __TOLOWER(c) # define toupper(c) __TOUPPER(c) # if (!defined(__STDC__) || __STDC__==0) && !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) /* deprecated */ # define isascii(c) __ISASCII(c) # define toascii(c) __TOASCII(c) # endif /* non-ANSI C functions */ #endif /* __cplusplus */ #endif /* __CALL_CTYPE_FUNCTIONS__ */ #if defined(__need_to_undef_inline_keyword) # undef __need_to_undef_inline_keyword # undef __Inline_keyword_ # undef __No_inline_functions #endif #if defined(__cplusplus) } /* extern "C" */ #endif /* __cplusplus */ #ifdef __ghs__ #if !defined(__GHS_INST_PRO_EPI_IN_C_HEADERS) #pragma ghs instrument_prologue_epilogue pop #endif #pragma ghs endnomisra #endif #endif /* _GHS_CTYPE_H */