mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 09:48:29 +00:00
Restore missing cosmopolitan documentation on website
This commit is contained in:
parent
58352df0a4
commit
d9d5f45e2d
36 changed files with 715 additions and 228 deletions
|
@ -43,7 +43,7 @@ static void bzero128(char *p, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
_Microarchitecture("avx") static void bzero_avx(char *p, size_t n) {
|
||||
xmm_t v = {0};
|
||||
if (IsAsan()) __asan_verify(p, n);
|
||||
|
@ -154,7 +154,7 @@ void bzero(void *p, size_t n) {
|
|||
b[--n] = x;
|
||||
} while (n);
|
||||
}
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
} else if (IsTiny()) {
|
||||
asm("rep stosb" : "+D"(b), "+c"(n), "=m"(*(char(*)[n])b) : "a"(0));
|
||||
return;
|
||||
|
|
|
@ -35,7 +35,7 @@ static inline const unsigned char *memchr_pure(const unsigned char *s,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
dontasan static inline const unsigned char *memchr_sse(const unsigned char *s,
|
||||
unsigned char c,
|
||||
size_t n) {
|
||||
|
@ -71,7 +71,7 @@ dontasan static inline const unsigned char *memchr_sse(const unsigned char *s,
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
void *memchr(const void *s, int c, size_t n) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
if (IsAsan()) __asan_verify(s, n);
|
||||
r = memchr_sse(s, c, n);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
|
||||
static dontinline antiquity int memcmp_sse(const unsigned char *p,
|
||||
const unsigned char *q, size_t n) {
|
||||
|
@ -143,7 +143,7 @@ int memcmp(const void *a, const void *b, size_t n) {
|
|||
const unsigned char *p, *q;
|
||||
if ((p = a) == (q = b) || !n) return 0;
|
||||
if ((c = *p - *q)) return c;
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (!IsTiny()) {
|
||||
if (n <= 16) {
|
||||
if (n >= 8) {
|
||||
|
|
|
@ -95,7 +95,7 @@ void *memmove(void *dst, const void *src, size_t n) {
|
|||
d = dst;
|
||||
s = src;
|
||||
|
||||
#ifdef __x86__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (IsTiny()) {
|
||||
uint16_t w1, w2;
|
||||
uint32_t l1, l2;
|
||||
|
@ -214,7 +214,7 @@ void *memmove(void *dst, const void *src, size_t n) {
|
|||
default:
|
||||
if (d == s) return d;
|
||||
|
||||
#ifdef __x86__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (n < kHalfCache3 || !kHalfCache3) {
|
||||
if (d > s) {
|
||||
if (IsAsan() || n < 900 || !X86_HAVE(ERMS)) {
|
||||
|
|
|
@ -35,7 +35,7 @@ static inline const unsigned char *memrchr_pure(const unsigned char *s,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
dontasan static inline const unsigned char *memrchr_sse(const unsigned char *s,
|
||||
unsigned char c,
|
||||
size_t n) {
|
||||
|
@ -69,7 +69,7 @@ dontasan static inline const unsigned char *memrchr_sse(const unsigned char *s,
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
void *memrchr(const void *s, int c, size_t n) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
if (IsAsan()) __asan_verify(s, n);
|
||||
r = memrchr_sse(s, c, n);
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
#include "libc/str/str.h"
|
||||
#ifndef __aarch64__
|
||||
|
||||
#ifndef __chibicc__
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
typedef long long xmm_a __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
|
||||
static void *memset_sse(char *p, char c, size_t n) {
|
||||
xmm_t v = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
|
||||
if (IsAsan()) __asan_verify(p, n);
|
||||
|
@ -44,8 +44,9 @@ static void *memset_sse(char *p, char c, size_t n) {
|
|||
}
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
_Microarchitecture("avx") static void *memset_avx(char *p, char c, size_t n) {
|
||||
char *t;
|
||||
xmm_t v = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
|
||||
|
@ -158,7 +159,7 @@ void *memset(void *p, int c, size_t n) {
|
|||
} while (n);
|
||||
}
|
||||
return b;
|
||||
#ifdef __x86__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
} else if (IsTiny()) {
|
||||
asm("rep stosb" : "+D"(b), "+c"(n), "=m"(*(char(*)[n])b) : "a"(c));
|
||||
return p;
|
||||
|
|
|
@ -38,7 +38,7 @@ dontasan char *stpcpy(char *d, const char *s) {
|
|||
if (IsAsan()) {
|
||||
__asan_verify(d, strlen(s) + 1);
|
||||
}
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
for (; (uintptr_t)(s + i) & 15; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
|
|
|
@ -30,7 +30,7 @@ static inline const char *strchr_pure(const char *s, int c) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
dontasan static inline const char *strchr_sse(const char *s, unsigned char c) {
|
||||
unsigned k;
|
||||
|
@ -95,7 +95,7 @@ static dontasan inline const char *strchr_x64(const char *p, uint64_t c) {
|
|||
* @vforksafe
|
||||
*/
|
||||
char *strchr(const char *s, int c) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const char *r;
|
||||
if (X86_HAVE(SSE)) {
|
||||
if (IsAsan()) __asan_verify(s, 1);
|
||||
|
|
|
@ -30,7 +30,7 @@ static inline const char *strchrnul_pure(const char *s, int c) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
dontasan static inline const char *strchrnul_sse(const char *s,
|
||||
unsigned char c) {
|
||||
|
@ -94,7 +94,7 @@ dontasan static const char *strchrnul_x64(const char *p, uint64_t c) {
|
|||
* NUL terminator if c is not found
|
||||
*/
|
||||
char *strchrnul(const char *s, int c) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const char *r;
|
||||
if (X86_HAVE(SSE)) {
|
||||
if (IsAsan()) __asan_verify(s, 1);
|
||||
|
|
|
@ -39,7 +39,7 @@ dontasan char *strcpy(char *d, const char *s) {
|
|||
if (IsAsan()) {
|
||||
__asan_verify(d, strlen(s) + 1);
|
||||
}
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
for (; (uintptr_t)(s + i) & 15; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
dontasan size_t strlen(const char *s) {
|
||||
if (IsAsan()) __asan_verify_str(s);
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
xmm_t z = {0};
|
||||
unsigned m, k = (uintptr_t)s & 15;
|
||||
|
|
|
@ -2,11 +2,15 @@
|
|||
#define COSMOPOLITAN_LIBC_BITS_WEAKEN_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#ifndef __chibicc__
|
||||
#define _weaken(symbol) \
|
||||
__extension__({ \
|
||||
extern __typeof__(symbol) symbol __attribute__((__weak__)); \
|
||||
&symbol; \
|
||||
})
|
||||
#else
|
||||
#define _weaken(symbol) (&(symbol))
|
||||
#endif
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_BITS_WEAKEN_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue