mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +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
|
@ -23,6 +23,7 @@
|
|||
|
||||
typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
|
||||
#if !defined(__chibicc__)
|
||||
static int bcmp_sse(const char *p, const char *q, size_t n) {
|
||||
xmm_t a;
|
||||
while (n > 32) {
|
||||
|
@ -36,8 +37,9 @@ static int bcmp_sse(const char *p, const char *q, size_t n) {
|
|||
*(const xmm_t *)(p + n - 16) ^ *(const xmm_t *)(q + n - 16);
|
||||
return !!(a[0] | a[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
_Microarchitecture("avx") static int bcmp_avx(const char *p, const char *q,
|
||||
size_t n) {
|
||||
xmm_t a, b, c, d;
|
||||
|
@ -123,12 +125,14 @@ int bcmp(const void *a, const void *b, size_t n) {
|
|||
__builtin_memcpy(&j, q + n - 4, 4);
|
||||
return !!(i ^ j);
|
||||
}
|
||||
#ifndef __chibicc__
|
||||
#ifdef __x86_64__
|
||||
} else if (LIKELY(X86_HAVE(AVX))) {
|
||||
return bcmp_avx(p, q, n);
|
||||
#endif
|
||||
} else {
|
||||
return bcmp_sse(p, q, n);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
while (n--) {
|
||||
|
|
|
@ -34,7 +34,7 @@ void djbsort(int32_t *a, size_t n) {
|
|||
__asan_verify(a, m);
|
||||
}
|
||||
if (n > 1) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (X86_HAVE(AVX2)) {
|
||||
djbsort_avx2(a, n);
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ dontasan bool _isutf8(const void *data, size_t size) {
|
|||
p = data;
|
||||
e = p + size;
|
||||
while (p < e) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (!((intptr_t)p & 15)) {
|
||||
for (;;) {
|
||||
if ((m = __builtin_ia32_pmovmskb128(*(xmm_t *)p >= (xmm_t){0}) ^
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
|||
*/
|
||||
dontasan void *memmem(const void *haystack, size_t haystacklen,
|
||||
const void *needle, size_t needlelen) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
char c;
|
||||
xmm_t n, *v;
|
||||
unsigned i, k, m;
|
||||
|
|
|
@ -34,7 +34,7 @@ static inline const char16_t *memrchr16_pure(const char16_t *s, char16_t c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
dontasan static inline const char16_t *memrchr16_sse(const char16_t *s,
|
||||
char16_t c, size_t n) {
|
||||
size_t i;
|
||||
|
@ -67,7 +67,7 @@ dontasan static inline const char16_t *memrchr16_sse(const char16_t *s,
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
void *memrchr16(const void *s, int c, size_t n) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
if (!IsTiny() && X86_HAVE(SSE)) {
|
||||
if (IsAsan()) __asan_verify(s, n * 2);
|
||||
|
|
|
@ -31,7 +31,7 @@ static inline const unsigned char *rawmemchr_pure(const unsigned char *s,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
dontasan static inline const char *rawmemchr_sse(const char *s,
|
||||
unsigned char c) {
|
||||
|
@ -68,7 +68,7 @@ static inline dontasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
|
|||
* @return is pointer to first instance of c
|
||||
*/
|
||||
void *rawmemchr(const void *s, int c) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
if (X86_HAVE(SSE)) {
|
||||
if (IsAsan()) __asan_verify(s, 1);
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
|||
* @see strstr()
|
||||
*/
|
||||
dontasan char *strcasestr(const char *haystack, const char *needle) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
char c;
|
||||
xmm_t *p;
|
||||
size_t i;
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef char16_t xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
dontasan size_t strlen16(const char16_t *s) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
size_t n;
|
||||
xmm_t z = {0};
|
||||
unsigned m, k = (uintptr_t)s & 15;
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
|||
* @see memmem()
|
||||
*/
|
||||
dontasan char *strstr(const char *haystack, const char *needle) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
xmm_t *p;
|
||||
size_t i;
|
||||
unsigned k, m;
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#ifndef __chibicc__
|
||||
typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
|
||||
dontasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
|
||||
size_t n) {
|
||||
uint64_t w;
|
||||
|
@ -39,8 +39,9 @@ dontasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q,
|
|||
w = a[0] | a[1];
|
||||
return w | w >> 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
dontasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p,
|
||||
const char *q,
|
||||
size_t n) {
|
||||
|
@ -141,12 +142,14 @@ int timingsafe_bcmp(const void *a, const void *b, size_t n) {
|
|||
__asan_verify(a, n);
|
||||
__asan_verify(b, n);
|
||||
}
|
||||
#ifndef __chibicc__
|
||||
#ifdef __x86_64__
|
||||
if (X86_HAVE(AVX)) {
|
||||
return timingsafe_bcmp_avx(p, q, n);
|
||||
}
|
||||
#endif
|
||||
return timingsafe_bcmp_sse(p, q, n);
|
||||
#endif
|
||||
}
|
||||
} else if (n >= 4) {
|
||||
__builtin_memcpy(&u0, p, 4);
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef wchar_t xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
dontasan size_t wcslen(const wchar_t *s) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
size_t n;
|
||||
xmm_t z = {0};
|
||||
unsigned m, k = (uintptr_t)s & 15;
|
||||
|
|
|
@ -30,7 +30,7 @@ extern const uint32_t kCombiningCharsBits;
|
|||
* Returns cell width of monospace character.
|
||||
*/
|
||||
int wcwidth(wchar_t c) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (LIKELY(32 <= c && c < 127)) {
|
||||
return 1;
|
||||
} else if (!c) {
|
||||
|
|
|
@ -35,7 +35,7 @@ static inline const wchar_t *wmemrchr_pure(const wchar_t *s, wchar_t c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
dontasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c,
|
||||
size_t n) {
|
||||
size_t i;
|
||||
|
@ -68,7 +68,7 @@ dontasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c,
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
void *wmemrchr(const wchar_t *s, wchar_t c, size_t n) {
|
||||
#ifdef __x86_64__
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
size_t bytes;
|
||||
const void *r;
|
||||
if (IsAsan()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue