mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Mint APE Loader v1.5
This change ports APE Loader to Linux AARCH64, so that Raspberry Pi users can run programs like redbean, without the executable needing to modify itself. Progress has also slipped into this change on the issue of making progress better conforming to user expectations and industry standards regarding which symbols we're allowed to declare
This commit is contained in:
parent
6843150e0c
commit
7e0a09feec
510 changed files with 1783 additions and 1483 deletions
|
@ -29,7 +29,7 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
// clang-format off
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
__static_yoink("zipos");
|
||||
|
||||
int fds[2];
|
||||
char buf[8];
|
||||
|
|
|
@ -30,7 +30,7 @@ char buf[6] = {0};
|
|||
struct rlimit rlim = {0, 10};
|
||||
|
||||
TEST(pipe, efault) {
|
||||
EXPECT_SYS(EFAULT, -1, pipe(VEIL("r", (void *)0)));
|
||||
EXPECT_SYS(EFAULT, -1, pipe(__veil("r", (void *)0)));
|
||||
}
|
||||
|
||||
TEST(pipe, einval) {
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
STATIC_YOINK("libc/testlib/hyperion.txt");
|
||||
__static_yoink("zipos");
|
||||
__static_yoink("libc/testlib/hyperion.txt");
|
||||
|
||||
#define THREADS 8
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -128,8 +129,8 @@ TEST(setrlimit, testMemoryLimit) {
|
|||
ASSERT_NE(-1, (wstatus = xspawn(0)));
|
||||
if (wstatus == -2) {
|
||||
ASSERT_EQ(0, SetKernelEnforcedMemoryLimit(MEM));
|
||||
for (gotsome = i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) {
|
||||
p = mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE,
|
||||
for (gotsome = i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) {
|
||||
p = mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0);
|
||||
if (p != MAP_FAILED) {
|
||||
gotsome = true;
|
||||
|
@ -141,7 +142,7 @@ TEST(setrlimit, testMemoryLimit) {
|
|||
ASSERT_EQ(ENOMEM, errno);
|
||||
_Exit(0);
|
||||
}
|
||||
rngset(p, APE_GUARDSIZE, _rand64, -1);
|
||||
rngset(p, getauxval(AT_PAGESZ), _rand64, -1);
|
||||
}
|
||||
_Exit(1);
|
||||
}
|
||||
|
@ -161,15 +162,15 @@ TEST(setrlimit, testVirtualMemoryLimit) {
|
|||
ASSERT_NE(-1, (wstatus = xspawn(0)));
|
||||
if (wstatus == -2) {
|
||||
ASSERT_EQ(0, setrlimit(RLIMIT_AS, &(struct rlimit){MEM, MEM}));
|
||||
for (i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) {
|
||||
p = sys_mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE,
|
||||
for (i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) {
|
||||
p = sys_mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0)
|
||||
.addr;
|
||||
if (p == MAP_FAILED) {
|
||||
ASSERT_EQ(ENOMEM, errno);
|
||||
_Exit(0);
|
||||
}
|
||||
rngset(p, APE_GUARDSIZE, _rand64, -1);
|
||||
rngset(p, getauxval(AT_PAGESZ), _rand64, -1);
|
||||
}
|
||||
_Exit(1);
|
||||
}
|
||||
|
@ -191,15 +192,15 @@ TEST(setrlimit, testDataMemoryLimit) {
|
|||
ASSERT_NE(-1, (wstatus = xspawn(0)));
|
||||
if (wstatus == -2) {
|
||||
ASSERT_EQ(0, setrlimit(RLIMIT_DATA, &(struct rlimit){MEM, MEM}));
|
||||
for (i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) {
|
||||
p = sys_mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE,
|
||||
for (i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) {
|
||||
p = sys_mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0)
|
||||
.addr;
|
||||
if (p == MAP_FAILED) {
|
||||
ASSERT_EQ(ENOMEM, errno);
|
||||
_Exit(0);
|
||||
}
|
||||
rngset(p, APE_GUARDSIZE, _rand64, -1);
|
||||
rngset(p, getauxval(AT_PAGESZ), _rand64, -1);
|
||||
}
|
||||
_Exit(1);
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void OnFpe(int sig, struct siginfo *si, void *vctx) {
|
|||
ctx->uc_mcontext.rdx = 0;
|
||||
}
|
||||
|
||||
noubsan void ubsanTrumpsSystemsEngineering(void) {
|
||||
dontubsan void ubsanTrumpsSystemsEngineering(void) {
|
||||
struct sigaction saint = {.sa_sigaction = OnFpe, .sa_flags = SA_SIGINFO};
|
||||
EXPECT_SYS(0, 0, sigaction(SIGFPE, &saint, &oldsa));
|
||||
volatile long x = 0;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
__static_yoink("zipos");
|
||||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
__static_yoink("zipos");
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int fd = open("/zip/life.elf", O_RDONLY);
|
||||
|
|
|
@ -573,29 +573,30 @@ TEST(strtol, invalidHex_consistentWithBsd2) {
|
|||
}
|
||||
|
||||
BENCH(atoi, bench) {
|
||||
EZBENCH2("atoi 10⁸", donothing, EXPROPRIATE(atoi(VEIL("r", "100000000"))));
|
||||
EZBENCH2("atoi 10⁸", donothing,
|
||||
__expropriate(atoi(__veil("r", "100000000"))));
|
||||
EZBENCH2("strtol 10⁸", donothing,
|
||||
EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtol(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("strtoul 10⁸", donothing,
|
||||
EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtol(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("wcstol 10⁸", donothing,
|
||||
EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstol(__veil("r", L"100000000"), 0, 10)));
|
||||
EZBENCH2("wcstoul 10⁸", donothing,
|
||||
EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstol(__veil("r", L"100000000"), 0, 10)));
|
||||
EZBENCH2("strtoimax 10⁸", donothing,
|
||||
EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtoimax(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("strtoumax 10⁸", donothing,
|
||||
EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtoimax(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("wcstoimax 10⁸", donothing,
|
||||
EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10)));
|
||||
EZBENCH2("wcstoumax 10⁸", donothing,
|
||||
EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10)));
|
||||
EZBENCH2("strtoi128 10⁸", donothing,
|
||||
EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtoi128(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("strtou128 10⁸", donothing,
|
||||
EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10)));
|
||||
__expropriate(strtoi128(__veil("r", "100000000"), 0, 10)));
|
||||
EZBENCH2("wcstoi128 10⁸", donothing,
|
||||
EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10)));
|
||||
EZBENCH2("wcstou128 10⁸", donothing,
|
||||
EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10)));
|
||||
__expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10)));
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ TEST(_bitreverse, test) {
|
|||
|
||||
BENCH(_bitreverse, bench) {
|
||||
EZBENCH2("_bitreverse8", donothing,
|
||||
EXPROPRIATE(_bitreverse8(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse8(__conceal("r", 123))));
|
||||
EZBENCH2("_bitreverse32", donothing,
|
||||
EXPROPRIATE(_bitreverse32(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse32(__conceal("r", 123))));
|
||||
EZBENCH2("_bitreverse64", donothing,
|
||||
EXPROPRIATE(_bitreverse64(CONCEAL("r", 123))));
|
||||
__expropriate(_bitreverse64(__conceal("r", 123))));
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ TEST(ksnprintf, fuzzTheUnbreakable) {
|
|||
uint64_t x;
|
||||
char *f, b[32];
|
||||
_Alignas(FRAMESIZE) static const char weasel[FRAMESIZE];
|
||||
f = VEIL("r", weasel);
|
||||
f = __veil("r", weasel);
|
||||
EXPECT_SYS(0, 0, mprotect(f, FRAMESIZE, PROT_READ | PROT_WRITE));
|
||||
strcpy(f, "hello %s\n");
|
||||
EXPECT_EQ(12, ksnprintf(b, sizeof(b), f, "world"));
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
static noasan void *golden(void *p, int c, size_t n) {
|
||||
static dontasan void *golden(void *p, int c, size_t n) {
|
||||
size_t i;
|
||||
if (IsAsan()) __asan_verify(p, n);
|
||||
for (i = 0; i < n; ++i) ((char *)p)[i] = c;
|
||||
|
|
|
@ -60,6 +60,6 @@ TEST(unmorton, test) {
|
|||
|
||||
BENCH(morton, bench) {
|
||||
EZBENCH2("morton", donothing,
|
||||
EXPROPRIATE(morton(CONCEAL("r", 123), CONCEAL("r", 123))));
|
||||
EZBENCH2("unmorton", donothing, EXPROPRIATE(unmorton(CONCEAL("r", 123))));
|
||||
__expropriate(morton(__conceal("r", 123), __conceal("r", 123))));
|
||||
EZBENCH2("unmorton", donothing, __expropriate(unmorton(__conceal("r", 123))));
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
@ -28,14 +28,14 @@ void SetUpOnce(void) {
|
|||
|
||||
TEST(popcnt, test) {
|
||||
EXPECT_EQ(32, popcnt(0x5555555555555555));
|
||||
EXPECT_EQ(32, popcnt(VEIL("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, (popcnt)(VEIL("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, popcnt(__veil("r", 0x5555555555555555)));
|
||||
EXPECT_EQ(32, (popcnt)(__veil("r", 0x5555555555555555)));
|
||||
}
|
||||
|
||||
BENCH(popcnt, bench) {
|
||||
EZBENCH2("popcnt", donothing,
|
||||
EXPROPRIATE(popcnt(VEIL("r", 0x5555555555555555))));
|
||||
__expropriate(popcnt(__veil("r", 0x5555555555555555))));
|
||||
EZBENCH2("(popcnt)", donothing,
|
||||
EXPROPRIATE((popcnt)(VEIL("r", 0x5555555555555555))));
|
||||
__expropriate((popcnt)(__veil("r", 0x5555555555555555))));
|
||||
EZBENCH_N("_countbits", kHyperionSize, _countbits(kHyperion, kHyperionSize));
|
||||
}
|
||||
|
|
|
@ -93,15 +93,16 @@ TEST(strchr, fuzz) {
|
|||
}
|
||||
|
||||
BENCH(strchr, bench) {
|
||||
EZBENCH2("strchr 0", donothing, EXPROPRIATE(strchr(VEIL("r", ""), 0)));
|
||||
EZBENCH2("strchr 5", donothing, EXPROPRIATE(strchr(VEIL("r", "hello"), 'o')));
|
||||
EZBENCH2("strchr 0", donothing, __expropriate(strchr(__veil("r", ""), 0)));
|
||||
EZBENCH2("strchr 5", donothing,
|
||||
__expropriate(strchr(__veil("r", "hello"), 'o')));
|
||||
EZBENCH2("strchr 8", donothing,
|
||||
EXPROPRIATE(strchr(VEIL("r", "hellzzzo"), 'o')));
|
||||
__expropriate(strchr(__veil("r", "hellzzzo"), 'o')));
|
||||
EZBENCH2("strchr 17", donothing,
|
||||
EXPROPRIATE(strchr(VEIL("r", "hellzzzhellzzzeeo"), 'o')));
|
||||
__expropriate(strchr(__veil("r", "hellzzzhellzzzeeo"), 'o')));
|
||||
EZBENCH2("strchr 34", donothing,
|
||||
EXPROPRIATE(
|
||||
strchr(VEIL("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o')));
|
||||
__expropriate(
|
||||
strchr(__veil("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o')));
|
||||
}
|
||||
|
||||
char *memchr_pure(const char *m, int c, size_t n) {
|
||||
|
|
|
@ -543,37 +543,37 @@ BENCH(bench_00_strcmp, bench) {
|
|||
dupe = gc(malloc(size));
|
||||
|
||||
EZBENCH2("strcmp [identity]", longstringislong(size, data),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), data)));
|
||||
__expropriate(strcmp(__veil("r", data), data)));
|
||||
|
||||
EZBENCH2("strcmp [2 diff]", donothing,
|
||||
EXPROPRIATE(strcmp(VEIL("r", "hi"), VEIL("r", "there"))));
|
||||
__expropriate(strcmp(__veil("r", "hi"), __veil("r", "there"))));
|
||||
EZBENCH2("scmppure [2 diff]", donothing,
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", "hi"), VEIL("r", "there"))));
|
||||
__expropriate(strcmp_pure(__veil("r", "hi"), __veil("r", "there"))));
|
||||
|
||||
EZBENCH2("strcmp [2 dupe]", randomize_buf2str_dupe(2, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [2 dupe]", randomize_buf2str_dupe(2, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [4 dupe]", randomize_buf2str_dupe(4, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [4 dupe]", randomize_buf2str_dupe(4, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [8 dupe]", randomize_buf2str_dupe(8, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [8 dupe]", randomize_buf2str_dupe(8, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcmp [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2("scmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
}
|
||||
|
||||
BENCH(bench_01_strcasecmp, bench) {
|
||||
|
@ -584,26 +584,28 @@ BENCH(bench_01_strcasecmp, bench) {
|
|||
dupe = gc(malloc(size));
|
||||
|
||||
EZBENCH2("strcasecmp [iden]", longstringislong(size, data),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), data)));
|
||||
__expropriate(strcasecmp(__veil("r", data), data)));
|
||||
|
||||
EZBENCH2("strcasecmp [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
EZBENCH2("sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcasecmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2(
|
||||
"sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe),
|
||||
__expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
|
||||
EZBENCH2("strcasecmp [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe))));
|
||||
EZBENCH2("sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe))));
|
||||
__expropriate(strcasecmp(__veil("r", data), __veil("r", dupe))));
|
||||
EZBENCH2(
|
||||
"sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe),
|
||||
__expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe))));
|
||||
}
|
||||
|
||||
BENCH(memcmp, bench) {
|
||||
volatile char *copy = gc(strdup(kHyperion));
|
||||
EZBENCH2("memcmp big", donothing,
|
||||
EXPROPRIATE(memcmp(kHyperion, copy, kHyperionSize)));
|
||||
__expropriate(memcmp(kHyperion, copy, kHyperionSize)));
|
||||
copy = gc(strdup("tough little ship"));
|
||||
EZBENCH2("memcmp 18", donothing,
|
||||
EXPROPRIATE(memcmp("tough little ship", copy, 18)));
|
||||
__expropriate(memcmp("tough little ship", copy, 18)));
|
||||
}
|
||||
|
||||
/* jart
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
#include "net/http/escape.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
STATIC_YOINK("backtrace.com");
|
||||
STATIC_YOINK("backtrace.com.dbg");
|
||||
__static_yoink("backtrace.com");
|
||||
__static_yoink("backtrace.com.dbg");
|
||||
|
||||
char testlib_enable_tmp_setup_teardown_once;
|
||||
|
||||
|
|
|
@ -26,5 +26,6 @@ TEST(memrchr, test) {
|
|||
}
|
||||
|
||||
BENCH(memrchr, bench) {
|
||||
EZBENCH2("memrchr", donothing, EXPROPRIATE(memrchr("yo.hi.there", '.', 11)));
|
||||
EZBENCH2("memrchr", donothing,
|
||||
__expropriate(memrchr("yo.hi.there", '.', 11)));
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ TEST(strcspn, test) {
|
|||
|
||||
BENCH(strcspn, bench) {
|
||||
EZBENCH2("strcspn", donothing,
|
||||
EXPROPRIATE(
|
||||
__expropriate(
|
||||
strcspn("pABCDEFGHIJKLMNOPABCDEFGHIJKLMNO", "abcdefghijklmnp")));
|
||||
EZBENCH2("strcspn", donothing,
|
||||
EXPROPRIATE(
|
||||
__expropriate(
|
||||
strcspn("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOp", "abcdefghijklmnp")));
|
||||
EZBENCH2(
|
||||
"strcspn", donothing,
|
||||
EXPROPRIATE(strcspn(
|
||||
__expropriate(strcspn(
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOABCDEFGHIJKLMNOPABCDEFGHIJKLMNOp",
|
||||
"abcdefghijklmnp")));
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
STATIC_YOINK("realloc");
|
||||
__static_yoink("realloc");
|
||||
|
||||
TEST(grow, testNull_hasAllocatingBehavior) {
|
||||
void *p = NULL;
|
||||
|
|
|
@ -50,128 +50,128 @@ void SetUp(void) {
|
|||
/* 32-BIT SIGNED NEGATION */
|
||||
|
||||
TEST(__negvsi2, testMax) {
|
||||
EXPECT_EQ(-INT_MAX, -VEIL("r", INT_MAX));
|
||||
EXPECT_EQ(-INT_MAX, -__veil("r", INT_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__negvsi2, testMin0) {
|
||||
EXPROPRIATE(-VEIL("r", INT_MIN));
|
||||
__expropriate(-__veil("r", INT_MIN));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
/* 64-BIT SIGNED NEGATION */
|
||||
|
||||
TEST(__negvdi2, testMax) {
|
||||
EXPECT_EQ(-LONG_MAX, -VEIL("r", LONG_MAX));
|
||||
EXPECT_EQ(-LONG_MAX, -__veil("r", LONG_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__negvdi2, testMin0) {
|
||||
EXPROPRIATE(-VEIL("r", LONG_MIN));
|
||||
__expropriate(-__veil("r", LONG_MIN));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
/* 32-BIT SIGNED MULTIPLICATION */
|
||||
|
||||
TEST(__mulvsi3, testMin0) {
|
||||
EXPECT_EQ(0, 0 * VEIL("r", INT_MIN));
|
||||
EXPECT_EQ(0, 0 * __veil("r", INT_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, testMin1) {
|
||||
EXPECT_EQ(INT_MIN, 1 * VEIL("r", INT_MIN));
|
||||
EXPECT_EQ(INT_MIN, 1 * __veil("r", INT_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, testMin2) {
|
||||
EXPROPRIATE(2 * VEIL("r", INT_MIN));
|
||||
__expropriate(2 * __veil("r", INT_MIN));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, testMax0) {
|
||||
EXPECT_EQ(0, 0 * VEIL("r", INT_MAX));
|
||||
EXPECT_EQ(0, 0 * __veil("r", INT_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, testMax1) {
|
||||
EXPECT_EQ(INT_MAX, 1 * VEIL("r", INT_MAX));
|
||||
EXPECT_EQ(INT_MAX, 1 * __veil("r", INT_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, testMax2) {
|
||||
EXPROPRIATE(2 * VEIL("r", INT_MAX));
|
||||
__expropriate(2 * __veil("r", INT_MAX));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, test7) {
|
||||
EXPECT_EQ(0x70000000, 7 * VEIL("r", 0x10000000));
|
||||
EXPECT_EQ(0x70000000, 7 * __veil("r", 0x10000000));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, test8) {
|
||||
EXPROPRIATE(8 * VEIL("r", 0x10000000));
|
||||
__expropriate(8 * __veil("r", 0x10000000));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, test31337) {
|
||||
EXPROPRIATE(0x31337 * VEIL("r", 0x31337));
|
||||
__expropriate(0x31337 * __veil("r", 0x31337));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvsi3, standAndDeliver_aNegativeTimesANegativeEqualsAPositive) {
|
||||
EXPECT_EQ(25, -5 * VEIL("r", -5));
|
||||
EXPECT_EQ(25, -5 * __veil("r", -5));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
/* 64-BIT SIGNED MULTIPLICATION */
|
||||
|
||||
TEST(__mulvdi3, testMin0) {
|
||||
EXPECT_EQ(0, 0 * VEIL("r", LONG_MIN));
|
||||
EXPECT_EQ(0, 0 * __veil("r", LONG_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, testMin1) {
|
||||
EXPECT_EQ(LONG_MIN, 1 * VEIL("r", LONG_MIN));
|
||||
EXPECT_EQ(LONG_MIN, 1 * __veil("r", LONG_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, testMin2) {
|
||||
EXPROPRIATE(2 * VEIL("r", LONG_MIN));
|
||||
__expropriate(2 * __veil("r", LONG_MIN));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, testMax0) {
|
||||
EXPECT_EQ(0, 0 * VEIL("r", LONG_MAX));
|
||||
EXPECT_EQ(0, 0 * __veil("r", LONG_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, testMax1) {
|
||||
EXPECT_EQ(LONG_MAX, 1 * VEIL("r", LONG_MAX));
|
||||
EXPECT_EQ(LONG_MAX, 1 * __veil("r", LONG_MAX));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, testMax2) {
|
||||
EXPROPRIATE(2 * VEIL("r", LONG_MAX));
|
||||
__expropriate(2 * __veil("r", LONG_MAX));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, test7) {
|
||||
EXPECT_EQ(0x7000000000000000l, 7 * VEIL("r", 0x1000000000000000l));
|
||||
EXPECT_EQ(0x7000000000000000l, 7 * __veil("r", 0x1000000000000000l));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, test8) {
|
||||
EXPROPRIATE(8 * VEIL("r", 0x1000000000000000l));
|
||||
__expropriate(8 * __veil("r", 0x1000000000000000l));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, test31337) {
|
||||
EXPROPRIATE(0x3133700000000l * VEIL("r", 0x3133700000000l));
|
||||
__expropriate(0x3133700000000l * __veil("r", 0x3133700000000l));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__mulvdi3, standAndDeliver_aNegativeTimesANegativeEqualsAPositive) {
|
||||
EXPECT_EQ(25l, -5l * VEIL("r", -5l));
|
||||
EXPECT_EQ(25l, -5l * __veil("r", -5l));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
|
@ -188,73 +188,73 @@ TEST(__mulvdi3, testOverflow) {
|
|||
/* 32-BIT SIGNED ADDITION */
|
||||
|
||||
TEST(__addvsi3, testMin1) {
|
||||
EXPECT_EQ(INT_MIN + 1, 1 + VEIL("r", INT_MIN));
|
||||
EXPECT_EQ(INT_MIN + 1, 1 + __veil("r", INT_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvsi3, testMax1) {
|
||||
EXPROPRIATE(1 + VEIL("r", INT_MAX));
|
||||
__expropriate(1 + __veil("r", INT_MAX));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvsi3, testNegPos) {
|
||||
EXPECT_EQ(2, -2 + VEIL("r", 4));
|
||||
EXPECT_EQ(2, -2 + __veil("r", 4));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvsi3, testPosNeg) {
|
||||
EXPECT_EQ(-2, 2 + VEIL("r", -4));
|
||||
EXPECT_EQ(-2, 2 + __veil("r", -4));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
/* 64-BIT SIGNED ADDITION */
|
||||
|
||||
TEST(__addvdi3, testMin1) {
|
||||
EXPECT_EQ(LONG_MIN + 1, 1 + VEIL("r", LONG_MIN));
|
||||
EXPECT_EQ(LONG_MIN + 1, 1 + __veil("r", LONG_MIN));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvdi3, testMax1) {
|
||||
EXPROPRIATE(1 + VEIL("r", LONG_MAX));
|
||||
__expropriate(1 + __veil("r", LONG_MAX));
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvdi3, testNegPos) {
|
||||
EXPECT_EQ(2l, -2l + VEIL("r", 4l));
|
||||
EXPECT_EQ(2l, -2l + __veil("r", 4l));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__addvdi3, testPosNeg) {
|
||||
EXPECT_EQ(-2l, 2l + VEIL("r", -4l));
|
||||
EXPECT_EQ(-2l, 2l + __veil("r", -4l));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
/* 32-BIT SIGNED SUBTRACTION */
|
||||
|
||||
TEST(__subvsi3, testMin1) {
|
||||
EXPROPRIATE(VEIL("r", INT_MIN) - 1);
|
||||
__expropriate(__veil("r", INT_MIN) - 1);
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__subvsi3, testMax1) {
|
||||
EXPECT_EQ(INT_MAX - 1, VEIL("r", INT_MAX) - 1);
|
||||
EXPECT_EQ(INT_MAX - 1, __veil("r", INT_MAX) - 1);
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__subvsi3, testPosNeg) {
|
||||
EXPECT_EQ(-2, 2 - VEIL("r", 4));
|
||||
EXPECT_EQ(-2, 2 - __veil("r", 4));
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
/* 64-BIT SIGNED SUBTRACTION */
|
||||
|
||||
TEST(__subvdi3, testMin1) {
|
||||
EXPROPRIATE(VEIL("r", LONG_MIN) - 1);
|
||||
__expropriate(__veil("r", LONG_MIN) - 1);
|
||||
EXPECT_TRUE(overflowed_);
|
||||
}
|
||||
|
||||
TEST(__subvdi3, testMax1) {
|
||||
EXPECT_EQ(LONG_MAX - 1, VEIL("r", LONG_MAX) - 1);
|
||||
EXPECT_EQ(LONG_MAX - 1, __veil("r", LONG_MAX) - 1);
|
||||
EXPECT_FALSE(overflowed_);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "libc/x/xspawn.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
__static_yoink("zipos");
|
||||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -116,9 +117,9 @@ void TearDown(void) {
|
|||
}
|
||||
|
||||
TEST(mprotect, testOkMemory) {
|
||||
char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
p[0] = 0;
|
||||
ASSERT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE));
|
||||
ASSERT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE));
|
||||
p[0] = 1;
|
||||
EXPECT_EQ(1, p[0]);
|
||||
EXPECT_FALSE(gotsegv);
|
||||
|
@ -127,19 +128,19 @@ TEST(mprotect, testOkMemory) {
|
|||
|
||||
TEST(mprotect, testSegfault_writeToReadOnlyAnonymous) {
|
||||
volatile char *p;
|
||||
p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
EXPECT_FALSE(gotsegv);
|
||||
p[0] = 1;
|
||||
EXPECT_FALSE(gotsegv);
|
||||
EXPECT_FALSE(gotbusted);
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ));
|
||||
_missingno(p[0]);
|
||||
EXPECT_FALSE(gotsegv);
|
||||
EXPECT_FALSE(gotbusted);
|
||||
p[0] = 2;
|
||||
EXPECT_TRUE(gotsegv | gotbusted);
|
||||
EXPECT_EQ(1, p[0]);
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE));
|
||||
}
|
||||
|
||||
TEST(mprotect, testExecOnly_canExecute) {
|
||||
|
@ -159,33 +160,34 @@ TEST(mprotect, testExecOnly_canExecute) {
|
|||
|
||||
TEST(mprotect, testProtNone_cantEvenRead) {
|
||||
volatile char *p;
|
||||
p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_NONE));
|
||||
p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_NONE));
|
||||
_missingno(p[0]);
|
||||
EXPECT_TRUE(gotsegv | gotbusted);
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE));
|
||||
}
|
||||
|
||||
TEST(mprotect, testExecJit_actuallyWorks) {
|
||||
int (*p)(void) = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
int (*p)(void) = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
memcpy(p, kRet31337, sizeof(kRet31337));
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_EXEC));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_EXEC));
|
||||
EXPECT_EQ(31337, p());
|
||||
EXPECT_FALSE(gotsegv);
|
||||
EXPECT_FALSE(gotbusted);
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE));
|
||||
}
|
||||
|
||||
TEST(mprotect, testRwxMap_vonNeumannRules) {
|
||||
if (IsOpenbsd()) return; // boo
|
||||
if (IsXnuSilicon()) return; // boo
|
||||
int (*p)(void) = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
int (*p)(void) = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
memcpy(p, kRet31337, sizeof(kRet31337));
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE | PROT_EXEC));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ),
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC));
|
||||
EXPECT_EQ(31337, p());
|
||||
EXPECT_FALSE(gotsegv);
|
||||
EXPECT_FALSE(gotbusted);
|
||||
EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE));
|
||||
EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE));
|
||||
}
|
||||
|
||||
TEST(mprotect, testExecuteFlatFileMapOpenedAsReadonly) {
|
||||
|
@ -220,13 +222,13 @@ TEST(mprotect, testFileMap_canChangeToExecWhileOpenInRdwrMode) {
|
|||
}
|
||||
|
||||
TEST(mprotect, testBadProt_failsEinval) {
|
||||
volatile char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
volatile char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
EXPECT_EQ(-1, mprotect(p, 9999, -1));
|
||||
EXPECT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
||||
TEST(mprotect, testZeroSize_doesNothing) {
|
||||
volatile char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE));
|
||||
volatile char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ)));
|
||||
EXPECT_NE(-1, mprotect(p, 0, PROT_READ));
|
||||
p[0] = 1;
|
||||
EXPECT_FALSE(gotsegv);
|
||||
|
|
|
@ -82,10 +82,15 @@ o/$(MODE)/test/libc/runtime/itsatrap_test.o: private \
|
|||
-fno-sanitize=all \
|
||||
-ftrapv
|
||||
|
||||
ifeq ($(ARCH), aarch64)
|
||||
FTRACEASM_LDSCRIPT = o/$(MODE)/ape/aarch64.lds
|
||||
endif
|
||||
|
||||
o/$(MODE)/test/libc/runtime/prog/ftraceasm.elf: \
|
||||
$(TEST_LIBC_RUNTIME_DEPS) \
|
||||
o/$(MODE)/test/libc/runtime/prog/ftraceasm.o \
|
||||
o/$(MODE)/test/libc/runtime/runtime.pkg
|
||||
o/$(MODE)/test/libc/runtime/runtime.pkg \
|
||||
$(FTRACEASM_LDSCRIPT)
|
||||
@$(ELFLINK)
|
||||
o/$(MODE)/test/libc/runtime/prog/ftraceasm.txt: \
|
||||
o/$(MODE)/test/libc/runtime/prog/ftraceasm.elf
|
||||
|
|
|
@ -30,7 +30,7 @@ _Thread_local long x;
|
|||
_Thread_local long y[1] = {40};
|
||||
_Alignas(A) _Thread_local long a;
|
||||
|
||||
noubsan void *Worker(void *arg) {
|
||||
dontubsan void *Worker(void *arg) {
|
||||
ASSERT_EQ(42, x + y[0] + z);
|
||||
ASSERT_EQ(0, (intptr_t)&a & (A - 1));
|
||||
if (IsAsan()) {
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/x/xiso8601.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
STATIC_YOINK("usr/share/zoneinfo/New_York");
|
||||
__static_yoink("zipos");
|
||||
__static_yoink("usr/share/zoneinfo/New_York");
|
||||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
|
|
|
@ -633,33 +633,36 @@ TEST(vsnprintf, issue785) {
|
|||
}
|
||||
|
||||
BENCH(palandprintf, bench) {
|
||||
EZBENCH2("ascii", donothing, Format(VEIL("r", "hiuhcreohucreo")));
|
||||
EZBENCH2("ascii %s", donothing, Format("%s", VEIL("r", "hiuhcreohucreo")));
|
||||
EZBENCH2("ascii %`'s", donothing, Format("%`'s", VEIL("r", "hiuhcreohucre")));
|
||||
EZBENCH2("utf8 %s", donothing, Format("%s", VEIL("r", "hi (╯°□°)╯")));
|
||||
EZBENCH2("snprintf %hs", donothing, Format("%hs", VEIL("r", u"hi (╯°□°)╯")));
|
||||
EZBENCH2("snprintf %ls", donothing, Format("%ls", VEIL("r", L"hi (╯°□°)╯")));
|
||||
EZBENCH2("23 %x", donothing, Format("%x", VEIL("r", 23)));
|
||||
EZBENCH2("23 %d", donothing, Format("%d", VEIL("r", 23)));
|
||||
EZBENCH2("%f M_PI", donothing, Format("%f", VEIL("x", M_PI)));
|
||||
EZBENCH2("%g M_PI", donothing, Format("%g", VEIL("x", M_PI)));
|
||||
EZBENCH2("%a M_PI", donothing, Format("%a", VEIL("x", M_PI)));
|
||||
EZBENCH2("%e M_PI", donothing, Format("%e", VEIL("x", M_PI)));
|
||||
EZBENCH2("ULONG_MAX %lo", donothing, Format("%lo", VEIL("r", ULONG_MAX)));
|
||||
EZBENCH2("INT_MIN %x", donothing, Format("%x", VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %d", donothing, Format("%d", VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %,d", donothing, Format("%,d", VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)VEIL("r", INT_MIN)));
|
||||
EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("ascii", donothing, Format(__veil("r", "hiuhcreohucreo")));
|
||||
EZBENCH2("ascii %s", donothing, Format("%s", __veil("r", "hiuhcreohucreo")));
|
||||
EZBENCH2("ascii %`'s", donothing,
|
||||
Format("%`'s", __veil("r", "hiuhcreohucre")));
|
||||
EZBENCH2("utf8 %s", donothing, Format("%s", __veil("r", "hi (╯°□°)╯")));
|
||||
EZBENCH2("snprintf %hs", donothing,
|
||||
Format("%hs", __veil("r", u"hi (╯°□°)╯")));
|
||||
EZBENCH2("snprintf %ls", donothing,
|
||||
Format("%ls", __veil("r", L"hi (╯°□°)╯")));
|
||||
EZBENCH2("23 %x", donothing, Format("%x", __veil("r", 23)));
|
||||
EZBENCH2("23 %d", donothing, Format("%d", __veil("r", 23)));
|
||||
EZBENCH2("%f M_PI", donothing, Format("%f", __veil("x", M_PI)));
|
||||
EZBENCH2("%g M_PI", donothing, Format("%g", __veil("x", M_PI)));
|
||||
EZBENCH2("%a M_PI", donothing, Format("%a", __veil("x", M_PI)));
|
||||
EZBENCH2("%e M_PI", donothing, Format("%e", __veil("x", M_PI)));
|
||||
EZBENCH2("ULONG_MAX %lo", donothing, Format("%lo", __veil("r", ULONG_MAX)));
|
||||
EZBENCH2("INT_MIN %x", donothing, Format("%x", __veil("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %d", donothing, Format("%d", __veil("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %,d", donothing, Format("%,d", __veil("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)__veil("r", INT_MIN)));
|
||||
EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", __veil("r", LONG_MIN)));
|
||||
EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", __veil("r", LONG_MIN)));
|
||||
EZBENCH2("INT128_MIN %jjd", donothing, Format("%jjd", INT128_MIN));
|
||||
EZBENCH2("INT128_MIN %jjx", donothing, Format("%jjx", INT128_MIN));
|
||||
EZBENCH2("int64toarray 23", donothing, FormatInt64(buffer, 23));
|
||||
EZBENCH2("int64toarray min", donothing, FormatInt64(buffer, INT_MIN));
|
||||
#ifdef __x86__
|
||||
EZBENCH2("%Lf M_PI", donothing, Format("%Lf", VEIL("t", M_PI)));
|
||||
EZBENCH2("%Lg M_PI", donothing, Format("%Lg", VEIL("t", M_PI)));
|
||||
EZBENCH2("%La M_PI", donothing, Format("%La", VEIL("t", M_PI)));
|
||||
EZBENCH2("%Le M_PI", donothing, Format("%Le", VEIL("t", M_PI)));
|
||||
EZBENCH2("%Lf M_PI", donothing, Format("%Lf", __veil("t", M_PI)));
|
||||
EZBENCH2("%Lg M_PI", donothing, Format("%Lg", __veil("t", M_PI)));
|
||||
EZBENCH2("%La M_PI", donothing, Format("%La", __veil("t", M_PI)));
|
||||
EZBENCH2("%Le M_PI", donothing, Format("%Le", __veil("t", M_PI)));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
/* MODE=tiny makes these dependencies optional */
|
||||
STATIC_YOINK("strnwidth");
|
||||
STATIC_YOINK("strnwidth16");
|
||||
STATIC_YOINK("wcsnwidth");
|
||||
__static_yoink("strnwidth");
|
||||
__static_yoink("strnwidth16");
|
||||
__static_yoink("wcsnwidth");
|
||||
|
||||
TEST(SUITE(sprintf), testStringLength) {
|
||||
ASSERT_STREQ("This", Format(FORMAT("%.4"), STRING("This is a test")));
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#include "libc/x/x.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
STATIC_YOINK("_tr");
|
||||
STATIC_YOINK("glob");
|
||||
__static_yoink("_tr");
|
||||
__static_yoink("glob");
|
||||
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
||||
|
|
|
@ -74,15 +74,17 @@ BENCH(crc32c, bench) {
|
|||
EZBENCH_N("crc32c", i, crc32c(0, kHyperion, i));
|
||||
EZBENCH_N("crc32_z", i, crc32_z(0, kHyperion, i));
|
||||
EZBENCH_N("fnv_hash", i,
|
||||
EXPROPRIATE(fnv_hash(VEIL("r", kHyperion), VEIL("r", i))));
|
||||
EZBENCH_N("KMH", i, EXPROPRIATE(KMH(VEIL("r", kHyperion), VEIL("r", i))));
|
||||
__expropriate(fnv_hash(__veil("r", kHyperion), __veil("r", i))));
|
||||
EZBENCH_N("KMH", i,
|
||||
__expropriate(KMH(__veil("r", kHyperion), __veil("r", i))));
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
EZBENCH_N("crc32c", kHyperionSize, crc32c(0, kHyperion, kHyperionSize));
|
||||
EZBENCH_N("crc32_z", kHyperionSize, crc32_z(0, kHyperion, kHyperionSize));
|
||||
EZBENCH_N("fnv_hash", kHyperionSize,
|
||||
__expropriate(
|
||||
fnv_hash(__veil("r", kHyperion), __veil("r", kHyperionSize))));
|
||||
EZBENCH_N(
|
||||
"fnv_hash", kHyperionSize,
|
||||
EXPROPRIATE(fnv_hash(VEIL("r", kHyperion), VEIL("r", kHyperionSize))));
|
||||
EZBENCH_N("KMH", kHyperionSize,
|
||||
EXPROPRIATE(KMH(VEIL("r", kHyperion), VEIL("r", kHyperionSize))));
|
||||
"KMH", kHyperionSize,
|
||||
__expropriate(KMH(__veil("r", kHyperion), __veil("r", kHyperionSize))));
|
||||
}
|
||||
|
|
|
@ -113,10 +113,10 @@ BENCH(highwayhash64, newbench) {
|
|||
|
||||
BENCH(highwayhash64, bench) {
|
||||
EZBENCH2("knuth small", donothing,
|
||||
EXPROPRIATE(KnuthMultiplicativeHash32(VEIL("r", "hello"), 5)));
|
||||
__expropriate(KnuthMultiplicativeHash32(__veil("r", "hello"), 5)));
|
||||
EZBENCH2("crc32c small", donothing, crc32c(0, "hello", 5));
|
||||
EZBENCH2("crc32 small", donothing,
|
||||
EXPROPRIATE(crc32_z(0, VEIL("r", "hello"), 5)));
|
||||
__expropriate(crc32_z(0, __veil("r", "hello"), 5)));
|
||||
EZBENCH2("highwayhash64 small", donothing,
|
||||
HighwayHash64((void *)"hello", 5, kTestKey1));
|
||||
EZBENCH2("crc32 big", donothing, crc32_z(0, kHyperion, kHyperionSize));
|
||||
|
@ -124,6 +124,6 @@ BENCH(highwayhash64, bench) {
|
|||
EZBENCH2("highwayhash64 big", donothing,
|
||||
HighwayHash64((void *)kHyperion, kHyperionSize, kTestKey1));
|
||||
EZBENCH2("knuth big", donothing,
|
||||
EXPROPRIATE(
|
||||
KnuthMultiplicativeHash32(VEIL("r", kHyperion), kHyperionSize)));
|
||||
__expropriate(KnuthMultiplicativeHash32(__veil("r", kHyperion),
|
||||
kHyperionSize)));
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
|
@ -35,5 +35,5 @@ TEST(memcasecmp, test) {
|
|||
BENCH(memcasecmp, bench) {
|
||||
volatile char *copy = gc(strdup(kHyperion));
|
||||
EZBENCH2("memcasecmp", donothing,
|
||||
EXPROPRIATE(memcasecmp(kHyperion, copy, kHyperionSize)));
|
||||
__expropriate(memcasecmp(kHyperion, copy, kHyperionSize)));
|
||||
}
|
||||
|
|
|
@ -154,20 +154,20 @@ TEST(memcpy, testBackwardsOverlap3) {
|
|||
volatile char *c;
|
||||
c = malloc(3);
|
||||
memcpy(c, "\e[C", 3);
|
||||
memcpy(c, c + 1, VEIL("r", 3) - 1);
|
||||
memcpy(c, c + 1, __veil("r", 3) - 1);
|
||||
EXPECT_EQ('[', c[0]);
|
||||
EXPECT_EQ('C', c[1]);
|
||||
free(c);
|
||||
}
|
||||
|
||||
#define B(F, N) \
|
||||
do { \
|
||||
char *d = rngset(malloc(N), N, _rand64, -1); \
|
||||
char *s = rngset(malloc(N), N, _rand64, -1); \
|
||||
EZBENCH2(#F " " #N, donothing, \
|
||||
EXPROPRIATE(F(VEIL("r", d), VEIL("r", s), N))); \
|
||||
free(d); \
|
||||
free(s); \
|
||||
#define B(F, N) \
|
||||
do { \
|
||||
char *d = rngset(malloc(N), N, _rand64, -1); \
|
||||
char *s = rngset(malloc(N), N, _rand64, -1); \
|
||||
EZBENCH2(#F " " #N, donothing, \
|
||||
__expropriate(F(__veil("r", d), __veil("r", s), N))); \
|
||||
free(d); \
|
||||
free(s); \
|
||||
} while (0)
|
||||
|
||||
void BB(size_t N) {
|
||||
|
|
|
@ -193,11 +193,11 @@ TEST(memmem, fuzz) {
|
|||
*/
|
||||
BENCH(memmem, bench) {
|
||||
EZBENCH2("memmem naive", donothing,
|
||||
EXPROPRIATE(memmem_naive(kHyperion, kHyperionSize, "THE END", 7)));
|
||||
__expropriate(memmem_naive(kHyperion, kHyperionSize, "THE END", 7)));
|
||||
EZBENCH2("memmem", donothing,
|
||||
EXPROPRIATE(memmem(kHyperion, kHyperionSize, "THE END", 7)));
|
||||
__expropriate(memmem(kHyperion, kHyperionSize, "THE END", 7)));
|
||||
EZBENCH2("memmem", donothing,
|
||||
EXPROPRIATE(memmem(
|
||||
__expropriate(memmem(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
62, "aaaaaab", 7)));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ TEST(memrchr16, test) {
|
|||
|
||||
BENCH(memrchr16, bench) {
|
||||
EZBENCH2("memrchr16", donothing,
|
||||
EXPROPRIATE(memrchr16(u"yo.hi.there", '.', 11)));
|
||||
__expropriate(memrchr16(u"yo.hi.there", '.', 11)));
|
||||
EZBENCH2("memrchr16 hyperion", donothing,
|
||||
EXPROPRIATE(memrchr16(kHyperion, '.', kHyperionSize / 2)));
|
||||
__expropriate(memrchr16(kHyperion, '.', kHyperionSize / 2)));
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ TEST(strcasecmp, test) {
|
|||
|
||||
BENCH(strcasecmp, bench) {
|
||||
EZBENCH2("strcasecmp 16 eq (same)", donothing,
|
||||
EXPROPRIATE(
|
||||
strcasecmp(VEIL("r", "abcdefghijklmnop"), "abcdefghijklmnop")));
|
||||
__expropriate(strcasecmp(__veil("r", "abcdefghijklmnop"),
|
||||
"abcdefghijklmnop")));
|
||||
EZBENCH2("strcasecmp 16 eq (evil)", donothing,
|
||||
EXPROPRIATE(
|
||||
strcasecmp(VEIL("r", "abcdefghijklmnop"), "ABCDEFGHIJKLMNOP")));
|
||||
__expropriate(strcasecmp(__veil("r", "abcdefghijklmnop"),
|
||||
"ABCDEFGHIJKLMNOP")));
|
||||
}
|
||||
|
|
|
@ -122,41 +122,41 @@ TEST(strcasestr, test) {
|
|||
*/
|
||||
BENCH(strcasestr, bench) {
|
||||
EZBENCH2("strcasestr naive", donothing,
|
||||
EXPROPRIATE(strcasestr_naive(kHyperion, "THE END")));
|
||||
__expropriate(strcasestr_naive(kHyperion, "THE END")));
|
||||
EZBENCH2("strcasestr", donothing,
|
||||
EXPROPRIATE(strcasestr(kHyperion, "THE END")));
|
||||
__expropriate(strcasestr(kHyperion, "THE END")));
|
||||
EZBENCH2("strcasestr tort 1", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"B")));
|
||||
EZBENCH2("strcasestr tort 2", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"ab")));
|
||||
EZBENCH2("strcasestr tort 4", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaab")));
|
||||
EZBENCH2("strcasestr tort 8", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaaaaaab")));
|
||||
EZBENCH2("strcasestr tort 16", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaaaaaaaaaaaaaab")));
|
||||
EZBENCH2("strcasestr tort 32", donothing,
|
||||
EXPROPRIATE(strcasestr(
|
||||
__expropriate(strcasestr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
|
|
|
@ -40,8 +40,10 @@ TEST(strlcpy, testShortBuffer_copies) {
|
|||
|
||||
BENCH(strlcpy, bench) {
|
||||
char buf[256];
|
||||
EZBENCH2("strlcpy", donothing,
|
||||
EXPROPRIATE(strlcpy(VEIL("r", buf), "hello there", sizeof(buf))));
|
||||
EZBENCH2("strncpy", donothing,
|
||||
EXPROPRIATE(strncpy(VEIL("r", buf), "hello there", sizeof(buf))));
|
||||
EZBENCH2(
|
||||
"strlcpy", donothing,
|
||||
__expropriate(strlcpy(__veil("r", buf), "hello there", sizeof(buf))));
|
||||
EZBENCH2(
|
||||
"strncpy", donothing,
|
||||
__expropriate(strncpy(__veil("r", buf), "hello there", sizeof(buf))));
|
||||
}
|
||||
|
|
|
@ -53,5 +53,5 @@ TEST(strwidth, cjk) {
|
|||
}
|
||||
|
||||
BENCH(strnwidth, bench) {
|
||||
EZBENCH2("strnwidth", donothing, EXPROPRIATE(strnwidth(kHyperion, -1, 0)));
|
||||
EZBENCH2("strnwidth", donothing, __expropriate(strnwidth(kHyperion, -1, 0)));
|
||||
}
|
||||
|
|
|
@ -129,40 +129,40 @@ TEST(strstr, breakit) {
|
|||
*/
|
||||
BENCH(strstr, bench) {
|
||||
EZBENCH2("strstr naive", donothing,
|
||||
EXPROPRIATE(strstr_naive(kHyperion, "THE END")));
|
||||
EZBENCH2("strstr", donothing, EXPROPRIATE(strstr(kHyperion, "THE END")));
|
||||
__expropriate(strstr_naive(kHyperion, "THE END")));
|
||||
EZBENCH2("strstr", donothing, __expropriate(strstr(kHyperion, "THE END")));
|
||||
EZBENCH2("strstr torture 1", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"b")));
|
||||
EZBENCH2("strstr torture 2", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"ab")));
|
||||
EZBENCH2("strstr torture 4", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaab")));
|
||||
EZBENCH2("strstr torture 8", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaaaaaab")));
|
||||
EZBENCH2("strstr torture 16", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
"aaaaaaaaaaaaaaab")));
|
||||
EZBENCH2("strstr torture 32", donothing,
|
||||
EXPROPRIATE(strstr(
|
||||
__expropriate(strstr(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
|
||||
|
|
|
@ -44,39 +44,45 @@ TEST(towlower, test) {
|
|||
}
|
||||
|
||||
BENCH(towupper, bench) {
|
||||
EZBENCH2("towupper ascii", donothing, EXPROPRIATE(towupper(VEIL("r", L'a'))));
|
||||
EZBENCH2("towupper ascii", donothing,
|
||||
__expropriate(towupper(__veil("r", L'a'))));
|
||||
EZBENCH2("towupper latin1", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", u'A'))));
|
||||
__expropriate(towupper(__veil("r", u'A'))));
|
||||
EZBENCH2("towupper watinc", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", u'Ỿ'))));
|
||||
EZBENCH2("towupper greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α'))));
|
||||
__expropriate(towupper(__veil("r", u'Ỿ'))));
|
||||
EZBENCH2("towupper greek", donothing,
|
||||
__expropriate(towupper(__veil("r", u'α'))));
|
||||
EZBENCH2("towupper astral", donothing,
|
||||
EXPROPRIATE(towupper(VEIL("r", L'𝛿'))));
|
||||
__expropriate(towupper(__veil("r", L'𝛿'))));
|
||||
}
|
||||
|
||||
BENCH(towlower, bench) {
|
||||
EZBENCH2("towlower ascii", donothing, EXPROPRIATE(towlower(VEIL("r", L'a'))));
|
||||
EZBENCH2("towlower ascii", donothing,
|
||||
__expropriate(towlower(__veil("r", L'a'))));
|
||||
EZBENCH2("towlower latin1", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", u'A'))));
|
||||
__expropriate(towlower(__veil("r", u'A'))));
|
||||
EZBENCH2("towlower watinc", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", u'Ỿ'))));
|
||||
EZBENCH2("towlower greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α'))));
|
||||
__expropriate(towlower(__veil("r", u'Ỿ'))));
|
||||
EZBENCH2("towlower greek", donothing,
|
||||
__expropriate(towupper(__veil("r", u'α'))));
|
||||
EZBENCH2("towlower astral", donothing,
|
||||
EXPROPRIATE(towlower(VEIL("r", L'𝛿'))));
|
||||
__expropriate(towlower(__veil("r", L'𝛿'))));
|
||||
}
|
||||
|
||||
BENCH(iswupper, bench) {
|
||||
EZBENCH2("iswupper ascii", donothing, EXPROPRIATE(iswupper(VEIL("r", L'A'))));
|
||||
EZBENCH2("iswupper ascii", donothing,
|
||||
__expropriate(iswupper(__veil("r", L'A'))));
|
||||
EZBENCH2("iswupper latin1", donothing,
|
||||
EXPROPRIATE(iswupper(VEIL("r", u'A'))));
|
||||
__expropriate(iswupper(__veil("r", u'A'))));
|
||||
EZBENCH2("iswupper astral", donothing,
|
||||
EXPROPRIATE(iswupper(VEIL("r", L'𝛿'))));
|
||||
__expropriate(iswupper(__veil("r", L'𝛿'))));
|
||||
}
|
||||
|
||||
BENCH(iswlower, bench) {
|
||||
EZBENCH2("iswlower ascii", donothing, EXPROPRIATE(iswlower(VEIL("r", L'a'))));
|
||||
EZBENCH2("iswlower ascii", donothing,
|
||||
__expropriate(iswlower(__veil("r", L'a'))));
|
||||
EZBENCH2("iswlower latin1", donothing,
|
||||
EXPROPRIATE(iswlower(VEIL("r", u'A'))));
|
||||
__expropriate(iswlower(__veil("r", u'A'))));
|
||||
EZBENCH2("iswlower astral", donothing,
|
||||
EXPROPRIATE(iswlower(VEIL("r", L'𝛿'))));
|
||||
__expropriate(iswlower(__veil("r", L'𝛿'))));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
STATIC_YOINK("strwidth");
|
||||
__static_yoink("strwidth");
|
||||
|
||||
volatile uint64_t v;
|
||||
|
||||
|
@ -45,7 +45,7 @@ TEST(_tpenc, testBeyondTheStandard) {
|
|||
}
|
||||
|
||||
uint64_t _Tpenc(int x) {
|
||||
return (v = EXPROPRIATE(_tpenc(VEIL("r", x))));
|
||||
return (v = __expropriate(_tpenc(__veil("r", x))));
|
||||
}
|
||||
|
||||
BENCH(_tpenc, bench) {
|
||||
|
|
|
@ -77,5 +77,5 @@ TEST(strwidth, testTextDelimitingControlCodes_dontHaveSubstance) {
|
|||
|
||||
BENCH(wcwidth, bench) {
|
||||
volatile int x;
|
||||
EZBENCH2("wcwidth", donothing, x = wcwidth(VEIL("r", u'→')));
|
||||
EZBENCH2("wcwidth", donothing, x = wcwidth(__veil("r", u'→')));
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@ TEST(wmemrchr, test) {
|
|||
|
||||
BENCH(wmemrchr, bench) {
|
||||
EZBENCH2("wmemrchr", donothing,
|
||||
EXPROPRIATE(wmemrchr(L"yo.hi.there", '.', 11)));
|
||||
__expropriate(wmemrchr(L"yo.hi.there", '.', 11)));
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ TEST(makecontext, args) {
|
|||
EXPECT_TRUE(gotsome);
|
||||
}
|
||||
|
||||
noasan noubsan void itsatrap(int x, int y) {
|
||||
dontasan dontubsan void itsatrap(int x, int y) {
|
||||
*(int *)(intptr_t)x = scalbn(x, y);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ TEST(atanhf, test) {
|
|||
|
||||
BENCH(_atanh, bench) {
|
||||
volatile double a = .5;
|
||||
EZBENCH2("atanhf", donothing, EXPROPRIATE(_atanhf(a)));
|
||||
EZBENCH2("atanh", donothing, EXPROPRIATE(_atanh(a)));
|
||||
EZBENCH2("atanhl", donothing, EXPROPRIATE(_atanhl(a)));
|
||||
EZBENCH2("atanhf", donothing, __expropriate(_atanhf(a)));
|
||||
EZBENCH2("atanh", donothing, __expropriate(_atanh(a)));
|
||||
EZBENCH2("atanhl", donothing, __expropriate(_atanhl(a)));
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ _hypotl l: 43𝑐 14𝑛𝑠 m: 74
|
|||
BENCH(_hypot, bench) {
|
||||
volatile double a = 2;
|
||||
volatile double b = 3;
|
||||
EZBENCH2("hypotf", donothing, EXPROPRIATE(_hypotf(a, b)));
|
||||
EZBENCH2("hypot", donothing, EXPROPRIATE(_hypot(a, b)));
|
||||
EZBENCH2("hypotl", donothing, EXPROPRIATE(_hypotl(a, b)));
|
||||
EZBENCH2("hypotf", donothing, __expropriate(_hypotf(a, b)));
|
||||
EZBENCH2("hypot", donothing, __expropriate(_hypot(a, b)));
|
||||
EZBENCH2("hypotl", donothing, __expropriate(_hypotl(a, b)));
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ TEST(magicu, test) {
|
|||
|
||||
BENCH(magicu, bench) {
|
||||
struct magicu d = __magicu_get(UINT32_MAX);
|
||||
EZBENCH2("__magicu_get", donothing, __magicu_get(VEIL("r", UINT32_MAX)));
|
||||
EZBENCH2("__magicu_get", donothing, __magicu_get(__veil("r", UINT32_MAX)));
|
||||
EZBENCH2("__magicu_div", donothing,
|
||||
EXPROPRIATE(__magicu_div(VEIL("r", 77u), d)));
|
||||
EZBENCH2("/", donothing, EXPROPRIATE(VEIL("r", 77u) / VEIL("r", UINT32_MAX)));
|
||||
__expropriate(__magicu_div(__veil("r", 77u), d)));
|
||||
EZBENCH2("/", donothing,
|
||||
__expropriate(__veil("r", 77u) / __veil("r", UINT32_MAX)));
|
||||
}
|
||||
|
|
|
@ -215,10 +215,12 @@ TEST(lroundl, test) {
|
|||
|
||||
BENCH(round, bench) {
|
||||
#ifdef __x86_64__
|
||||
EZBENCH2("double+.5", donothing, EXPROPRIATE(VEIL("x", (double)(-3.5)) + .5));
|
||||
EZBENCH2("float+.5f", donothing, EXPROPRIATE(VEIL("x", (float)(-3.5)) + .5));
|
||||
EZBENCH2("double+.5", donothing,
|
||||
__expropriate(__veil("x", (double)(-3.5)) + .5));
|
||||
EZBENCH2("float+.5f", donothing,
|
||||
__expropriate(__veil("x", (float)(-3.5)) + .5));
|
||||
EZBENCH2("ldbl+.5l", donothing,
|
||||
EXPROPRIATE(VEIL("t", (long double)(-3.5)) + .5));
|
||||
__expropriate(__veil("t", (long double)(-3.5)) + .5));
|
||||
#endif
|
||||
EZBENCH2("round", donothing, _round(.7)); /* ~4ns */
|
||||
EZBENCH2("roundf", donothing, _roundf(.7)); /* ~3ns */
|
||||
|
|
|
@ -48,16 +48,16 @@ int hard_static(void) {
|
|||
int hard_dynamic(void) {
|
||||
char *b, *p;
|
||||
p = b = malloc(16);
|
||||
p = stpcpy(p, VEIL("r", "eins"));
|
||||
p = stpcpy(p, VEIL("r", "zwei"));
|
||||
p = stpcpy(p, VEIL("r", "drei"));
|
||||
p = stpcpy(p, __veil("r", "eins"));
|
||||
p = stpcpy(p, __veil("r", "zwei"));
|
||||
p = stpcpy(p, __veil("r", "drei"));
|
||||
free(b);
|
||||
return (intptr_t)b;
|
||||
}
|
||||
|
||||
BENCH(xstrcat, bench) {
|
||||
EZBENCH2("hard_static", donothing, EXPROPRIATE(hard_static()));
|
||||
EZBENCH2("hard_dynamic", donothing, EXPROPRIATE(hard_dynamic()));
|
||||
EZBENCH2("hard_static", donothing, __expropriate(hard_static()));
|
||||
EZBENCH2("hard_dynamic", donothing, __expropriate(hard_dynamic()));
|
||||
EZBENCH2("xstrcat", donothing, free(xstrcat("eins", "zwei", "drei")));
|
||||
EZBENCH2("xasprintf", donothing,
|
||||
free(xasprintf("%s%s%s", "eins", "zwei", "drei")));
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/thread/spawn.h"
|
||||
|
||||
STATIC_YOINK("zipos");
|
||||
STATIC_YOINK("libc/testlib/hyperion.txt");
|
||||
STATIC_YOINK("inflate");
|
||||
STATIC_YOINK("inflateInit2");
|
||||
STATIC_YOINK("inflateEnd");
|
||||
__static_yoink("zipos");
|
||||
__static_yoink("libc/testlib/hyperion.txt");
|
||||
__static_yoink("inflate");
|
||||
__static_yoink("inflateInit2");
|
||||
__static_yoink("inflateEnd");
|
||||
|
||||
int Worker(void *arg, int tid) {
|
||||
int i, fd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue