mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-13 06:29:11 +00:00
Improve redbean
- Improve serialization - Add Benchmark() API to redbean - Refactor UNIX API to be assert() friendly - Make the redbean Lua REPL print data structures - Fix recent regressions in linenoise reverse search - Add -i flag so redbean can be a language interpreter
This commit is contained in:
parent
2046c0d2ae
commit
451e3f73d9
74 changed files with 1781 additions and 1024 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
const char *DescribeMapFlags(int x) {
|
||||
static char mapflags[256];
|
||||
_Alignas(char) static char mapflags[256];
|
||||
const struct DescribeFlags kMapFlags[] = {
|
||||
{MAP_ANONYMOUS, "ANONYMOUS"}, //
|
||||
{MAP_PRIVATE, "PRIVATE"}, //
|
||||
|
|
|
@ -34,7 +34,7 @@ static const struct DescribeFlags kConsoleModeInputFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtConsoleModeInputFlags(uint32_t x) {
|
||||
static char consolemodeinputflags[256];
|
||||
_Alignas(char) static char consolemodeinputflags[256];
|
||||
return DescribeFlags(consolemodeinputflags, sizeof(consolemodeinputflags),
|
||||
kConsoleModeInputFlags, ARRAYLEN(kConsoleModeInputFlags),
|
||||
"kNtEnable", x);
|
||||
|
|
|
@ -29,7 +29,7 @@ static const struct DescribeFlags kConsoleModeOutputFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtConsoleModeOutputFlags(uint32_t x) {
|
||||
static char consolemodeoutputflags[128];
|
||||
_Alignas(char) static char consolemodeoutputflags[128];
|
||||
return DescribeFlags(consolemodeoutputflags, sizeof(consolemodeoutputflags),
|
||||
kConsoleModeOutputFlags,
|
||||
ARRAYLEN(kConsoleModeOutputFlags), "kNt", x);
|
||||
|
|
|
@ -64,7 +64,7 @@ static const struct DescribeFlags kFileAccessflags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtFileAccessFlags(uint32_t x) {
|
||||
static char ntfileaccessflags[512];
|
||||
_Alignas(char) static char ntfileaccessflags[512];
|
||||
return DescribeFlags(ntfileaccessflags, sizeof(ntfileaccessflags),
|
||||
kFileAccessflags, ARRAYLEN(kFileAccessflags), "kNt", x);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static const struct DescribeFlags kFileFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtFileFlagsAndAttributes(uint32_t x) {
|
||||
static char ntfileflags[256];
|
||||
_Alignas(char) static char ntfileflags[256];
|
||||
if (x == -1u) return "-1u";
|
||||
return DescribeFlags(ntfileflags, sizeof(ntfileflags), kFileFlags,
|
||||
ARRAYLEN(kFileFlags), "kNtFile", x);
|
||||
|
|
|
@ -31,7 +31,7 @@ static const struct DescribeFlags kFileMapFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtFileMapFlags(uint32_t x) {
|
||||
static char filemapflags[64];
|
||||
_Alignas(char) static char filemapflags[64];
|
||||
return DescribeFlags(filemapflags, sizeof(filemapflags), kFileMapFlags,
|
||||
ARRAYLEN(kFileMapFlags), "kNtFileMap", x);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ static const struct DescribeFlags kFileShareflags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtFileShareFlags(uint32_t x) {
|
||||
static char ntfileshareflags[64];
|
||||
_Alignas(char) static char ntfileshareflags[64];
|
||||
return DescribeFlags(ntfileshareflags, sizeof(ntfileshareflags),
|
||||
kFileShareflags, ARRAYLEN(kFileShareflags),
|
||||
"kNtFileShare", x);
|
||||
|
|
|
@ -29,7 +29,7 @@ static const struct DescribeFlags kFiletypeFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtFiletypeFlags(uint32_t x) {
|
||||
static char filetypeflags[64];
|
||||
_Alignas(char) static char filetypeflags[64];
|
||||
return DescribeFlags(filetypeflags, sizeof(filetypeflags), kFiletypeFlags,
|
||||
ARRAYLEN(kFiletypeFlags), "kNtFileType", x);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ static const struct DescribeFlags kMoveFileInputFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtMoveFileInputFlags(uint32_t x) {
|
||||
static char movefileflags[256];
|
||||
_Alignas(char) static char movefileflags[256];
|
||||
return DescribeFlags(movefileflags, sizeof(movefileflags),
|
||||
kMoveFileInputFlags, ARRAYLEN(kMoveFileInputFlags),
|
||||
"kNtMovefile", x);
|
||||
|
|
|
@ -42,7 +42,7 @@ static const struct DescribeFlags kPageFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtPageFlags(uint32_t x) {
|
||||
static char pageflags[64];
|
||||
_Alignas(char) static char pageflags[64];
|
||||
return DescribeFlags(pageflags, sizeof(pageflags), kPageFlags,
|
||||
ARRAYLEN(kPageFlags), "kNt", x);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ static const struct DescribeFlags kPipeModeFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtPipeModeFlags(uint32_t x) {
|
||||
static char pipemodeflags[64];
|
||||
_Alignas(char) static char pipemodeflags[64];
|
||||
return DescribeFlags(pipemodeflags, sizeof(pipemodeflags), kPipeModeFlags,
|
||||
ARRAYLEN(kPipeModeFlags), "kNtPipe", x);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ static const struct DescribeFlags kPipeOpenFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtPipeOpenFlags(uint32_t x) {
|
||||
static char pipeopenflags[64];
|
||||
_Alignas(char) static char pipeopenflags[64];
|
||||
return DescribeFlags(pipeopenflags, sizeof(pipeopenflags), kPipeOpenFlags,
|
||||
ARRAYLEN(kPipeOpenFlags), "kNtPipeAccess", x);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ static const struct DescribeFlags kProcessAccessflags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtProcessAccessFlags(uint32_t x) {
|
||||
static char ntprocessaccessflags[256];
|
||||
_Alignas(char) static char ntprocessaccessflags[256];
|
||||
return DescribeFlags(ntprocessaccessflags, sizeof(ntprocessaccessflags),
|
||||
kProcessAccessflags, ARRAYLEN(kProcessAccessflags),
|
||||
"kNtProcess", x);
|
||||
|
|
|
@ -39,7 +39,7 @@ static const struct DescribeFlags kNtStartFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtStartFlags(uint32_t x) {
|
||||
static char startflags[128];
|
||||
_Alignas(char) static char startflags[128];
|
||||
return DescribeFlags(startflags, sizeof(startflags), kNtStartFlags,
|
||||
ARRAYLEN(kNtStartFlags), "kNtStartf", x);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ static const struct DescribeFlags kSymbolicLinkflags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeNtSymbolicLinkFlags(uint32_t x) {
|
||||
static char ntsymboliclinkflags[64];
|
||||
_Alignas(char) static char ntsymboliclinkflags[64];
|
||||
return DescribeFlags(ntsymboliclinkflags, sizeof(ntsymboliclinkflags),
|
||||
kSymbolicLinkflags, ARRAYLEN(kSymbolicLinkflags),
|
||||
"kNtSymbolicLinkFlag", x);
|
||||
|
|
|
@ -27,7 +27,7 @@ static const struct DescribeFlags kProtFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeProtFlags(int x) {
|
||||
static char protflags[64];
|
||||
_Alignas(char) static char protflags[64];
|
||||
return DescribeFlags(protflags, sizeof(protflags), kProtFlags,
|
||||
ARRAYLEN(kProtFlags), "PROT_", x);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ static const struct DescribeFlags kRemapFlags[] = {
|
|||
};
|
||||
|
||||
const char *DescribeRemapFlags(int x) {
|
||||
static char remapflags[64];
|
||||
_Alignas(char) static char remapflags[64];
|
||||
return DescribeFlags(remapflags, sizeof(remapflags), kRemapFlags,
|
||||
ARRAYLEN(kRemapFlags), "MREMAP_", x);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
|
||||
const char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
char *GetMagnumStr(const struct MagnumStr *ms, int x) {
|
||||
int i;
|
||||
for (i = 0; ms[i].x != -123; ++i) {
|
||||
if (x == *(const int *)((uintptr_t)ms + ms[i].x)) {
|
||||
return (const char *)((uintptr_t)ms + ms[i].s);
|
||||
for (i = 0; ms[i].x != MAGNUM_TERMINATOR; ++i) {
|
||||
if (x == MAGNUM_NUMBER(ms, i)) {
|
||||
return MAGNUM_STRING(ms, i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue