Add minor improvements and cleanup
parent
9e3e985ae5
commit
feed0d2b0e
1
Makefile
1
Makefile
|
@ -117,7 +117,6 @@ include libc/ohmyplus/ohmyplus.mk # │
|
|||
include libc/zipos/zipos.mk # │
|
||||
include third_party/dtoa/dtoa.mk # │
|
||||
include libc/time/time.mk # │
|
||||
include libc/escape/escape.mk # │
|
||||
include libc/alg/alg.mk # │
|
||||
include libc/calls/hefty/hefty.mk # │
|
||||
include libc/stdio/stdio.mk # │
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
/* Long Mode Paging
|
||||
@see Intel Manual V.3A §4.1 §4.5
|
||||
IsValid (ignored on CR3) V┐
|
||||
┌Block Instr. Fetches (if NXE) IsWritable (ignored on CR3) RW┐│
|
||||
┌XD:No Inst. Fetches (if NXE) IsWritable (ignored on CR3) RW┐│
|
||||
│ Permit User-Mode Access - u┐││
|
||||
│ Page-level Write-Through - PWT┐│││
|
||||
│ Page-level Cache Disable - PCD┐││││
|
||||
|
@ -147,7 +147,6 @@
|
|||
││ ││ ││├──────────────────┐ │ ││ ││││││││││
|
||||
││ ││ │││ Phys. Addr. 1GB │ │ ││ ││││││││││
|
||||
││ ││ │││ │ │ ││ ││││││││││
|
||||
0b00000000000011111111111111111111111111111111111111000000000000
|
||||
6666555555555544444444443333333333222222222211111111110000000000
|
||||
3210987654321098765432109876543210987654321098765432109876543210*/
|
||||
#define PAGE_V /* */ 0b000000001
|
||||
|
|
|
@ -15,22 +15,22 @@
|
|||
# remove comments
|
||||
s/[ \t][ \t]*#.*//
|
||||
|
||||
#s/leave\(q\|\)/leavew/
|
||||
#s/call\(q\|\)/callw/
|
||||
#s/ret\(q\|\)/retw/
|
||||
#s/popq\t%rbp/pop\t%bp/
|
||||
#s/pushq\t%rbp/push\t%bp/
|
||||
#s/pushq\t\(.*\)/sub $6,%sp\n\tpush \1/
|
||||
#s/popq\t\(.*\)/pop \1\n\tadd $6,%sp/
|
||||
|
||||
# preserve hardcoded stack offsets
|
||||
# bloats code size 13%
|
||||
s/leave\(q\|\)/leavew\n\tadd\t$6,%sp/
|
||||
s/call\(q\|\)\t/sub\t$6,%sp\n\tcallw\t/
|
||||
s/ret\(q\|\)/retw\t$6/
|
||||
s/leave\(q\|\)/leavew/
|
||||
s/call\(q\|\)/callw/
|
||||
s/ret\(q\|\)/retw/
|
||||
s/popq\t%rbp/pop\t%bp/
|
||||
s/pushq\t%rbp/push\t%bp/
|
||||
s/pushq\t\(.*\)/sub\t$6,%sp\n\tpush\t\1/
|
||||
s/popq\t\(.*\)/pop\t\1\n\tadd\t$6,%sp/
|
||||
|
||||
# # preserve hardcoded stack offsets
|
||||
# # bloats code size 13%
|
||||
# s/leave\(q\|\)/leavew\n\tadd\t$6,%sp/
|
||||
# s/call\(q\|\)\t/sub\t$6,%sp\n\tcallw\t/
|
||||
# s/ret\(q\|\)/retw\t$6/
|
||||
# s/pushq\t\(.*\)/sub\t$6,%sp\n\tpush\t\1/
|
||||
# s/popq\t\(.*\)/pop\t\1\n\tadd\t$6,%sp/
|
||||
|
||||
s/, /,/g
|
||||
|
||||
# 32-bitify
|
||||
|
|
|
@ -27,24 +27,21 @@ struct Itoa8 kItoa8;
|
|||
static textstartup void itoa8_init(void) {
|
||||
int i;
|
||||
uint8_t z;
|
||||
char p[4];
|
||||
uint32_t w;
|
||||
for (i = 0; i < 256; ++i) {
|
||||
memset(p, 0, sizeof(p));
|
||||
if (i < 10) {
|
||||
z = 1;
|
||||
p[0] = '0' + i;
|
||||
w = '0' + i;
|
||||
} else if (i < 100) {
|
||||
z = 2;
|
||||
p[0] = '0' + i / 10;
|
||||
p[1] = '0' + i % 10;
|
||||
w = ('0' + i / 10) | ('0' + i % 10) << 8;
|
||||
} else {
|
||||
z = 3;
|
||||
p[0] = '0' + i / 100;
|
||||
p[1] = '0' + i % 100 / 10;
|
||||
p[2] = '0' + i % 100 % 10;
|
||||
w = ('0' + i / 100) | ('0' + i % 100 / 10) << 8 |
|
||||
('0' + i % 100 % 10) << 16;
|
||||
}
|
||||
kItoa8.size[i] = z;
|
||||
memcpy(&kItoa8.data[i], p, sizeof(p));
|
||||
kItoa8.data[i] = w;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,9 +240,10 @@ static const struct Pick kPicksMixBlock[32] = {
|
|||
{TL, TR, 9}, /* ▓ */
|
||||
};
|
||||
|
||||
static unsigned short bdist(struct TtyRgb a, struct TtyRgb b, struct TtyRgb c,
|
||||
struct TtyRgb d, struct TtyRgb w, struct TtyRgb x,
|
||||
struct TtyRgb y, struct TtyRgb z) {
|
||||
static unsigned short GetBlockDist(struct TtyRgb a, struct TtyRgb b,
|
||||
struct TtyRgb c, struct TtyRgb d,
|
||||
struct TtyRgb w, struct TtyRgb x,
|
||||
struct TtyRgb y, struct TtyRgb z) {
|
||||
unsigned short dist;
|
||||
dist = 0;
|
||||
dist += ABS(a.r - w.r);
|
||||
|
@ -260,7 +261,7 @@ static unsigned short bdist(struct TtyRgb a, struct TtyRgb b, struct TtyRgb c,
|
|||
return dist;
|
||||
}
|
||||
|
||||
static uint16_t *mixblock(uint16_t *p, struct TtyRgb ttl, struct TtyRgb ttr,
|
||||
static uint16_t *MixBlock(uint16_t *p, struct TtyRgb ttl, struct TtyRgb ttr,
|
||||
struct TtyRgb tbl, struct TtyRgb tbr,
|
||||
struct TtyRgb qtl, struct TtyRgb qtr,
|
||||
struct TtyRgb qbl, struct TtyRgb qbr) {
|
||||
|
@ -465,15 +466,15 @@ static uint16_t *mixblock(uint16_t *p, struct TtyRgb ttl, struct TtyRgb ttr,
|
|||
return p;
|
||||
}
|
||||
|
||||
static struct TtyRgb getquant(struct TtyRgb rgb) {
|
||||
static struct TtyRgb GetQuant(struct TtyRgb rgb) {
|
||||
return g_ansi2rgb_[rgb.xt];
|
||||
}
|
||||
|
||||
static uint16_t *pickunicode(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
||||
static uint16_t *PickUnicode(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br,
|
||||
struct TtyRgb tl2, struct TtyRgb tr2,
|
||||
struct TtyRgb bl2, struct TtyRgb br2) {
|
||||
#define PICK(A, B, C, D) *p++ = bdist(tl, tr, bl, br, A, B, C, D)
|
||||
#define PICK(A, B, C, D) *p++ = GetBlockDist(tl, tr, bl, br, A, B, C, D)
|
||||
PICK(bl2, bl2, bl2, bl2); /* k=0 bg=bl fg=NULL */
|
||||
PICK(bl2, bl2, bl2, br2); /* ▗ k=4 bg=bl fg=br */
|
||||
PICK(bl2, bl2, bl2, tl2); /* ▗ k=4 bg=bl fg=tl */
|
||||
|
@ -566,11 +567,11 @@ static uint16_t *pickunicode(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
|||
return p;
|
||||
}
|
||||
|
||||
static uint16_t *pickcp437(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
||||
static uint16_t *PickCp437(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br,
|
||||
struct TtyRgb tl2, struct TtyRgb tr2,
|
||||
struct TtyRgb bl2, struct TtyRgb br2) {
|
||||
#define PICK(A, B, C, D) *p++ = bdist(tl, tr, bl, br, A, B, C, D)
|
||||
#define PICK(A, B, C, D) *p++ = GetBlockDist(tl, tr, bl, br, A, B, C, D)
|
||||
PICK(bl2, bl2, bl2, bl2); /* k=0 bg=bl fg=NULL */
|
||||
PICK(bl2, bl2, br2, br2); /* ▄ k=1 bg=bl fg=br */
|
||||
PICK(bl2, bl2, tl2, tl2); /* ▄ k=1 bg=bl fg=tl */
|
||||
|
@ -603,30 +604,30 @@ static uint16_t *pickcp437(uint16_t *p, struct TtyRgb tl, struct TtyRgb tr,
|
|||
return p;
|
||||
}
|
||||
|
||||
static struct Pick pickblock_unicode_ansi(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
struct TtyRgb tl2 = getquant(tl);
|
||||
struct TtyRgb tr2 = getquant(tr);
|
||||
struct TtyRgb bl2 = getquant(bl);
|
||||
struct TtyRgb br2 = getquant(br);
|
||||
static struct Pick PickBlockUnicodeAnsi(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
struct TtyRgb tl2 = GetQuant(tl);
|
||||
struct TtyRgb tr2 = GetQuant(tr);
|
||||
struct TtyRgb bl2 = GetQuant(bl);
|
||||
struct TtyRgb br2 = GetQuant(br);
|
||||
unsigned i, p1, p2;
|
||||
uint16_t picks1[96] aligned(32);
|
||||
uint16_t picks2[32] aligned(32);
|
||||
memset(picks1, 0x79, sizeof(picks1));
|
||||
memset(picks2, 0x79, sizeof(picks2));
|
||||
pickunicode(picks1, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
mixblock(picks2, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
PickUnicode(picks1, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
MixBlock(picks2, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
p1 = windex(picks1, 96);
|
||||
p2 = windex(picks2, 32);
|
||||
return picks1[p1] <= picks2[p2] ? kPicksUnicode[p1] : kPicksMixBlock[p2];
|
||||
}
|
||||
|
||||
static struct Pick pickblock_unicode_true(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
static struct Pick PickBlockUnicodeTrue(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
unsigned i;
|
||||
uint16_t picks[96] aligned(32);
|
||||
memset(picks, 0x79, sizeof(picks));
|
||||
pickunicode(picks, tl, tr, bl, br, tl, tr, bl, br);
|
||||
PickUnicode(picks, tl, tr, bl, br, tl, tr, bl, br);
|
||||
i = windex(picks, 96);
|
||||
if (i >= 88) {
|
||||
unsigned j;
|
||||
|
@ -640,39 +641,39 @@ static struct Pick pickblock_unicode_true(struct TtyRgb tl, struct TtyRgb tr,
|
|||
return kPicksUnicode[i];
|
||||
}
|
||||
|
||||
static struct Pick pickblock_cp437_ansi(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
struct TtyRgb tl2 = getquant(tl);
|
||||
struct TtyRgb tr2 = getquant(tr);
|
||||
struct TtyRgb bl2 = getquant(bl);
|
||||
struct TtyRgb br2 = getquant(br);
|
||||
static struct Pick PickBlockCp437Ansi(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
struct TtyRgb tl2 = GetQuant(tl);
|
||||
struct TtyRgb tr2 = GetQuant(tr);
|
||||
struct TtyRgb bl2 = GetQuant(bl);
|
||||
struct TtyRgb br2 = GetQuant(br);
|
||||
unsigned i, p1, p2;
|
||||
uint16_t picks1[32] aligned(32);
|
||||
uint16_t picks2[32] aligned(32);
|
||||
memset(picks1, 0x79, sizeof(picks1));
|
||||
memset(picks2, 0x79, sizeof(picks2));
|
||||
pickcp437(picks1, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
mixblock(picks2, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
PickCp437(picks1, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
MixBlock(picks2, tl, tr, bl, br, tl2, tr2, bl2, br2);
|
||||
p1 = windex(picks1, 32);
|
||||
p2 = windex(picks2, 32);
|
||||
return picks1[p1] <= picks2[p2] ? kPicksCp437[p1] : kPicksMixBlock[p2];
|
||||
}
|
||||
|
||||
static struct Pick pickblock_cp437_true(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
static struct Pick PickBlockCp437True(struct TtyRgb tl, struct TtyRgb tr,
|
||||
struct TtyRgb bl, struct TtyRgb br) {
|
||||
unsigned i;
|
||||
uint16_t picks[32] aligned(32);
|
||||
memset(picks, 0x79, sizeof(picks));
|
||||
pickcp437(picks, tl, tr, bl, br, tl, tr, bl, br);
|
||||
PickCp437(picks, tl, tr, bl, br, tl, tr, bl, br);
|
||||
return kPicksCp437[windex(picks, 32)];
|
||||
}
|
||||
|
||||
static char *copyglyph(char *v, struct Glyph glyph) {
|
||||
static char *CopyGlyph(char *v, struct Glyph glyph) {
|
||||
memcpy(v, &glyph, 4);
|
||||
return v + glyph.len;
|
||||
}
|
||||
|
||||
static char *copyblock(char *v, const struct TtyRgb chunk[hasatleast 4],
|
||||
static char *CopyBlock(char *v, const struct TtyRgb chunk[hasatleast 4],
|
||||
struct Pick pick, struct TtyRgb *bg, struct TtyRgb *fg,
|
||||
struct Glyph *glyph) {
|
||||
unsigned i;
|
||||
|
@ -721,16 +722,16 @@ static char *copyblock(char *v, const struct TtyRgb chunk[hasatleast 4],
|
|||
} else if (!ttyeq(*bg, chunk[pick.bg])) {
|
||||
v = setbg(v, (*bg = chunk[pick.bg]));
|
||||
}
|
||||
return copyglyph(v, (*glyph = kGlyphs[i][pick.k]));
|
||||
return CopyGlyph(v, (*glyph = kGlyphs[i][pick.k]));
|
||||
}
|
||||
|
||||
static bool chunkeq(struct TtyRgb c[hasatleast 4],
|
||||
static bool ChunkEq(struct TtyRgb c[hasatleast 4],
|
||||
struct TtyRgb c2[hasatleast 4]) {
|
||||
return ttyeq(c[TL], c[TR]) && ttyeq(c[BL], c[BR]) && ttyeq(c2[TL], c2[TR]) &&
|
||||
ttyeq(c2[BL], c2[BR]);
|
||||
}
|
||||
|
||||
static struct TtyRgb *copychunk(struct TtyRgb chunk[hasatleast 4],
|
||||
static struct TtyRgb *CopyChunk(struct TtyRgb chunk[hasatleast 4],
|
||||
const struct TtyRgb *c, size_t n) {
|
||||
chunk[TL] = c[0 + 0];
|
||||
chunk[TR] = c[0 + 1];
|
||||
|
@ -739,7 +740,7 @@ static struct TtyRgb *copychunk(struct TtyRgb chunk[hasatleast 4],
|
|||
return chunk;
|
||||
}
|
||||
|
||||
static noinline char *copyrun(char *v, size_t n,
|
||||
static noinline char *CopyRun(char *v, size_t n,
|
||||
struct TtyRgb lastchunk[hasatleast 4],
|
||||
const struct TtyRgb **c, size_t *x,
|
||||
struct TtyRgb *bg, struct TtyRgb *fg,
|
||||
|
@ -752,12 +753,12 @@ static noinline char *copyrun(char *v, size_t n,
|
|||
*glyph = kGlyphs[0][0];
|
||||
}
|
||||
do {
|
||||
v = copyglyph(v, *glyph);
|
||||
v = CopyGlyph(v, *glyph);
|
||||
*x += 2;
|
||||
*c += 2;
|
||||
if (*x >= n) break;
|
||||
copychunk(chunk, *c, n);
|
||||
} while (chunkeq(chunk, lastchunk));
|
||||
CopyChunk(chunk, *c, n);
|
||||
} while (ChunkEq(chunk, lastchunk));
|
||||
*x -= 2;
|
||||
*c -= 2;
|
||||
return v;
|
||||
|
@ -776,21 +777,21 @@ char *ttyraster(char *v, const struct TtyRgb *c, size_t yn, size_t n,
|
|||
for (y = 0; y < yn; y += 2, c += n) {
|
||||
if (y) *v++ = '\r', *v++ = '\n';
|
||||
for (x = 0; x < n; x += 2, c += 2) {
|
||||
copychunk(chun, c, n);
|
||||
CopyChunk(chun, c, n);
|
||||
if (ttyquant()->alg == kTtyQuantTrue) {
|
||||
if (ttyquant()->blocks == kTtyBlocksCp437) {
|
||||
p = pickblock_cp437_true(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
p = PickBlockCp437True(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
} else {
|
||||
p = pickblock_unicode_true(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
p = PickBlockUnicodeTrue(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
}
|
||||
} else {
|
||||
if (ttyquant()->blocks == kTtyBlocksCp437) {
|
||||
p = pickblock_cp437_ansi(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
p = PickBlockCp437Ansi(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
} else {
|
||||
p = pickblock_unicode_ansi(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
p = PickBlockUnicodeAnsi(chun[TL], chun[TR], chun[BL], chun[BR]);
|
||||
}
|
||||
}
|
||||
v = copyblock(v, chun, p, &bg, &fg, &glyph);
|
||||
v = CopyBlock(v, chun, p, &bg, &fg, &glyph);
|
||||
memcpy(lastchunk, chun, sizeof(chun));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,5 @@ textstartup int ttyraw(enum TtyRawFlags flags) {
|
|||
} else {
|
||||
rc = ttyraw_disable();
|
||||
}
|
||||
cancolor();
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "libc/conv/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
|
|||
*
|
||||
* 1. gc() automates calling free() on return.
|
||||
* 2. xasprintf("foo %s", "bar") is our version of "foo %s" % ("bar")
|
||||
* 3. Demonstrates correct escaping for bourne shell cf. xaescapeshq()
|
||||
* 3. Demonstrates correct escaping for bourne shell
|
||||
*/
|
||||
if (!fileexists(kProgram)) {
|
||||
system(gc(xasprintf("%s '%s'", "make -j4",
|
||||
|
|
|
@ -620,12 +620,12 @@
|
|||
#define octtobin(c) ((c) - '0')
|
||||
#define scopy(s1, s2) ((void)strcpy(s2, s1))
|
||||
|
||||
/* #define TRACE(param) */
|
||||
#define TRACE(param) \
|
||||
do { \
|
||||
printf("TRACE: "); \
|
||||
printf param; \
|
||||
} while (0)
|
||||
#define TRACE(param)
|
||||
/* #define TRACE(param) \ */
|
||||
/* do { \ */
|
||||
/* printf("TRACE: "); \ */
|
||||
/* printf param; \ */
|
||||
/* } while (0) */
|
||||
|
||||
#define TRACEV(param)
|
||||
#define digit_val(c) ((c) - '0')
|
||||
|
@ -634,8 +634,6 @@
|
|||
#define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
|
||||
#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
|
||||
#define is_special(c) ((is_type + SYNBASE)[(signed char)(c)] & (ISSPECL | ISDIGIT))
|
||||
/* #define likely(x) __builtin_expect(!!(x), 1) */
|
||||
/* #define unlikely(x) __builtin_expect(!!(x), 0) */
|
||||
|
||||
#define uninitialized_var(x) x = x /* suppress uninitialized warning w/o code */
|
||||
|
||||
|
@ -643,9 +641,7 @@
|
|||
* Shell variables.
|
||||
*/
|
||||
#define vifs varinit[0]
|
||||
#define vmail (&vifs)[1]
|
||||
#define vmpath (&vmail)[1]
|
||||
#define vpath (&vmpath)[1]
|
||||
#define vpath (&vifs)[1]
|
||||
#define vps1 (&vpath)[1]
|
||||
#define vps2 (&vps1)[1]
|
||||
#define vps4 (&vps2)[1]
|
||||
|
@ -1497,46 +1493,48 @@ enum token {
|
|||
|
||||
enum token_types { UNOP, BINOP, BUNOP, BBINOP, PAREN };
|
||||
|
||||
static struct t_op const ops[] = {{"-r", FILRD, UNOP},
|
||||
{"-w", FILWR, UNOP},
|
||||
{"-x", FILEX, UNOP},
|
||||
{"-e", FILEXIST, UNOP},
|
||||
{"-f", FILREG, UNOP},
|
||||
{"-d", FILDIR, UNOP},
|
||||
{"-c", FILCDEV, UNOP},
|
||||
{"-b", FILBDEV, UNOP},
|
||||
{"-p", FILFIFO, UNOP},
|
||||
{"-u", FILSUID, UNOP},
|
||||
{"-g", FILSGID, UNOP},
|
||||
{"-k", FILSTCK, UNOP},
|
||||
{"-s", FILGZ, UNOP},
|
||||
{"-t", FILTT, UNOP},
|
||||
{"-z", STREZ, UNOP},
|
||||
{"-n", STRNZ, UNOP},
|
||||
{"-h", FILSYM, UNOP}, /* for backwards compat */
|
||||
{"-O", FILUID, UNOP},
|
||||
{"-G", FILGID, UNOP},
|
||||
{"-L", FILSYM, UNOP},
|
||||
{"-S", FILSOCK, UNOP},
|
||||
{"=", STREQ, BINOP},
|
||||
{"!=", STRNE, BINOP},
|
||||
{"<", STRLT, BINOP},
|
||||
{">", STRGT, BINOP},
|
||||
{"-eq", INTEQ, BINOP},
|
||||
{"-ne", INTNE, BINOP},
|
||||
{"-ge", INTGE, BINOP},
|
||||
{"-gt", INTGT, BINOP},
|
||||
{"-le", INTLE, BINOP},
|
||||
{"-lt", INTLT, BINOP},
|
||||
{"-nt", FILNT, BINOP},
|
||||
{"-ot", FILOT, BINOP},
|
||||
{"-ef", FILEQ, BINOP},
|
||||
{"!", UNOT, BUNOP},
|
||||
{"-a", BAND, BBINOP},
|
||||
{"-o", BOR, BBINOP},
|
||||
{"(", LPAREN, PAREN},
|
||||
{")", RPAREN, PAREN},
|
||||
{0, 0, 0}};
|
||||
static struct t_op const ops[] = {
|
||||
{"-r", FILRD, UNOP},
|
||||
{"-w", FILWR, UNOP},
|
||||
{"-x", FILEX, UNOP},
|
||||
{"-e", FILEXIST, UNOP},
|
||||
{"-f", FILREG, UNOP},
|
||||
{"-d", FILDIR, UNOP},
|
||||
{"-c", FILCDEV, UNOP},
|
||||
{"-b", FILBDEV, UNOP},
|
||||
{"-p", FILFIFO, UNOP},
|
||||
{"-u", FILSUID, UNOP},
|
||||
{"-g", FILSGID, UNOP},
|
||||
{"-k", FILSTCK, UNOP},
|
||||
{"-s", FILGZ, UNOP},
|
||||
{"-t", FILTT, UNOP},
|
||||
{"-z", STREZ, UNOP},
|
||||
{"-n", STRNZ, UNOP},
|
||||
{"-h", FILSYM, UNOP}, /* for backwards compat */
|
||||
{"-O", FILUID, UNOP},
|
||||
{"-G", FILGID, UNOP},
|
||||
{"-L", FILSYM, UNOP},
|
||||
{"-S", FILSOCK, UNOP},
|
||||
{"=", STREQ, BINOP},
|
||||
{"!=", STRNE, BINOP},
|
||||
{"<", STRLT, BINOP},
|
||||
{">", STRGT, BINOP},
|
||||
{"-eq", INTEQ, BINOP},
|
||||
{"-ne", INTNE, BINOP},
|
||||
{"-ge", INTGE, BINOP},
|
||||
{"-gt", INTGT, BINOP},
|
||||
{"-le", INTLE, BINOP},
|
||||
{"-lt", INTLT, BINOP},
|
||||
{"-nt", FILNT, BINOP},
|
||||
{"-ot", FILOT, BINOP},
|
||||
{"-ef", FILEQ, BINOP},
|
||||
{"!", UNOT, BUNOP},
|
||||
{"-a", BAND, BBINOP},
|
||||
{"-o", BOR, BBINOP},
|
||||
{"(", LPAREN, PAREN},
|
||||
{")", RPAREN, PAREN},
|
||||
{0, 0, 0},
|
||||
};
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § the unbourne shell » text ─╬─│┼
|
||||
|
@ -3644,7 +3642,7 @@ static int evalcommand(union node *cmd, int flags) {
|
|||
}
|
||||
/* Now locate the command. */
|
||||
if (cmdentry.cmdtype != CMDBUILTIN || !(cmdentry.u.cmd->flags & BUILTIN_REGULAR)) {
|
||||
path = unlikely(path != NULL) ? path : pathval();
|
||||
path = unlikely(path != NULL) ? path : pathval(); /* wut */
|
||||
find_command(argv[0], &cmdentry, cmd_flag | DO_ERR, path);
|
||||
}
|
||||
jp = NULL;
|
||||
|
@ -4213,21 +4211,21 @@ static void hashcd(void) {
|
|||
* Called with interrupts off.
|
||||
*/
|
||||
static void changepath(const char *newval) {
|
||||
const char *new;
|
||||
int idx;
|
||||
int bltin;
|
||||
new = newval;
|
||||
const char *neu;
|
||||
neu = newval;
|
||||
idx = 0;
|
||||
bltin = -1;
|
||||
for (;;) {
|
||||
if (*new == '%' && prefix(new + 1, "builtin")) {
|
||||
if (*neu == '%' && prefix(neu + 1, "builtin")) {
|
||||
bltin = idx;
|
||||
break;
|
||||
}
|
||||
new = strchr(new, ':');
|
||||
if (!new) break;
|
||||
neu = strchr(neu, ':');
|
||||
if (!neu) break;
|
||||
idx++;
|
||||
new ++;
|
||||
neu++;
|
||||
}
|
||||
builtinloc = bltin;
|
||||
clearcmdentry();
|
||||
|
@ -9603,6 +9601,9 @@ static char *conv_escape(char *str, int *conv_ch) {
|
|||
case 'f':
|
||||
value = '\f';
|
||||
break; /* form-feed */
|
||||
case 'e':
|
||||
value = '\e';
|
||||
break; /* escape */
|
||||
case 'n':
|
||||
value = '\n';
|
||||
break; /* newline */
|
||||
|
@ -10787,6 +10788,7 @@ static int exitcmd(int argc, char **argv) {
|
|||
*/
|
||||
int main(int argc, char **argv) {
|
||||
showcrashreports();
|
||||
unsetenv("PS1");
|
||||
char *shinit;
|
||||
volatile int state;
|
||||
struct jmploc jmploc;
|
||||
|
|
|
@ -111,7 +111,7 @@ int fchmod(int, uint32_t) nothrow;
|
|||
int fchmodat(int, const char *, uint32_t, uint32_t);
|
||||
int fchown(int, uint32_t, uint32_t);
|
||||
int fchownat(int, const char *, uint32_t, uint32_t, uint32_t);
|
||||
int fcntl();
|
||||
int fcntl(int, int, ...);
|
||||
int fdatasync(int);
|
||||
int filecmp(const char *, const char *);
|
||||
int flock(int, int);
|
||||
|
@ -189,7 +189,7 @@ int uname(struct utsname *);
|
|||
int unlink(const char *);
|
||||
int unlink_s(const char **);
|
||||
int unlinkat(int, const char *, int);
|
||||
int vfork(void);
|
||||
int vfork(void) returnstwice;
|
||||
int wait(int *);
|
||||
int wait3(int *, int, struct rusage *);
|
||||
int wait4(int, int *, int, struct rusage *);
|
||||
|
@ -242,7 +242,7 @@ int vdprintf(int, const char *, va_list) paramsnonnull();
|
|||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
|
||||
void _init_onntconsoleevent(void);
|
||||
void _init_onwincrash(void);
|
||||
void _init_wincrash(void);
|
||||
|
||||
#define __SIGACTION(FN, SIG, ...) \
|
||||
({ \
|
||||
|
@ -260,14 +260,14 @@ void _init_onwincrash(void);
|
|||
case SIGSEGV: \
|
||||
case SIGABRT: \
|
||||
case SIGFPE: \
|
||||
YOINK(_init_onwincrash); \
|
||||
YOINK(_init_wincrash); \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} else { \
|
||||
YOINK(_init_onntconsoleevent); \
|
||||
YOINK(_init_onwincrash); \
|
||||
YOINK(_init_wincrash); \
|
||||
} \
|
||||
} \
|
||||
(FN)(SIG, __VA_ARGS__); \
|
||||
|
|
|
@ -24,16 +24,17 @@
|
|||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int fcntl$nt(int fd, int cmd, unsigned arg) {
|
||||
uint32_t flags;
|
||||
if (!isfdkind(fd, kFdFile)) return ebadf();
|
||||
switch (cmd) {
|
||||
case F_GETFD:
|
||||
return GetHandleInformation(g_fds.p[fd].handle, &arg) ? (arg ^ FD_CLOEXEC)
|
||||
: -1;
|
||||
if (!GetHandleInformation(g_fds.p[fd].handle, &flags)) return -1;
|
||||
arg = (flags & FD_CLOEXEC) ^ FD_CLOEXEC;
|
||||
return arg;
|
||||
case F_SETFD:
|
||||
return SetHandleInformation(g_fds.p[fd].handle, FD_CLOEXEC,
|
||||
arg ^ FD_CLOEXEC)
|
||||
? 0
|
||||
: -1;
|
||||
arg ^= FD_CLOEXEC;
|
||||
if (!SetHandleInformation(g_fds.p[fd].handle, FD_CLOEXEC, arg)) return -1;
|
||||
return 0;
|
||||
default:
|
||||
return 0; /* TODO(jart): Implement me. */
|
||||
}
|
||||
|
|
|
@ -31,7 +31,12 @@
|
|||
* @return 0 on success, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int fcntl(int fd, int cmd, int arg) {
|
||||
int fcntl(int fd, int cmd, ...) {
|
||||
va_list va;
|
||||
unsigned arg;
|
||||
va_start(va, cmd);
|
||||
arg = va_arg(va, unsigned);
|
||||
va_end(va);
|
||||
if (!IsWindows()) {
|
||||
return fcntl$sysv(fd, cmd, arg);
|
||||
} else {
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*-*- 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 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/ntmagicpaths.h"
|
||||
#include "libc/nexgen32e/tinystrcmp.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
textwindows const char *(fixntmagicpath)(const char *path, unsigned flags) {
|
||||
const struct NtMagicPaths *mp = &kNtMagicPaths;
|
||||
asm("" : "+r"(mp));
|
||||
if (path[0] != '/') return path;
|
||||
if (tinystrcmp(path, mp->devtty) == 0) {
|
||||
if ((flags & O_ACCMODE) == O_RDONLY) {
|
||||
return mp->conin;
|
||||
} else if ((flags & O_ACCMODE) == O_WRONLY) {
|
||||
return mp->conout;
|
||||
}
|
||||
}
|
||||
if (tinystrcmp(path, mp->devnull) == 0) return mp->nul;
|
||||
if (tinystrcmp(path, mp->devstdin) == 0) return mp->conin;
|
||||
if (tinystrcmp(path, mp->devstdout) == 0) return mp->conout;
|
||||
return path;
|
||||
}
|
|
@ -261,15 +261,11 @@ void ntcontext2linux(struct ucontext *, const struct NtContext *) hidden;
|
|||
struct NtOverlapped *offset2overlap(int64_t, struct NtOverlapped *) hidden;
|
||||
bool32 ntsetprivilege(i64, const char16_t *, u32) hidden;
|
||||
bool32 onntconsoleevent$nt(u32) hidden;
|
||||
void onntalarm(void *, uint32_t, uint32_t) hidden;
|
||||
void __winalarm(void *, uint32_t, uint32_t) hidden;
|
||||
int ntaccesscheck(const char16_t *, u32) paramsnonnull() hidden;
|
||||
i64 ntreturn(u32);
|
||||
i64 winerr(void) nocallback privileged;
|
||||
|
||||
const char *__fixntmagicpath(const char *, unsigned) paramsnonnull() hidden;
|
||||
int __mkntpath(const char *, unsigned, char16_t[hasatleast PATH_MAX - 16])
|
||||
paramsnonnull() hidden;
|
||||
|
||||
#define mkntpath(PATH, PATH16) mkntpath2(PATH, -1u, PATH16)
|
||||
#define mkntpath2(PATH, FLAGS, PATH16) \
|
||||
({ \
|
||||
|
@ -281,16 +277,6 @@ int __mkntpath(const char *, unsigned, char16_t[hasatleast PATH_MAX - 16])
|
|||
Count; \
|
||||
})
|
||||
|
||||
#define fixntmagicpath(PATH, FLAGS) \
|
||||
({ \
|
||||
const char *Path2; \
|
||||
asm("call\tfixntmagicpath" \
|
||||
: "=a"(Path2) \
|
||||
: "D"(PATH), "S"(FLAGS), "m"((PATH)[0]) \
|
||||
: "cc"); \
|
||||
Path2; \
|
||||
})
|
||||
|
||||
#undef sigset
|
||||
#undef i32
|
||||
#undef i64
|
||||
|
|
|
@ -17,15 +17,31 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/pushpop.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/calls/hefty/ntspawn.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/calls/ntmagicpaths.h"
|
||||
#include "libc/nexgen32e/tinystrcmp.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpdecode.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows static const char *FixNtMagicPath(const char *path,
|
||||
unsigned flags) {
|
||||
const struct NtMagicPaths *mp = &kNtMagicPaths;
|
||||
asm("" : "+r"(mp));
|
||||
if (path[0] != '/') return path;
|
||||
if (tinystrcmp(path, mp->devtty) == 0) {
|
||||
if ((flags & O_ACCMODE) == O_RDONLY) {
|
||||
return mp->conin;
|
||||
} else if ((flags & O_ACCMODE) == O_WRONLY) {
|
||||
return mp->conout;
|
||||
}
|
||||
}
|
||||
if (tinystrcmp(path, mp->devnull) == 0) return mp->nul;
|
||||
if (tinystrcmp(path, mp->devstdin) == 0) return mp->conin;
|
||||
if (tinystrcmp(path, mp->devstdout) == 0) return mp->conout;
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies path for Windows NT.
|
||||
*
|
||||
|
@ -33,13 +49,13 @@
|
|||
* forward-slashes with backslashes; and (3) remapping several
|
||||
* well-known paths (e.g. /dev/null → NUL) for convenience.
|
||||
*
|
||||
* @param flags is used by open()
|
||||
* @param path16 is shortened so caller can prefix, e.g. \\.\pipe\, and
|
||||
* due to a plethora of special-cases throughout the Win32 API
|
||||
* @param flags is used by open(), see fixntmagicpath2()
|
||||
* @return short count excluding NUL on success, or -1 w/ errno
|
||||
* @error ENAMETOOLONG
|
||||
*/
|
||||
forcealignargpointer textwindows int(mkntpath)(
|
||||
forcealignargpointer textwindows int mkntpath(
|
||||
const char *path, unsigned flags,
|
||||
char16_t path16[hasatleast PATH_MAX - 16]) {
|
||||
/*
|
||||
|
@ -52,7 +68,7 @@ forcealignargpointer textwindows int(mkntpath)(
|
|||
int rc;
|
||||
wint_t wc;
|
||||
size_t i, j;
|
||||
path = fixntmagicpath(path, flags);
|
||||
path = FixNtMagicPath(path, flags);
|
||||
i = 0;
|
||||
j = 0;
|
||||
for (;;) {
|
||||
|
|
|
@ -55,7 +55,7 @@ static struct ItimerNt {
|
|||
static uint32_t ItimerWorker(void *arg) {
|
||||
do {
|
||||
if (!WaitForSingleObject(g_itimernt.ith, -1)) {
|
||||
onntalarm(NULL, 0, 0);
|
||||
__winalarm(NULL, 0, 0);
|
||||
}
|
||||
} while (g_itimernt.ith && g_itimernt.tid == GetCurrentThreadId());
|
||||
return 0;
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
|
||||
onntconsoleevent$nt:
|
||||
ezlea onntconsoleevent,ax
|
||||
jmp nt2sysv
|
||||
jmp __nt2sysv
|
||||
.endfn onntconsoleevent$nt,globl,hidden
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
.text.windows
|
||||
.source __FILE__
|
||||
|
||||
onwincrash$nt:
|
||||
ezlea onwincrash,ax
|
||||
jmp nt2sysv
|
||||
.endfn onwincrash$nt,globl
|
||||
__wincrash$nt:
|
||||
ezlea __wincrash,ax
|
||||
jmp __nt2sysv
|
||||
.endfn __wincrash$nt,globl
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
.text.windows
|
||||
.source __FILE__
|
||||
|
||||
onntalarm$nt:
|
||||
ezlea onntalarm,ax
|
||||
jmp nt2sysv
|
||||
.endfn onntalarm$nt,globl,hidden
|
||||
__winalarm$nt:
|
||||
ezlea __winalarm,ax
|
||||
jmp __nt2sysv
|
||||
.endfn __winalarm$nt,globl,hidden
|
|
@ -22,8 +22,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
void onntalarm(void *lpArgToCompletionRoutine, uint32_t dwTimerLowValue,
|
||||
uint32_t dwTimerHighValue) {
|
||||
void __winalarm(void *lpArgToCompletionRoutine, uint32_t dwTimerLowValue,
|
||||
uint32_t dwTimerHighValue) {
|
||||
siginfo_t info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.si_signo = SIGALRM;
|
|
@ -27,7 +27,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
textwindows unsigned onwincrash(struct NtExceptionPointers *ep) {
|
||||
textwindows unsigned __wincrash(struct NtExceptionPointers *ep) {
|
||||
int sig;
|
||||
struct Goodies {
|
||||
ucontext_t ctx;
|
|
@ -20,8 +20,8 @@
|
|||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
.init.start 300,_init_onwincrash
|
||||
.init.start 300,_init_wincrash
|
||||
pushpop 1,%rcx
|
||||
ezlea onwincrash$nt,dx
|
||||
ezlea __wincrash$nt,dx
|
||||
ntcall __imp_AddVectoredExceptionHandler
|
||||
.init.end 300,_init_onwincrash,globl,hidden
|
||||
.init.end 300,_init_wincrash,globl,hidden
|
|
@ -54,9 +54,8 @@ _start: test %rdi,%rdi
|
|||
mov %rdi,%rcx # auxv
|
||||
mov %ebx,%edi
|
||||
call _executive
|
||||
9: .endfn _start,weak,hidden
|
||||
|
||||
ud2
|
||||
9: ud2
|
||||
.endfn _start,weak,hidden
|
||||
|
||||
/ Macintosh userspace program entrypoint.
|
||||
/
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
/**
|
||||
* Resolves address for internet name.
|
||||
*
|
||||
* @param node is either an ip string or a utf-8 hostname
|
||||
* @param name is either an ip string or a utf-8 hostname
|
||||
* @param service is the port number as a string
|
||||
* @param hints may be passed to specialize behavior (optional)
|
||||
* @param res receives a pointer that must be freed with freeaddrinfo(),
|
||||
|
|
262
libc/errno.h
262
libc/errno.h
|
@ -6,137 +6,137 @@
|
|||
* @see libc/sysv/consts.sh for numbers
|
||||
*/
|
||||
|
||||
#define EPERM EPERM /* operation not permitted */
|
||||
#define ENOENT ENOENT /* no such file or directory */
|
||||
#define ESRCH ESRCH /* no such process */
|
||||
#define EINTR EINTR /* interrupted system call */
|
||||
#define EIO EIO /* input/output error */
|
||||
#define ENXIO ENXIO /* no such device or address */
|
||||
#define E2BIG E2BIG /* argument list too long */
|
||||
#define ENOEXEC ENOEXEC /* exec format error */
|
||||
#define EBADF EBADF /* bad file descriptor */
|
||||
#define ECHILD ECHILD /* no child processes */
|
||||
#define EAGAIN EAGAIN /* resource temporarily unavailable */
|
||||
#define ENOMEM ENOMEM /* not enough space */
|
||||
#define EACCES EACCES /* permission denied */
|
||||
#define EFAULT EFAULT /* bad address */
|
||||
#define ENOTBLK ENOTBLK /* block device required */
|
||||
#define EBUSY EBUSY /* device or resource busy */
|
||||
#define EEXIST EEXIST /* file exists */
|
||||
#define EXDEV EXDEV /* improper link */
|
||||
#define ENODEV ENODEV /* no such device */
|
||||
#define ENOTDIR ENOTDIR /* not a directory */
|
||||
#define EISDIR EISDIR /* is a directory */
|
||||
#define EINVAL EINVAL /* invalid argument */
|
||||
#define ENFILE ENFILE /* too many open files in system */
|
||||
#define EMFILE EMFILE /* too many open files */
|
||||
#define ENOTTY ENOTTY /* inappropriate I/O control op */
|
||||
#define ETXTBSY ETXTBSY /* text file busy */
|
||||
#define EFBIG EFBIG /* file too large */
|
||||
#define ENOSPC ENOSPC /* no space left on device */
|
||||
#define ESPIPE ESPIPE /* invalid seek */
|
||||
#define EROFS EROFS /* read-only filesystem */
|
||||
#define EMLINK EMLINK /* too many links */
|
||||
#define EPIPE EPIPE /* broken pipe */
|
||||
#define EDOM EDOM /* argument out of function domain */
|
||||
#define ERANGE ERANGE /* result too large */
|
||||
#define EDEADLK EDEADLK /* resource deadlock avoided */
|
||||
#define ENAMETOOLONG ENAMETOOLONG /* filename too long */
|
||||
#define ENOLCK ENOLCK /* no locks available */
|
||||
#define ENOSYS ENOSYS /* system call not implemented */
|
||||
#define ENOTEMPTY ENOTEMPTY /* directory not empty */
|
||||
#define ELOOP ELOOP /* too many levels of symbolic links */
|
||||
#define ENOMSG ENOMSG /* no message of the desired type */
|
||||
#define EIDRM EIDRM /* identifier removed */
|
||||
#define ECHRNG ECHRNG /* channel number out of range */
|
||||
#define EL2NSYNC EL2NSYNC /* level 2 not synchronized */
|
||||
#define EL3HLT EL3HLT /* level 3 halted */
|
||||
#define EL3RST EL3RST /* level 3 halted */
|
||||
#define ELNRNG ELNRNG /* link number out of range */
|
||||
#define EUNATCH EUNATCH /* protocol driver not attached */
|
||||
#define ENOCSI ENOCSI /* no csi structure available */
|
||||
#define EL2HLT EL2HLT /* level 2 halted */
|
||||
#define EBADE EBADE /* invalid exchange */
|
||||
#define EBADR EBADR /* invalid request descriptor */
|
||||
#define EXFULL EXFULL /* exchange full */
|
||||
#define ENOANO ENOANO /* no anode */
|
||||
#define EBADRQC EBADRQC /* invalid request code */
|
||||
#define EBADSLT EBADSLT /* invalid slot */
|
||||
#define ENOSTR ENOSTR /* no string */
|
||||
#define ENODATA ENODATA /* no data */
|
||||
#define ETIME ETIME /* timer expired */
|
||||
#define ENOSR ENOSR /* out of streams resources */
|
||||
#define ENONET ENONET /* no network */
|
||||
#define ENOPKG ENOPKG /* package not installed */
|
||||
#define EREMOTE EREMOTE /* object is remote */
|
||||
#define ENOLINK ENOLINK /* link severed */
|
||||
#define EADV EADV /* todo */
|
||||
#define ESRMNT ESRMNT /* todo */
|
||||
#define ECOMM ECOMM /* communication error on send */
|
||||
#define EPROTO EPROTO /* protocol error */
|
||||
#define EMULTIHOP EMULTIHOP /* multihop attempted */
|
||||
#define EDOTDOT EDOTDOT /* todo */
|
||||
#define EBADMSG EBADMSG /* bad message */
|
||||
#define EOVERFLOW EOVERFLOW /* value too large for type */
|
||||
#define ENOTUNIQ ENOTUNIQ /* name not unique on network */
|
||||
#define EBADFD EBADFD /* fd in bad *state* (cf. EBADF) */
|
||||
#define EREMCHG EREMCHG /* remote address changed */
|
||||
#define ELIBACC ELIBACC /* cannot access dso */
|
||||
#define ELIBBAD ELIBBAD /* corrupted shared library */
|
||||
#define ELIBSCN ELIBSCN /* a.out section corrupted */
|
||||
#define ELIBMAX ELIBMAX /* too many shared libraries */
|
||||
#define ELIBEXEC ELIBEXEC /* cannot exec a dso directly */
|
||||
#define EILSEQ EILSEQ /* invalid wide character */
|
||||
#define ERESTART ERESTART /* please restart syscall */
|
||||
#define ESTRPIPE ESTRPIPE /* streams pipe error */
|
||||
#define EUSERS EUSERS /* too many users */
|
||||
#define ENOTSOCK ENOTSOCK /* not a socket */
|
||||
#define EDESTADDRREQ EDESTADDRREQ /* dest address needed */
|
||||
#define EMSGSIZE EMSGSIZE /* message too long */
|
||||
#define EPROTOTYPE EPROTOTYPE /* protocol wrong for socket */
|
||||
#define ENOPROTOOPT ENOPROTOOPT /* protocol not available */
|
||||
#define EPROTONOSUPPORT EPROTONOSUPPORT /* protocol not supported */
|
||||
#define ESOCKTNOSUPPORT ESOCKTNOSUPPORT /* socket type not supported */
|
||||
#define EOPNOTSUPP EOPNOTSUPP /* operation not supported on socket */
|
||||
#define EPFNOSUPPORT EPFNOSUPPORT /* protocol family not supported */
|
||||
#define EAFNOSUPPORT EAFNOSUPPORT /* address family not supported */
|
||||
#define EADDRINUSE EADDRINUSE /* address already in use */
|
||||
#define EADDRNOTAVAIL EADDRNOTAVAIL /* address not available */
|
||||
#define ENETDOWN ENETDOWN /* network is down */
|
||||
#define ENETUNREACH ENETUNREACH /* network unreachable */
|
||||
#define ENETRESET ENETRESET /* connection aborted by network */
|
||||
#define ECONNABORTED ECONNABORTED /* connection aborted */
|
||||
#define ECONNRESET ECONNRESET /* connection reset */
|
||||
#define ENOBUFS ENOBUFS /* no buffer space available */
|
||||
#define EISCONN EISCONN /* socket is connected */
|
||||
#define ENOTCONN ENOTCONN /* the socket is not connected */
|
||||
#define ESHUTDOWN ESHUTDOWN /* no send after endpoint shutdown */
|
||||
#define ETOOMANYREFS ETOOMANYREFS /* too many refs */
|
||||
#define ETIMEDOUT ETIMEDOUT /* connection timed out */
|
||||
#define ECONNREFUSED ECONNREFUSED /* connection refused */
|
||||
#define EHOSTDOWN EHOSTDOWN /* host is down */
|
||||
#define EHOSTUNREACH EHOSTUNREACH /* host is unreachable */
|
||||
#define EALREADY EALREADY /* connection already in progress */
|
||||
#define EINPROGRESS EINPROGRESS /* operation in progress */
|
||||
#define ESTALE ESTALE /* stale file handle */
|
||||
#define EUCLEAN EUCLEAN /* structure needs cleaning */
|
||||
#define ENOTNAM ENOTNAM /* todo */
|
||||
#define ENAVAIL ENAVAIL /* todo */
|
||||
#define EISNAM EISNAM /* is a named type file */
|
||||
#define EREMOTEIO EREMOTEIO /* remote i/o error */
|
||||
#define EDQUOT EDQUOT /* disk quota exceeded */
|
||||
#define ENOMEDIUM ENOMEDIUM /* no medium found */
|
||||
#define EMEDIUMTYPE EMEDIUMTYPE /* wrong medium type */
|
||||
#define ECANCELED ECANCELED /* operation canceled */
|
||||
#define ENOKEY ENOKEY /* required key not available */
|
||||
#define EKEYEXPIRED EKEYEXPIRED /* key has expired */
|
||||
#define EKEYREVOKED EKEYREVOKED /* key has been revoked */
|
||||
#define EKEYREJECTED EKEYREJECTED /* key was rejected by service */
|
||||
#define EOWNERDEAD EOWNERDEAD /* owner died */
|
||||
#define ENOTRECOVERABLE ENOTRECOVERABLE /* state not recoverable */
|
||||
#define ERFKILL ERFKILL /* can't op b/c RF-kill */
|
||||
#define EHWPOISON EHWPOISON /* mempage has h/w error */
|
||||
#define EWOULDBLOCK EAGAIN /* poll fd and try again */
|
||||
#define EPERM EPERM // operation not permitted
|
||||
#define ENOENT ENOENT // no such file or directory
|
||||
#define ESRCH ESRCH // no such process
|
||||
#define EINTR EINTR // interrupted system call
|
||||
#define EIO EIO // input/output error
|
||||
#define ENXIO ENXIO // no such device or address
|
||||
#define E2BIG E2BIG // argument list too long
|
||||
#define ENOEXEC ENOEXEC // exec format error
|
||||
#define EBADF EBADF // bad file descriptor
|
||||
#define ECHILD ECHILD // no child processes
|
||||
#define EAGAIN EAGAIN // resource temporarily unavailable
|
||||
#define ENOMEM ENOMEM // not enough space
|
||||
#define EACCES EACCES // permission denied
|
||||
#define EFAULT EFAULT // bad address
|
||||
#define ENOTBLK ENOTBLK // block device required
|
||||
#define EBUSY EBUSY // device or resource busy
|
||||
#define EEXIST EEXIST // file exists
|
||||
#define EXDEV EXDEV // improper link
|
||||
#define ENODEV ENODEV // no such device
|
||||
#define ENOTDIR ENOTDIR // not a directory
|
||||
#define EISDIR EISDIR // is a directory
|
||||
#define EINVAL EINVAL // invalid argument
|
||||
#define ENFILE ENFILE // too many open files in system
|
||||
#define EMFILE EMFILE // too many open files
|
||||
#define ENOTTY ENOTTY // inappropriate I/O control op
|
||||
#define ETXTBSY ETXTBSY // text file busy
|
||||
#define EFBIG EFBIG // file too large
|
||||
#define ENOSPC ENOSPC // no space left on device
|
||||
#define ESPIPE ESPIPE // invalid seek
|
||||
#define EROFS EROFS // read-only filesystem
|
||||
#define EMLINK EMLINK // too many links
|
||||
#define EPIPE EPIPE // broken pipe
|
||||
#define EDOM EDOM // argument out of function domain
|
||||
#define ERANGE ERANGE // result too large
|
||||
#define EDEADLK EDEADLK // resource deadlock avoided
|
||||
#define ENAMETOOLONG ENAMETOOLONG // filename too long
|
||||
#define ENOLCK ENOLCK // no locks available
|
||||
#define ENOSYS ENOSYS // system call not implemented
|
||||
#define ENOTEMPTY ENOTEMPTY // directory not empty
|
||||
#define ELOOP ELOOP // too many levels of symbolic links
|
||||
#define ENOMSG ENOMSG // no message of the desired type
|
||||
#define EIDRM EIDRM // identifier removed
|
||||
#define ECHRNG ECHRNG // channel number out of range
|
||||
#define EL2NSYNC EL2NSYNC // level 2 not synchronized
|
||||
#define EL3HLT EL3HLT // level 3 halted
|
||||
#define EL3RST EL3RST // level 3 halted
|
||||
#define ELNRNG ELNRNG // link number out of range
|
||||
#define EUNATCH EUNATCH // protocol driver not attached
|
||||
#define ENOCSI ENOCSI // no csi structure available
|
||||
#define EL2HLT EL2HLT // level 2 halted
|
||||
#define EBADE EBADE // invalid exchange
|
||||
#define EBADR EBADR // invalid request descriptor
|
||||
#define EXFULL EXFULL // exchange full
|
||||
#define ENOANO ENOANO // no anode
|
||||
#define EBADRQC EBADRQC // invalid request code
|
||||
#define EBADSLT EBADSLT // invalid slot
|
||||
#define ENOSTR ENOSTR // no string
|
||||
#define ENODATA ENODATA // no data
|
||||
#define ETIME ETIME // timer expired
|
||||
#define ENOSR ENOSR // out of streams resources
|
||||
#define ENONET ENONET // no network
|
||||
#define ENOPKG ENOPKG // package not installed
|
||||
#define EREMOTE EREMOTE // object is remote
|
||||
#define ENOLINK ENOLINK // link severed
|
||||
#define EADV EADV // todo
|
||||
#define ESRMNT ESRMNT // todo
|
||||
#define ECOMM ECOMM // communication error on send
|
||||
#define EPROTO EPROTO // protocol error
|
||||
#define EMULTIHOP EMULTIHOP // multihop attempted
|
||||
#define EDOTDOT EDOTDOT // todo
|
||||
#define EBADMSG EBADMSG // bad message
|
||||
#define EOVERFLOW EOVERFLOW // value too large for type
|
||||
#define ENOTUNIQ ENOTUNIQ // name not unique on network
|
||||
#define EBADFD EBADFD // fd in bad *state* (cf. EBADF)
|
||||
#define EREMCHG EREMCHG // remote address changed
|
||||
#define ELIBACC ELIBACC // cannot access dso
|
||||
#define ELIBBAD ELIBBAD // corrupted shared library
|
||||
#define ELIBSCN ELIBSCN // a.out section corrupted
|
||||
#define ELIBMAX ELIBMAX // too many shared libraries
|
||||
#define ELIBEXEC ELIBEXEC // cannot exec a dso directly
|
||||
#define EILSEQ EILSEQ // invalid wide character
|
||||
#define ERESTART ERESTART // please restart syscall
|
||||
#define ESTRPIPE ESTRPIPE // streams pipe error
|
||||
#define EUSERS EUSERS // too many users
|
||||
#define ENOTSOCK ENOTSOCK // not a socket
|
||||
#define EDESTADDRREQ EDESTADDRREQ // dest address needed
|
||||
#define EMSGSIZE EMSGSIZE // message too long
|
||||
#define EPROTOTYPE EPROTOTYPE // protocol wrong for socket
|
||||
#define ENOPROTOOPT ENOPROTOOPT // protocol not available
|
||||
#define EPROTONOSUPPORT EPROTONOSUPPORT // protocol not supported
|
||||
#define ESOCKTNOSUPPORT ESOCKTNOSUPPORT // socket type not supported
|
||||
#define EOPNOTSUPP EOPNOTSUPP // operation not supported on socket
|
||||
#define EPFNOSUPPORT EPFNOSUPPORT // protocol family not supported
|
||||
#define EAFNOSUPPORT EAFNOSUPPORT // address family not supported
|
||||
#define EADDRINUSE EADDRINUSE // address already in use
|
||||
#define EADDRNOTAVAIL EADDRNOTAVAIL // address not available
|
||||
#define ENETDOWN ENETDOWN // network is down
|
||||
#define ENETUNREACH ENETUNREACH // network unreachable
|
||||
#define ENETRESET ENETRESET // connection aborted by network
|
||||
#define ECONNABORTED ECONNABORTED // connection aborted
|
||||
#define ECONNRESET ECONNRESET // connection reset
|
||||
#define ENOBUFS ENOBUFS // no buffer space available
|
||||
#define EISCONN EISCONN // socket is connected
|
||||
#define ENOTCONN ENOTCONN // the socket is not connected
|
||||
#define ESHUTDOWN ESHUTDOWN // no send after endpoint shutdown
|
||||
#define ETOOMANYREFS ETOOMANYREFS // too many refs
|
||||
#define ETIMEDOUT ETIMEDOUT // connection timed out
|
||||
#define ECONNREFUSED ECONNREFUSED // connection refused
|
||||
#define EHOSTDOWN EHOSTDOWN // host is down
|
||||
#define EHOSTUNREACH EHOSTUNREACH // host is unreachable
|
||||
#define EALREADY EALREADY // connection already in progress
|
||||
#define EINPROGRESS EINPROGRESS // operation in progress
|
||||
#define ESTALE ESTALE // stale file handle
|
||||
#define EUCLEAN EUCLEAN // structure needs cleaning
|
||||
#define ENOTNAM ENOTNAM // todo
|
||||
#define ENAVAIL ENAVAIL // todo
|
||||
#define EISNAM EISNAM // is a named type file
|
||||
#define EREMOTEIO EREMOTEIO // remote i/o error
|
||||
#define EDQUOT EDQUOT // disk quota exceeded
|
||||
#define ENOMEDIUM ENOMEDIUM // no medium found
|
||||
#define EMEDIUMTYPE EMEDIUMTYPE // wrong medium type
|
||||
#define ECANCELED ECANCELED // operation canceled
|
||||
#define ENOKEY ENOKEY // required key not available
|
||||
#define EKEYEXPIRED EKEYEXPIRED // key has expired
|
||||
#define EKEYREVOKED EKEYREVOKED // key has been revoked
|
||||
#define EKEYREJECTED EKEYREJECTED // key was rejected by service
|
||||
#define EOWNERDEAD EOWNERDEAD // owner died
|
||||
#define ENOTRECOVERABLE ENOTRECOVERABLE // state not recoverable
|
||||
#define ERFKILL ERFKILL // can't op b/c RF-kill
|
||||
#define EHWPOISON EHWPOISON // mempage has h/w error
|
||||
#define EWOULDBLOCK EAGAIN // poll fd and try again
|
||||
#define ENOTSUP ENOTSUP
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/*-*- 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 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/escape/escape.h"
|
||||