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:
Justine Tunney 2023-07-26 13:54:49 -07:00
parent 6843150e0c
commit 7e0a09feec
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
510 changed files with 1783 additions and 1483 deletions

View file

@ -20,7 +20,7 @@
#include "libc/sysv/consts/o.h"
#include "libc/testlib/testlib.h"
STATIC_YOINK("zipos");
__static_yoink("zipos");
/**
* Extracts zip asset to filesystem.

View file

@ -24,7 +24,7 @@
#include "libc/time/time.h"
#include "libc/x/x.h"
STATIC_YOINK("strnwidth");
__static_yoink("strnwidth");
void __testlib_ezbenchreport(const char *form, double c1, double c2) {
long ns1, ns2;
@ -32,7 +32,7 @@ void __testlib_ezbenchreport(const char *form, double c1, double c2) {
ns1 = lrintl(ConvertTicksToNanos(c1));
ns2 = lrintl(ConvertTicksToNanos(c2));
(fprintf)(stderr,
VEIL("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"),
__veil("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"),
form, lrint(c1), ns1, lrint(c2), ns2);
}
@ -47,40 +47,41 @@ void __testlib_ezbenchreport_n(const char *form, char z, size_t n, double c) {
(fprintf)(stderr, "\n");
(fprintf)(stderr, " * %-28s", msg);
if (cn < 1) {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn * 1024),
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(cn * 1024),
"picoseconds");
} else if (cn > 1024) {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn / 1024),
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(cn / 1024),
"microseconds");
} else {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)cn, "nanoseconds");
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)cn,
"nanoseconds");
}
} else {
(fprintf)(stderr, " * %-28s", msg);
bps = n / cn * 1e9;
lat = cn / n;
if (lat < 1e-3) {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024 * 1024),
"fs/byte");
(fprintf)(stderr, __veil("r", " %,9lu %-12s"),
(int64_t)(lat * 1024 * 1024), "fs/byte");
} else if (lat < 1) {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024),
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(lat * 1024),
"ps/byte");
} else if (lat > 1024) {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat / 1024),
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(lat / 1024),
"µs/byte");
} else {
(fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)lat, "ns/byte");
(fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)lat, "ns/byte");
}
if (bps < 10 * 1000) {
(fprintf)(stderr, VEIL("r", " %,9lu b/s"), bps);
(fprintf)(stderr, __veil("r", " %,9lu b/s"), bps);
} else if (bps < 10 * 1000 * 1024) {
(fprintf)(stderr, VEIL("r", " %,9lu kb/s"), bps / 1024);
(fprintf)(stderr, __veil("r", " %,9lu kb/s"), bps / 1024);
} else if (bps < 10ul * 1000 * 1024 * 1024) {
(fprintf)(stderr, VEIL("r", " %,9lu mb/s"), bps / (1024 * 1024));
(fprintf)(stderr, __veil("r", " %,9lu mb/s"), bps / (1024 * 1024));
} else if (bps < 10ul * 1000 * 1024 * 1024 * 1024) {
(fprintf)(stderr, VEIL("r", " %,9lu GB/s"), bps / (1024 * 1024 * 1024));
(fprintf)(stderr, __veil("r", " %,9lu GB/s"), bps / (1024 * 1024 * 1024));
} else {
(fprintf)(stderr, VEIL("r", " %,9lu TB/s"),
(fprintf)(stderr, __veil("r", " %,9lu TB/s"),
bps / (1024ul * 1024 * 1024 * 1024));
}
}

View file

@ -51,7 +51,7 @@ static void ContinueOnError(int sig, siginfo_t *si, void *vctx) {
* on error. It then attempts a volatile read and if it faults, then
* this function shall return false. The value at `p` isn't considered.
*/
noasan bool testlib_memoryexists(const void *p) {
dontasan bool testlib_memoryexists(const void *p) {
volatile char c;
const atomic_char *mem = p;
struct sigaction old[2];
@ -60,11 +60,11 @@ noasan bool testlib_memoryexists(const void *p) {
.sa_flags = SA_SIGINFO,
};
gotsignal = 0;
_npassert(!sigaction(SIGSEGV, &sa, old + 0));
_npassert(!sigaction(SIGBUS, &sa, old + 1));
npassert(!sigaction(SIGSEGV, &sa, old + 0));
npassert(!sigaction(SIGBUS, &sa, old + 1));
c = atomic_load(mem);
(void)c;
_npassert(!sigaction(SIGBUS, old + 1, 0));
_npassert(!sigaction(SIGSEGV, old + 0, 0));
npassert(!sigaction(SIGBUS, old + 1, 0));
npassert(!sigaction(SIGSEGV, old + 0, 0));
return !gotsignal;
}

View file

@ -34,7 +34,7 @@
#include "libc/testlib/testlib.h"
#include "third_party/dlmalloc/dlmalloc.h"
static noasan noubsan relegated uint64_t CountMappedBytes(void) {
static dontasan dontubsan relegated uint64_t CountMappedBytes(void) {
size_t i;
uint64_t x, y;
for (x = i = 0; i < _mmi.i; ++i) {

View file

@ -13,7 +13,7 @@ COSMOPOLITAN_C_START_
* the (SUITE, NAME) tuple passed here.
*/
#define TEST(SUITE, NAME) \
STATIC_YOINK("__testcase_start"); \
__static_yoink("__testcase_start"); \
__TEST_PROTOTYPE(SUITE, NAME, __TEST_ARRAY, )
/**
@ -26,7 +26,7 @@ COSMOPOLITAN_C_START_
* are also guaranteed by the linker to be run in sorted order.
*/
#define FIXTURE(SUITE, NAME) \
STATIC_YOINK("__fixture_start"); \
__static_yoink("__fixture_start"); \
__FIXTURE("fixture", SUITE, NAME)
/**
@ -37,7 +37,7 @@ COSMOPOLITAN_C_START_
* more appropriate for testing pure code (i.e. no syscalls) like math.
*/
#define COMBO(GROUP, ENTRY) \
STATIC_YOINK("__combo_start"); \
__static_yoink("__combo_start"); \
__FIXTURE("combo", GROUP, ENTRY)
/**
@ -50,7 +50,7 @@ COSMOPOLITAN_C_START_
* @see EZBENCH()
*/
#define BENCH(SUITE, NAME) \
STATIC_YOINK("__bench_start"); \
__static_yoink("__bench_start"); \
__TEST_PROTOTYPE(SUITE, NAME, __BENCH_ARRAY, optimizespeed)
#define ASSERT_GE(C, X) _TEST2("ASSERT_GE", C, >=, (X), #C, " ≥ ", #X, 1)

View file

@ -67,10 +67,10 @@ Flags:\n\
-h show this information\n\
\n"
STATIC_YOINK("__die");
STATIC_YOINK("GetSymbolByAddr");
STATIC_YOINK("testlib_quota_handlers");
STATIC_YOINK("stack_usage_logging");
__static_yoink("__die");
__static_yoink("GetSymbolByAddr");
__static_yoink("testlib_quota_handlers");
__static_yoink("stack_usage_logging");
static bool runbenchmarks_;
@ -163,7 +163,7 @@ static void SetLimit(int resource, uint64_t soft, uint64_t hard) {
/**
* Generic test program main function.
*/
noasan int main(int argc, char *argv[]) {
dontasan int main(int argc, char *argv[]) {
unsigned cpus;
const char *comdbg;
__log_level = kLogInfo;

View file

@ -120,7 +120,7 @@ static void CheckSignalHandler(int sig) {
#if 0
int i;
struct sigaction sa = {0};
_unassert(0 <= sig - 1 && sig - 1 < ARRAYLEN(wanthandlers));
unassert(0 <= sig - 1 && sig - 1 < ARRAYLEN(wanthandlers));
CHECK_EQ(0, sigaction(sig, 0, &sa));
CHECK_EQ(0, memcmp(wanthandlers + sig - 1, &sa, sizeof(sa)),
"signal handler for %s was %p/%#x/%#x:%x "

View file

@ -22,7 +22,7 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
STATIC_YOINK("strsignal");
__static_yoink("strsignal");
void testlib_waitforexit(const char *file, int line, const char *code, int rc,
int pid) {

View file

@ -22,7 +22,7 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
STATIC_YOINK("strsignal");
__static_yoink("strsignal");
void testlib_waitforterm(const char *file, int line, const char *code, int sig,
int pid) {