mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Make minor improvements
- Work towards simplifying ape.S startup process - Rewrote ar because it took minutes to build cosmopolitan.a
This commit is contained in:
parent
95bc650be8
commit
aea89fe832
70 changed files with 1037 additions and 456 deletions
|
@ -256,97 +256,6 @@ bool luhn(const char *);
|
|||
|
||||
char *strsignal(int) returnsnonnull libcesque;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § strings » hooks ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
extern int (*const hook$strcmp16)(const char16_t *, const char16_t *);
|
||||
extern int (*const hook$strncmp16)(const char16_t *, const char16_t *, size_t);
|
||||
extern int (*const hook$wcscmp)(const wchar_t *, const wchar_t *);
|
||||
extern int (*const hook$wcsncmp)(const wchar_t *, const wchar_t *, size_t);
|
||||
#define __STR_HOOK(SYMBOL) hook$##SYMBOL
|
||||
#else
|
||||
#define __STR_HOOK(SYMBOL) SYMBOL
|
||||
#endif /* GNUC && !ANSI */
|
||||
|
||||
/* TODO(jart): Use @gotpcrel. */
|
||||
#undef __STR_HOOK
|
||||
#define __STR_HOOK(SYMBOL) SYMBOL
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § strings » generic typing ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#if __STDC_VERSION__ + 0 >= 201112
|
||||
|
||||
#define strnlen(s, n) \
|
||||
_Generic(*(s), wchar_t \
|
||||
: wcsnlen, char16_t \
|
||||
: strnlen16, default \
|
||||
: strnlen)(s, n)
|
||||
|
||||
#define strnlen_s(s, n) \
|
||||
_Generic(*(s), wchar_t \
|
||||
: wcsnlen_s, char16_t \
|
||||
: strnlen16_s, default \
|
||||
: strnlen_s)(s, n)
|
||||
|
||||
#define strpbrk(s, c) \
|
||||
_Generic(*(s), wchar_t \
|
||||
: wcspbrk, char16_t \
|
||||
: strpbrk16, default \
|
||||
: strpbrk)(s, c)
|
||||
|
||||
#define strspn(s, c) \
|
||||
_Generic(*(s), wchar_t : wcsspn, char16_t : strspn16, default : strspn)(s, c)
|
||||
|
||||
#define strcspn(s, c) \
|
||||
_Generic(*(s), wchar_t \
|
||||
: wcscspn, char16_t \
|
||||
: strcspn16, default \
|
||||
: strcspn)(s, c)
|
||||
|
||||
/* clang-format off */
|
||||
#define strcmp(s1, s2) \
|
||||
_Generic((s1)[0], \
|
||||
wchar_t: __STR_HOOK(wcscmp), \
|
||||
char16_t: _Generic(*(s2), \
|
||||
char: strcmp16to8, \
|
||||
default: __STR_HOOK(strcmp16)), \
|
||||
default: _Generic(*(s2), \
|
||||
char16_t: strcmp8to16, \
|
||||
default: strcmp))(s1, s2)
|
||||
/* clang-format on */
|
||||
|
||||
#define strncmp(s1, s2, n) \
|
||||
_Generic(*(s1), wchar_t \
|
||||
: __STR_HOOK(wcsncmp), char16_t \
|
||||
: _Generic(*(s2), char \
|
||||
: strncmp16to8, default \
|
||||
: __STR_HOOK(strncmp16)), \
|
||||
default \
|
||||
: _Generic(*(s2), char16_t \
|
||||
: strncmp8to16, default \
|
||||
: strncmp))(s1, s2, n)
|
||||
|
||||
#define strcasecmp(s1, s2) \
|
||||
_Generic(*(s1), wchar_t \
|
||||
: wcscasecmp, char16_t \
|
||||
: strcasecmp16, default \
|
||||
: strcasecmp)(s1, s2)
|
||||
|
||||
#define strncasecmp(s1, s2, n) \
|
||||
_Generic(*(s1), wchar_t \
|
||||
: wcsncasecmp, char16_t \
|
||||
: strncasecmp16, default \
|
||||
: strncasecmp)(s1, s2, n)
|
||||
|
||||
#define chomp(s) \
|
||||
_Generic(*(s), wchar_t : wchomp, char16_t : chomp16, default : chomp)(s)
|
||||
|
||||
#endif /* C11 */
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § strings » optimizations ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue