mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Fix MODE=aarch64 build
This commit is contained in:
parent
8767e9ad6a
commit
7512318a2a
9 changed files with 96 additions and 80 deletions
|
@ -11,13 +11,13 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
#define __ToUpper(c) ((c) >= 'a' && (c) <= 'z' ? (c) - 'a' + 'A' : (c))
|
||||
|
||||
forceinline int __strcmp(const char *l, const char *r) {
|
||||
__funline int __strcmp(const char *l, const char *r) {
|
||||
size_t i = 0;
|
||||
while (l[i] == r[i] && r[i]) ++i;
|
||||
return (l[i] & 255) - (r[i] & 255);
|
||||
}
|
||||
|
||||
forceinline char *__stpcpy(char *d, const char *s) {
|
||||
__funline char *__stpcpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
|
@ -26,7 +26,7 @@ forceinline char *__stpcpy(char *d, const char *s) {
|
|||
}
|
||||
}
|
||||
|
||||
forceinline void *__repstosb(void *di, char al, size_t cx) {
|
||||
__funline void *__repstosb(void *di, char al, size_t cx) {
|
||||
#if defined(__x86__) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
asm("rep stosb"
|
||||
: "=D"(di), "=c"(cx), "=m"(*(char(*)[cx])di)
|
||||
|
@ -39,7 +39,7 @@ forceinline void *__repstosb(void *di, char al, size_t cx) {
|
|||
#endif
|
||||
}
|
||||
|
||||
forceinline void *__repmovsb(void *di, const void *si, size_t cx) {
|
||||
__funline void *__repmovsb(void *di, const void *si, size_t cx) {
|
||||
#if defined(__x86__) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
asm("rep movsb"
|
||||
: "=D"(di), "=S"(si), "=c"(cx), "=m"(*(char(*)[cx])di)
|
||||
|
@ -53,7 +53,7 @@ forceinline void *__repmovsb(void *di, const void *si, size_t cx) {
|
|||
#endif
|
||||
}
|
||||
|
||||
forceinline void *__mempcpy(void *d, const void *s, size_t n) {
|
||||
__funline void *__mempcpy(void *d, const void *s, size_t n) {
|
||||
size_t i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
((char *)d)[i] = ((const char *)s)[i];
|
||||
|
@ -61,7 +61,7 @@ forceinline void *__mempcpy(void *d, const void *s, size_t n) {
|
|||
return (char *)d + n;
|
||||
}
|
||||
|
||||
forceinline char *__uintcpy(char p[hasatleast 21], uint64_t x) {
|
||||
__funline char *__uintcpy(char p[hasatleast 21], uint64_t x) {
|
||||
char t;
|
||||
size_t i, a, b;
|
||||
i = 0;
|
||||
|
@ -80,22 +80,22 @@ forceinline char *__uintcpy(char p[hasatleast 21], uint64_t x) {
|
|||
return p + i;
|
||||
}
|
||||
|
||||
forceinline char *__intcpy(char p[hasatleast 21], int64_t x) {
|
||||
__funline char *__intcpy(char p[hasatleast 21], int64_t x) {
|
||||
if (x < 0) *p++ = '-', x = -(uint64_t)x;
|
||||
return __uintcpy(p, x);
|
||||
}
|
||||
|
||||
forceinline char *__fixcpy(char p[hasatleast 17], uint64_t x, uint8_t k) {
|
||||
__funline char *__fixcpy(char p[hasatleast 17], uint64_t x, uint8_t k) {
|
||||
while (k > 0) *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15];
|
||||
*p = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
forceinline char *__hexcpy(char p[hasatleast 17], uint64_t x) {
|
||||
__funline char *__hexcpy(char p[hasatleast 17], uint64_t x) {
|
||||
return __fixcpy(p, x, ROUNDUP(x ? (__builtin_clzll(x) ^ 63) + 1 : 1, 4));
|
||||
}
|
||||
|
||||
forceinline const void *__memchr(const void *s, unsigned char c, size_t n) {
|
||||
__funline const void *__memchr(const void *s, unsigned char c, size_t n) {
|
||||
size_t i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (((const unsigned char *)s)[i] == c) {
|
||||
|
@ -105,7 +105,7 @@ forceinline const void *__memchr(const void *s, unsigned char c, size_t n) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
forceinline char *__strstr(const char *haystack, const char *needle) {
|
||||
__funline char *__strstr(const char *haystack, const char *needle) {
|
||||
size_t i;
|
||||
for (;;) {
|
||||
for (i = 0;; ++i) {
|
||||
|
@ -118,8 +118,8 @@ forceinline char *__strstr(const char *haystack, const char *needle) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
forceinline char16_t *__strstr16(const char16_t *haystack,
|
||||
const char16_t *needle) {
|
||||
__funline char16_t *__strstr16(const char16_t *haystack,
|
||||
const char16_t *needle) {
|
||||
size_t i;
|
||||
for (;;) {
|
||||
for (i = 0;; ++i) {
|
||||
|
@ -132,7 +132,7 @@ forceinline char16_t *__strstr16(const char16_t *haystack,
|
|||
return 0;
|
||||
}
|
||||
|
||||
forceinline char *__getenv(char **p, const char *s) {
|
||||
__funline char *__getenv(char **p, const char *s) {
|
||||
size_t i, j;
|
||||
if (p) {
|
||||
for (i = 0; p[i]; ++i) {
|
||||
|
@ -152,7 +152,7 @@ forceinline char *__getenv(char **p, const char *s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
forceinline const char *__strchr(const char *s, unsigned char c) {
|
||||
__funline const char *__strchr(const char *s, unsigned char c) {
|
||||
char *r;
|
||||
for (;; ++s) {
|
||||
if ((*s & 255) == c) return s;
|
||||
|
@ -160,14 +160,14 @@ forceinline const char *__strchr(const char *s, unsigned char c) {
|
|||
}
|
||||
}
|
||||
|
||||
forceinline unsigned long __atoul(const char *p) {
|
||||
__funline unsigned long __atoul(const char *p) {
|
||||
int c;
|
||||
unsigned long x = 0;
|
||||
while ('0' <= (c = *p++) && c <= '9') x *= 10, x += c - '0';
|
||||
return x;
|
||||
}
|
||||
|
||||
forceinline long __atol(const char *p) {
|
||||
__funline long __atol(const char *p) {
|
||||
int s = *p;
|
||||
unsigned long x;
|
||||
if (s == '-' || s == '+') ++p;
|
||||
|
@ -176,6 +176,41 @@ forceinline long __atol(const char *p) {
|
|||
return x;
|
||||
}
|
||||
|
||||
__funline void *__memset(void *a, int c, unsigned long n) {
|
||||
char *d = a;
|
||||
unsigned long i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
d[i] = c;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
__funline void *__memcpy(void *a, const void *b, unsigned long n) {
|
||||
char *d = a;
|
||||
unsigned long i;
|
||||
const char *s = b;
|
||||
for (i = 0; i < n; ++i) {
|
||||
d[i] = s[i];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
__funline void *__memmove(void *a, const void *b, unsigned long n) {
|
||||
char *d = a;
|
||||
unsigned long i;
|
||||
const char *s = b;
|
||||
if (d > s) {
|
||||
for (i = n; i--;) {
|
||||
d[i] = s[i];
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < n; ++i) {
|
||||
d[i] = s[i];
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LOG_LIBFATAL_INTERNAL_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue