mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +00:00
Make numerous improvements
- Python static hello world now 1.8mb - Python static fully loaded now 10mb - Python HTTPS client now uses MbedTLS - Python REPL now completes import stmts - Increase stack size for Python for now - Begin synthesizing posixpath and ntpath - Restore Python \N{UNICODE NAME} support - Restore Python NFKD symbol normalization - Add optimized code path for Intel SHA-NI - Get more Python unit tests passing faster - Get Python help() pagination working on NT - Python hashlib now supports MbedTLS PBKDF2 - Make memcpy/memmove/memcmp/bcmp/etc. faster - Add Mersenne Twister and Vigna to LIBC_RAND - Provide privileged __printf() for error code - Fix zipos opendir() so that it reports ENOTDIR - Add basic chmod() implementation for Windows NT - Add Cosmo's best functions to Python cosmo module - Pin function trace indent depth to that of caller - Show memory diagram on invalid access in MODE=dbg - Differentiate stack overflow on crash in MODE=dbg - Add stb_truetype and tools for analyzing font files - Upgrade to UNICODE 13 and reduce its binary footprint - COMPILE.COM now logs resource usage of build commands - Start implementing basic poll() support on bare metal - Set getauxval(AT_EXECFN) to GetModuleFileName() on NT - Add descriptions to strerror() in non-TINY build modes - Add COUNTBRANCH() macro to help with micro-optimizations - Make error / backtrace / asan / memory code more unbreakable - Add fast perfect C implementation of μ-Law and a-Law audio codecs - Make strtol() functions consistent with other libc implementations - Improve Linenoise implementation (see also github.com/jart/bestline) - COMPILE.COM now suppresses stdout/stderr of successful build commands
This commit is contained in:
parent
fa7b4f5bd1
commit
39bf41f4eb
806 changed files with 77494 additions and 63859 deletions
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/str/blake2.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
|
@ -83,8 +84,16 @@ TEST(BLAKE2B256Test, ABC) {
|
|||
}
|
||||
|
||||
BENCH(blake2, bench) {
|
||||
EZBENCH2("blake2b256 0", donothing, EZBLAKE2B256(0, 0));
|
||||
EZBENCH2("blake2b256 8", donothing, EZBLAKE2B256("helloooo", 8));
|
||||
EZBENCH2("blake2b256 22851", donothing,
|
||||
EZBLAKE2B256(kHyperion, kHyperionSize));
|
||||
char fun[256];
|
||||
rngset(fun, 256, rand64, -1);
|
||||
EZBENCH_N("blake2b256", 0, EZBLAKE2B256(0, 0));
|
||||
EZBENCH_N("blake2b256", 8, EZBLAKE2B256("helloooo", 8));
|
||||
EZBENCH_N("blake2b256", 31, EZBLAKE2B256(fun, 31));
|
||||
EZBENCH_N("blake2b256", 32, EZBLAKE2B256(fun, 32));
|
||||
EZBENCH_N("blake2b256", 63, EZBLAKE2B256(fun, 63));
|
||||
EZBENCH_N("blake2b256", 64, EZBLAKE2B256(fun, 64));
|
||||
EZBENCH_N("blake2b256", 128, EZBLAKE2B256(fun, 128));
|
||||
EZBENCH_N("blake2b256", 256, EZBLAKE2B256(fun, 256));
|
||||
EZBENCH_N("blake2b256", kHyperionSize,
|
||||
EZBLAKE2B256(kHyperion, kHyperionSize));
|
||||
}
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/crc32.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
|
@ -40,6 +43,10 @@ TEST(crc32c, test) {
|
|||
EXPECT_EQ(0x6d6eefba, crc32c(crc32c(0, FANATICS, strlen(FANATICS)),
|
||||
hyperion + strlen(FANATICS),
|
||||
strlen(hyperion) - strlen(FANATICS)));
|
||||
EXPECT_EQ(0xf372f045, crc32c(0, hyperion + 1, strlen(hyperion) - 1));
|
||||
EXPECT_EQ(0x5aaad5f8, crc32c(0, hyperion + 7, strlen(hyperion) - 7));
|
||||
EXPECT_EQ(0xf8e51ea6, crc32c(0, hyperion + 7, strlen(hyperion) - 8));
|
||||
EXPECT_EQ(0xecc9871d, crc32c(0, kHyperion, kHyperionSize));
|
||||
}
|
||||
|
||||
BENCH(crc32c, bench) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,59 +16,45 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/crc32.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/fastrandomstring.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
int unfancy_memcmp(const void *a, const void *b, size_t n) {
|
||||
int c;
|
||||
size_t i;
|
||||
const unsigned char *x, *y;
|
||||
for (x = a, y = b, i = 0; i < n; ++i) {
|
||||
if ((c = x[i] - y[i])) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#define FANATICS "Fanatics"
|
||||
|
||||
static const char hyperion[] =
|
||||
FANATICS " have their dreams, wherewith they weave / "
|
||||
"A paradise for a sect; the savage too / "
|
||||
"From forth the loftiest fashion of his sleep / "
|
||||
"...";
|
||||
|
||||
TEST(crc32_z, test) {
|
||||
char *p;
|
||||
p = gc(strdup(kHyperion));
|
||||
EXPECT_EQ(0, crc32_z(0, 0, 0));
|
||||
EXPECT_EQ(0, crc32_z(0, "", 0));
|
||||
EXPECT_EQ(0xcbf43926, crc32_z(0, "123456789", 9));
|
||||
EXPECT_EQ(0xc386e7e4, crc32_z(0, hyperion, strlen(hyperion)));
|
||||
EXPECT_EQ(0xc386e7e4, crc32_z(crc32_z(0, FANATICS, strlen(FANATICS)),
|
||||
hyperion + strlen(FANATICS),
|
||||
strlen(hyperion) - strlen(FANATICS)));
|
||||
EXPECT_EQ(0xcbfc3df2, crc32_z(0, hyperion + 1, strlen(hyperion) - 1));
|
||||
EXPECT_EQ(0x9feb0e30, crc32_z(0, hyperion + 7, strlen(hyperion) - 7));
|
||||
EXPECT_EQ(0x5b80e54e, crc32_z(0, hyperion + 7, strlen(hyperion) - 8));
|
||||
EXPECT_EQ(0xe9ded8e6, crc32_z(0, p, kHyperionSize));
|
||||
}
|
||||
|
||||
TEST(memcmp, test) {
|
||||
EXPECT_EQ(0, memcmp("hi", "hi", 2));
|
||||
EXPECT_NE(0, memcmp("hi", "HI", 2));
|
||||
EXPECT_EQ(-1, memcmp("a", "b", 1));
|
||||
EXPECT_EQ(+1, memcmp("b", "a", 1));
|
||||
}
|
||||
|
||||
TEST(memcmp, fuzz) {
|
||||
int i, n;
|
||||
char a[32], b[32];
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
n = rand() & 31;
|
||||
rngset(a, n, rand64, -1);
|
||||
rngset(b, n, rand64, -1);
|
||||
ASSERT_EQ(unfancy_memcmp(a, b, n), memcmp(a, b, n), "n=%d", n);
|
||||
}
|
||||
}
|
||||
|
||||
BENCH(memcmp, bench) {
|
||||
extern int funcmp(const void *a, const void *b, size_t n) asm("memcmp");
|
||||
volatile int v;
|
||||
const char *volatile a;
|
||||
const char *volatile b;
|
||||
b = a = "123456789123456789123456789123456789123456789123456789";
|
||||
EZBENCH2("memcmp same", donothing, v = funcmp(a, b, 7));
|
||||
b = gc(strdup(b));
|
||||
EZBENCH2("memcmp 1", donothing, v = funcmp(a, b, 1));
|
||||
EZBENCH2("memcmp 2", donothing, v = funcmp(a, b, 2));
|
||||
EZBENCH2("memcmp 3", donothing, v = funcmp(a, b, 3));
|
||||
EZBENCH2("memcmp 4", donothing, v = funcmp(a, b, 4));
|
||||
EZBENCH2("memcmp 5", donothing, v = funcmp(a, b, 5));
|
||||
EZBENCH2("memcmp 6", donothing, v = funcmp(a, b, 6));
|
||||
EZBENCH2("memcmp 7", donothing, v = funcmp(a, b, 7));
|
||||
EZBENCH2("memcmp 8", donothing, v = funcmp(a, b, 8));
|
||||
EZBENCH2("memcmp 9", donothing, v = funcmp(a, b, 9));
|
||||
EZBENCH2("memcmp 16", donothing, v = funcmp(a, b, 16));
|
||||
EZBENCH2("memcmp 32", donothing, v = funcmp(a, b, 32));
|
||||
BENCH(crc32_z, bench) {
|
||||
EZBENCH_N("crc32_z", kHyperionSize, crc32_z(0, kHyperion, kHyperionSize));
|
||||
EZBENCH_N("crc32_z", kHyperionSize, crc32_z(0, kHyperion, kHyperionSize));
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/nexgen32e/crc32.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/highwayhash64.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -93,6 +94,21 @@ TEST(highwayhash64, test) {
|
|||
TestHash64(0x53c516cce478cad7ull, data, 33, kTestKey2);
|
||||
}
|
||||
|
||||
BENCH(highwayhash64, newbench) {
|
||||
char fun[256];
|
||||
rngset(fun, 256, rand64, -1);
|
||||
EZBENCH_N("highwayhash64", 0, HighwayHash64(0, 0, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 8, HighwayHash64("helloooo", 8, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 31, HighwayHash64(fun, 31, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 32, HighwayHash64(fun, 32, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 63, HighwayHash64(fun, 63, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 64, HighwayHash64(fun, 64, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 128, HighwayHash64(fun, 128, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", 256, HighwayHash64(fun, 256, kTestKey1));
|
||||
EZBENCH_N("highwayhash64", kHyperionSize,
|
||||
HighwayHash64(kHyperion, kHyperionSize, kTestKey1));
|
||||
}
|
||||
|
||||
BENCH(highwayhash64, bench) {
|
||||
EZBENCH2("knuth small", donothing,
|
||||
EXPROPRIATE(KnuthMultiplicativeHash32(VEIL("r", "hello"), 5)));
|
||||
|
|
|
@ -160,8 +160,6 @@ TEST(memcpy, testBackwardsOverlap3) {
|
|||
free(c);
|
||||
}
|
||||
|
||||
void *MemCpy(void *, const void *, size_t);
|
||||
|
||||
#define B(F, N) \
|
||||
do { \
|
||||
char *d = rngset(malloc(N), N, rand64, -1); \
|
||||
|
@ -173,9 +171,7 @@ void *MemCpy(void *, const void *, size_t);
|
|||
} while (0)
|
||||
|
||||
void BB(size_t N) {
|
||||
B(memmove_pure, N);
|
||||
B(memcpy, N);
|
||||
B(MemCpy, N);
|
||||
(fprintf)(stderr, "\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,12 @@ char u8[] = "utf-8 ☻";
|
|||
char16_t u16[] = u"utf16 ☻";
|
||||
wchar_t u32[] = L"utf32 ☻";
|
||||
|
||||
size_t strlen_pure(const char *s) {
|
||||
size_t n = 0;
|
||||
while (*s++) ++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
TEST(strlen, usageExample_c11) {
|
||||
_Alignas(16) char ugh[] = "eeeeeeeeeeeeeee\017";
|
||||
EXPECT_EQ(1, strlen_pure(ugh + 15));
|
||||
|
|
|
@ -28,6 +28,7 @@ TEST_LIBC_STR_DIRECTDEPS = \
|
|||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RAND \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue