lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | User-configurable |
| 2 | |
| 3 | UCLIBC_HAS_CTYPE_TABLES |
| 4 | Make toupper etc work thru translation tables |
| 5 | and isalhum etc thru lookup tables. Help says: |
| 6 | "While the non-table versions are often smaller when building |
| 7 | statically linked apps, they work only in stub locale mode." |
| 8 | |
| 9 | "stub locale mode" is when !UCLIBC_HAS_LOCALE I presume, |
| 10 | when we are permanently in POSIX/C locale. |
| 11 | |
| 12 | UCLIBC_HAS_CTYPE_SIGNED |
| 13 | Handle sign-extended chars. I.e. if you want |
| 14 | toupper((char)0xa0) => toupper(0xffffffa0) => still works correctly, |
| 15 | as if toupper(0xa0) was called. |
| 16 | |
| 17 | UCLIBC_HAS_CTYPE_UNSAFE/CHECKED/ENFORCED |
| 18 | Do not check ctype function argument's range/check it and return |
| 19 | error/check it and abort(). Help says: |
| 20 | NOTE: This only affects the 'ctype' _functions_. It does not affect |
| 21 | the macro implementations. [so what happens to macros?] |
| 22 | [examples?] |
| 23 | |
| 24 | UCLIBC_HAS_WCHAR |
| 25 | Wide character support. I assume all those wchar_t types and functions |
| 26 | |
| 27 | UCLIBC_HAS_LOCALE/XLOCALE |
| 28 | Support locale / extended locale |
| 29 | |
| 30 | UCLIBC_PREGENERATED_LOCALE_DATA |
| 31 | Not recommended |
| 32 | |
| 33 | |
| 34 | uclibc internal machinery |
| 35 | |
| 36 | __LOCALE_C_ONLY |
| 37 | #defined if !UCLIBC_HAS_LOCALE |
| 38 | |
| 39 | __NO_CTYPE |
| 40 | #defined only by some .c files. Prevents ctype macros to be #defined |
| 41 | (those w/o underscores. __ctype() macros will still be defined). |
| 42 | Looks like user is expected to never mess with defining it. |
| 43 | |
| 44 | __UCLIBC_DO_XLOCALE |
| 45 | #defined only by some .c files. Looks like user is expected to never |
| 46 | mess with defining it. |
| 47 | |
| 48 | __XL_NPP(N) - "add _l suffix if locale support is on" |
| 49 | #defined to N ## _l if __UCLIBC_HAS_XLOCALE__ && __UCLIBC_DO_XLOCALE, |
| 50 | else #defined to just N. |
| 51 | |
| 52 | __CTYPE_HAS_8_BIT_LOCALES |
| 53 | __CTYPE_HAS_UTF_8_LOCALES |
| 54 | Depends on contents of extra/locale/LOCALES data file. Looks like |
| 55 | both will be set if UCLIBC_HAS_LOCALE and extra/locale/LOCALES |
| 56 | is not edited. |
| 57 | |
| 58 | __WCHAR_ENABLED |
| 59 | locale_mmap.h defines it unconditionally, extra/locale/gen_ldc.c |
| 60 | defines it too with a warning, and _then_ includes locale_mmap.h. |
| 61 | Makefile seems to prevent the warning in gen_ldc.c: |
| 62 | ifeq ($(UCLIBC_HAS_WCHAR),y) |
| 63 | BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1 |
| 64 | BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1 |
| 65 | endif |
| 66 | A mess. Why they can't just use __UCLIBC_HAS_WCHAR__? |
| 67 | |
| 68 | __WCHAR_REPLACEMENT_CHAR |
| 69 | Never defined (dead code???) |
| 70 | |
| 71 | |
| 72 | |
| 73 | Actual ctype macros are a bloody mess! |
| 74 | |
| 75 | __C_isspace(c), __C_tolower(c) et al |
| 76 | Defined in bits/uClibc_ctype.h. Non-locale-aware, unsafe |
| 77 | wrt multiple-evaluation, macros. Return unsigned int. |
| 78 | |
| 79 | __isspace(c), __tolower(c) et al |
| 80 | Defined in bits/uClibc_ctype.h. Non-locale-aware, |
| 81 | but safe wrt multiple-evaluation, macros. Return int. |
| 82 | |
| 83 | __isdigit_char, __isdigit_int |
| 84 | Visible only to uclibc code. ((unsigned char/int)((c) - '0') <= 9). |
| 85 | |
| 86 | _tolower(c), _toupper(c) |
| 87 | Even more unsafe versions (they just do | 0x20 or ^ 0x20). Sheesh. |
| 88 | They are mandated by POSIX so we must have them defined, |
| 89 | but I removed all uses in uclibc code. Half of them were buggy. |
| 90 | |
| 91 | isspace(c), tolower(c) et al |
| 92 | Declared as int isXXXX(int c) in bits/uClibc_ctype.h. Then, |
| 93 | if not C++ compile, defined as macros to __usXXXX(c) |
| 94 | |
| 95 | bits/uClibc_ctype.h is included by ctype.h only if !__UCLIBC_HAS_CTYPE_TABLES__. |
| 96 | |
| 97 | Otherwise, ctype.h declares int isXXXX(int c) functions, |
| 98 | then defines macros for isXXXX(c), __isXXX(c), toXXXX(c). |
| 99 | Surprisingly, there are no __toXXXX(c), but if __USE_EXTERN_INLINES, |
| 100 | there are inlines (yes, not macros!) for toXXXX(c) functions, |
| 101 | so those may have both inlines and macros!). |
| 102 | It also defines "unsafe" _toXXXX macros. |
| 103 | |
| 104 | All in all, __isXXXX(c) and __toXXXXX(c) seem to be useless, |
| 105 | they are full equivalents to non-underscored versions. |
| 106 | Remove? |
| 107 | |
| 108 | Macro-ization of isXXX(c) for __UCLIBC_HAS_XLOCALE__ case is problematic: |
| 109 | it is done by indexing: __UCLIBC_CTYPE_B[c], and in __UCLIBC_HAS_XLOCALE__ |
| 110 | case __UCLIBC_CTYPE_B is doing a __ctype_b_loc() call! We do not save |
| 111 | function call! Thus, why not have dedicated optimized functions |
| 112 | for each isXXXX() instead? Looking deeper, __ctype_b_loc() may have |
| 113 | another lever of function calls inside! What a mess... |