mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Make major improvements to redbean and libraries
The most exciting improvement is dynamic pages will soon be able to use the executable itself as an object store. it required a heroic technique for overcoming ETXTBSY restrictions which lets us open the executable in read/write mode, which means (1) wa can restore the APE header, and (2) we can potentially containerize redbean extension code so that modules you download for your redbean online will only impact your redbean. Here's a list of breaking changes to redbean: - Remove /tool/net/ prefix from magic ZIP paths - GetHeader() now returns NIL if header is absent Here's a list of fixes and enhancements to redbean: - Support 64-bit ZIP archives - Record User-Agent header in logs - Add twelve error handlers to accept() - Display octal st_mode on listing page - Show ZIP file comments on listing page - Restore APE MZ header on redbean startup - Track request count on redbean index page - Report server uptime on redbean index page - Don't bind server socket using SO_REUSEPORT - Fix #151 where Lua LoadAsset() could free twice - Report rusage accounting when workers exit w/ -vv - Use ZIP iattr field as text/plain vs. binary hint - Add ParseUrl() API for parsing things like a.href - Add ParseParams() API for parsing HTTP POST bodies - Add IsAcceptablePath() API for checking dots, etc. - Add IsValidHttpToken() API for validating sane ASCII - Add IsAcceptableHostPort() for validating HOST[:PORT] - Send 400 response to HTTP/1.1 requests without a Host - Send 403 response if ZIP or file isn't other readable - Add virtual hosting that tries prepending Host to path - Route requests based on Host in Request-URI if present - Host routing will attempt to remove or add the www. prefix - Sign-extend UNIX timestamps and don't adjust FileTime zone Here's some of the improvements made to Cosmopolitan Libc: - Fix ape.S indentation - Improve consts.sh magnums - Write pretty good URL parser - Improve rusage accounting apis - Bring mremap() closer to working - Added ZIP APIs which will change - Check for overflow in reallocarray() - Remove overly fancy linkage in strerror() - Fix GDB attach on crash w/ OpenBSD msyscall() - Make sigqueue() portable to most UNIX distros - Make integer serialization macros more elegant - Bring back 34x tprecode8to16() performance boost - Make malloc() more resilient to absurdly large sizes
This commit is contained in:
parent
69c508729e
commit
bf03b2e64c
307 changed files with 4557 additions and 2581 deletions
76
ape/ape.S
76
ape/ape.S
|
@ -865,48 +865,48 @@ ape_macho:
|
|||
@see "The Portable Executable File Format from Top to Bottom",
|
||||
Randy Kath, Microsoft Developer Network Technology Group. */
|
||||
|
||||
// ┌14:Uniprocessor Machine ┌─────────────────────────┐
|
||||
// │┌13:DLL │ PE File Characteristics │
|
||||
// ││┌12:System ├─────────────────────────┤
|
||||
// │││┌11:If Net Run From Swap │ r │ reserved │
|
||||
// ││││┌10:If Removable Run From Swap │ d │ deprecated │
|
||||
// │││││┌9:Debug Stripped │ D │ deprecated with │
|
||||
// ││││││┌8:32bit Machine │ │ extreme prejudice │
|
||||
// │││││││ ┌5:Large Address Aware └───┴─────────────────────┘
|
||||
// │││││││ │ ┌1:Executable
|
||||
// │││││││ │ │┌0:Relocs Stripped
|
||||
// d│││││││dr│Ddd││
|
||||
PEEXE = 0b0000001000100011
|
||||
// ┌14:Uniprocessor Machine ┌─────────────────────────┐
|
||||
// │┌13:DLL │ PE File Characteristics │
|
||||
// ││┌12:System ├─────────────────────────┤
|
||||
// │││┌11:If Net Run From Swap │ r │ reserved │
|
||||
// ││││┌10:If Removable Run From Swap │ d │ deprecated │
|
||||
// │││││┌9:Debug Stripped │ D │ deprecated with │
|
||||
// ││││││┌8:32bit Machine │ │ extreme prejudice │
|
||||
// │││││││ ┌5:Large Address Aware └───┴─────────────────────┘
|
||||
// │││││││ │ ┌1:Executable
|
||||
// │││││││ │ │┌0:Relocs Stripped
|
||||
// d│││││││dr│Ddd││
|
||||
PEEXE = 0b00000001000100011
|
||||
|
||||
// ┌15:TERMINAL_SERVER_AWARE ┌─────────────────────────┐
|
||||
// │┌14:GUARD_CF │ PE DLL Characteristics │
|
||||
// ││┌13:WDM_DRIVER ├─────────────────────────┤
|
||||
// │││┌12:APPCONTAINER │ r │ reserved │
|
||||
// ││││┌11:NO_BIND └───┴─────────────────────┘
|
||||
// │││││┌10:NO_SEH
|
||||
// ││││││┌9:NO_ISOLATION
|
||||
// │││││││┌8:NX_COMPAT
|
||||
// ││││││││┌7:FORCE_INTEGRITY
|
||||
// │││││││││┌6:DYNAMIC_BASE
|
||||
// ││││││││││┌5:HIGH_ENTROPY_VA
|
||||
// │││││││││││rrrrr
|
||||
// ┌15:TERMINAL_SERVER_AWARE ┌─────────────────────────┐
|
||||
// │┌14:GUARD_CF │ PE DLL Characteristics │
|
||||
// ││┌13:WDM_DRIVER ├─────────────────────────┤
|
||||
// │││┌12:APPCONTAINER │ r │ reserved │
|
||||
// ││││┌11:NO_BIND └───┴─────────────────────┘
|
||||
// │││││┌10:NO_SEH
|
||||
// ││││││┌9:NO_ISOLATION
|
||||
// │││││││┌8:NX_COMPAT
|
||||
// ││││││││┌7:FORCE_INTEGRITY
|
||||
// │││││││││┌6:DYNAMIC_BASE
|
||||
// ││││││││││┌5:HIGH_ENTROPY_VA
|
||||
// │││││││││││rrrrr
|
||||
DLLSTD = 0b0000000100100000
|
||||
DLLPIE = 0b0000000001100000
|
||||
DLLEXE = DLLSTD
|
||||
|
||||
// ┌31:Writeable ┌─────────────────────────┐
|
||||
// │┌30:Readable │ PE Section Flags │
|
||||
// ││┌29:Executable ├─────────────────────────┤
|
||||
// │││┌28:Shareable │ o │ for object files │
|
||||
// ││││┌27:Unpageable │ r │ reserved │
|
||||
// │││││┌26:Uncacheable └───┴─────────────────────┘
|
||||
// ││││││┌25:Discardable
|
||||
// │││││││┌24:Contains Extended Relocations
|
||||
// ││││││││ ┌15:Contains Global Pointer (GP) Relative Data
|
||||
// ││││││││ │ ┌7:Contains Uninitialized Data
|
||||
// ││││││││ │ │┌6:Contains Initialized Data
|
||||
// ││││││││ o │ ││┌5:Contains Code
|
||||
// ││││││││┌┴─┐rrrr│ ooror│││rorrr
|
||||
// ┌31:Writeable ┌─────────────────────────┐
|
||||
// │┌30:Readable │ PE Section Flags │
|
||||
// ││┌29:Executable ├─────────────────────────┤
|
||||
// │││┌28:Shareable │ o │ for object files │
|
||||
// ││││┌27:Unpageable │ r │ reserved │
|
||||
// │││││┌26:Uncacheable └───┴─────────────────────┘
|
||||
// ││││││┌25:Discardable
|
||||
// │││││││┌24:Contains Extended Relocations
|
||||
// ││││││││ ┌15:Contains Global Pointer (GP) Relative Data
|
||||
// ││││││││ │ ┌7:Contains Uninitialized Data
|
||||
// ││││││││ │ │┌6:Contains Initialized Data
|
||||
// ││││││││ o │ ││┌5:Contains Code
|
||||
// ││││││││┌┴─┐rrrr│ ooror│││rorrr
|
||||
PETEXT = 0b01110000000000000000000001100000
|
||||
PEDATA = 0b11000000000000000000000011000000
|
||||
PEIMPS = 0b11000000000000000000000001000000
|
||||
|
@ -1437,7 +1437,7 @@ long: push $GDT_LONG_DATA
|
|||
.endfn long
|
||||
|
||||
/* ▄▄▒▀▀▀▀▒▒▄
|
||||
█████▓▓▄░░░░ ▒▒▄░
|
||||
█████▓▓▄░░░░ ▒▒▄
|
||||
▐█▓▓█▓▄█████▓░ ▀▒▄
|
||||
▓█▓▓▓▓▓▓▓▓▓█▓ ░▀▒░
|
||||
▀▀▓█▓▓▓▓▓▓█▓ ░▀▒▄▄▒▄▄▄▒▒▒▀▀▀▀▀▀▀▀▀▀▀▀▀▀▒▒▄▒
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -6,19 +6,23 @@ COSMOPOLITAN_C_START_
|
|||
forceinline void *bisect(const void *k, const void *data, size_t n, size_t size,
|
||||
int cmp(const void *a, const void *b, void *arg),
|
||||
void *arg) {
|
||||
int dir;
|
||||
const char *p, *pos;
|
||||
p = data;
|
||||
while (n > 0) {
|
||||
pos = p + size * (n / 2);
|
||||
dir = cmp(k, pos, arg);
|
||||
if (dir < 0) {
|
||||
n /= 2;
|
||||
} else if (dir > 0) {
|
||||
p = pos + size;
|
||||
n -= n / 2 + 1;
|
||||
} else {
|
||||
return (void *)pos;
|
||||
int c;
|
||||
const char *p;
|
||||
ssize_t m, l, r;
|
||||
if (n) {
|
||||
l = 0;
|
||||
r = n - 1;
|
||||
p = data;
|
||||
while (l <= r) {
|
||||
m = (l + r) >> 1;
|
||||
c = cmp(k, p + m * size, arg);
|
||||
if (c > 0) {
|
||||
l = m + 1;
|
||||
} else if (c < 0) {
|
||||
r = m - 1;
|
||||
} else {
|
||||
return p + m * size;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
/**
|
||||
* Reverses bits in 16-bit word.
|
||||
*/
|
||||
uint16_t(bitreverse16)(uint16_t x) {
|
||||
return kReverseBits[x & 0x00FF] << 8 | kReverseBits[(x & 0xFF00) >> 8];
|
||||
int bitreverse16(int x) {
|
||||
return BITREVERSE16(x);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
/**
|
||||
* Reverses bits in 32-bit word.
|
||||
*/
|
||||
uint32_t(bitreverse32)(uint32_t x) {
|
||||
uint32_t bitreverse32(uint32_t x) {
|
||||
x = bswap_32(x);
|
||||
x = ((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1);
|
||||
x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2);
|
||||
x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4);
|
||||
x = (x & 0xaaaaaaaa) >> 1 | (x & 0x55555555) << 1;
|
||||
x = (x & 0xcccccccc) >> 2 | (x & 0x33333333) << 2;
|
||||
x = (x & 0xf0f0f0f0) >> 4 | (x & 0x0f0f0f0f) << 4;
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
*/
|
||||
uint64_t bitreverse64(uint64_t x) {
|
||||
x = bswap_64(x);
|
||||
x = ((x & 0xaaaaaaaaaaaaaaaa) >> 1) | ((x & 0x5555555555555555) << 1);
|
||||
x = ((x & 0xcccccccccccccccc) >> 2) | ((x & 0x3333333333333333) << 2);
|
||||
x = ((x & 0xf0f0f0f0f0f0f0f0) >> 4) | ((x & 0x0f0f0f0f0f0f0f0f) << 4);
|
||||
x = (x & 0xaaaaaaaaaaaaaaaa) >> 1 | (x & 0x5555555555555555) << 1;
|
||||
x = (x & 0xcccccccccccccccc) >> 2 | (x & 0x3333333333333333) << 2;
|
||||
x = (x & 0xf0f0f0f0f0f0f0f0) >> 4 | (x & 0x0f0f0f0f0f0f0f0f) << 4;
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
/**
|
||||
* Reverses bits in 8-bit word.
|
||||
*/
|
||||
uint8_t(bitreverse8)(uint8_t x) {
|
||||
return kReverseBits[x];
|
||||
int bitreverse8(int x) {
|
||||
return BITREVERSE8(x);
|
||||
}
|
||||
|
|
198
libc/bits/bits.h
198
libc/bits/bits.h
|
@ -13,8 +13,8 @@ extern const uint8_t kReverseBits[256];
|
|||
|
||||
uint32_t gray(uint32_t) pureconst;
|
||||
uint32_t ungray(uint32_t) pureconst;
|
||||
uint8_t bitreverse8(uint8_t) libcesque pureconst;
|
||||
uint16_t bitreverse16(uint16_t) libcesque pureconst;
|
||||
int bitreverse8(int) libcesque pureconst;
|
||||
int bitreverse16(int) libcesque pureconst;
|
||||
uint32_t bitreverse32(uint32_t) libcesque pureconst;
|
||||
uint64_t bitreverse64(uint64_t) libcesque pureconst;
|
||||
unsigned long roundup2pow(unsigned long) libcesque pureconst;
|
||||
|
@ -31,106 +31,104 @@ intptr_t atomic_store(void *, intptr_t, size_t);
|
|||
│ cosmopolitan § bits » no assembly required ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#define bitreverse8(X) (kReverseBits[(uint8_t)(X)])
|
||||
#define bitreverse16(X) \
|
||||
((uint16_t)kReverseBits[(uint8_t)(X)] << 010 | \
|
||||
kReverseBits[((uint16_t)(X) >> 010) & 0xff])
|
||||
#define BITREVERSE8(X) (kReverseBits[255 & (X)])
|
||||
#define BITREVERSE16(X) \
|
||||
(kReverseBits[0x00FF & (X)] << 8 | kReverseBits[(0xFF00 & (X)) >> 8])
|
||||
|
||||
#define READ16LE(S) \
|
||||
((uint16_t)((unsigned char *)(S))[1] << 010 | \
|
||||
(uint16_t)((unsigned char *)(S))[0] << 000)
|
||||
#define READ32LE(S) \
|
||||
((uint32_t)((unsigned char *)(S))[3] << 030 | \
|
||||
(uint32_t)((unsigned char *)(S))[2] << 020 | \
|
||||
(uint32_t)((unsigned char *)(S))[1] << 010 | \
|
||||
(uint32_t)((unsigned char *)(S))[0] << 000)
|
||||
#define READ64LE(S) \
|
||||
((uint64_t)((unsigned char *)(S))[7] << 070 | \
|
||||
(uint64_t)((unsigned char *)(S))[6] << 060 | \
|
||||
(uint64_t)((unsigned char *)(S))[5] << 050 | \
|
||||
(uint64_t)((unsigned char *)(S))[4] << 040 | \
|
||||
(uint64_t)((unsigned char *)(S))[3] << 030 | \
|
||||
(uint64_t)((unsigned char *)(S))[2] << 020 | \
|
||||
(uint64_t)((unsigned char *)(S))[1] << 010 | \
|
||||
(uint64_t)((unsigned char *)(S))[0] << 000)
|
||||
#ifdef __STRICT_ANSI__
|
||||
#define READ16LE(S) ((255 & (S)[1]) << 8 | (255 & (S)[0]))
|
||||
#define READ16BE(S) ((255 & (S)[0]) << 8 | (255 & (S)[1]))
|
||||
#define READ32LE(S) \
|
||||
((uint32_t)(255 & (S)[3]) << 030 | (uint32_t)(255 & (S)[2]) << 020 | \
|
||||
(uint32_t)(255 & (S)[1]) << 010 | (uint32_t)(255 & (S)[0]) << 000)
|
||||
#define READ32BE(S) \
|
||||
((uint32_t)(255 & (S)[0]) << 030 | (uint32_t)(255 & (S)[1]) << 020 | \
|
||||
(uint32_t)(255 & (S)[2]) << 010 | (uint32_t)(255 & (S)[3]) << 000)
|
||||
#define READ64LE(S) \
|
||||
((uint64_t)(255 & (S)[7]) << 070 | (uint64_t)(255 & (S)[6]) << 060 | \
|
||||
(uint64_t)(255 & (S)[5]) << 050 | (uint64_t)(255 & (S)[4]) << 040 | \
|
||||
(uint64_t)(255 & (S)[3]) << 030 | (uint64_t)(255 & (S)[2]) << 020 | \
|
||||
(uint64_t)(255 & (S)[1]) << 010 | (uint64_t)(255 & (S)[0]) << 000)
|
||||
#define READ64BE(S) \
|
||||
((uint64_t)(255 & (S)[0]) << 070 | (uint64_t)(255 & (S)[1]) << 060 | \
|
||||
(uint64_t)(255 & (S)[2]) << 050 | (uint64_t)(255 & (S)[3]) << 040 | \
|
||||
(uint64_t)(255 & (S)[4]) << 030 | (uint64_t)(255 & (S)[5]) << 020 | \
|
||||
(uint64_t)(255 & (S)[6]) << 010 | (uint64_t)(255 & (S)[7]) << 000)
|
||||
#else /* gcc needs help knowing above are mov if s isn't a variable */
|
||||
#define READ16LE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
Ptr[1] << 8 | Ptr[0]; \
|
||||
})
|
||||
#define READ16BE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
Ptr[0] << 8 | Ptr[1]; \
|
||||
})
|
||||
#define READ32LE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
((uint32_t)Ptr[3] << 030 | (uint32_t)Ptr[2] << 020 | \
|
||||
(uint32_t)Ptr[1] << 010 | (uint32_t)Ptr[0] << 000); \
|
||||
})
|
||||
#define READ32BE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
((uint32_t)Ptr[0] << 030 | (uint32_t)Ptr[1] << 020 | \
|
||||
(uint32_t)Ptr[2] << 010 | (uint32_t)Ptr[3] << 000); \
|
||||
})
|
||||
#define READ64LE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
((uint64_t)Ptr[7] << 070 | (uint64_t)Ptr[6] << 060 | \
|
||||
(uint64_t)Ptr[5] << 050 | (uint64_t)Ptr[4] << 040 | \
|
||||
(uint64_t)Ptr[3] << 030 | (uint64_t)Ptr[2] << 020 | \
|
||||
(uint64_t)Ptr[1] << 010 | (uint64_t)Ptr[0] << 000); \
|
||||
})
|
||||
#define READ64BE(S) \
|
||||
({ \
|
||||
const uint8_t *Ptr = (const uint8_t *)(S); \
|
||||
((uint64_t)Ptr[0] << 070 | (uint64_t)Ptr[1] << 060 | \
|
||||
(uint64_t)Ptr[2] << 050 | (uint64_t)Ptr[3] << 040 | \
|
||||
(uint64_t)Ptr[4] << 030 | (uint64_t)Ptr[5] << 020 | \
|
||||
(uint64_t)Ptr[6] << 010 | (uint64_t)Ptr[7] << 000); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define READ16BE(S) \
|
||||
((uint16_t)((unsigned char *)(S))[0] << 010 | \
|
||||
(uint16_t)((unsigned char *)(S))[1] << 000)
|
||||
#define READ32BE(S) \
|
||||
((uint32_t)((unsigned char *)(S))[0] << 030 | \
|
||||
(uint32_t)((unsigned char *)(S))[1] << 020 | \
|
||||
(uint32_t)((unsigned char *)(S))[2] << 010 | \
|
||||
(uint32_t)((unsigned char *)(S))[3] << 000)
|
||||
#define READ64BE(S) \
|
||||
((uint64_t)((unsigned char *)(S))[0] << 070 | \
|
||||
(uint64_t)((unsigned char *)(S))[1] << 060 | \
|
||||
(uint64_t)((unsigned char *)(S))[2] << 050 | \
|
||||
(uint64_t)((unsigned char *)(S))[3] << 040 | \
|
||||
(uint64_t)((unsigned char *)(S))[4] << 030 | \
|
||||
(uint64_t)((unsigned char *)(S))[5] << 020 | \
|
||||
(uint64_t)((unsigned char *)(S))[6] << 010 | \
|
||||
(uint64_t)((unsigned char *)(S))[7] << 000)
|
||||
|
||||
#define WRITE16LE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint16_t Vle = (V); \
|
||||
Ple[0] = (uint8_t)(Vle >> 000); \
|
||||
Ple[1] = (uint8_t)(Vle >> 010); \
|
||||
} while (0)
|
||||
#define WRITE32LE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint32_t Vle = (V); \
|
||||
Ple[0] = (uint8_t)(Vle >> 000); \
|
||||
Ple[1] = (uint8_t)(Vle >> 010); \
|
||||
Ple[2] = (uint8_t)(Vle >> 020); \
|
||||
Ple[3] = (uint8_t)(Vle >> 030); \
|
||||
} while (0)
|
||||
#define WRITE64LE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint64_t Vle = (V); \
|
||||
Ple[0] = (uint8_t)(Vle >> 000); \
|
||||
Ple[1] = (uint8_t)(Vle >> 010); \
|
||||
Ple[2] = (uint8_t)(Vle >> 020); \
|
||||
Ple[3] = (uint8_t)(Vle >> 030); \
|
||||
Ple[4] = (uint8_t)(Vle >> 040); \
|
||||
Ple[5] = (uint8_t)(Vle >> 050); \
|
||||
Ple[6] = (uint8_t)(Vle >> 060); \
|
||||
Ple[7] = (uint8_t)(Vle >> 070); \
|
||||
} while (0)
|
||||
|
||||
#define WRITE16BE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint16_t Vle = (V); \
|
||||
Ple[1] = (uint8_t)(Vle >> 000); \
|
||||
Ple[0] = (uint8_t)(Vle >> 010); \
|
||||
} while (0)
|
||||
#define WRITE32BE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint32_t Vle = (V); \
|
||||
Ple[3] = (uint8_t)(Vle >> 000); \
|
||||
Ple[2] = (uint8_t)(Vle >> 010); \
|
||||
Ple[1] = (uint8_t)(Vle >> 020); \
|
||||
Ple[0] = (uint8_t)(Vle >> 030); \
|
||||
} while (0)
|
||||
#define WRITE64BE(P, V) \
|
||||
do { \
|
||||
uint8_t *Ple = (uint8_t *)(P); \
|
||||
uint64_t Vle = (V); \
|
||||
Ple[7] = (uint8_t)(Vle >> 000); \
|
||||
Ple[6] = (uint8_t)(Vle >> 010); \
|
||||
Ple[5] = (uint8_t)(Vle >> 020); \
|
||||
Ple[4] = (uint8_t)(Vle >> 030); \
|
||||
Ple[3] = (uint8_t)(Vle >> 040); \
|
||||
Ple[2] = (uint8_t)(Vle >> 050); \
|
||||
Ple[1] = (uint8_t)(Vle >> 060); \
|
||||
Ple[0] = (uint8_t)(Vle >> 070); \
|
||||
} while (0)
|
||||
#define WRITE16LE(P, V) \
|
||||
((P)[0] = (0x00000000000000FF & (V)) >> 000, \
|
||||
(P)[1] = (0x000000000000FF00 & (V)) >> 010, (P) + 2)
|
||||
#define WRITE16BE(P, V) \
|
||||
((P)[0] = (0x000000000000FF00 & (V)) >> 010, \
|
||||
(P)[1] = (0x00000000000000FF & (V)) >> 000, (P) + 2)
|
||||
#define WRITE32LE(P, V) \
|
||||
((P)[0] = (0x00000000000000FF & (V)) >> 000, \
|
||||
(P)[1] = (0x000000000000FF00 & (V)) >> 010, \
|
||||
(P)[2] = (0x0000000000FF0000 & (V)) >> 020, \
|
||||
(P)[3] = (0x00000000FF000000 & (V)) >> 030, (P) + 4)
|
||||
#define WRITE32BE(P, V) \
|
||||
((P)[0] = (0x00000000FF000000 & (V)) >> 030, \
|
||||
(P)[1] = (0x0000000000FF0000 & (V)) >> 020, \
|
||||
(P)[2] = (0x000000000000FF00 & (V)) >> 010, \
|
||||
(P)[3] = (0x00000000000000FF & (V)) >> 000, (P) + 4)
|
||||
#define WRITE64LE(P, V) \
|
||||
((P)[0] = (0x00000000000000FF & (V)) >> 000, \
|
||||
(P)[1] = (0x000000000000FF00 & (V)) >> 010, \
|
||||
(P)[2] = (0x0000000000FF0000 & (V)) >> 020, \
|
||||
(P)[3] = (0x00000000FF000000 & (V)) >> 030, \
|
||||
(P)[4] = (0x000000FF00000000 & (V)) >> 040, \
|
||||
(P)[5] = (0x0000FF0000000000 & (V)) >> 050, \
|
||||
(P)[6] = (0x00FF000000000000 & (V)) >> 060, \
|
||||
(P)[7] = (0xFF00000000000000 & (V)) >> 070, (P) + 8)
|
||||
#define WRITE64BE(P, V) \
|
||||
((P)[0] = (0xFF00000000000000 & (V)) >> 070, \
|
||||
(P)[1] = (0x00FF000000000000 & (V)) >> 060, \
|
||||
(P)[2] = (0x0000FF0000000000 & (V)) >> 050, \
|
||||
(P)[3] = (0x000000FF00000000 & (V)) >> 040, \
|
||||
(P)[4] = (0x00000000FF000000 & (V)) >> 030, \
|
||||
(P)[5] = (0x0000000000FF0000 & (V)) >> 020, \
|
||||
(P)[6] = (0x000000000000FF00 & (V)) >> 010, \
|
||||
(P)[7] = (0x00000000000000FF & (V)) >> 000, (P) + 8)
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § bits » some assembly required ─╬─│┼
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/sysinfo.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
|
@ -120,6 +121,7 @@ int getrlimit(int, struct rlimit *);
|
|||
int getrusage(int, struct rusage *);
|
||||
int kill(int, int);
|
||||
int killpg(int, int);
|
||||
int sigqueue(int, int, const union sigval);
|
||||
int link(const char *, const char *) nothrow;
|
||||
int linkat(int, const char *, int, const char *, uint32_t);
|
||||
int lstat(const char *, struct stat *);
|
||||
|
|
|
@ -30,14 +30,10 @@
|
|||
* time. Among the more popular is CLOCK_MONOTONIC. This function has a
|
||||
* zero syscall implementation of that on modern x86.
|
||||
*
|
||||
* @param clockid can be CLOCK_REALTIME, CLOCK_MONOTONIC, etc. noting
|
||||
* that on Linux CLOCK_MONOTONIC is redefined to use the monotonic
|
||||
* clock that's actually monotonic lool
|
||||
* @param clockid can be CLOCK_REALTIME, CLOCK_MONOTONIC, etc.
|
||||
* @param ts is where the result is stored
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @error ENOSYS if clockid isn't available; in which case this function
|
||||
* guarantees an ordinary timestamp is still stored to ts; and
|
||||
* errno isn't restored to its original value, to detect prec. loss
|
||||
* @error EINVAL if clockid isn't supported on this system
|
||||
* @see strftime(), gettimeofday()
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
|
@ -46,6 +42,7 @@ int clock_gettime(int clockid, struct timespec *ts) {
|
|||
axdx_t ad;
|
||||
struct NtFileTime ft;
|
||||
if (!ts) return efault();
|
||||
if (clockid == -1) return einval();
|
||||
if (!IsWindows()) {
|
||||
if ((rc = sys_clock_gettime(clockid, ts)) == -1 && errno == ENOSYS) {
|
||||
ad = sys_gettimeofday((struct timeval *)ts, NULL, NULL);
|
||||
|
|
35
libc/calls/getrusage-sysv.c
Normal file
35
libc/calls/getrusage-sysv.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Returns resource usage statistics.
|
||||
*
|
||||
* @param who can be RUSAGE_{SELF,CHILDREN,THREAD}
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
*/
|
||||
int sys_getrusage(int who, struct rusage *usage) {
|
||||
int rc;
|
||||
if ((rc = __sys_getrusage(who, usage)) != -1) {
|
||||
__rusage2linux(usage);
|
||||
}
|
||||
return rc;
|
||||
}
|
|
@ -4,7 +4,10 @@
|
|||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sigaction-xnu.internal.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/dce.h"
|
||||
|
@ -108,9 +111,11 @@ i32 __sys_dup3(i32, i32, i32) hidden;
|
|||
i32 __sys_execve(const char *, char *const[], char *const[]) hidden;
|
||||
i32 __sys_fstat(i32, struct stat *) hidden;
|
||||
i32 __sys_fstatat(i32, const char *, struct stat *, i32) hidden;
|
||||
i32 __sys_getrusage(i32, struct rusage *) hidden;
|
||||
i32 __sys_openat(i32, const char *, i32, u32) hidden;
|
||||
i32 __sys_pipe2(i32[hasatleast 2], u32) hidden;
|
||||
i32 __sys_utimensat(i32, const char *, const struct timespec *, i32) hidden;
|
||||
i32 __sys_wait4(i32, i32 *, i32, struct rusage *) hidden;
|
||||
i32 getdents(i32, char *, u32, i64 *) hidden;
|
||||
i32 sys_chdir(const char *) hidden;
|
||||
i32 sys_clock_gettime(i32, struct timespec *) hidden;
|
||||
|
@ -170,6 +175,8 @@ i32 sys_setrlimit(i32, const struct rlimit *) hidden;
|
|||
i32 sys_setsid(void) hidden;
|
||||
i32 sys_sigaction(i32, const void *, void *, i64, i64) hidden;
|
||||
i32 sys_sigprocmask(i32, const sigset *, sigset *, u64) hidden;
|
||||
i32 sys_sigqueue(i32, i32, const union sigval) hidden;
|
||||
i32 sys_sigqueueinfo(i32, const siginfo_t *) hidden;
|
||||
i32 sys_sigsuspend(const sigset *, u64) hidden;
|
||||
i32 sys_symlinkat(const char *, i32, const char *) hidden;
|
||||
i32 sys_sync(void) hidden;
|
||||
|
@ -220,6 +227,7 @@ int gethostname_linux(char *, size_t) hidden;
|
|||
int gethostname_bsd(char *, size_t) hidden;
|
||||
int gethostname_nt(char *, size_t) hidden;
|
||||
size_t __iovec_size(const struct iovec *, size_t) hidden;
|
||||
void __rusage2linux(struct rusage *) hidden;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § syscalls » windows nt » veneers ─╬─│┼
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* <-1 signals all processes in -pid process group
|
||||
* @param sig can be:
|
||||
* >0 can be SIGINT, SIGTERM, SIGKILL, SIGUSR1, etc.
|
||||
* =0 is for error checking
|
||||
* =0 checks both if pid exists and we can signal it
|
||||
* @return 0 if something was accomplished, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
|
|
|
@ -39,12 +39,12 @@ privileged int mprotect(void *addr, uint64_t len, int prot) {
|
|||
int64_t rc;
|
||||
uint32_t oldprot;
|
||||
if (!IsWindows()) {
|
||||
asm volatile(CFLAG_ASM("syscall")
|
||||
asm volatile(CFLAG_ASM("clc\n\tsyscall")
|
||||
: CFLAG_CONSTRAINT(cf), "=a"(rc)
|
||||
: "1"(__NR_mprotect), "D"(addr), "S"(len), "d"(prot)
|
||||
: "rcx", "r11", "memory", "cc");
|
||||
if (cf) {
|
||||
rc = -rc;
|
||||
errno = rc;
|
||||
rc = -1;
|
||||
} else if (rc > -4096ul) {
|
||||
errno = -rc;
|
||||
|
|
|
@ -47,14 +47,11 @@ static textwindows int64_t sys_open_nt_impl(int dirfd, const char *path,
|
|||
? kNtFileShareExclusive
|
||||
: kNtFileShareRead | kNtFileShareWrite | kNtFileShareDelete,
|
||||
&kNtIsInheritable,
|
||||
(flags & O_CREAT) && (flags & O_EXCL)
|
||||
? kNtCreateNew
|
||||
: (flags & O_CREAT) && (flags & O_TRUNC)
|
||||
? kNtCreateAlways
|
||||
: (flags & O_CREAT)
|
||||
? kNtOpenAlways
|
||||
: (flags & O_TRUNC) ? kNtTruncateExisting
|
||||
: kNtOpenExisting,
|
||||
(flags & O_CREAT) && (flags & O_EXCL) ? kNtCreateNew
|
||||
: (flags & O_CREAT) && (flags & O_TRUNC) ? kNtCreateAlways
|
||||
: (flags & O_CREAT) ? kNtOpenAlways
|
||||
: (flags & O_TRUNC) ? kNtTruncateExisting
|
||||
: kNtOpenExisting,
|
||||
/* TODO(jart): Should we just always set overlapped? */
|
||||
(/* note: content indexer demolishes unix-ey i/o performance */
|
||||
kNtFileAttributeNotContentIndexed | kNtFileAttributeNormal |
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -16,16 +16,10 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/calls/internal.h"
|
||||
|
||||
TEST(memcpy, testBackwardsOverlap3) {
|
||||
volatile char *c;
|
||||
c = malloc(3);
|
||||
memcpy(c, "\e[C", 3);
|
||||
memcpy(c, c + 1, VEIL("r", 3) - 1);
|
||||
EXPECT_EQ('[', c[0]);
|
||||
EXPECT_EQ('C', c[1]);
|
||||
free(c);
|
||||
void __rusage2linux(struct rusage *ru) {
|
||||
if (IsXnu()) {
|
||||
ru->ru_maxrss /= 1024;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#define SA_RESTORER 0x04000000
|
||||
|
||||
#ifndef SWITCHEROO
|
||||
#define SWITCHEROO(S1, S2, A, B, C, D) \
|
||||
do { \
|
||||
|
|
59
libc/calls/sigqueue.c
Normal file
59
libc/calls/sigqueue.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
|
||||
/* TODO(jart): XNU */
|
||||
|
||||
/**
|
||||
* Sends signal to process, with data.
|
||||
*
|
||||
* The impact of this action can be terminating the process, or
|
||||
* interrupting it to request something happen.
|
||||
*
|
||||
* @param pid can be:
|
||||
* >0 signals one process by id
|
||||
* =0 signals all processes in current process group
|
||||
* -1 signals all processes possible (except init)
|
||||
* <-1 signals all processes in -pid process group
|
||||
* @param sig can be:
|
||||
* >0 can be SIGINT, SIGTERM, SIGKILL, SIGUSR1, etc.
|
||||
* =0 checks both if pid exists and we can signal it
|
||||
* @return 0 if something was accomplished, or -1 w/ errno
|
||||
* @note this isn't supported on OpenBSD
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int sigqueue(int pid, int sig, const union sigval value) {
|
||||
siginfo_t info;
|
||||
if (IsFreebsd()) {
|
||||
return sys_sigqueue(pid, sig, value);
|
||||
} else {
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.si_signo = sig;
|
||||
info.si_code = SI_QUEUE;
|
||||
info.si_pid = getpid();
|
||||
info.si_uid = geteuid();
|
||||
info.si_value = value;
|
||||
return sys_sigqueueinfo(pid, &info);
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct rlimit {
|
||||
int64_t rlim_cur;
|
||||
int64_t rlim_max;
|
||||
uint64_t rlim_cur; /* current (soft) limit in bytes */
|
||||
uint64_t rlim_max; /* maximum limit in bytes */
|
||||
};
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -8,12 +8,12 @@ struct rusage {
|
|||
struct {
|
||||
struct timeval ru_utime; /* user CPU time used */
|
||||
struct timeval ru_stime; /* system CPU time used */
|
||||
int64_t ru_maxrss; /* maximum resident set size */
|
||||
int64_t ru_ixrss; /* integral shared memory size */
|
||||
int64_t ru_idrss; /* integral unshared data size */
|
||||
int64_t ru_isrss; /* integral unshared stack size */
|
||||
int64_t ru_minflt; /* page reclaims (soft page faults) */
|
||||
int64_t ru_majflt; /* page faults (hard page faults) */
|
||||
int64_t ru_maxrss; /* maximum resident set size in (kb) */
|
||||
int64_t ru_ixrss; /* shared memory size (integral kb CLK_TCK) */
|
||||
int64_t ru_idrss; /* unshared data size (integral kb CLK_TCK) */
|
||||
int64_t ru_isrss; /* unshared stack size (integral kb CLK_TCK) */
|
||||
int64_t ru_minflt; /* page reclaims */
|
||||
int64_t ru_majflt; /* page faults */
|
||||
int64_t ru_nswap; /* swaps */
|
||||
int64_t ru_inblock; /* block input operations */
|
||||
int64_t ru_oublock; /* block output operations */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
struct siginfo {
|
||||
int32_t si_signo;
|
||||
int32_t si_errno;
|
||||
int32_t si_code;
|
||||
int32_t si_code; /* {SICODE,SEGV,ILL,FPE,POLL}_xxx */
|
||||
union {
|
||||
struct {
|
||||
union {
|
||||
|
@ -20,7 +20,7 @@ struct siginfo {
|
|||
};
|
||||
};
|
||||
union {
|
||||
union sigval si_value;
|
||||
union sigval si_value; /* provided by third arg of sigqueue(2) */
|
||||
struct {
|
||||
int32_t si_status;
|
||||
int64_t si_utime, si_stime;
|
||||
|
|
31
libc/calls/wait4-sysv.c
Normal file
31
libc/calls/wait4-sysv.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
|
||||
int sys_wait4(int pid, int *opt_out_wstatus, int options,
|
||||
struct rusage *opt_out_rusage) {
|
||||
int rc;
|
||||
if ((rc = __sys_wait4(pid, opt_out_wstatus, options, opt_out_rusage)) != -1) {
|
||||
if (opt_out_rusage) {
|
||||
__rusage2linux(opt_out_rusage);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
#define time_t int64_t
|
||||
#define timer_t void*
|
||||
#define uid_t uint32_t
|
||||
#define rlim_t uint64_t /* int64_t on bsd */
|
||||
|
||||
#define int_fast8_t __INT_FAST8_TYPE__
|
||||
#define uint_fast8_t __UINT_FAST8_TYPE__
|
||||
|
|
|
@ -45,12 +45,6 @@
|
|||
#define IsTrustworthy() 0
|
||||
#endif
|
||||
|
||||
#ifdef SECURITY_BLANKETS
|
||||
#define UseSecurityBlankets() 1
|
||||
#else
|
||||
#define UseSecurityBlankets() 0
|
||||
#endif
|
||||
|
||||
#ifdef TINY
|
||||
#define IsTiny() 1
|
||||
#else
|
||||
|
|
|
@ -26,285 +26,153 @@
|
|||
#include "libc/nt/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
STATIC_YOINK("E2BIG");
|
||||
STATIC_YOINK("EACCES");
|
||||
STATIC_YOINK("EADDRINUSE");
|
||||
STATIC_YOINK("EADDRNOTAVAIL");
|
||||
STATIC_YOINK("EADV");
|
||||
STATIC_YOINK("EAFNOSUPPORT");
|
||||
STATIC_YOINK("EAGAIN");
|
||||
STATIC_YOINK("EALREADY");
|
||||
STATIC_YOINK("EBADE");
|
||||
STATIC_YOINK("EBADF");
|
||||
STATIC_YOINK("EBADFD");
|
||||
STATIC_YOINK("EBADMSG");
|
||||
STATIC_YOINK("EBADR");
|
||||
STATIC_YOINK("EBADRQC");
|
||||
STATIC_YOINK("EBADSLT");
|
||||
STATIC_YOINK("EBFONT");
|
||||
STATIC_YOINK("EBUSY");
|
||||
STATIC_YOINK("ECANCELED");
|
||||
STATIC_YOINK("ECHILD");
|
||||
STATIC_YOINK("ECHRNG");
|
||||
STATIC_YOINK("ECOMM");
|
||||
STATIC_YOINK("ECONNABORTED");
|
||||
STATIC_YOINK("ECONNREFUSED");
|
||||
STATIC_YOINK("ECONNRESET");
|
||||
STATIC_YOINK("EDEADLK");
|
||||
STATIC_YOINK("EDESTADDRREQ");
|
||||
STATIC_YOINK("EDOM");
|
||||
STATIC_YOINK("EDOTDOT");
|
||||
STATIC_YOINK("EDQUOT");
|
||||
STATIC_YOINK("EEXIST");
|
||||
STATIC_YOINK("EFAULT");
|
||||
STATIC_YOINK("EFBIG");
|
||||
STATIC_YOINK("EHOSTDOWN");
|
||||
STATIC_YOINK("EHOSTUNREACH");
|
||||
STATIC_YOINK("EHWPOISON");
|
||||
STATIC_YOINK("EIDRM");
|
||||
STATIC_YOINK("EILSEQ");
|
||||
STATIC_YOINK("EINPROGRESS");
|
||||
STATIC_YOINK("EINTR");
|
||||
STATIC_YOINK("EINVAL");
|
||||
STATIC_YOINK("EIO");
|
||||
STATIC_YOINK("EISCONN");
|
||||
STATIC_YOINK("EISDIR");
|
||||
STATIC_YOINK("EISNAM");
|
||||
STATIC_YOINK("EKEYEXPIRED");
|
||||
STATIC_YOINK("EKEYREJECTED");
|
||||
STATIC_YOINK("EKEYREVOKED");
|
||||
STATIC_YOINK("EL2HLT");
|
||||
STATIC_YOINK("EL2NSYNC");
|
||||
STATIC_YOINK("EL3HLT");
|
||||
STATIC_YOINK("EL3RST");
|
||||
STATIC_YOINK("ELIBACC");
|
||||
STATIC_YOINK("ELIBBAD");
|
||||
STATIC_YOINK("ELIBEXEC");
|
||||
STATIC_YOINK("ELIBMAX");
|
||||
STATIC_YOINK("ELIBSCN");
|
||||
STATIC_YOINK("ELNRNG");
|
||||
STATIC_YOINK("ELOOP");
|
||||
STATIC_YOINK("EMEDIUMTYPE");
|
||||
STATIC_YOINK("EMFILE");
|
||||
STATIC_YOINK("EMLINK");
|
||||
STATIC_YOINK("EMSGSIZE");
|
||||
STATIC_YOINK("EMULTIHOP");
|
||||
STATIC_YOINK("ENAMETOOLONG");
|
||||
STATIC_YOINK("ENAVAIL");
|
||||
STATIC_YOINK("ENETDOWN");
|
||||
STATIC_YOINK("ENETRESET");
|
||||
STATIC_YOINK("ENETUNREACH");
|
||||
STATIC_YOINK("ENFILE");
|
||||
STATIC_YOINK("ENOANO");
|
||||
STATIC_YOINK("ENOBUFS");
|
||||
STATIC_YOINK("ENOCSI");
|
||||
STATIC_YOINK("ENODATA");
|
||||
STATIC_YOINK("ENODEV");
|
||||
STATIC_YOINK("ENOENT");
|
||||
STATIC_YOINK("ENOEXEC");
|
||||
STATIC_YOINK("ENOKEY");
|
||||
STATIC_YOINK("ENOLCK");
|
||||
STATIC_YOINK("ENOLINK");
|
||||
STATIC_YOINK("ENOMEDIUM");
|
||||
STATIC_YOINK("ENOMEM");
|
||||
STATIC_YOINK("ENOMSG");
|
||||
STATIC_YOINK("ENONET");
|
||||
STATIC_YOINK("ENOPKG");
|
||||
STATIC_YOINK("ENOPROTOOPT");
|
||||
STATIC_YOINK("ENOSPC");
|
||||
STATIC_YOINK("ENOSR");
|
||||
STATIC_YOINK("ENOSTR");
|
||||
STATIC_YOINK("ENOSYS");
|
||||
STATIC_YOINK("ENOTBLK");
|
||||
STATIC_YOINK("ENOTCONN");
|
||||
STATIC_YOINK("ENOTDIR");
|
||||
STATIC_YOINK("ENOTEMPTY");
|
||||
STATIC_YOINK("ENOTNAM");
|
||||
STATIC_YOINK("ENOTRECOVERABLE");
|
||||
STATIC_YOINK("ENOTSOCK");
|
||||
STATIC_YOINK("ENOTSUP");
|
||||
STATIC_YOINK("ENOTTY");
|
||||
STATIC_YOINK("ENOTUNIQ");
|
||||
STATIC_YOINK("ENXIO");
|
||||
STATIC_YOINK("EOPNOTSUPP");
|
||||
STATIC_YOINK("EOVERFLOW");
|
||||
STATIC_YOINK("EOWNERDEAD");
|
||||
STATIC_YOINK("EPERM");
|
||||
STATIC_YOINK("EPFNOSUPPORT");
|
||||
STATIC_YOINK("EPIPE");
|
||||
STATIC_YOINK("EPROTO");
|
||||
STATIC_YOINK("EPROTONOSUPPORT");
|
||||
STATIC_YOINK("EPROTOTYPE");
|
||||
STATIC_YOINK("ERANGE");
|
||||
STATIC_YOINK("EREMCHG");
|
||||
STATIC_YOINK("EREMOTE");
|
||||
STATIC_YOINK("EREMOTEIO");
|
||||
STATIC_YOINK("ERESTART");
|
||||
STATIC_YOINK("ERFKILL");
|
||||
STATIC_YOINK("EROFS");
|
||||
STATIC_YOINK("ESHUTDOWN");
|
||||
STATIC_YOINK("ESOCKTNOSUPPORT");
|
||||
STATIC_YOINK("ESPIPE");
|
||||
STATIC_YOINK("ESRCH");
|
||||
STATIC_YOINK("ESRMNT");
|
||||
STATIC_YOINK("ESTALE");
|
||||
STATIC_YOINK("ESTRPIPE");
|
||||
STATIC_YOINK("ETIME");
|
||||
STATIC_YOINK("ETIMEDOUT");
|
||||
STATIC_YOINK("ETOOMANYREFS");
|
||||
STATIC_YOINK("ETXTBSY");
|
||||
STATIC_YOINK("EUCLEAN");
|
||||
STATIC_YOINK("EUNATCH");
|
||||
STATIC_YOINK("EUSERS");
|
||||
STATIC_YOINK("EXDEV");
|
||||
STATIC_YOINK("EXFULL");
|
||||
const struct Error {
|
||||
const long *x;
|
||||
const char *s;
|
||||
} kErrors[] = {
|
||||
{&ENOSYS, "ENOSYS"},
|
||||
{&EPERM, "EPERM"},
|
||||
{&ENOENT, "ENOENT"},
|
||||
{&ESRCH, "ESRCH"},
|
||||
{&EINTR, "EINTR"},
|
||||
{&EIO, "EIO"},
|
||||
{&ENXIO, "ENXIO"},
|
||||
{&E2BIG, "E2BIG"},
|
||||
{&ENOEXEC, "ENOEXEC"},
|
||||
{&EBADF, "EBADF"},
|
||||
{&ECHILD, "ECHILD"},
|
||||
{&EAGAIN, "EAGAIN"},
|
||||
{&ENOMEM, "ENOMEM"},
|
||||
{&EACCES, "EACCES"},
|
||||
{&EFAULT, "EFAULT"},
|
||||
{&ENOTBLK, "ENOTBLK"},
|
||||
{&EBUSY, "EBUSY"},
|
||||
{&EEXIST, "EEXIST"},
|
||||
{&EXDEV, "EXDEV"},
|
||||
{&ENODEV, "ENODEV"},
|
||||
{&ENOTDIR, "ENOTDIR"},
|
||||
{&EISDIR, "EISDIR"},
|
||||
{&EINVAL, "EINVAL"},
|
||||
{&ENFILE, "ENFILE"},
|
||||
{&EMFILE, "EMFILE"},
|
||||
{&ENOTTY, "ENOTTY"},
|
||||
{&ETXTBSY, "ETXTBSY"},
|
||||
{&EFBIG, "EFBIG"},
|
||||
{&ENOSPC, "ENOSPC"},
|
||||
{&EDQUOT, "EDQUOT"},
|
||||
{&ESPIPE, "ESPIPE"},
|
||||
{&EROFS, "EROFS"},
|
||||
{&EMLINK, "EMLINK"},
|
||||
{&EPIPE, "EPIPE"},
|
||||
{&EDOM, "EDOM"},
|
||||
{&ERANGE, "ERANGE"},
|
||||
{&EDEADLK, "EDEADLK"},
|
||||
{&ENAMETOOLONG, "ENAMETOOLONG"},
|
||||
{&ENOLCK, "ENOLCK"},
|
||||
{&ENOTEMPTY, "ENOTEMPTY"},
|
||||
{&ELOOP, "ELOOP"},
|
||||
{&ENOMSG, "ENOMSG"},
|
||||
{&EIDRM, "EIDRM"},
|
||||
{&ETIME, "ETIME"},
|
||||
{&EPROTO, "EPROTO"},
|
||||
{&EOVERFLOW, "EOVERFLOW"},
|
||||
{&EILSEQ, "EILSEQ"},
|
||||
{&EUSERS, "EUSERS"},
|
||||
{&ENOTSOCK, "ENOTSOCK"},
|
||||
{&EDESTADDRREQ, "EDESTADDRREQ"},
|
||||
{&EMSGSIZE, "EMSGSIZE"},
|
||||
{&EPROTOTYPE, "EPROTOTYPE"},
|
||||
{&ENOPROTOOPT, "ENOPROTOOPT"},
|
||||
{&EPROTONOSUPPORT, "EPROTONOSUPPORT"},
|
||||
{&ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT"},
|
||||
{&ENOTSUP, "ENOTSUP"},
|
||||
{&EOPNOTSUPP, "EOPNOTSUPP"},
|
||||
{&EPFNOSUPPORT, "EPFNOSUPPORT"},
|
||||
{&EAFNOSUPPORT, "EAFNOSUPPORT"},
|
||||
{&EADDRINUSE, "EADDRINUSE"},
|
||||
{&EADDRNOTAVAIL, "EADDRNOTAVAIL"},
|
||||
{&ENETDOWN, "ENETDOWN"},
|
||||
{&ENETUNREACH, "ENETUNREACH"},
|
||||
{&ENETRESET, "ENETRESET"},
|
||||
{&ECONNABORTED, "ECONNABORTED"},
|
||||
{&ECONNRESET, "ECONNRESET"},
|
||||
{&ENOBUFS, "ENOBUFS"},
|
||||
{&EISCONN, "EISCONN"},
|
||||
{&ENOTCONN, "ENOTCONN"},
|
||||
{&ESHUTDOWN, "ESHUTDOWN"},
|
||||
{&ETOOMANYREFS, "ETOOMANYREFS"},
|
||||
{&ETIMEDOUT, "ETIMEDOUT"},
|
||||
{&ECONNREFUSED, "ECONNREFUSED"},
|
||||
{&EHOSTDOWN, "EHOSTDOWN"},
|
||||
{&EHOSTUNREACH, "EHOSTUNREACH"},
|
||||
{&EALREADY, "EALREADY"},
|
||||
{&EINPROGRESS, "EINPROGRESS"},
|
||||
{&ESTALE, "ESTALE"},
|
||||
{&EREMOTE, "EREMOTE"},
|
||||
{&EBADMSG, "EBADMSG"},
|
||||
{&ECANCELED, "ECANCELED"},
|
||||
{&EOWNERDEAD, "EOWNERDEAD"},
|
||||
{&ENOTRECOVERABLE, "ENOTRECOVERABLE"},
|
||||
{&ENONET, "ENONET"},
|
||||
{&ERESTART, "ERESTART"},
|
||||
{&ECHRNG, "ECHRNG"},
|
||||
{&EL2NSYNC, "EL2NSYNC"},
|
||||
{&EL3HLT, "EL3HLT"},
|
||||
{&EL3RST, "EL3RST"},
|
||||
{&ELNRNG, "ELNRNG"},
|
||||
{&EUNATCH, "EUNATCH"},
|
||||
{&ENOCSI, "ENOCSI"},
|
||||
{&EL2HLT, "EL2HLT"},
|
||||
{&EBADE, "EBADE"},
|
||||
{&EBADR, "EBADR"},
|
||||
{&EXFULL, "EXFULL"},
|
||||
{&ENOANO, "ENOANO"},
|
||||
{&EBADRQC, "EBADRQC"},
|
||||
{&EBADSLT, "EBADSLT"},
|
||||
{&ENOSTR, "ENOSTR"},
|
||||
{&ENODATA, "ENODATA"},
|
||||
{&ENOSR, "ENOSR"},
|
||||
{&ENOPKG, "ENOPKG"},
|
||||
{&ENOLINK, "ENOLINK"},
|
||||
{&EADV, "EADV"},
|
||||
{&ESRMNT, "ESRMNT"},
|
||||
{&ECOMM, "ECOMM"},
|
||||
{&EMULTIHOP, "EMULTIHOP"},
|
||||
{&EDOTDOT, "EDOTDOT"},
|
||||
{&ENOTUNIQ, "ENOTUNIQ"},
|
||||
{&EBADFD, "EBADFD"},
|
||||
{&EREMCHG, "EREMCHG"},
|
||||
{&ELIBACC, "ELIBACC"},
|
||||
{&ELIBBAD, "ELIBBAD"},
|
||||
{&ELIBSCN, "ELIBSCN"},
|
||||
{&ELIBMAX, "ELIBMAX"},
|
||||
{&ELIBEXEC, "ELIBEXEC"},
|
||||
{&ESTRPIPE, "ESTRPIPE"},
|
||||
{&EUCLEAN, "EUCLEAN"},
|
||||
{&ENOTNAM, "ENOTNAM"},
|
||||
{&ENAVAIL, "ENAVAIL"},
|
||||
{&EISNAM, "EISNAM"},
|
||||
{&EREMOTEIO, "EREMOTEIO"},
|
||||
{&ENOMEDIUM, "ENOMEDIUM"},
|
||||
{&EMEDIUMTYPE, "EMEDIUMTYPE"},
|
||||
{&ENOKEY, "ENOKEY"},
|
||||
{&EKEYEXPIRED, "EKEYEXPIRED"},
|
||||
{&EKEYREVOKED, "EKEYREVOKED"},
|
||||
{&EKEYREJECTED, "EKEYREJECTED"},
|
||||
{&ERFKILL, "ERFKILL"},
|
||||
{&EHWPOISON, "EHWPOISON"},
|
||||
};
|
||||
|
||||
_Alignas(char) static const char kErrnoNames[] = "\
|
||||
2BIG\000\
|
||||
ACCES\000\
|
||||
ADDRINUSE\000\
|
||||
ADDRNOTAVAIL\000\
|
||||
ADV\000\
|
||||
AFNOSUPPORT\000\
|
||||
AGAIN\000\
|
||||
ALREADY\000\
|
||||
BADE\000\
|
||||
BADF\000\
|
||||
BADFD\000\
|
||||
BADMSG\000\
|
||||
BADR\000\
|
||||
BADRQC\000\
|
||||
BADSLT\000\
|
||||
BFONT\000\
|
||||
BUSY\000\
|
||||
CANCELED\000\
|
||||
CHILD\000\
|
||||
CHRNG\000\
|
||||
COMM\000\
|
||||
CONNABORTED\000\
|
||||
CONNREFUSED\000\
|
||||
CONNRESET\000\
|
||||
DEADLK\000\
|
||||
DESTADDRREQ\000\
|
||||
DOM\000\
|
||||
DOTDOT\000\
|
||||
DQUOT\000\
|
||||
EXIST\000\
|
||||
FAULT\000\
|
||||
FBIG\000\
|
||||
HOSTDOWN\000\
|
||||
HOSTUNREACH\000\
|
||||
HWPOISON\000\
|
||||
IDRM\000\
|
||||
ILSEQ\000\
|
||||
INPROGRESS\000\
|
||||
INTR\000\
|
||||
INVAL\000\
|
||||
IO\000\
|
||||
ISCONN\000\
|
||||
ISDIR\000\
|
||||
ISNAM\000\
|
||||
KEYEXPIRED\000\
|
||||
KEYREJECTED\000\
|
||||
KEYREVOKED\000\
|
||||
L2HLT\000\
|
||||
L2NSYNC\000\
|
||||
L3HLT\000\
|
||||
L3RST\000\
|
||||
LIBACC\000\
|
||||
LIBBAD\000\
|
||||
LIBEXEC\000\
|
||||
LIBMAX\000\
|
||||
LIBSCN\000\
|
||||
LNRNG\000\
|
||||
LOOP\000\
|
||||
MEDIUMTYPE\000\
|
||||
MFILE\000\
|
||||
MLINK\000\
|
||||
MSGSIZE\000\
|
||||
MULTIHOP\000\
|
||||
NAMETOOLONG\000\
|
||||
NAVAIL\000\
|
||||
NETDOWN\000\
|
||||
NETRESET\000\
|
||||
NETUNREACH\000\
|
||||
NFILE\000\
|
||||
NOANO\000\
|
||||
NOBUFS\000\
|
||||
NOCSI\000\
|
||||
NODATA\000\
|
||||
NODEV\000\
|
||||
NOENT\000\
|
||||
NOEXEC\000\
|
||||
NOKEY\000\
|
||||
NOLCK\000\
|
||||
NOLINK\000\
|
||||
NOMEDIUM\000\
|
||||
NOMEM\000\
|
||||
NOMSG\000\
|
||||
NONET\000\
|
||||
NOPKG\000\
|
||||
NOPROTOOPT\000\
|
||||
NOSPC\000\
|
||||
NOSR\000\
|
||||
NOSTR\000\
|
||||
NOSYS\000\
|
||||
NOTBLK\000\
|
||||
NOTCONN\000\
|
||||
NOTDIR\000\
|
||||
NOTEMPTY\000\
|
||||
NOTNAM\000\
|
||||
NOTRECOVERABLE\000\
|
||||
NOTSOCK\000\
|
||||
NOTSUP\000\
|
||||
NOTTY\000\
|
||||
NOTUNIQ\000\
|
||||
NXIO\000\
|
||||
OPNOTSUPP\000\
|
||||
OVERFLOW\000\
|
||||
OWNERDEAD\000\
|
||||
PERM\000\
|
||||
PFNOSUPPORT\000\
|
||||
PIPE\000\
|
||||
PROTO\000\
|
||||
PROTONOSUPPORT\000\
|
||||
PROTOTYPE\000\
|
||||
RANGE\000\
|
||||
REMCHG\000\
|
||||
REMOTE\000\
|
||||
REMOTEIO\000\
|
||||
RESTART\000\
|
||||
RFKILL\000\
|
||||
ROFS\000\
|
||||
SHUTDOWN\000\
|
||||
SOCKTNOSUPPORT\000\
|
||||
SPIPE\000\
|
||||
SRCH\000\
|
||||
SRMNT\000\
|
||||
STALE\000\
|
||||
STRPIPE\000\
|
||||
TIME\000\
|
||||
TIMEDOUT\000\
|
||||
TOOMANYREFS\000\
|
||||
TXTBSY\000\
|
||||
UCLEAN\000\
|
||||
UNATCH\000\
|
||||
USERS\000\
|
||||
XDEV\000\
|
||||
XFULL\000\
|
||||
\000";
|
||||
|
||||
static const char *geterrname(long code) {
|
||||
const long *e;
|
||||
size_t i, n;
|
||||
e = &E2BIG;
|
||||
n = &EXFULL + 1 - e;
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (code == e[i]) {
|
||||
return IndexDoubleNulString(kErrnoNames, i);
|
||||
static const char *geterrname(long x) {
|
||||
int i;
|
||||
if (!IsTiny() && x) {
|
||||
for (i = 0; i < ARRAYLEN(kErrors); ++i) {
|
||||
if (x == *kErrors[i].x) {
|
||||
return kErrors[i].s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return "EUNKNOWN";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,13 +183,9 @@ int strerror_r(int err, char *buf, size_t size) {
|
|||
const char *s;
|
||||
char16_t buf16[100];
|
||||
int winstate, sysvstate;
|
||||
if (!err || IsTiny()) {
|
||||
s = "?";
|
||||
} else {
|
||||
s = firstnonnull(geterrname(err), "?");
|
||||
}
|
||||
s = geterrname(err);
|
||||
if (!SupportsWindows()) {
|
||||
(snprintf)(buf, size, "E%s[%d]", s, err);
|
||||
(snprintf)(buf, size, "%s[%d]", s, err);
|
||||
} else {
|
||||
winstate = GetLastError();
|
||||
sysvstate = errno;
|
||||
|
@ -332,7 +196,7 @@ int strerror_r(int err, char *buf, size_t size) {
|
|||
} else {
|
||||
buf16[0] = u'\0';
|
||||
}
|
||||
(snprintf)(buf, size, "E%s/err=%d/errno:%d/GetLastError:%d%s%hs", s, err,
|
||||
(snprintf)(buf, size, "%s/err=%d/errno:%d/GetLastError:%d%s%hs", s, err,
|
||||
sysvstate, winstate, buf16[0] ? " " : "", buf16);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/**
|
||||
* Attachs GDB temporarilly, to do something like print a variable.
|
||||
*/
|
||||
int(gdbexec)(const char *cmd) {
|
||||
privileged int(gdbexec)(const char *cmd) {
|
||||
struct StackFrame *bp;
|
||||
int pid, ttyin, ttyout;
|
||||
intptr_t continuetoaddr;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
|
@ -27,5 +28,11 @@
|
|||
* @return new address or NULL w/ errno and ptr is NOT free()'d
|
||||
*/
|
||||
void *reallocarray(void *ptr, size_t nmemb, size_t itemsize) {
|
||||
return realloc(ptr, nmemb * itemsize);
|
||||
size_t n;
|
||||
if (!__builtin_mul_overflow(nmemb, itemsize, &n)) {
|
||||
return realloc(ptr, n);
|
||||
} else {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
75
libc/runtime/clktck.c
Normal file
75
libc/runtime/clktck.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/clktck.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
struct clockinfo_netbsd {
|
||||
int32_t hz; // number of clock ticks per second
|
||||
int32_t tick; // µs per tick
|
||||
int32_t tickadj; // skew rate for adjtime()
|
||||
int32_t stathz; // statistics clock frequency
|
||||
int32_t profhz; // profiling clock frequency
|
||||
};
|
||||
|
||||
static int clk_tck;
|
||||
|
||||
static noinline int __clk_tck_init(void) {
|
||||
int x;
|
||||
int cmd[2];
|
||||
size_t len;
|
||||
struct clockinfo_netbsd clock;
|
||||
if (IsXnu() || IsOpenbsd()) {
|
||||
x = 100;
|
||||
} else if (IsFreebsd()) {
|
||||
x = 128;
|
||||
} else if (IsNetbsd()) {
|
||||
cmd[0] = 1; // CTL_KERN
|
||||
cmd[1] = 12; // KERN_CLOCKRATE
|
||||
len = sizeof(clock);
|
||||
if (sysctl(cmd, 2, &clock, &len, NULL, 0) != -1) {
|
||||
x = clock.hz;
|
||||
} else {
|
||||
x = -1;
|
||||
}
|
||||
} else {
|
||||
x = getauxval(AT_CLKTCK);
|
||||
}
|
||||
if (x < 1) x = 100;
|
||||
clk_tck = x;
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns system clock ticks per second.
|
||||
*
|
||||
* The returned value is memoized. This function is intended to be
|
||||
* used via the `CLK_TCK` macro wrapper.
|
||||
*
|
||||
* The returned value is always greater than zero. It's usually 100
|
||||
* hertz which means each clock tick is 10 milliseconds long.
|
||||
*/
|
||||
int __clk_tck(void) {
|
||||
if (clk_tck) {
|
||||
return clk_tck;
|
||||
} else {
|
||||
return __clk_tck_init();
|
||||
}
|
||||
}
|
12
libc/runtime/clktck.h
Normal file
12
libc/runtime/clktck.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_CLKTCK_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_CLKTCK_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define CLK_TCK (__clk_tck())
|
||||
|
||||
int __clk_tck(void) pureconst;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_RUNTIME_CLKTCK_H_ */
|
|
@ -59,8 +59,9 @@
|
|||
*/
|
||||
void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
||||
struct DirectMap dm;
|
||||
int i, x, n, a, b, f;
|
||||
int i, x, n, m, a, b, f;
|
||||
if (!size) return VIP(einval());
|
||||
if (size > 0x0000010000000000) return VIP(enomem());
|
||||
if (!ALIGNED(off)) return VIP(einval());
|
||||
if (!ALIGNED(addr)) return VIP(einval());
|
||||
if (!CANONICAL(addr)) return VIP(einval());
|
||||
|
@ -77,6 +78,7 @@ void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
|||
n = ROUNDUP(size, FRAMESIZE) >> 16;
|
||||
for (i = 0; i < _mmi.i; ++i) {
|
||||
if (_mmi.p[i].y < x) continue;
|
||||
if (__builtin_add_overflow(_mmi.p[i].y, n, &m)) return VIP(enomem());
|
||||
if (_mmi.p[i].x > x + n - 1) break;
|
||||
x = _mmi.p[i].y + 1;
|
||||
}
|
||||
|
|
55
libc/runtime/mremap-sysv.c
Normal file
55
libc/runtime/mremap-sysv.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
privileged void *sys_mremap(void *p, size_t n, size_t m, int f, void *q) {
|
||||
bool cf;
|
||||
uintptr_t rax, rdi, rsi, rdx;
|
||||
register uintptr_t r8 asm("r8");
|
||||
register uintptr_t r10 asm("r10");
|
||||
if (IsLinux()) {
|
||||
r10 = f;
|
||||
r8 = (uintptr_t)q;
|
||||
asm("syscall"
|
||||
: "=a"(rax)
|
||||
: "0"(0x019), "D"(p), "S"(n), "d"(m), "r"(r10), "r"(r8)
|
||||
: "rcx", "r11", "memory", "cc");
|
||||
if (rax > -4096ul) errno = -rax, rax = -1;
|
||||
} else if (IsNetbsd()) {
|
||||
if (f & MREMAP_MAYMOVE) {
|
||||
rax = 0x19B;
|
||||
r10 = m;
|
||||
r8 = (f & MREMAP_FIXED) ? MAP_FIXED : 0;
|
||||
asm(CFLAG_ASM("syscall")
|
||||
: CFLAG_CONSTRAINT(cf), "+a"(rax)
|
||||
: "D"(p), "S"(n), "d"(q), "r"(r10), "r"(r8)
|
||||
: "rcx", "r11", "memory", "cc");
|
||||
if (cf) errno = rax, rax = -1;
|
||||
} else {
|
||||
rax = einval();
|
||||
}
|
||||
} else {
|
||||
rax = enosys();
|
||||
}
|
||||
return (void *)rax;
|
||||
}
|
|
@ -17,9 +17,46 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
void *mremap(void *old_address, size_t old_size, size_t new_size, int flags,
|
||||
void *new_address) {
|
||||
return (void *)(intptr_t)enosys();
|
||||
#define IP(X) (intptr_t)(X)
|
||||
#define VIP(X) (void *)IP(X)
|
||||
#define ALIGNED(p) (!(IP(p) & (FRAMESIZE - 1)))
|
||||
|
||||
/**
|
||||
* Relocates mapping.
|
||||
*
|
||||
* @param p is old address
|
||||
* @param n is old size
|
||||
* @param m is new size
|
||||
* @param f should have MREMAP_MAYMOVE and may have MAP_FIXED
|
||||
* @param q is new address
|
||||
*/
|
||||
void *mremap(void *p, size_t n, size_t m, int f, ... /* void *q */) {
|
||||
return VIP(enosys()); /* TODO: Implement Me! */
|
||||
void *q;
|
||||
va_list va;
|
||||
if (!IsWindows()) {
|
||||
if (!n) return VIP(einval());
|
||||
if (!m) return VIP(einval());
|
||||
if (!ALIGNED(p)) return VIP(einval());
|
||||
n = ROUNDUP(n, FRAMESIZE);
|
||||
m = ROUNDUP(m, FRAMESIZE);
|
||||
if (f & MREMAP_FIXED) {
|
||||
va_start(va, f);
|
||||
q = va_arg(va, void *);
|
||||
va_end(va);
|
||||
if (!ALIGNED(q)) return VIP(einval());
|
||||
} else {
|
||||
q = NULL;
|
||||
if (!(f & MREMAP_MAYMOVE)) {
|
||||
}
|
||||
}
|
||||
return VIP(enosys());
|
||||
} else {
|
||||
return VIP(enosys());
|
||||
}
|
||||
}
|
||||
|
|
188
libc/runtime/openexecutable.S
Normal file
188
libc/runtime/openexecutable.S
Normal file
|
@ -0,0 +1,188 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
.privileged
|
||||
|
||||
// Opens executable in O_RDWR mode.
|
||||
//
|
||||
// To avoid ETXTBSY we need to unmap the running executable first,
|
||||
// then open the file, and finally load the code back into memory.
|
||||
//
|
||||
// @return file descriptor
|
||||
// @note only works on .com binary (not .com.dbg)
|
||||
// @note only supports linux, freebsd, openbsd, and netbsd
|
||||
OpenExecutable:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
pushq __NR_open(%rip) # -0x08(%rbp)
|
||||
pushq __NR_mmap(%rip) # -0x10(%rbp)
|
||||
pushq __NR_munmap(%rip) # -0x18(%rbp)
|
||||
pushq O_RDWR(%rip) # -0x20(%rbp)
|
||||
pushq MAP_ANONYMOUS(%rip) # -0x28(%rbp)
|
||||
pushq MAP_PRIVATE(%rip) # -0x30(%rbp)
|
||||
pushq MAP_FIXED(%rip) # -0x38(%rbp)
|
||||
pushq MAP_SHARED(%rip) # -0x40(%rbp)
|
||||
push %rbx # code buffer
|
||||
push %r12 # data buffer
|
||||
push %r14 # filename
|
||||
push %r15 # fd
|
||||
|
||||
// Get filename.
|
||||
mov AT_EXECFN,%edi
|
||||
call getauxval
|
||||
mov %rax,%r14
|
||||
|
||||
// Allocate code buffer.
|
||||
mov -0x10(%rbp),%eax # __NR_mmap
|
||||
xor %edi,%edi
|
||||
mov $PAGESIZE,%esi
|
||||
mov $PROT_READ|PROT_WRITE|PROT_EXEC,%edx
|
||||
mov -0x28(%rbp),%r10d # MAP_ANONYMOUS
|
||||
or -0x30(%rbp),%r10d # MAP_PRIVATE
|
||||
mov $-1,%r8
|
||||
mov $0,%r9
|
||||
push %r9 # openbsd:pad
|
||||
push %r9 # openbsd:align
|
||||
syscall
|
||||
pop %r9
|
||||
pop %r9
|
||||
mov %rax,%rbx
|
||||
|
||||
// Allocate data buffer.
|
||||
mov -0x10(%rbp),%eax # __NR_mmap
|
||||
xor %edi,%edi
|
||||
mov $ape_ram_filesz,%esi
|
||||
mov $PROT_READ|PROT_WRITE,%edx
|
||||
mov -0x28(%rbp),%r10d # MAP_ANONYMOUS
|
||||
or -0x30(%rbp),%r10d # MAP_PRIVATE
|
||||
mov $-1,%r8
|
||||
mov $0,%r9
|
||||
push %r9 # openbsd:pad
|
||||
push %r9 # openbsd:align
|
||||
syscall
|
||||
pop %r9
|
||||
pop %r9
|
||||
mov %rax,%r12
|
||||
|
||||
// Move data.
|
||||
mov %r12,%rdi
|
||||
mov $ape_ram_vaddr,%esi
|
||||
mov $ape_ram_filesz,%ecx
|
||||
rep movsb
|
||||
|
||||
// Move code.
|
||||
mov %rbx,%rdi
|
||||
mov $8f,%esi
|
||||
mov $9f-8f,%ecx
|
||||
rep movsb
|
||||
jmp *%rbx
|
||||
|
||||
// <LIMBO>
|
||||
|
||||
// Unmap code segment.
|
||||
8: mov -0x18(%rbp),%eax # __NR_munmap
|
||||
mov $ape_rom_vaddr,%edi
|
||||
mov $ape_rom_filesz,%esi
|
||||
syscall
|
||||
|
||||
// Unmap data segment.
|
||||
mov -0x18(%rbp),%eax # __NR_munmap
|
||||
mov $ape_ram_vaddr,%edi
|
||||
mov $ape_ram_filesz,%esi
|
||||
syscall
|
||||
|
||||
// Open executable in read-write mode.
|
||||
mov -0x08(%rbp),%eax # __NR_open
|
||||
mov %r14,%rdi
|
||||
mov -0x20(%rbp),%esi # O_RDWR
|
||||
syscall
|
||||
mov %eax,%r15d
|
||||
|
||||
// Map code segment.
|
||||
mov -0x10(%rbp),%eax # __NR_mmap
|
||||
mov $ape_rom_vaddr,%edi
|
||||
mov $ape_rom_filesz,%esi
|
||||
mov $PROT_READ|PROT_EXEC,%edx
|
||||
mov -0x38(%rbp),%r10d # MAP_FIXED
|
||||
or -0x40(%rbp),%r10d # MAP_SHARED
|
||||
mov %r15d,%r8d
|
||||
mov $ape_rom_offset,%r9d
|
||||
push %r9 # openbsd:pad
|
||||
push %r9 # openbsd:align
|
||||
syscall
|
||||
pop %r9
|
||||
pop %r9
|
||||
|
||||
// Allocate data segment.
|
||||
mov -0x10(%rbp),%eax # __NR_mmap
|
||||
mov $ape_ram_vaddr,%edi
|
||||
mov $ape_ram_filesz,%esi
|
||||
mov $PROT_READ|PROT_WRITE,%edx
|
||||
mov -0x38(%rbp),%r10d # MAP_FIXED
|
||||
or -0x30(%rbp),%r10d # MAP_PRIVATE
|
||||
or -0x28(%rbp),%r10d # MAP_ANONYMOUS
|
||||
mov $-1,%r8
|
||||
mov $0,%r9
|
||||
push %r9 # openbsd:pad
|
||||
push %r9 # openbsd:align
|
||||
syscall
|
||||
pop %r9
|
||||
pop %r9
|
||||
|
||||
// Put data back.
|
||||
mov $ape_ram_vaddr,%edi
|
||||
xchg %eax,%esi
|
||||
mov $ape_ram_filesz,%ecx
|
||||
rep movsb
|
||||
|
||||
// Jump back.
|
||||
mov $9f,%eax
|
||||
jmp *%rax
|
||||
|
||||
// </LIMBO>
|
||||
|
||||
// Deallocate code buffer.
|
||||
9: mov __NR_munmap,%eax
|
||||
mov %rbx,%rdi
|
||||
mov $PAGESIZE,%esi
|
||||
syscall
|
||||
|
||||
// Deallocate data buffer.
|
||||
mov __NR_munmap,%eax
|
||||
mov %r12,%rdi
|
||||
mov $ape_ram_filesz,%esi
|
||||
syscall
|
||||
|
||||
mov %r15d,%eax
|
||||
pop %r15
|
||||
pop %r14
|
||||
pop %r12
|
||||
pop %rbx
|
||||
leave
|
||||
ret
|
||||
9: .endfn OpenExecutable,globl
|
||||
|
||||
.weak ape_rom_vaddr
|
||||
.weak ape_rom_filesz
|
||||
.weak ape_rom_offset
|
||||
.weak ape_ram_vaddr
|
||||
.weak ape_ram_filesz
|
|
@ -55,7 +55,7 @@ int clearenv(void);
|
|||
void fpreset(void);
|
||||
int issetugid(void);
|
||||
void *mmap(void *, uint64_t, int32_t, int32_t, int32_t, int64_t);
|
||||
void *mremap(void *, uint64_t, uint64_t, int32_t, void *);
|
||||
void *mremap(void *, size_t, size_t, int, ...);
|
||||
int munmap(void *, uint64_t);
|
||||
int mprotect(void *, uint64_t, int) privileged;
|
||||
int msync(void *, size_t, int);
|
||||
|
@ -87,6 +87,7 @@ void _savexmm(void *);
|
|||
void _weakfree(void *);
|
||||
void free_s(void *) paramsnonnull() libcesque;
|
||||
int close_s(int *) paramsnonnull() libcesque;
|
||||
int OpenExecutable(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -16,10 +16,32 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/clktck.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
|
||||
/**
|
||||
* Returns configuration value about system.
|
||||
* @param thing can be _SC_XXX
|
||||
*
|
||||
* The following parameters are supported:
|
||||
*
|
||||
* - `_SC_CLK_TCK` returns number of clock ticks per second
|
||||
* - `_SC_ARG_MAX` currently always returns 32768 due to Windows
|
||||
* - `_SC_PAGESIZE` currently always returns 65536 due to Windows
|
||||
*
|
||||
* You are encouraged to undiamond calls to this API as follows:
|
||||
*
|
||||
* - Use `CLK_TCK` instead of `getconf(_SC_CLK_TCK)`
|
||||
* - Use `PAGESIZE` or `FRAMESIZE` instead of `getconf(_SC_PAGESIZE)`
|
||||
*/
|
||||
long(sysconf)(int thing) { return __sysconf(thing); }
|
||||
long sysconf(int name) {
|
||||
switch (name) {
|
||||
case _SC_ARG_MAX:
|
||||
return ARG_MAX;
|
||||
case _SC_CLK_TCK:
|
||||
return CLK_TCK;
|
||||
case _SC_PAGESIZE:
|
||||
return FRAMESIZE;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
#define _SC_ARG_MAX 0
|
||||
#define _SC_CLK_TCK 2
|
||||
|
@ -13,26 +11,6 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
long sysconf(int);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define sysconf(X) __sysconf(X)
|
||||
forceinline long __sysconf(int thing) {
|
||||
switch (thing) {
|
||||
case _SC_ARG_MAX:
|
||||
return ARG_MAX;
|
||||
case _SC_CLK_TCK: {
|
||||
extern const long __AT_CLKTCK asm("AT_CLKTCK");
|
||||
long res = getauxval(__AT_CLKTCK);
|
||||
if (!res) res = 100;
|
||||
return res;
|
||||
}
|
||||
case _SC_PAGESIZE:
|
||||
return FRAMESIZE;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* GNU && !ANSI */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_ */
|
||||
|
|
|
@ -160,17 +160,15 @@ static noasan textwindows wontreturn void WinMainNew(void) {
|
|||
* able to assume that stack addresses are located at higher
|
||||
* addresses than heap and program memory.
|
||||
*
|
||||
* 5. Windows users are afraid of "drive-by downloads" where someone
|
||||
* might accidentally an evil DLL to their Downloads folder which
|
||||
* then overrides the behavior of a legitimate EXE being run from
|
||||
* the downloads folder. Since we don't even use dynamic linking,
|
||||
* we've cargo culted some API calls, that may harden against it.
|
||||
* 5. Reconfigure x87 FPU so long double is actually long (80 bits).
|
||||
*
|
||||
* 6. Reconfigure x87 FPU so long double is actually long (80 bits).
|
||||
*
|
||||
* 7. Finally, we need fork. Microsoft designed Windows to prevent us
|
||||
* from having fork() so we pass pipe handles in an environment
|
||||
* variable literally copy all the memory.
|
||||
* 6. Finally, we need fork. Since disagreeing with fork is axiomatic to
|
||||
* Microsoft's engineering culture, we need to go to great lengths to
|
||||
* have it anyway without breaking Microsoft's rules: using the WIN32
|
||||
* API (i.e. not NTDLL) to copy MAP_PRIVATE pages via a pipe. It'd go
|
||||
* faster if the COW pages CreateFileMappingNuma claims to have turns
|
||||
* out to be true. Until then we have a "PC Scale" and entirely legal
|
||||
* workaround that they hopefully won't block using Windows Defender.
|
||||
*
|
||||
* @param hInstance call GetModuleHandle(NULL) from main if you need it
|
||||
*/
|
||||
|
|
|
@ -42,7 +42,7 @@ int system(const char *cmdline) {
|
|||
struct sigaction ignore, saveint, savequit;
|
||||
if (!cmdline) {
|
||||
if (IsWindows()) return 1;
|
||||
if (access(_PATH_BSHELL, X_OK) == 0) return 1;
|
||||
if (!access(_PATH_BSHELL, X_OK)) return 1;
|
||||
return 0;
|
||||
}
|
||||
ignore.sa_flags = 0;
|
||||
|
@ -54,13 +54,13 @@ int system(const char *cmdline) {
|
|||
sigaddset(&chldmask, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &chldmask, &savemask);
|
||||
if (!(pid = fork())) {
|
||||
sigaction(SIGINT, &saveint, NULL);
|
||||
sigaction(SIGQUIT, &savequit, NULL);
|
||||
sigprocmask(SIG_SETMASK, &savemask, NULL);
|
||||
sigaction(SIGINT, &saveint, 0);
|
||||
sigaction(SIGQUIT, &savequit, 0);
|
||||
sigprocmask(SIG_SETMASK, &savemask, 0);
|
||||
systemexec(cmdline);
|
||||
_exit(127);
|
||||
} else if (pid != -1) {
|
||||
while (wait4(pid, &wstatus, 0, NULL) == -1) {
|
||||
while (wait4(pid, &wstatus, 0, 0) == -1) {
|
||||
if (errno != EINTR) {
|
||||
wstatus = -1;
|
||||
break;
|
||||
|
@ -69,8 +69,8 @@ int system(const char *cmdline) {
|
|||
} else {
|
||||
wstatus = -1;
|
||||
}
|
||||
sigaction(SIGINT, &saveint, NULL);
|
||||
sigaction(SIGQUIT, &savequit, NULL);
|
||||
sigprocmask(SIG_SETMASK, &savemask, NULL);
|
||||
sigaction(SIGINT, &saveint, 0);
|
||||
sigaction(SIGQUIT, &savequit, 0);
|
||||
sigprocmask(SIG_SETMASK, &savemask, 0);
|
||||
return wstatus;
|
||||
}
|
||||
|
|
|
@ -20,19 +20,28 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/paths.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Executes system command replacing current process.
|
||||
* @vforksafe
|
||||
*/
|
||||
int systemexec(const char *cmdline) {
|
||||
char comspec[128];
|
||||
const char *prog, *arg;
|
||||
strcpy(comspec, kNtSystemDirectory);
|
||||
strcat(comspec, "cmd.exe");
|
||||
prog = !IsWindows() ? _PATH_BSHELL : comspec;
|
||||
arg = !IsWindows() ? "-c" : "/C";
|
||||
return execv(prog, (char *const[]){prog, arg, cmdline, NULL});
|
||||
size_t n, m;
|
||||
char *a, *b, *argv[4], comspec[PATH_MAX + 1];
|
||||
if (!IsWindows()) {
|
||||
argv[0] = _PATH_BSHELL;
|
||||
argv[1] = "-c";
|
||||
} else {
|
||||
b = "cmd.exe";
|
||||
a = kNtSystemDirectory;
|
||||
if ((n = strlen(a)) + (m = strlen(b)) > PATH_MAX) return enametoolong();
|
||||
memcpy(mempcpy(comspec, a, n), b, m + 1);
|
||||
argv[0] = comspec;
|
||||
argv[1] = "/C";
|
||||
}
|
||||
argv[2] = cmdline;
|
||||
argv[3] = NULL;
|
||||
return execv(argv[0], argv);
|
||||
}
|
||||
|
|
53
libc/str/getzipcdir.c
Normal file
53
libc/str/getzipcdir.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Locates End Of Central Directory record in ZIP file.
|
||||
*
|
||||
* The ZIP spec says this header can be anywhere in the last 64kb.
|
||||
* We search it backwards for the ZIP-64 "PK♠♠" magic number. If that's
|
||||
* not found, then we search again for the original "PK♣♠" magnum. The
|
||||
* caller needs to check the first four bytes of the returned value to
|
||||
* determine whether to use ZIP_CDIR_xxx() or ZIP_CDIR64_xxx() macros.
|
||||
*
|
||||
* @param p points to file memory
|
||||
* @param n is byte size of file
|
||||
* @return pointer to EOCD64 or EOCD, or NULL if not found
|
||||
*/
|
||||
uint8_t *GetZipCdir(const uint8_t *p, size_t n) {
|
||||
size_t i, j;
|
||||
if (n >= kZipCdirHdrMinSize) {
|
||||
i = n - kZipCdirHdrMinSize;
|
||||
do {
|
||||
if (READ32LE(p + i) == kZipCdir64HdrMagic && IsZipCdir64(p, n, i)) {
|
||||
return (/*unconst*/ uint8_t *)(p + i);
|
||||
} else if (READ32LE(p + i) == kZipCdirHdrMagic && IsZipCdir32(p, n, i)) {
|
||||
j = i;
|
||||
do {
|
||||
if (READ32LE(p + j) == kZipCdir64HdrMagic && IsZipCdir64(p, n, j)) {
|
||||
return (/*unconst*/ uint8_t *)(p + j);
|
||||
}
|
||||
} while (j-- && i - j < 64 * 1024);
|
||||
return (/*unconst*/ uint8_t *)(p + i);
|
||||
}
|
||||
} while (i--);
|
||||
}
|
||||
return NULL;
|
||||
}
|
30
libc/str/getzipcdiroffset.c
Normal file
30
libc/str/getzipcdiroffset.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns offset of zip central directory.
|
||||
*/
|
||||
uint64_t GetZipCdirOffset(const uint8_t *eocd) {
|
||||
if (READ32LE(eocd) == kZipCdir64HdrMagic) {
|
||||
return ZIP_CDIR64_OFFSET(eocd);
|
||||
} else {
|
||||
return ZIP_CDIR_OFFSET(eocd);
|
||||
}
|
||||
}
|
30
libc/str/getzipcdirrecords.c
Normal file
30
libc/str/getzipcdirrecords.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns number of records in zip central directory.
|
||||
*/
|
||||
uint64_t GetZipCdirRecords(const uint8_t *eocd) {
|
||||
if (READ32LE(eocd) == kZipCdir64HdrMagic) {
|
||||
return ZIP_CDIR64_RECORDS(eocd);
|
||||
} else {
|
||||
return ZIP_CDIR_RECORDS(eocd);
|
||||
}
|
||||
}
|
37
libc/str/getzipcfilecompressedsize.c
Normal file
37
libc/str/getzipcfilecompressedsize.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns compressed size in bytes from zip central directory header.
|
||||
*/
|
||||
uint64_t GetZipCfileCompressedSize(const uint8_t *z) {
|
||||
uint64_t x;
|
||||
const uint8_t *p, *pe;
|
||||
if ((x = ZIP_CFILE_COMPRESSEDSIZE(z)) == 0xFFFFFFFF) {
|
||||
for (p = ZIP_CFILE_EXTRA(z), pe = p + ZIP_CFILE_EXTRASIZE(z); p < pe;
|
||||
p += ZIP_EXTRA_SIZE(p)) {
|
||||
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64 &&
|
||||
8 + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
|
||||
return READ64LE(ZIP_EXTRA_CONTENT(p) + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
47
libc/str/getzipcfilemode.c
Normal file
47
libc/str/getzipcfilemode.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
static int ConvertWindowsToUnixMode(int x) {
|
||||
int m;
|
||||
if (x & kNtFileAttributeReadonly) {
|
||||
m = 0444;
|
||||
} else {
|
||||
m = 0644;
|
||||
}
|
||||
if (x & kNtFileAttributeDirectory) {
|
||||
m |= S_IFDIR | 0111;
|
||||
} else {
|
||||
m |= S_IFREG;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns st_mode from ZIP central directory record.
|
||||
*/
|
||||
int GetZipCfileMode(const uint8_t *p) {
|
||||
if (ZIP_CFILE_FILEATTRCOMPAT(p) == kZipOsUnix) {
|
||||
return ZIP_CFILE_EXTERNALATTRIBUTES(p) >> 16;
|
||||
} else {
|
||||
return ConvertWindowsToUnixMode(ZIP_CFILE_EXTERNALATTRIBUTES(p));
|
||||
}
|
||||
}
|
37
libc/str/getzipcfileoffset.c
Normal file
37
libc/str/getzipcfileoffset.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns offset of local file header.
|
||||
*/
|
||||
uint64_t GetZipCfileOffset(const uint8_t *z) {
|
||||
uint64_t x;
|
||||
const uint8_t *p, *pe;
|
||||
if ((x = ZIP_CFILE_OFFSET(z)) == 0xFFFFFFFF) {
|
||||
for (p = ZIP_CFILE_EXTRA(z), pe = p + ZIP_CFILE_EXTRASIZE(z); p < pe;
|
||||
p += ZIP_EXTRA_SIZE(p)) {
|
||||
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64 &&
|
||||
16 + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
|
||||
return READ64LE(ZIP_EXTRA_CONTENT(p) + 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
37
libc/str/getzipcfileuncompressedsize.c
Normal file
37
libc/str/getzipcfileuncompressedsize.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns uncompressed size in bytes from zip central directory header.
|
||||
*/
|
||||
uint64_t GetZipCfileUncompressedSize(const uint8_t *z) {
|
||||
uint64_t x;
|
||||
const uint8_t *p, *pe;
|
||||
if ((x = ZIP_CFILE_UNCOMPRESSEDSIZE(z)) == 0xFFFFFFFF) {
|
||||
for (p = ZIP_CFILE_EXTRA(z), pe = p + ZIP_CFILE_EXTRASIZE(z); p < pe;
|
||||
p += ZIP_EXTRA_SIZE(p)) {
|
||||
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64 &&
|
||||
0 + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
|
||||
return READ64LE(ZIP_EXTRA_CONTENT(p) + 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
37
libc/str/getziplfilecompressedsize.c
Normal file
37
libc/str/getziplfilecompressedsize.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns compressed size in bytes from zip local file header.
|
||||
*/
|
||||
uint64_t GetZipLfileCompressedSize(const uint8_t *z) {
|
||||
uint64_t x;
|
||||
const uint8_t *p, *pe;
|
||||
if ((x = ZIP_LFILE_COMPRESSEDSIZE(z)) == 0xFFFFFFFF) {
|
||||
for (p = ZIP_LFILE_EXTRA(z), pe = p + ZIP_LFILE_EXTRASIZE(z); p < pe;
|
||||
p += ZIP_EXTRA_SIZE(p)) {
|
||||
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64 &&
|
||||
8 + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
|
||||
return READ64LE(ZIP_EXTRA_CONTENT(p) + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
38
libc/str/getziplfileuncompressedsize.c
Normal file
38
libc/str/getziplfileuncompressedsize.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns uncompressed size in bytes from zip local file header.
|
||||
*/
|
||||
uint64_t GetZipLfileUncompressedSize(const uint8_t *z) {
|
||||
uint64_t x;
|
||||
const uint8_t *p, *pe;
|
||||
x = ZIP_LFILE_UNCOMPRESSEDSIZE(z);
|
||||
if (x == 0xFFFFFFFF) {
|
||||
for (p = ZIP_LFILE_EXTRA(z), pe = p + ZIP_LFILE_EXTRASIZE(z); p < pe;
|
||||
p += ZIP_EXTRA_SIZE(p)) {
|
||||
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64 &&
|
||||
0 + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
|
||||
return READ64LE(ZIP_EXTRA_CONTENT(p) + 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
38
libc/str/iszipcdir32.c
Normal file
38
libc/str/iszipcdir32.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns true if zip end of central directory header seems legit.
|
||||
*/
|
||||
bool IsZipCdir32(const uint8_t *p, size_t n, size_t i) {
|
||||
if (i > n || n - i < kZipCdirHdrMinSize) return false;
|
||||
if (READ32LE(p + i) != kZipCdirHdrMagic) return false;
|
||||
if (i + ZIP_CDIR_HDRSIZE(p + i) > n) return false;
|
||||
if (ZIP_CDIR_DISK(p + i) != ZIP_CDIR_STARTINGDISK(p + i)) return false;
|
||||
if (ZIP_CDIR_RECORDSONDISK(p + i) != ZIP_CDIR_RECORDS(p + i)) return false;
|
||||
if (ZIP_CDIR_RECORDS(p + i) * kZipCfileHdrMinSize > ZIP_CDIR_SIZE(p + i)) {
|
||||
return false;
|
||||
}
|
||||
if (ZIP_CDIR_OFFSET(p + i) + ZIP_CDIR_SIZE(p + i) > i) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
41
libc/str/iszipcdir64.c
Normal file
41
libc/str/iszipcdir64.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
/**
|
||||
* Returns true if zip64 end of central directory header seems legit.
|
||||
*/
|
||||
bool IsZipCdir64(const uint8_t *p, size_t n, size_t i) {
|
||||
if (i > n || n - i < kZipCdir64HdrMinSize) return false;
|
||||
if (READ32LE(p + i) != kZipCdir64HdrMagic) return false;
|
||||
if (i + ZIP_CDIR64_HDRSIZE(p + i) > n) return false;
|
||||
if (ZIP_CDIR64_DISK(p + i) != ZIP_CDIR64_STARTINGDISK(p + i)) return false;
|
||||
if (ZIP_CDIR64_RECORDSONDISK(p + i) != ZIP_CDIR64_RECORDS(p + i)) {
|
||||
return false;
|
||||
}
|
||||
if (ZIP_CDIR64_RECORDS(p + i) * kZipCfileHdrMinSize >
|
||||
ZIP_CDIR64_SIZE(p + i)) {
|
||||
return false;
|
||||
}
|
||||
if (ZIP_CDIR64_OFFSET(p + i) + ZIP_CDIR64_SIZE(p + i) > i) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -16,12 +16,14 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static inline noasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
|
||||
return (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
|
||||
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
|
||||
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
|
||||
return (uint64_t)(255 & p[7]) << 070 | (uint64_t)(255 & p[6]) << 060 |
|
||||
(uint64_t)(255 & p[5]) << 050 | (uint64_t)(255 & p[4]) << 040 |
|
||||
(uint64_t)(255 & p[3]) << 030 | (uint64_t)(255 & p[2]) << 020 |
|
||||
(uint64_t)(255 & p[1]) << 010 | (uint64_t)(255 & p[0]) << 000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,6 +29,6 @@
|
|||
int strcasecmp16(const char16_t *l, const char16_t *r) {
|
||||
int x, y;
|
||||
size_t i = 0;
|
||||
while ((x = tolower(l[i])) == (y = tolower(r[i])) && r[i]) ++i;
|
||||
while ((x = towlower(l[i])) == (y = towlower(r[i])) && r[i]) ++i;
|
||||
return x - y;
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
noasan static const unsigned char *strchrnul_x64(const unsigned char *p,
|
||||
uint64_t c) {
|
||||
noasan static const char *strchrnul_x64(const char *p, uint64_t c) {
|
||||
unsigned a, b;
|
||||
uint64_t w, x, y;
|
||||
for (c *= 0x0101010101010101;; p += 8) {
|
||||
w = (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
|
||||
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
|
||||
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
|
||||
w = (uint64_t)(255 & p[7]) << 070 | (uint64_t)(255 & p[6]) << 060 |
|
||||
(uint64_t)(255 & p[5]) << 050 | (uint64_t)(255 & p[4]) << 040 |
|
||||
(uint64_t)(255 & p[3]) << 030 | (uint64_t)(255 & p[2]) << 020 |
|
||||
(uint64_t)(255 & p[1]) << 010 | (uint64_t)(255 & p[0]) << 000;
|
||||
if ((x = ~(w ^ c) & ((w ^ c) - 0x0101010101010101) & 0x8080808080808080) |
|
||||
(y = ~w & (w - 0x0101010101010101) & 0x8080808080808080)) {
|
||||
if (x) {
|
||||
|
@ -59,11 +59,11 @@ noasan static const unsigned char *strchrnul_x64(const unsigned char *p,
|
|||
*/
|
||||
char *strchrnul(const char *s, int c) {
|
||||
char *r;
|
||||
for (c &= 0xff; (uintptr_t)s & 7; ++s) {
|
||||
for (c &= 255; (uintptr_t)s & 7; ++s) {
|
||||
if ((*s & 0xff) == c) return s;
|
||||
if (!*s) return s;
|
||||
}
|
||||
r = (char *)strchrnul_x64((const unsigned char *)s, c);
|
||||
assert((*r & 0xff) == c || !*r);
|
||||
r = strchrnul_x64(s, c);
|
||||
assert((*r & 255) == c || !*r);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static inline noasan uint64_t UncheckedAlignedRead64(unsigned char *p) {
|
||||
return (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
|
||||
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
|
||||
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
|
||||
static inline noasan uint64_t UncheckedAlignedRead64(const char *p) {
|
||||
return (uint64_t)(255 & p[7]) << 070 | (uint64_t)(255 & p[6]) << 060 |
|
||||
(uint64_t)(255 & p[5]) << 050 | (uint64_t)(255 & p[4]) << 040 |
|
||||
(uint64_t)(255 & p[3]) << 030 | (uint64_t)(255 & p[2]) << 020 |
|
||||
(uint64_t)(255 & p[1]) << 010 | (uint64_t)(255 & p[0]) << 000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,20 +17,15 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static noasan size_t strlen_pure_x64(const char *s, size_t i) {
|
||||
uint64_t w;
|
||||
const unsigned char *p;
|
||||
for (;;) {
|
||||
p = (const unsigned char *)s + i;
|
||||
w = (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
|
||||
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
|
||||
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
|
||||
for (;; i += 8) {
|
||||
w = READ64LE(s + i);
|
||||
if ((w = ~w & (w - 0x0101010101010101) & 0x8080808080808080)) {
|
||||
return i + ((unsigned)__builtin_ctzll(w) >> 3);
|
||||
} else {
|
||||
i += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,13 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static noasan size_t strnlen_x64(const char *s, size_t n, size_t i) {
|
||||
uint64_t w;
|
||||
const unsigned char *p;
|
||||
for (; i + 8 < n; i += 8) {
|
||||
p = (const unsigned char *)s + i;
|
||||
w = (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 |
|
||||
(uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 |
|
||||
(uint64_t)p[1] << 010 | (uint64_t)p[0] << 000;
|
||||
w = READ64LE(s + i);
|
||||
if ((w = ~w & (w - 0x0101010101010101) & 0x8080808080808080)) {
|
||||
i += (unsigned)__builtin_ctzll(w) >> 3;
|
||||
break;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "libc/str/utf16.h"
|
||||
|
||||
/* 34x speedup for ascii */
|
||||
static noasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize,
|
||||
const char *src, axdx_t r) {
|
||||
static inline noasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize,
|
||||
const char *src, axdx_t r) {
|
||||
uint8_t v1[16], v2[16], vz[16];
|
||||
memset(vz, 0, 16);
|
||||
while (r.ax + 16 < dstsize) {
|
||||
|
@ -54,26 +54,25 @@ static noasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize,
|
|||
*/
|
||||
axdx_t tprecode8to16(char16_t *dst, size_t dstsize, const char *src) {
|
||||
axdx_t r;
|
||||
unsigned n;
|
||||
uint64_t w;
|
||||
wint_t x, y;
|
||||
unsigned w;
|
||||
int x, y, a, b, i, n;
|
||||
r.ax = 0;
|
||||
r.dx = 0;
|
||||
for (;;) {
|
||||
/* TODO(jart): Why is it now so much slower refactored? */
|
||||
/* if (!IsTiny() && !((uintptr_t)(src + r.dx) & 15)) { */
|
||||
/* tprecode8to16_sse2(dst, dstsize, src, r); */
|
||||
/* } */
|
||||
x = src[r.dx++] & 0xff;
|
||||
if (ThomPikeCont(x)) continue;
|
||||
if (!isascii(x)) {
|
||||
n = ThomPikeLen(x);
|
||||
x = ThomPikeByte(x);
|
||||
while (--n) {
|
||||
if ((y = src[r.dx++] & 0xff)) {
|
||||
x = ThomPikeMerge(x, y);
|
||||
} else {
|
||||
x = 0;
|
||||
if (!IsTiny() && !((uintptr_t)(src + r.dx) & 15)) {
|
||||
r = tprecode8to16_sse2(dst, dstsize, src, r);
|
||||
}
|
||||
x = src[r.dx++] & 0377;
|
||||
if (x >= 0300) {
|
||||
a = ThomPikeByte(x);
|
||||
n = ThomPikeLen(x) - 1;
|
||||
for (i = 0;;) {
|
||||
if (!(b = src[r.dx + i] & 0377)) break;
|
||||
if (!ThomPikeCont(b)) break;
|
||||
a = ThomPikeMerge(a, b);
|
||||
if (++i == n) {
|
||||
r.dx += i;
|
||||
x = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ axdx_t tprecode8to16(char16_t *dst, size_t dstsize, const char *src) {
|
|||
if (!x) break;
|
||||
w = EncodeUtf16(x);
|
||||
while (w && r.ax + 1 < dstsize) {
|
||||
dst[r.ax++] = w & 0xFFFF;
|
||||
dst[r.ax++] = w;
|
||||
w >>= 16;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ static struct DeflateHold undeflatesymbol(struct DeflateHold hold,
|
|||
uint32_t search, key;
|
||||
left = 0;
|
||||
right = treecount;
|
||||
search = bitreverse16(hold.word);
|
||||
search = BITREVERSE16(hold.word);
|
||||
search <<= 16;
|
||||
search |= 0xffff;
|
||||
while (left < right) { /* TODO(jart): Make this O(1) like Zlib. */
|
||||
|
|
|
@ -11,15 +11,15 @@ COSMOPOLITAN_C_START_
|
|||
#define IsUcs2(wc) (((wc)&UTF16_MASK) != UTF16_MOAR)
|
||||
#define IsUtf16Cont(wc) (((wc)&UTF16_MASK) == UTF16_CONT)
|
||||
#define MergeUtf16(lo, hi) ((((lo)-0xD800) << 10) + ((hi)-0xDC00) + 0x10000)
|
||||
#define EncodeUtf16(wc) \
|
||||
(__builtin_expect(((0x0000 <= (wc) && (wc) <= 0xFFFF) || \
|
||||
(0xE000 <= (wc) && (wc) <= 0xFFFF)), \
|
||||
1) \
|
||||
? (wc) \
|
||||
: 0x10000 <= (wc) && (wc) <= 0x10FFFF \
|
||||
? (((((wc)-0x10000) >> 10) + 0xD800) | \
|
||||
((((wc)-0x10000) & 1023) + 0xDC00) << 16) \
|
||||
: 0xFFFD)
|
||||
#define EncodeUtf16(wc) \
|
||||
(__builtin_expect(((0x0000 <= (wc) && (wc) <= 0xFFFF) || \
|
||||
(0xE000 <= (wc) && (wc) <= 0xFFFF)), \
|
||||
1) \
|
||||
? (wc) \
|
||||
: 0x10000 <= (wc) && (wc) <= 0x10FFFF \
|
||||
? (((((wc)-0x10000) >> 10) + 0xD800) | \
|
||||
(unsigned)((((wc)-0x10000) & 1023) + 0xDC00) << 16) \
|
||||
: 0xFFFD)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
|
||||
/* TODO(jart): DELETE */
|
||||
|
||||
/**
|
||||
* Locates End Of Central Directory record in ZIP file.
|
||||
*
|
||||
|
@ -36,13 +38,7 @@ uint8_t *zipfindcentraldir(const uint8_t *p, size_t n) {
|
|||
if (n >= kZipCdirHdrMinSize) {
|
||||
i = n - kZipCdirHdrMinSize;
|
||||
do {
|
||||
if (ZIP_CDIR_MAGIC(p + i) == kZipCdirHdrMagic &&
|
||||
i + ZIP_CDIR_HDRSIZE(p + i) <= n &&
|
||||
ZIP_CDIR_DISK(p + i) == ZIP_CDIR_STARTINGDISK(p + i) &&
|
||||
ZIP_CDIR_RECORDSONDISK(p + i) == ZIP_CDIR_RECORDS(p + i) &&
|
||||
ZIP_CDIR_RECORDS(p + i) * kZipCdirHdrMinSize <=
|
||||
ZIP_CDIR_SIZE(p + i) &&
|
||||
ZIP_CDIR_OFFSET(p + i) + ZIP_CDIR_SIZE(p + i) <= i) {
|
||||
if (ZIP_CDIR_MAGIC(p + i) == kZipCdirHdrMagic && IsZipCdir32(p, n, i)) {
|
||||
return (/*unconst*/ uint8_t *)(p + i);
|
||||
}
|
||||
} while (i--);
|
||||
|
|
2
libc/sysv/calls/__sys_getrusage.s
Normal file
2
libc/sysv/calls/__sys_getrusage.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall __sys_getrusage,0x1bd0130752075062,globl,hidden
|
2
libc/sysv/calls/__sys_mremap.s
Normal file
2
libc/sysv/calls/__sys_mremap.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall __sys_mremap,0x19bffffffffff019,globl,hidden
|
2
libc/sysv/calls/__sys_wait4.s
Normal file
2
libc/sysv/calls/__sys_wait4.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall __sys_wait4,0x1c100b007200703d,globl,hidden
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall rt_sigqueueinfo,0xfffffffffffff081,globl
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sigqueue,0xffffff1c8fffffff,globl
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_getrusage,0x1bd0130752075062,globl,hidden
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_mremap,0x19bffffffffff019,globl,hidden
|
2
libc/sysv/calls/sys_sigqueue.s
Normal file
2
libc/sysv/calls/sys_sigqueue.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_sigqueue,0xffffff1c8fffffff,globl
|
2
libc/sysv/calls/sys_sigqueueinfo.s
Normal file
2
libc/sysv/calls/sys_sigqueueinfo.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_sigqueueinfo,0x0f5ffffffffff081,globl
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_wait4,0x1c100b007200703d,globl,hidden
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
lineno = 0
|
||||
|
||||
def atoi(s):
|
||||
try:
|
||||
if s == '0':
|
||||
return 0
|
||||
elif s.startswith('0x'):
|
||||
return int(s[2:], 16)
|
||||
elif s.startswith('0b'):
|
||||
return int(s[2:], 2)
|
||||
elif s.startswith('0'):
|
||||
return int(s[1:], 8)
|
||||
return int(s)
|
||||
except ValueError:
|
||||
sys.stderr.write('error: %s on line %d\n' % (s, lineno))
|
||||
sys.exit(1)
|
||||
|
||||
for line in open('consts.sh'):
|
||||
f = line.split()
|
||||
lineno = lineno + 1
|
||||
if len(f) >= 8 and f[0] == 'syscon':
|
||||
linux = atoi(f[3])
|
||||
xnu = atoi(f[4])
|
||||
freebsd = atoi(f[5])
|
||||
openbsd = atoi(f[6])
|
||||
windows = atoi(f[7])
|
||||
if linux == xnu and xnu == freebsd and freebsd == openbsd and openbsd == windows:
|
||||
sys.stdout.write('%s\t%s\n' % (f[1], f[2]))
|
|
@ -23,180 +23,176 @@ dir=libc/sysv/consts
|
|||
# » catalogue of carnage
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD Windows Commentary
|
||||
syscon errno ENOSYS 38 78 78 78 78 1 # bsd consensus & kNtErrorInvalidFunction
|
||||
syscon errno EPERM 1 1 1 1 1 12 # unix consensus & kNtErrorInvalidAccess (should be kNtErrorNotOwner but is that mutex only??)
|
||||
syscon errno ENOENT 2 2 2 2 2 2 # unix consensus & kNtErrorFileNotFound
|
||||
syscon errno ESRCH 3 3 3 3 3 566 # "no such process" & kNtErrorThreadNotInProcess (cf. kNtErrorInvalidHandle)
|
||||
syscon errno EINTR 4 4 4 4 4 10004 # unix consensus & WSAEINTR
|
||||
syscon errno EIO 5 5 5 5 5 1117 # unix consensus & kNtErrorIoDevice
|
||||
syscon errno ENXIO 6 6 6 6 6 1112 # unix consensus & kNtErrorNoMediaInDrive
|
||||
syscon errno E2BIG 7 7 7 7 7 1639 # unix consensus & kNtErrorInvalidCommandLine
|
||||
syscon errno ENOEXEC 8 8 8 8 8 193 # unix consensus & kNtErrorBadExeFormat
|
||||
syscon errno EBADF 9 9 9 9 9 6 # bad file descriptor; cf. EBADFD; unix consensus & kNtErrorInvalidHandle
|
||||
syscon errno ECHILD 10 10 10 10 10 128 # unix consensus & kNtErrorWaitNoChildren
|
||||
syscon errno EAGAIN 11 35 35 35 35 0x2733 # bsd consensus & WSAEWOULDBLOCK
|
||||
syscon errno EWOULDBLOCK 11 35 35 35 35 0x2733 # bsd consensus & WSAEWOULDBLOCK
|
||||
syscon errno ENOMEM 12 12 12 12 12 14 # unix consensus & kNtErrorOutofmemory
|
||||
syscon errno EACCES 13 13 13 13 13 5 # unix consensus & kNtErrorAccessDenied
|
||||
syscon errno EFAULT 14 14 14 14 14 487 # unix consensus & kNtErrorInvalidAddress
|
||||
syscon errno ENOTBLK 15 15 15 15 15 26 # unix consensus & kNtErrorNotDosDisk
|
||||
syscon errno EBUSY 16 16 16 16 16 170 # unix consensus & kNtErrorBusy
|
||||
syscon errno EEXIST 17 17 17 17 17 183 # unix consensus & kNtErrorAlreadyExists (should be kNtErrorFileExists too)
|
||||
syscon errno EXDEV 18 18 18 18 18 17 # unix consensus & kNtErrorNotSameDevice
|
||||
syscon errno ENODEV 19 19 19 19 19 1200 # unix consensus & kNtErrorBadDevice
|
||||
syscon errno ENOTDIR 20 20 20 20 20 3 # unix consensus & kNtErrorPathNotFound
|
||||
syscon errno EISDIR 21 21 21 21 21 267 # unix consensus & kNtErrorDirectoryNotSupported
|
||||
syscon errno EINVAL 22 22 22 22 22 87 # unix consensus & kNtErrorInvalidParameter
|
||||
syscon errno ENFILE 23 23 23 23 23 331 # unix consensus & kNtErrorTooManyDescriptors
|
||||
syscon errno EMFILE 24 24 24 24 24 336 # unix consensus & kNtErrorTooManyOpenFiles
|
||||
syscon errno ENOTTY 25 25 25 25 25 1118 # unix consensus & kNtErrorSerialNoDevice
|
||||
syscon errno ETXTBSY 26 26 26 26 26 148 # unix consensus & kNtErrorPathBusy
|
||||
syscon errno EFBIG 27 27 27 27 27 223 # unix consensus & kNtErrorFileTooLarge
|
||||
syscon errno ENOSPC 28 28 28 28 28 39 # unix consensus & kNtErrorDiskFull
|
||||
syscon errno EDQUOT 122 69 69 69 69 0x2755 # bsd consensus
|
||||
syscon errno ESPIPE 29 29 29 29 29 25 # unix consensus & kNtErrorSeek
|
||||
syscon errno EROFS 30 30 30 30 30 6009 # unix consensus & kNtErrorFileReadOnly
|
||||
syscon errno EMLINK 31 31 31 31 31 4 # unix consensus & kNtErrorTooManyLinks
|
||||
syscon errno EPIPE 32 32 32 32 32 109 # unix consensus & kNtErrorBrokenPipe
|
||||
syscon errno EDOM 33 33 33 33 33 33 # bsd consensus & fudged on NT
|
||||
syscon errno ERANGE 34 34 34 34 34 34 # bsd consensus & fudged on NT
|
||||
syscon errno EDEADLK 35 11 11 11 11 1131 # bsd consensus & kNtErrorPossibleDeadlock
|
||||
syscon errno ENAMETOOLONG 36 63 63 63 63 0x274f # bsd consensus & WSAENAMETOOLONG
|
||||
syscon errno ENOLCK 37 77 77 77 77 0 # bsd consensus
|
||||
syscon errno ENOTEMPTY 39 66 66 66 66 145 # bsd consensus & kNtErrorDirNotEmpty (TODO: What is WSAENOTEMPTY? 0x2752)
|
||||
syscon errno ELOOP 40 62 62 62 62 0x274e # bsd consensus & WSAELOOP
|
||||
syscon errno ENOMSG 42 91 83 90 83 0
|
||||
syscon errno EIDRM 43 90 82 89 82 0
|
||||
syscon errno EUSERS 87 68 68 68 68 0x2754 # bsd consensus & WSAEUSERS
|
||||
syscon errno ENOTSOCK 88 38 38 38 38 0x2736 # bsd consensus & WSAENOTSOCK
|
||||
syscon errno EDESTADDRREQ 89 39 39 39 39 0x2737 # bsd consensus & WSAEDESTADDRREQ
|
||||
syscon errno EMSGSIZE 90 40 40 40 40 0x2738 # bsd consensus & WSAEMSGSIZE
|
||||
syscon errno EPROTOTYPE 91 41 41 41 41 0x2739 # bsd consensus & WSAEPROTOTYPE
|
||||
syscon errno ENOPROTOOPT 92 42 42 42 42 0x273a # bsd consensus & WSAENOPROTOOPT
|
||||
syscon errno EPROTONOSUPPORT 93 43 43 43 43 0x273b # bsd consensus & WSAEPROTONOSUPPORT
|
||||
syscon errno ESOCKTNOSUPPORT 94 44 44 44 44 0x273c # bsd consensus & WSAESOCKTNOSUPPORT
|
||||
syscon errno ENOTSUP 95 45 45 91 86 0x273d
|
||||
syscon errno EOPNOTSUPP 95 102 45 45 45 0x273d
|
||||
syscon errno EPFNOSUPPORT 96 46 46 46 46 0x273e # bsd consensus & WSAEPFNOSUPPORT
|
||||
syscon errno EAFNOSUPPORT 97 47 47 47 47 0x273f # bsd consensus & WSAEAFNOSUPPORT
|
||||
syscon errno EADDRINUSE 98 48 48 48 48 0x2740 # bsd consensus & WSAEADDRINUSE
|
||||
syscon errno EADDRNOTAVAIL 99 49 49 49 49 0x2741 # bsd consensus & WSAEADDRNOTAVAIL
|
||||
syscon errno ENETDOWN 100 50 50 50 50 0x2742 # bsd consensus & WSAENETDOWN
|
||||
syscon errno ENETUNREACH 101 51 51 51 51 0x2743 # bsd consensus & WSAENETUNREACH
|
||||
syscon errno ENETRESET 102 52 52 52 52 0x2744 # bsd consensus & WSAENETRESET
|
||||
syscon errno ECONNABORTED 103 53 53 53 53 0x2745 # bsd consensus & WSAECONNABORTED
|
||||
syscon errno ECONNRESET 104 54 54 54 54 0x2746 # bsd consensus & WSAECONNRESET
|
||||
syscon errno ENOBUFS 105 55 55 55 55 0x2747 # bsd consensus & WSAENOBUFS
|
||||
syscon errno EISCONN 106 56 56 56 56 0x2748 # bsd consensus & WSAEISCONN
|
||||
syscon errno ENOTCONN 107 57 57 57 57 0x2749 # bsd consensus & WSAENOTCONN
|
||||
syscon errno ESHUTDOWN 108 58 58 58 58 0x274a # bsd consensus & WSAESHUTDOWN
|
||||
syscon errno ETOOMANYREFS 109 59 59 59 59 0x274b # bsd consensus & WSAETOOMANYREFS
|
||||
syscon errno ETIMEDOUT 110 60 60 60 60 0x274c # bsd consensus & WSAETIMEDOUT
|
||||
syscon errno ECONNREFUSED 111 61 61 61 61 0x274d # bsd consensus & WSAECONNREFUSED
|
||||
syscon errno EHOSTDOWN 112 64 64 64 64 0x2750 # bsd consensus & WSAEHOSTDOWN
|
||||
syscon errno EHOSTUNREACH 113 65 65 65 65 0x2751 # bsd consensus & WSAEHOSTUNREACH
|
||||
syscon errno EALREADY 114 37 37 37 37 0x2735 # bsd consensus & WSAEALREADY
|
||||
syscon errno EINPROGRESS 115 36 36 36 36 0x2734 # bsd consensus & WSAEINPROGRESS
|
||||
syscon errno ESTALE 116 70 70 70 70 0x2756 # bsd consensus & WSAESTALE
|
||||
syscon errno ECHRNG 44 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EL2NSYNC 45 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EL3HLT 46 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EL3RST 47 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELNRNG 48 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EUNATCH 49 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOCSI 50 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EL2HLT 51 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADE 52 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADR 53 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EXFULL 54 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOANO 55 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADRQC 56 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADSLT 57 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBFONT 59 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOSTR 60 99 0 0 91 0
|
||||
syscon errno ENODATA 61 96 0 0 89 0
|
||||
syscon errno ETIME 62 101 0 0 92 0
|
||||
syscon errno ENOSR 63 98 0 0 90 0
|
||||
syscon errno ENONET 64 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOPKG 65 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOSYS 38 78 78 78 78 1 # system call unavailable; bsd consensus; kNtErrorInvalidFunction
|
||||
syscon errno EPERM 1 1 1 1 1 12 # operation not permitted; unix consensus; kNtErrorInvalidAccess (should be kNtErrorNotOwner but is that mutex only??); raised by accept(2), acct(2), add_key(2), adjtimex(2), arch_prctl(2), bdflush(2), bpf(2), capget(2), chmod(2), chown(2), chroot(2), clock_getres(2), clone(2), copy_file_range(2), create_module(2), delete_module(2), epoll_ctl(2), execve(2), fallocate(2), fanotify_init(2), fcntl(2), futex(2), get_robust_list(2), getdomainname(2), getgroups(2), gethostname(2), getpriority(2), getrlimit(2), getsid(2), gettimeofday(2), idle(2), init_module(2), io_submit(2), ioctl_console(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), ioctl_ns(2), ioctl_tty(2), ioperm(2), iopl(2), ioprio_set(2), kcmp(2), kexec_load(2), keyctl(2), kill(2), link(2), lookup_dcookie(2), madvise(2), mbind(2), membarrier(2), migrate_pages(2), mkdir(2), mknod(2), mlock(2), mmap(2), mount(2), move_pages(2), msgctl(2), nice(2), open(2), open_by_handle_at(2), pciconfig_read(2), perf_event_open(2), pidfd_getfd(2), pidfd_send_signal(2), pivot_root(2), prctl(2), process_vm_readv(2), ptrace(2), quotactl(2), reboot(2), rename(2), request_key(2), rmdir(2), rt_sigqueueinfo(2), sched_setaffinity(2), sched_setattr(2), sched_setparam(2), sched_setscheduler(2), semctl(2), seteuid(2), setfsgid(2), setfsuid(2), setgid(2), setns(2), setpgid(2), setresuid(2), setreuid(2), setsid(2), setuid(2), setup(2), setxattr(2), shmctl(2), shmget(2), sigaltstack(2), spu_create(2), stime(2), swapon(2), symlink(2), syslog(2), timer_create(2), timerfd_create(2), tkill(2), truncate(2), umount(2), unlink(2), unshare(2), utime(2), utimensat(2), vhangup(2), vm86(2), write(2), unix(7), ip(7)
|
||||
syscon errno ENOENT 2 2 2 2 2 2 # no such file or directory; unix consensus; kNtErrorFileNotFound; raised by access(2), acct(2), alloc_hugepages(2), bind(2), bpf(2), chdir(2), chmod(2), chown(2), chroot(2), clock_getres(2), delete_module(2), epoll_ctl(2), execve(2), execveat(2), fanotify_mark(2), getdents(2), inotify_add_watch(2), ioctl_fat(2), kcmp(2), keyctl(2), link(2), mkdir(2), mknod(2), mount(2), msgget(2), open(2), open_by_handle_at(2), perf_event_open(2), query_module(2), quotactl(2), readdir(2), readlink(2), rename(2), rmdir(2), semget(2), shmget(2), spu_create(2), stat(2), statfs(2), statx(2), swapon(2), symlink(2), truncate(2), umount(2), unlink(2), utime(2), utimensat(2), unix(7), ip(7)
|
||||
syscon errno ESRCH 3 3 3 3 3 566 # no such process; kNtErrorThreadNotInProcess (cf. kNtErrorInvalidHandle); raised by capget(2), get_robust_list(2), getpriority(2), getrlimit(2), getsid(2), ioprio_set(2), kcmp(2), kill(2), migrate_pages(2), move_pages(2), perf_event_open(2), pidfd_getfd(2), pidfd_open(2), pidfd_send_signal(2), process_vm_readv(2), ptrace(2), quotactl(2), rt_sigqueueinfo(2), sched_rr_get_interval(2), sched_setaffinity(2), sched_setattr(2), sched_setparam(2), sched_setscheduler(2), set_thread_area(2), setpgid(2), tkill(2), utimensat(2), unix(7)
|
||||
syscon errno EINTR 4 4 4 4 4 10004 # crucial for building real time reliable software; unix consensus; WSAEINTR; raised by accept(2), clock_nanosleep(2), close(2), connect(2), dup(2), epoll_wait(2), fallocate(2), fcntl(2), flock(2), futex(2), getrandom(2), io_getevents(2), msgop(2), nanosleep(2), open(2), pause(2), perf_event_open(2), poll(2), ptrace(2), read(2), recv(2), request_key(2), select(2), semop(2), send(2), sigsuspend(2), sigwaitinfo(2), spu_run(2), statfs(2), truncate(2), wait(2), write(2),
|
||||
syscon errno EIO 5 5 5 5 5 1117 # unix consensus; kNtErrorIoDevice; raised by access(2) acct(2) chdir(2) chmod(2) chown(2) chroot(2) close(2) copy_file_range(2) execve(2) fallocate(2) fsync(2) ioperm(2) link(2) madvise(2) mbind(2) pciconfig_read(2) ptrace(2) read(2) readlink(2) sendfile(2) statfs(2) symlink(2) sync_file_range(2) truncate(2) unlink(2) write(2)
|
||||
syscon errno ENXIO 6 6 6 6 6 1112 # no such device or address; unix consensus; kNtErrorNoMediaInDrive; raised by lseek(2), mount(2), open(2), prctl(2)
|
||||
syscon errno E2BIG 7 7 7 7 7 1639 # argument list too long; unix consensus; kNtErrorInvalidCommandLine; raised by bpf(2), execve(2), getxattr(2), listxattr(2), move_pages(2), msgop(2), openat2(2), perf_event_open(2), sched_setattr(2), semop(2),
|
||||
syscon errno ENOEXEC 8 8 8 8 8 193 # exec format error; unix consensus; kNtErrorBadExeFormat; raised by execve(2), init_module(2), kexec_load(2), uselib(2)
|
||||
syscon errno EBADF 9 9 9 9 9 6 # bad file descriptor; cf. EBADFD; unix consensus; kNtErrorInvalidHandle; raised by accept(2), access(2), bind(2), bpf(2), chdir(2), chmod(2), chown(2), close(2), connect(2), copy_file_range(2), dup(2), epoll_ctl(2), epoll_wait(2), execveat(2), fallocate(2), fanotify_mark(2), fcntl(2), flock(2), fsync(2), futimesat(2), getdents(2), getpeername(2), getsockname(2), getsockopt(2), init_module(2), inotify_add_watch(2), inotify_rm_watch(2), io_submit(2), ioctl(2), ioctl_console(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), ioctl_getfsmap(2), kcmp(2), kexec_load(2), link(2), listen(2), llseek(2), lseek(2), madvise(2), mkdir(2), mknod(2), mmap(2), open(2), open_by_handle_at(2), perf_event_open(2), pidfd_getfd(2), pidfd_send_signal(2), posix_fadvise(2), prctl(2), read(2), readahead(2), readdir(2), readlink(2), recv(2), rename(2), select(2), send(2), sendfile(2), setns(2), shutdown(2), signalfd(2), splice(2), spu_run(2), stat(2), statfs(2), statx(2), symlink(2), sync(2), sync_file_range(2), timerfd_create(2), truncate(2), unlink(2), utimensat(2), vmsplice(2), write(2), unix(7)
|
||||
syscon errno ECHILD 10 10 10 10 10 128 # no child process; unix consensus; kNtErrorWaitNoChildren; raised by wait(2), waitpid(2), waitid(2), wait3(2), wait4(2)
|
||||
syscon errno EAGAIN 11 35 35 35 35 0x2733 # resource temporarily unavailable (e.g. too many processes, read or write with O_NONBLOCK needs polling, too much memory locked, etc.); bsd consensus; WSAEWOULDBLOCK; raised by accept(2), clone(2), connect(2), eventfd(2), fcntl(2), fork(2), futex(2), getrandom(2), io_cancel(2), io_setup(2), io_submit(2), ioctl_userfaultfd(2), keyctl(2), madvise(2), mincore(2), mlock(2), mmap(2), mremap(2), msgop(2), openat2(2), poll(2), read(2), rt_sigqueueinfo(2), select(2), semop(2), send(2), sendfile(2), setresuid(2), setreuid(2), setuid(2), signalfd(2), sigwaitinfo(2), splice(2), tee(2), timer_create(2), timerfd_create(2), tkill(2), umount(2), vmsplice(2), write(2), ip(7)
|
||||
syscon errno ENOMEM 12 12 12 12 12 14 # we require more vespene gas; unix consensus; kNtErrorOutofmemory; raised by access(2), acct(2), add_key(2), bind(2), bpf(2), chdir(2), chmod(2), chown(2), chroot(2), clone(2), copy_file_range(2), create_module(2), epoll_create(2), epoll_ctl(2), eventfd(2), execve(2), fanotify_init(2), fanotify_mark(2), fork(2), getgroups(2), getrlimit(2), init_module(2), inotify_add_watch(2), inotify_init(2), io_setup(2), ioctl_fideduperange(2), ioctl_getfsmap(2), ioperm(2), kexec_load(2), keyctl(2), link(2), lookup_dcookie(2), madvise(2), mbind(2), memfd_create(2), mincore(2), mkdir(2), mknod(2), mlock(2), mmap(2), mount(2), mprotect(2), mremap(2), msgget(2), msgop(2), msync(2), open(2), pidfd_open(2), poll(2), process_vm_readv(2), readlink(2), recv(2), rename(2), request_key(2), rmdir(2), s390_guarded_storage(2), s390_pci_mmio_write(2), s390_runtime_instr(2), s390_sthyi(2), select(2), semget(2), semop(2), send(2), sendfile(2), set_mempolicy(2), setns(2), shmctl(2), shmget(2), shmop(2), sigaltstack(2), signalfd(2), splice(2), spu_create(2), spu_run(2), stat(2), statfs(2), statx(2), subpage_prot(2), swapon(2), symlink(2), sync_file_range(2), tee(2), timer_create(2), timerfd_create(2), umount(2), unlink(2), unshare(2), userfaultfd(2), vmsplice(2), unix(7), ip(7)
|
||||
syscon errno EACCES 13 13 13 13 13 5 # permission denied; unix consensus; kNtErrorAccessDenied; raised by access(2), acct(2), add_key(2), bind(2), bpf(2), chdir(2), chmod(2), chown(2), chroot(2), clock_getres(2), connect(2), execve(2), fcntl(2), futex(2), getpriority(2), inotify_add_watch(2), keyctl(2), link(2), madvise(2), mkdir(2), mknod(2), mmap(2), mount(2), move_pages(2), mprotect(2), msgctl(2), msgget(2), msgop(2), open(2), perf_event_open(2), prctl(2), ptrace(2), quotactl(2), readlink(2), rename(2), request_key(2), rmdir(2), semctl(2), semget(2), semop(2), send(2), setpgid(2), shmctl(2), shmget(2), shmop(2), socket(2), spu_create(2), stat(2), statfs(2), statx(2), symlink(2), truncate(2), unlink(2), uselib(2), utime(2), utimensat(2), ip(7)
|
||||
syscon errno EFAULT 14 14 14 14 14 487 # pointer passed to system call that would otherwise segfault; unix consensus; kNtErrorInvalidAddress; raised by accept(2), access(2), acct(2), add_key(2), adjtimex(2), arch_prctl(2), bdflush(2), bind(2), bpf(2), cacheflush(2), capget(2), chdir(2), chmod(2), chown(2), chroot(2), clock_getres(2), clock_nanosleep(2), connect(2), create_module(2), delete_module(2), epoll_wait(2), execve(2), fcntl(2), futex(2), get_mempolicy(2), get_robust_list(2), getcpu(2), getdents(2), getdomainname(2), getgroups(2), gethostname(2), getitimer(2), getpeername(2), getrandom(2), getresuid(2), getrlimit(2), getrusage(2), getsockname(2), getsockopt(2), gettimeofday(2), getunwind(2), init_module(2), inotify_add_watch(2), io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), io_submit(2), ioctl(2), ioctl_getfsmap(2), ioctl_userfaultfd(2), kcmp(2), keyctl(2), link(2), llseek(2), lookup_dcookie(2), mbind(2), memfd_create(2), migrate_pages(2), mincore(2), mkdir(2), mknod(2), mmap2(2), modify_ldt(2), mount(2), move_pages(2), mremap(2), msgctl(2), msgop(2), msync(2), nanosleep(2), open(2), open_by_handle_at(2), perf_event_open(2), pipe(2), poll(2), prctl(2), process_vm_readv(2), ptrace(2), query_module(2), quotactl(2), read(2), readdir(2), readlink(2), reboot(2), recv(2), rename(2), request_key(2), rmdir(2), s390_guarded_storage(2), s390_pci_mmio_write(2), s390_sthyi(2), sched_rr_get_interval(2), sched_setaffinity(2), semctl(2), semop(2), send(2), sendfile(2), set_mempolicy(2), set_thread_area(2), shmctl(2), sigaction(2), sigaltstack(2), sigpending(2), sigprocmask(2), sigsuspend(2), socketpair(2), spu_create(2), spu_run(2), stat(2), statfs(2), statx(2), stime(2), subpage_prot(2), symlink(2), sysctl(2), sysfs(2), sysinfo(2), time(2), timer_settime(2), timerfd_create(2), times(2), truncate(2), umount(2), uname(2), unlink(2), ustat(2), utimensat(2), vm86(2), write(2), unix(7)
|
||||
syscon errno ENOTBLK 15 15 15 15 15 26 # block device required; unix consensus; kNtErrorNotDosDisk; raised by mount(2), quotactl(2), umount(2)
|
||||
syscon errno EBUSY 16 16 16 16 16 170 # device or resource busy; unix consensus; kNtErrorBusy; raised by bdflush(2), delete_module(2), dup(2), fcntl(2), init_module(2), ioctl_tty(2), ioctl_userfaultfd(2), kexec_load(2), mount(2), msync(2), pivot_root(2), prctl(2), ptrace(2), quotactl(2), rename(2), rmdir(2), sched_setattr(2), swapon(2), umount(2)
|
||||
syscon errno EEXIST 17 17 17 17 17 183 # file exists; unix consensus; kNtErrorAlreadyExists (should be kNtErrorFileExists too); raised by bpf(2), create_module(2), epoll_ctl(2), init_module(2), inotify_add_watch(2), keyctl(2), link(2), mkdir(2), mknod(2), mmap(2), msgget(2), open(2), rename(2), rmdir(2), semget(2), setxattr(2), shmget(2), spu_create(2), symlink(2)
|
||||
syscon errno EXDEV 18 18 18 18 18 17 # improper link; unix consensus; kNtErrorNotSameDevice; raised by copy_file_range(2), fanotify_mark(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), link(2), openat2(2), rename(2)
|
||||
syscon errno ENODEV 19 19 19 19 19 1200 # no such device; unix consensus; kNtErrorBadDevice; raised by arch_prctl(2), eventfd(2), fallocate(2), fanotify_mark(2), mmap(2), mount(2), move_pages(2), open(2), pciconfig_read(2), perf_event_open(2), pidfd_open(2), prctl(2), s390_pci_mmio_write(2), signalfd(2), spu_create(2), timerfd_create(2)
|
||||
syscon errno ENOTDIR 20 20 20 20 20 3 # not a directory; unix consensus; kNtErrorPathNotFound; raised by access(2), acct(2), bind(2), chdir(2), chmod(2), chown(2), chroot(2), execve(2), execveat(2), fanotify_mark(2), fcntl(2), futimesat(2), getdents(2), inotify_add_watch(2), ioctl_fat(2), keyctl(2), link(2), mkdir(2), mknod(2), mount(2), open(2), open_by_handle_at(2), pivot_root(2), readdir(2), readlink(2), rename(2), rmdir(2), spu_create(2), stat(2), statfs(2), statx(2), symlink(2), sysctl(2), truncate(2), unlink(2), utimensat(2)
|
||||
syscon errno EISDIR 21 21 21 21 21 267 # is a a directory; unix consensus; kNtErrorDirectoryNotSupported; raised by acct(2), copy_file_range(2), execve(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), open(2), read(2), rename(2), truncate(2), unlink(2)
|
||||
syscon errno EINVAL 22 22 22 22 22 87 # invalid argument; unix consensus; kNtErrorInvalidParameter; raised by accept(2), access(2), add_key(2), adjtimex(2), arch_prctl(2), bdflush(2), bind(2), bpf(2), cacheflush(2), capget(2), chmod(2), chown(2), clock_getres(2), clock_nanosleep(2), clone(2), copy_file_range(2), create_module(2), dup(2), epoll_create(2), epoll_ctl(2), epoll_wait(2), eventfd(2), execve(2), execveat(2), fallocate(2), fanotify_init(2), fanotify_mark(2), fcntl(2), flock(2), futex(2), get_mempolicy(2), get_robust_list(2), getdents(2), getdomainname(2), getgroups(2), gethostname(2), getitimer(2), getpeername(2), getpriority(2), getrandom(2), getrlimit(2), getrusage(2), getsockname(2), getsockopt(2), gettimeofday(2), init_module(2), inotify_add_watch(2), inotify_init(2), inotify_rm_watch(2), io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), io_submit(2), ioctl(2), ioctl_console(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), ioctl_getfsmap(2), ioctl_ns(2), ioctl_tty(2), ioctl_userfaultfd(2), ioperm(2), iopl(2), ioprio_set(2), kcmp(2), kexec_load(2), keyctl(2), kill(2), link(2), llseek(2), lookup_dcookie(2), lseek(2), madvise(2), mbind(2), membarrier(2), memfd_create(2), migrate_pages(2), mincore(2), mkdir(2), mknod(2), mlock(2), mmap(2), mmap2(2), modify_ldt(2), mount(2), move_pages(2), mprotect(2), mremap(2), msgctl(2), msgop(2), msync(2), nanosleep(2), open(2), open_by_handle_at(2), openat2(2), pciconfig_read(2), perf_event_open(2), personality(2), pidfd_getfd(2), pidfd_open(2), pidfd_send_signal(2), pipe(2), pivot_root(2), pkey_alloc(2), poll(2), posix_fadvise(2), prctl(2), process_vm_readv(2), ptrace(2), query_module(2), quotactl(2), read(2), readahead(2), readdir(2), readlink(2), readv(2), reboot(2), recv(2), recvmmsg(2), remap_file_pages(2), rename(2), request_key(2), rmdir(2), rt_sigqueueinfo(2), s390_guarded_storage(2), s390_pci_mmio_write(2), s390_runtime_instr(2), s390_sthyi(2), sched_get_priority_max(2), sched_rr_get_interval(2), sched_setaffinity(2), sched_setattr(2), sched_setparam(2), sched_setscheduler(2), seccomp(2), select(2), semctl(2), semget(2), semop(2), send(2), sendfile(2), set_mempolicy(2), set_thread_area(2), seteuid(2), setfsgid(2), setfsuid(2), setgid(2), setns(2), setpgid(2), setresuid(2), setreuid(2), setuid(2), shmctl(2), shmget(2), shmop(2), shutdown(2), sigaction(2), sigaltstack(2), signal(2), signalfd(2), sigprocmask(2), sigsuspend(2), sigwaitinfo(2), socket(2), splice(2), spu_create(2), spu_run(2), stat(2), statx(2), subpage_prot(2), swapon(2), sync_file_range(2), sysfs(2), syslog(2), tee(2), timer_create(2), timer_delete(2), timer_getoverrun(2), timer_settime(2), timerfd_create(2), tkill(2), truncate(2), umount(2), unlink(2), unshare(2), userfaultfd(2), ustat(2), utimensat(2), vmsplice(2), wait(2), write(2), unix(7), ip(7)
|
||||
syscon errno ENFILE 23 23 23 23 23 331 # too many open files in system; unix consensus; kNtErrorTooManyDescriptors; raised by accept(2), acct(2), epoll_create(2), eventfd(2), execve(2), futex(2), inotify_init(2), memfd_create(2), mmap(2), open(2), pidfd_getfd(2), pidfd_open(2), pipe(2), shmget(2), signalfd(2), socket(2), socketpair(2), spu_create(2), swapon(2), timerfd_create(2), uselib(2), userfaultfd(2)
|
||||
syscon errno EMFILE 24 24 24 24 24 336 # too many open files; unix consensus; kNtErrorTooManyOpenFiles; raised by accept(2), dup(2), epoll_create(2), eventfd(2), execve(2), fanotify_init(2), fcntl(2), inotify_init(2), memfd_create(2), mount(2), open(2), perf_event_open(2), pidfd_getfd(2), pidfd_open(2), pipe(2), signalfd(2), socket(2), socketpair(2), spu_create(2), timerfd_create(2)
|
||||
syscon errno ENOTTY 25 25 25 25 25 1118 # inappropriate i/o control operation; unix consensus; kNtErrorSerialNoDevice; raised by ioctl(2), ioctl_console(2), ioctl_fat(2), ioctl_ns(2), ioctl_tty(2)
|
||||
syscon errno ETXTBSY 26 26 26 26 26 148 # won't open executable that's executing in write mode; try UnlockExecutable(); unix consensus; kNtErrorPathBusy; raised by access(2), copy_file_range(2), execve(2), fallocate(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), mmap(2), open(2), truncate(2)
|
||||
syscon errno EFBIG 27 27 27 27 27 223 # file too large; unix consensus; kNtErrorFileTooLarge; raised by copy_file_range(2), fallocate(2), init_module(2), open(2), semop(2), truncate(2), write(2)
|
||||
syscon errno ENOSPC 28 28 28 28 28 39 # no space left on device; unix consensus; kNtErrorDiskFull; raised by copy_file_range(2), epoll_ctl(2), fallocate(2), fanotify_mark(2), fsync(2), inotify_add_watch(2), link(2), mkdir(2), mknod(2), msgget(2), open(2), perf_event_open(2), pkey_alloc(2), query_module(2), rename(2), semget(2), setxattr(2), shmget(2), spu_create(2), symlink(2), sync_file_range(2), write(2)
|
||||
syscon errno EDQUOT 122 69 69 69 69 0x2755 # disk quota exceeded; bsd consensus; raised by add_key(2), keyctl(2), link(2), mkdir(2), mknod(2), open(2), rename(2), request_key(2), setxattr(2), symlink(2), write(2)
|
||||
syscon errno ESPIPE 29 29 29 29 29 25 # invalid seek; unix consensus; kNtErrorSeek; raised by fallocate(2), lseek(2), posix_fadvise(2), sendfile(2), splice(2), sync_file_range(2)
|
||||
syscon errno EROFS 30 30 30 30 30 6009 # read-only filesystem; unix consensus; kNtErrorFileReadOnly; raised by access(2), acct(2), bind(2), chmod(2), chown(2), link(2), mkdir(2), mknod(2), mount(2), open(2), rename(2), rmdir(2), symlink(2), truncate(2), unlink(2), utime(2), utimensat(2)
|
||||
syscon errno EMLINK 31 31 31 31 31 4 # too many links; unix consensus; kNtErrorTooManyLinks; raised by link(2), mkdir(2), rename(2)
|
||||
syscon errno EPIPE 32 32 32 32 32 109 # broken pipe; unix consensus; kNtErrorBrokenPipe; raised by send(2), write(2), tcp(7), unix(7), ip(7)
|
||||
syscon errno EDOM 33 33 33 33 33 33 # mathematics argument out of domain of function; bsd consensus; fudged on NT; returned by cos(3), fmod(3), log1p(3), sin(3), tan(3), tgamma(3)
|
||||
syscon errno ERANGE 34 34 34 34 34 34 # result too large; bsd consensus; fudged on NT; raised by getxattr(2), listxattr(2), lookup_dcookie(2), prctl(2), quotactl(2), semctl(2), semop(2), setxattr(2)
|
||||
syscon errno EDEADLK 35 11 11 11 11 1131 # resource deadlock avoided; bsd consensus; kNtErrorPossibleDeadlock; raised by fcntl(2), keyctl(2)
|
||||
syscon errno ENAMETOOLONG 36 63 63 63 63 0x274f # filename too long; bsd consensus; WSAENAMETOOLONG; raised by access(2), acct(2), bind(2), chdir(2), chmod(2), chown(2), chroot(2), execve(2), gethostname(2), inotify_add_watch(2), link(2), lookup_dcookie(2), mkdir(2), mknod(2), mount(2), open(2), readlink(2), rename(2), rmdir(2), spu_create(2), stat(2), statfs(2), statx(2), symlink(2), truncate(2), umount(2), unlink(2), utimensat(2)
|
||||
syscon errno ENOLCK 37 77 77 77 77 0 # no locks available; bsd consensus; raised by fcntl(2), flock(2)
|
||||
syscon errno ENOTEMPTY 39 66 66 66 66 145 # directory not empty; bsd consensus; kNtErrorDirNotEmpty (TODO: What is WSAENOTEMPTY? 0x2752); raised by rmdir(2)
|
||||
syscon errno ELOOP 40 62 62 62 62 0x274e # too many levels of symbolic links; bsd consensus; WSAELOOP; raised by access(2), acct(2), bind(2), chdir(2), chmod(2), chown(2), chroot(2), epoll_ctl(2), execve(2), execveat(2), keyctl(2), link(2), mkdir(2), mknod(2), mount(2), open(2), open_by_handle_at(2), openat2(2), readlink(2), rename(2), rmdir(2), spu_create(2), stat(2), statfs(2), statx(2), symlink(2), truncate(2), unlink(2), utimensat(2)
|
||||
syscon errno ENOMSG 42 91 83 90 83 0 # raised by msgop(2)
|
||||
syscon errno EIDRM 43 90 82 89 82 0 # identifier removed; raised by msgctl(2), msgget(2), msgop(2), semctl(2), semop(2), shmctl(2), shmget(2), shmop(2)
|
||||
syscon errno ETIME 62 101 60 60 92 0 # timer expired; timer expired; raised by connect(2), futex(2), keyctl(2), mq_receive(2), mq_send(2), rtime(2), sem_wait(2)
|
||||
syscon errno EPROTO 71 100 92 95 96 0 # raised by accept(2), connect(2), socket(2), socketpair(2)
|
||||
syscon errno EOVERFLOW 75 84 84 87 84 0 # raised by aio_read(2), copy_file_range(2), ctime(2), fanotify_init(2), lseek(2), mmap(2), open(2), open_by_handle_at(2), sem_post(2), sendfile(2), shmctl(2), stat(2), statfs(2), statvfs(2), time(2), timegm(2)
|
||||
syscon errno EILSEQ 84 92 86 84 85 0 # returned by fgetwc(3), fputwc(3), getwchar(3), putwchar(3), scanf(3), ungetwc(3)
|
||||
syscon errno EUSERS 87 68 68 68 68 0x2754 # too many users; bsd consensus; WSAEUSERS; raised by acct(2)
|
||||
syscon errno ENOTSOCK 88 38 38 38 38 0x2736 # not a socket; bsd consensus; WSAENOTSOCK; raised by accept(2), bind(2), connect(2), getpeername(2), getsockname(2), getsockopt(2), listen(2), recv(2), send(2), shutdown(2)
|
||||
syscon errno EDESTADDRREQ 89 39 39 39 39 0x2737 # destination address required; bsd consensus; WSAEDESTADDRREQ; raised by send(2), write(2)
|
||||
syscon errno EMSGSIZE 90 40 40 40 40 0x2738 # message too long; bsd consensus; WSAEMSGSIZE; raised by keyctl(2), send(2), ip(7)
|
||||
syscon errno EPROTOTYPE 91 41 41 41 41 0x2739 # protocol wrong type for socket; bsd consensus; WSAEPROTOTYPE; raised by connect(2), unix(7)
|
||||
syscon errno ENOPROTOOPT 92 42 42 42 42 0x273a # protocol not available; bsd consensus; WSAENOPROTOOPT; raised by getsockopt(2), accept(2), ip(7)
|
||||
syscon errno EPROTONOSUPPORT 93 43 43 43 43 0x273b # protocol not supported; bsd consensus; WSAEPROTONOSUPPORT; raised by socket(2), socketpair(2), unix(7)
|
||||
syscon errno ESOCKTNOSUPPORT 94 44 44 44 44 0x273c # socket type not supported; bsd consensus; WSAESOCKTNOSUPPORT; raised by unix(7), ip(7)
|
||||
syscon errno ENOTSUP 95 45 45 91 86 0x273d # operation not supported; raised by chmod(2), clock_getres(2), clock_nanosleep(2), getxattr(2), listxattr(2), removexattr(2), setxattr(2), timer_create(2)
|
||||
syscon errno EOPNOTSUPP 95 102 45 45 45 0x273d # socket operation not supported; raised by accept(2), fallocate(2), fanotify_mark(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), ioctl_getfsmap(2), keyctl(2), listen(2), mmap(2), open_by_handle_at(2), pciconfig_read(2), perf_event_open(2), prctl(2), readv(2), s390_guarded_storage(2), s390_runtime_instr(2), s390_sthyi(2), send(2), socketpair(2), unix(7), ip(7)
|
||||
syscon errno EPFNOSUPPORT 96 46 46 46 46 0x273e # protocol family not supported; bsd consensus; WSAEPFNOSUPPORT
|
||||
syscon errno EAFNOSUPPORT 97 47 47 47 47 0x273f # address family not supported; bsd consensus; WSAEAFNOSUPPORT; raised by connect(2), socket(2), socketpair(2), tcp(7)
|
||||
syscon errno EADDRINUSE 98 48 48 48 48 0x2740 # address already in use; bsd consensus; WSAEADDRINUSE; raised by bind(2), connect(2), listen(2), unix(7), ip(7)
|
||||
syscon errno EADDRNOTAVAIL 99 49 49 49 49 0x2741 # address not available; bsd consensus; WSAEADDRNOTAVAIL; raised by bind(2), connect(2), kexec_load(2), ip(7)
|
||||
syscon errno ENETDOWN 100 50 50 50 50 0x2742 # network is down; bsd consensus; WSAENETDOWN; raised by accept(2)
|
||||
syscon errno ENETUNREACH 101 51 51 51 51 0x2743 # host is unreachable; bsd consensus; WSAENETUNREACH; raised by accept(2), connect(2)
|
||||
syscon errno ENETRESET 102 52 52 52 52 0x2744 # connection reset by network; bsd consensus; WSAENETRESET
|
||||
syscon errno ECONNABORTED 103 53 53 53 53 0x2745 # connection reset before accept; bsd consensus; WSAECONNABORTED; raised by accept(2)
|
||||
syscon errno ECONNRESET 104 54 54 54 54 0x2746 # connection reset by client; bsd consensus; WSAECONNRESET; raised by send(2), unix(7)
|
||||
syscon errno ENOBUFS 105 55 55 55 55 0x2747 # no buffer space available; bsd consensus; WSAENOBUFS; raised by getpeername(2), getsockname(2), send(2), ip(7)
|
||||
syscon errno EISCONN 106 56 56 56 56 0x2748 # socket is connected; bsd consensus; WSAEISCONN; raised by connect(2), send(2), unix(7), ip(7)
|
||||
syscon errno ENOTCONN 107 57 57 57 57 0x2749 # socket is not connected; bsd consensus; WSAENOTCONN; raised by getpeername(2), recv(2), send(2), shutdown(2), ip(7)
|
||||
syscon errno ESHUTDOWN 108 58 58 58 58 0x274a # cannot send after transport endpoint shutdown; note that shutdown write is an EPIPE; bsd consensus; WSAESHUTDOWN
|
||||
syscon errno ETOOMANYREFS 109 59 59 59 59 0x274b # too many references: cannot splice; bsd consensus; WSAETOOMANYREFS; raised by sendmsg(2), unix(7)
|
||||
syscon errno ETIMEDOUT 110 60 60 60 60 0x274c # connection timed out; bsd consensus; WSAETIMEDOUT; raised by connect(2), futex(2), keyctl(2), tcp(7)
|
||||
syscon errno ECONNREFUSED 111 61 61 61 61 0x274d # bsd consensus; WSAECONNREFUSED; raised by connect(2), listen(2), recv(2), unix(7), udp(7)system-imposed limit on the number of threads was encountered.
|
||||
syscon errno EHOSTDOWN 112 64 64 64 64 0x2750 # bsd consensus; WSAEHOSTDOWN; raised by accept(2)
|
||||
syscon errno EHOSTUNREACH 113 65 65 65 65 0x2751 # bsd consensus; WSAEHOSTUNREACH; raised by accept(2), ip(7)
|
||||
syscon errno EALREADY 114 37 37 37 37 0x2735 # connection already in progress; bsd consensus; WSAEALREADY; raised by connect(2), send(2), ip(7)
|
||||
syscon errno EINPROGRESS 115 36 36 36 36 0x2734 # bsd consensus; WSAEINPROGRESS; raised by connect(2) w/ O_NONBLOCK
|
||||
syscon errno ESTALE 116 70 70 70 70 0x2756 # bsd consensus; WSAESTALE; raised by open_by_handle_at(2)
|
||||
syscon errno EREMOTE 66 71 71 71 71 0x2757 # bsd consensus
|
||||
syscon errno ENOLINK 67 97 91 0 95 0
|
||||
syscon errno EADV 68 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ESRMNT 69 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ECOMM 70 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EPROTO 71 100 92 95 96 0
|
||||
syscon errno EMULTIHOP 72 95 90 0 94 0
|
||||
syscon errno EDOTDOT 73 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADMSG 74 94 89 92 88 0
|
||||
syscon errno EOVERFLOW 75 84 84 87 84 0
|
||||
syscon errno ENOTUNIQ 76 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADFD 77 9 9 9 9 6 # file descriptor in bad state; cf. EBADF; fudged on non-Linux
|
||||
syscon errno EREMCHG 78 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELIBACC 79 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELIBBAD 80 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELIBSCN 81 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELIBMAX 82 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ELIBEXEC 83 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EILSEQ 84 92 86 84 85 0
|
||||
syscon errno ERESTART 85 0 0 0 -3 0 # bsd consensus
|
||||
syscon errno ESTRPIPE 86 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EUCLEAN 117 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOTNAM 118 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENAVAIL 119 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EISNAM 120 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EREMOTEIO 121 0 0 0 0 0 # bsd consensus
|
||||
syscon errno ENOMEDIUM 123 0 0 85 85 0
|
||||
syscon errno EMEDIUMTYPE 124 0 0 86 86 0
|
||||
syscon errno ECANCELED 125 89 85 88 87 0
|
||||
syscon errno ENOKEY 126 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EKEYEXPIRED 127 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EKEYREVOKED 128 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EKEYREJECTED 129 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EOWNERDEAD 130 105 96 94 97 0
|
||||
syscon errno ENOTRECOVERABLE 131 104 95 93 98 0
|
||||
syscon errno ERFKILL 132 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EHWPOISON 133 0 0 0 0 0 # bsd consensus
|
||||
syscon errno EBADMSG 74 94 89 92 88 0 # raised by ioctl_getfsmap(2)
|
||||
syscon errno ECANCELED 125 89 85 88 87 0 # raised by timerfd_create(2)
|
||||
syscon errno EOWNERDEAD 130 105 96 94 97 0 # raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3)
|
||||
syscon errno ENOTRECOVERABLE 131 104 95 93 98 0 # raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3)
|
||||
syscon errno ENONET 64 0 0 0 0 0 # bsd consensus; raised by accept(2)
|
||||
syscon errno ERESTART 85 0 0 0 -3 0 # bsd consensus; should only be seen in ptrace()
|
||||
syscon junkerr ECHRNG 44 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EL2NSYNC 45 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EL3HLT 46 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EL3RST 47 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELNRNG 48 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EUNATCH 49 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOCSI 50 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EL2HLT 51 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EBADE 52 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EBADR 53 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EXFULL 54 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOANO 55 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EBADRQC 56 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EBADSLT 57 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOSTR 60 99 0 0 91 0 #
|
||||
syscon junkerr ENODATA 61 96 0 0 89 0 # raised by getxattr(2), removexattr(2), setxattr(2)
|
||||
syscon junkerr ENOSR 63 98 0 0 90 0 #
|
||||
syscon junkerr ENOPKG 65 0 0 0 0 0 # bsd consensus, ip(7)
|
||||
syscon junkerr ENOLINK 67 97 91 0 95 0 #
|
||||
syscon junkerr EADV 68 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ESRMNT 69 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ECOMM 70 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EMULTIHOP 72 95 90 0 94 0 #
|
||||
syscon junkerr EDOTDOT 73 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOTUNIQ 76 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EREMCHG 78 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELIBACC 79 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELIBBAD 80 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELIBSCN 81 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELIBMAX 82 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ELIBEXEC 83 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ESTRPIPE 86 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EUCLEAN 117 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOTNAM 118 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENAVAIL 119 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EISNAM 120 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EREMOTEIO 121 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ENOMEDIUM 123 0 0 85 85 0 #
|
||||
syscon junkerr EMEDIUMTYPE 124 0 0 86 86 0 #
|
||||
syscon junkerr ENOKEY 126 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EKEYEXPIRED 127 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EKEYREVOKED 128 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EKEYREJECTED 129 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr ERFKILL 132 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EHWPOISON 133 0 0 0 0 0 # bsd consensus
|
||||
syscon junkerr EBADFD 77 9 9 9 9 6 # file descriptor in bad state; cf. EBADF; fudged on non-Linux
|
||||
syscon compat EWOULDBLOCK 11 35 35 35 35 0x2733 # same as EWOULDBLOCK
|
||||
|
||||
# signals
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon sig SIGHUP 1 1 1 1 1 1 # unix consensus & faked on nt
|
||||
syscon sig SIGINT 2 2 2 2 2 2 # unix consensus & faked on nt
|
||||
syscon sig SIGQUIT 3 3 3 3 3 3 # unix consensus & faked on nt
|
||||
syscon sig SIGILL 4 4 4 4 4 4 # unix consensus & faked on nt
|
||||
syscon sig SIGTRAP 5 5 5 5 5 5 # unix consensus & faked on nt
|
||||
syscon sig SIGABRT 6 6 6 6 6 6 # unix consensus & faked on nt
|
||||
syscon sig SIGIOT 6 6 6 6 6 6 # unix consensus & faked on nt
|
||||
syscon sig SIGFPE 8 8 8 8 8 8 # unix consensus & faked on nt
|
||||
syscon sig SIGKILL 9 9 9 9 9 9 # unix consensus & faked on nt
|
||||
syscon sig SIGSEGV 11 11 11 11 11 11 # unix consensus & faked on nt
|
||||
syscon sig SIGPIPE 13 13 13 13 13 13 # unix consensus & faked on nt
|
||||
syscon sig SIGALRM 14 14 14 14 14 14 # unix consensus & faked on nt
|
||||
syscon sig SIGTERM 15 15 15 15 15 15 # unix consensus & faked on nt
|
||||
syscon sig SIGTTIN 21 21 21 21 21 21 # unix consensus & faked on nt
|
||||
syscon sig SIGTTOU 22 22 22 22 22 22 # unix consensus & faked on nt
|
||||
syscon sig SIGXCPU 24 24 24 24 24 24 # unix consensus & faked on nt
|
||||
syscon sig SIGXFSZ 25 25 25 25 25 25 # unix consensus & faked on nt
|
||||
syscon sig SIGVTALRM 26 26 26 26 26 26 # unix consensus & faked on nt
|
||||
syscon sig SIGPROF 27 27 27 27 27 27 # unix consensus & faked on nt
|
||||
syscon sig SIGWINCH 28 28 28 28 28 28 # unix consensus & faked on nt
|
||||
syscon sig SIGBUS 7 10 10 10 10 7 # bsd consensus
|
||||
syscon sig SIGUSR1 10 30 30 30 30 10 # bsd consensus
|
||||
syscon sig SIGCHLD 17 20 20 20 20 17 # bsd consensus
|
||||
syscon sig SIGCONT 18 19 19 19 19 18 # bsd consensus
|
||||
syscon sig SIGHUP 1 1 1 1 1 1 # terminal hangup or daemon reload; resumable; auto-broadcasted to process group; unix consensus & faked on nt
|
||||
syscon sig SIGINT 2 2 2 2 2 2 # terminal ctrl-c keystroke; resumable; auto-broadcasted to process group; unix consensus & faked on nt
|
||||
syscon sig SIGQUIT 3 3 3 3 3 3 # terminal ctrl-\ keystroke; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGILL 4 4 4 4 4 4 # illegal instruction; unresumable (unless you longjmp() or edit ucontex->rip+=ild(ucontex->rip)); unix consensus & faked on nt
|
||||
syscon sig SIGTRAP 5 5 5 5 5 5 # int3 instruction; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGABRT 6 6 6 6 6 6 # process aborted; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGBUS 7 10 10 10 10 7 # valid memory access that went beyond underlying end of file; bsd consensus
|
||||
syscon sig SIGFPE 8 8 8 8 8 8 # illegal math; unresumable (unless you longjmp() or edit ucontex->rip+=ild(ucontex->rip)); unix consensus & faked on nt
|
||||
syscon sig SIGKILL 9 9 9 9 9 9 # terminate with extreme prejudice; unreceivable; unix consensus & faked on nt
|
||||
syscon sig SIGUSR1 10 30 30 30 30 10 # do whatever you want; bsd consensus
|
||||
syscon sig SIGSEGV 11 11 11 11 11 11 # invalid memory access; unresumable (unless you longjmp() or edit ucontex->rip+=ild(ucontex->rip)); unix consensus & faked on nt
|
||||
syscon sig SIGUSR2 12 31 31 31 31 12 # do whatever you want; bsd consensus
|
||||
syscon sig SIGPIPE 13 13 13 13 13 13 # write to closed file descriptor; unix consensus & faked on nt
|
||||
syscon sig SIGALRM 14 14 14 14 14 14 # sent by setitimer(2) or timer_settime(2); unix consensus & faked on nt
|
||||
syscon sig SIGTERM 15 15 15 15 15 15 # terminate; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGCHLD 17 20 20 20 20 17 # child process exited or terminated and is now a zombie (unless this is SIG_IGN or SA_NOCLDWAIT) or child process stopped due to terminal i/o or profiling/debugging (unless you used SA_NOCLDSTOP); bsd consensus
|
||||
syscon sig SIGCONT 18 19 19 19 19 18 # child process resumed from profiling/debugging; bsd consensus
|
||||
syscon sig SIGSTOP 19 17 17 17 17 19 # child process stopped due to profiling/debugging; bsd consensus
|
||||
syscon sig SIGTSTP 20 18 18 18 18 20 # terminal ctrl-z keystroke; bsd consensus
|
||||
syscon sig SIGTTIN 21 21 21 21 21 21 # terminal input for background process; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGTTOU 22 22 22 22 22 22 # terminal output for background process; resumable; unix consensus & faked on nt
|
||||
syscon sig SIGURG 23 16 16 16 16 23 # bsd consensus
|
||||
syscon sig SIGXCPU 24 24 24 24 24 24 # cpu time limit exceeded; unix consensus & faked on nt
|
||||
syscon sig SIGXFSZ 25 25 25 25 25 25 # file size limit exceeded; unix consensus & faked on nt
|
||||
syscon sig SIGVTALRM 26 26 26 26 26 26 # virtual alarm clock; wut; unix consensus & faked on nt
|
||||
syscon sig SIGPROF 27 27 27 27 27 27 # profiling timer expired; unix consensus & faked on nt
|
||||
syscon sig SIGWINCH 28 28 28 28 28 28 # terminal resized; unix consensus & faked on nt
|
||||
syscon sig SIGIO 29 23 23 23 23 29 # bsd consensus
|
||||
syscon sig SIGSTOP 19 17 17 17 17 19 # bsd consensus
|
||||
syscon sig SIGSYS 31 12 12 12 12 31 # bsd consensus
|
||||
syscon sig SIGTSTP 20 18 18 18 18 20 # bsd consensus
|
||||
syscon sig SIGURG 23 0x10 0x10 0x10 0x10 23 # bsd consensus
|
||||
syscon sig SIGUSR2 12 31 31 31 31 12 # bsd consensus
|
||||
syscon sig SIGSTKSZ 0x2000 0x020000 0x8800 0x7000 0x7000 0x2000
|
||||
syscon sig SIGPOLL 29 0 0 0 0 29
|
||||
syscon sig SIGPWR 30 0 0 0 32 30
|
||||
syscon sig SIGSTKFLT 0x10 0 0 0 0 0x10
|
||||
syscon sig SIGUNUSED 31 0 0 0 0 31
|
||||
syscon sig SIGSYS 31 12 12 12 12 31 # wut; bsd consensus
|
||||
syscon sig SIGRTMAX 0 0 126 0 63 0
|
||||
syscon sig SIGRTMIN 0 0 65 0 33 0
|
||||
syscon compat SIGPOLL 29 23 23 23 23 29 # same as SIGIO
|
||||
syscon compat SIGIOT 6 6 6 6 6 6 # PDP-11 feature; same as SIGABRT
|
||||
syscon compat SIGPWR 30 30 30 30 32 30 # not implemented in most community editions of system five; consider doing this using SIGUSR1 or SIGUSR2 instead
|
||||
|
||||
# open() flags ┌──────hoo boy
|
||||
# ┌──────┐
|
||||
|
@ -232,6 +228,10 @@ syscon open O_EXEC 0 0 0x040000 0 0x4000000 0
|
|||
syscon open O_TTY_INIT 0 0 0x080000 0 0 0
|
||||
syscon compat O_LARGEFILE 0 0 0 0 0 0
|
||||
|
||||
# mmap() flags
|
||||
# the revolutionary praxis of malloc()
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon compat MAP_FILE 0 0 0 0 0 0 # consensus
|
||||
syscon mmap MAP_SHARED 1 1 1 1 1 1 # forced consensus & faked nt
|
||||
syscon mmap MAP_PRIVATE 2 2 2 2 2 2 # forced consensus & faked nt
|
||||
|
@ -254,6 +254,10 @@ syscon compat MAP_EXECUTABLE 0x1000 0 0 0 0 0 # ignored
|
|||
syscon compat MAP_DENYWRITE 0x0800 0 0 0 0 0
|
||||
syscon compat MAP_32BIT 0x40 0 0x080000 0 0 0 # iffy
|
||||
|
||||
# madvise() flags
|
||||
# beneath the iceberg memory management
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon madv MADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal
|
||||
syscon compat POSIX_FADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal
|
||||
syscon compat POSIX_MADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal
|
||||
|
@ -276,7 +280,7 @@ syscon madv MADV_HUGEPAGE 14 0 0 0 0 0 # TODO(jart): why would we
|
|||
syscon madv MADV_NOHUGEPAGE 15 0 0 0 0 0 # TODO(jart): why would we need it?
|
||||
syscon madv MADV_DODUMP 17 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_DOFORK 11 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_DONTDUMP 0x10 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_DONTDUMP 16 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_DONTFORK 10 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_HWPOISON 100 0 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon madv MADV_REMOVE 9 0 0 0 0 0 # TODO(jart): what is it?
|
||||
|
@ -293,9 +297,16 @@ syscon mprot PROT_EXEC 4 4 4 4 4 4 # mmap, mprotect, unix consens
|
|||
syscon mprot PROT_GROWSDOWN 0x01000000 0 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap() (todo: what was 0x01000000 on nt)
|
||||
syscon mprot PROT_GROWSUP 0x02000000 0 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap()
|
||||
|
||||
# mremap() flags
|
||||
# the revolutionary praxis of realloc()
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon mremap MREMAP_MAYMOVE 1 1 1 1 1 1 # faked non-linux (b/c linux only)
|
||||
syscon mremap MREMAP_FIXED 2 2 2 2 2 2 # faked non-linux (b/c linux only)
|
||||
|
||||
# splice() flags
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon splice SPLICE_F_MOVE 1 0 0 0 0 0 # can be safely ignored by polyfill; it's a hint
|
||||
syscon splice SPLICE_F_NONBLOCK 2 0 0 0 0 0 # can be safely ignored by polyfill, since linux says it doesn't apply to underlying FDs
|
||||
syscon splice SPLICE_F_MORE 4 0 0 0 0 0 # can be safely ignored by polyfill; it's a hint
|
||||
|
@ -320,7 +331,7 @@ syscon lock LOCK_UN 8 8 8 8 8 8 # unlock [unix consensus & faked
|
|||
# waitpid() / wait4() options
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon waitpid WNOHANG 1 1 1 1 1 0 # unix consensus
|
||||
syscon waitpid WNOHANG 1 1 1 1 1 0 # helps you reap zombies; unix consensus
|
||||
syscon waitpid WUNTRACED 2 2 2 2 2 0 # unix consensus
|
||||
syscon waitpid WCONTINUED 8 0x10 4 8 16 0
|
||||
|
||||
|
@ -334,41 +345,32 @@ syscon waitid WNOWAIT 0x01000000 0x20 8 0 0x10000 0
|
|||
# stat::st_mode constants
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon stat S_IFREG 0100000 0100000 0100000 0100000 0100000 0100000
|
||||
syscon stat S_IFBLK 0060000 0060000 0060000 0060000 0060000 0060000
|
||||
syscon stat S_IFCHR 0020000 0020000 0020000 0020000 0020000 0020000
|
||||
syscon stat S_IFDIR 0040000 0040000 0040000 0040000 0040000 0040000
|
||||
syscon stat S_IFIFO 0010000 0010000 0010000 0010000 0010000 0010000
|
||||
syscon stat S_IFMT 0170000 0170000 0170000 0170000 0170000 0170000
|
||||
syscon stat S_IFLNK 0120000 0120000 0120000 0120000 0120000 0120000
|
||||
syscon stat S_IFSOCK 0140000 0140000 0140000 0140000 0140000 0140000
|
||||
|
||||
# chmod() permission flag constants
|
||||
# consider just typing the octal codes
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon stat S_ISVTX 01000 01000 01000 01000 01000 01000 # unix consensus STICKY BIT
|
||||
syscon stat S_ISGID 02000 02000 02000 02000 02000 02000 # unix consensus a.k.a. setgid bit
|
||||
syscon stat S_ISUID 04000 04000 04000 04000 04000 04000 # unix consensus a.k.a. setuid bit
|
||||
|
||||
syscon stat S_IEXEC 00100 00100 00100 00100 00100 00100 # unix consensus
|
||||
syscon stat S_IWRITE 00200 00200 00200 00200 00200 00200 # unix consensus
|
||||
syscon stat S_IREAD 00400 00400 00400 00400 00400 00400 # unix consensus
|
||||
|
||||
syscon stat S_IXUSR 00100 00100 00100 00100 00100 00100 # unix consensus
|
||||
syscon stat S_IWUSR 00200 00200 00200 00200 00200 00200 # unix consensus
|
||||
syscon stat S_IRUSR 00400 00400 00400 00400 00400 00400 # unix consensus
|
||||
syscon stat S_IRWXU 00700 00700 00700 00700 00700 00700 # unix consensus
|
||||
|
||||
syscon stat S_IXGRP 00010 00010 00010 00010 00010 00010 # unix consensus
|
||||
syscon stat S_IWGRP 00020 00020 00020 00020 00020 00020 # unix consensus
|
||||
syscon stat S_IRGRP 00040 00040 00040 00040 00040 00040 # unix consensus
|
||||
syscon stat S_IRWXG 00070 00070 00070 00070 00070 00070 # unix consensus
|
||||
|
||||
syscon stat S_IXOTH 00001 00001 00001 00001 00001 00001 # unix consensus
|
||||
syscon stat S_IWOTH 00002 00002 00002 00002 00002 00002 # unix consensus
|
||||
syscon stat S_IROTH 00004 00004 00004 00004 00004 00004 # unix consensus
|
||||
syscon stat S_IRWXO 00007 00007 00007 00007 00007 00007 # unix consensus
|
||||
syscon stat S_IFREG 0100000 0100000 0100000 0100000 0100000 0100000 # regular file (unix consensus; faked nt)
|
||||
syscon stat S_IFBLK 0060000 0060000 0060000 0060000 0060000 0060000 # block device (unix consensus; faked nt)
|
||||
syscon stat S_IFCHR 0020000 0020000 0020000 0020000 0020000 0020000 # character device (unix consensus; faked nt)
|
||||
syscon stat S_IFDIR 0040000 0040000 0040000 0040000 0040000 0040000 # directory (unix consensus; faked nt)
|
||||
syscon stat S_IFIFO 0010000 0010000 0010000 0010000 0010000 0010000 # pipe (unix consensus; faked nt)
|
||||
syscon stat S_IFLNK 0120000 0120000 0120000 0120000 0120000 0120000 # symbolic link (unix consensus; faked nt)
|
||||
syscon stat S_IFSOCK 0140000 0140000 0140000 0140000 0140000 0140000 # socket (unix consensus; faked nt)
|
||||
syscon stat S_IFMT 0170000 0170000 0170000 0170000 0170000 0170000 # FILE TYPE MASK (unix consensus; faked nt)
|
||||
syscon stat S_ISVTX 0001000 0001000 0001000 0001000 0001000 0001000 # THE STICKY BIT (unix consensus; faked nt)
|
||||
syscon stat S_ISGID 0002000 0002000 0002000 0002000 0002000 0002000 # the setgid bit (unix consensus; faked nt)
|
||||
syscon stat S_ISUID 0004000 0004000 0004000 0004000 0004000 0004000 # the setuid bit (unix consensus; faked nt)
|
||||
syscon stat S_IEXEC 0000100 0000100 0000100 0000100 0000100 0000100 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IWRITE 0000200 0000200 0000200 0000200 0000200 0000200 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IREAD 0000400 0000400 0000400 0000400 0000400 0000400 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IXUSR 0000100 0000100 0000100 0000100 0000100 0000100 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IWUSR 0000200 0000200 0000200 0000200 0000200 0000200 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IRUSR 0000400 0000400 0000400 0000400 0000400 0000400 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IRWXU 0000700 0000700 0000700 0000700 0000700 0000700 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IXGRP 0000010 0000010 0000010 0000010 0000010 0000010 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IWGRP 0000020 0000020 0000020 0000020 0000020 0000020 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IRGRP 0000040 0000040 0000040 0000040 0000040 0000040 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IRWXG 0000070 0000070 0000070 0000070 0000070 0000070 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IXOTH 0000001 0000001 0000001 0000001 0000001 0000001 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IWOTH 0000002 0000002 0000002 0000002 0000002 0000002 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IROTH 0000004 0000004 0000004 0000004 0000004 0000004 # just use octal (unix consensus; faked nt)
|
||||
syscon stat S_IRWXO 0000007 0000007 0000007 0000007 0000007 0000007 # just use octal (unix consensus; faked nt)
|
||||
|
||||
# fcntl()
|
||||
#
|
||||
|
@ -428,17 +430,24 @@ syscon at AT_EACCESS 0x0200 0x10 0x0100 1 0x100 0
|
|||
syscon at AT_SYMLINK_FOLLOW 0x0400 0x40 0x0400 4 4 0
|
||||
syscon at AT_EMPTY_PATH 0x1000 0 0 0 0 0 # linux 2.6.39+; see unlink, O_TMPFILE, etc.
|
||||
|
||||
# memfd_create() flags
|
||||
#
|
||||
# Unsupported flags are encoded as 0.
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon memfd MFD_CLOEXEC 1 0 0 0 0 0
|
||||
syscon memfd MFD_ALLOW_SEALING 2 0 0 0 0 0
|
||||
|
||||
# utimensat()
|
||||
# utimensat() special values
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon utime UTIME_NOW 0x3fffffff 0x3fffffff -1 -2 0x3fffffff -2 # polyfilled xnu/nt
|
||||
syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -1 0x3ffffffe -1 # polyfilled xnu/nt
|
||||
syscon utime UTIME_NOW 0x3fffffff 0x3fffffff -1 -2 0x3fffffff -2 # timespec::tv_sec may be this; polyfilled xnu/nt
|
||||
syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -1 0x3ffffffe -1 # timespec::tv_nsec may be this; polyfilled xnu/nt
|
||||
|
||||
# getauxval() keys
|
||||
#
|
||||
# Unsupported values are encoded as 0.
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon auxv AT_EXECFD 2 0 2 0 2 0 # file descriptor of program
|
||||
syscon auxv AT_PHDR 3 0 3 0 3 0 # address of program headers of executable
|
||||
|
@ -468,81 +477,121 @@ syscon auxv AT_EXECFN 31 31 999 999 2014 31 # address of string c
|
|||
syscon auxv AT_SYSINFO_EHDR 33 0 0 0 0 0
|
||||
syscon auxv AT_NO_AUTOMOUNT 0x0800 0 0 0 0 0
|
||||
|
||||
# ptrace() codes
|
||||
# getrlimit() / setrlimit() resource parameter
|
||||
#
|
||||
# Unsupported values are encoded as 127.
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon ptrace PTRACE_TRACEME 0 0 0 0 -1 -1 # unix consensus a.k.a. PT_TRACE_ME
|
||||
syscon ptrace PTRACE_PEEKTEXT 1 1 1 1 -1 -1 # unix consensus a.k.a. PT_READ_I
|
||||
syscon ptrace PTRACE_PEEKDATA 2 2 2 2 -1 -1 # unix consensus a.k.a. PT_READ_D
|
||||
syscon ptrace PTRACE_PEEKUSER 3 3 -1 -1 -1 -1 # a.k.a. PT_READ_U
|
||||
syscon ptrace PTRACE_POKETEXT 4 4 4 4 -1 -1 # unix consensus a.k.a. PT_WRITE_I
|
||||
syscon ptrace PTRACE_POKEDATA 5 5 5 5 -1 -1 # unix consensus a.k.a. PT_WRITE_D
|
||||
syscon ptrace PTRACE_POKEUSER 6 6 -1 -1 -1 -1 # a.k.a. PT_WRITE_U
|
||||
syscon ptrace PTRACE_CONT 7 7 7 7 -1 -1 # unix consensus a.k.a. PT_CONTINUE
|
||||
syscon ptrace PTRACE_KILL 8 8 8 8 -1 -1 # unix consensus a.k.a. PT_KILL
|
||||
syscon ptrace PTRACE_SINGLESTEP 9 9 9 32 -1 -1 # a.k.a. PT_STEP
|
||||
syscon ptrace PTRACE_GETREGS 12 -1 33 33 -1 -1 # a.k.a. PT_GETREGS
|
||||
syscon ptrace PTRACE_SETREGS 13 -1 34 34 -1 -1 # a.k.a. PT_SETREGS
|
||||
syscon ptrace PTRACE_GETFPREGS 14 -1 35 35 -1 -1 # a.k.a. PT_GETFPREGS
|
||||
syscon ptrace PTRACE_SETFPREGS 15 -1 36 36 -1 -1 # a.k.a. PT_SETFPREGS
|
||||
syscon ptrace PTRACE_ATTACH 16 10 10 9 -1 -1 # a.k.a. PT_ATTACH
|
||||
syscon ptrace PTRACE_DETACH 17 11 11 10 -1 -1 # a.k.a. PT_DETACH
|
||||
syscon ptrace PTRACE_GETFPXREGS 18 -1 -1 -1 -1 -1 # a.k.a. PT_GETFPXREGS
|
||||
syscon ptrace PTRACE_SETFPXREGS 19 -1 -1 -1 -1 -1 # a.k.a. PT_SETFPXREGS
|
||||
syscon ptrace PTRACE_SYSCALL 24 -1 22 -1 -1 -1 # a.k.a. PT_SYSCALL
|
||||
syscon ptrace PTRACE_GETEVENTMSG 0x4201 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETSIGINFO 0x4202 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETOPTIONS 0x4200 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETSIGINFO 0x4203 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETREGSET 0x4204 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETSIGMASK 0x420a -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_INTERRUPT 0x4207 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_LISTEN 0x4208 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_PEEKSIGINFO 0x4209 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SECCOMP_GET_FILTER 0x420c -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SEIZE 0x4206 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETREGSET 0x4205 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETSIGMASK 0x420b -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACESYSGOOD 0x0001 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEFORK 0x0002 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEVFORK 0x0004 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACECLONE 0x0008 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEEXEC 0x0010 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEVFORKDONE 0x0020 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEEXIT 0x0040 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_MASK 0x007f -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_FORK 1 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_VFORK 2 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_CLONE 3 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_EXEC 4 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_VFORK_DONE 5 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_EXIT 6 -1 -1 -1 -1 -1
|
||||
syscon rlimit RLIMIT_CPU 0 0 0 0 0 127 # max cpu time in seconds; see SIGXCPU; unix consensus
|
||||
syscon rlimit RLIMIT_FSIZE 1 1 1 1 1 127 # max file size in bytes; unix consensus
|
||||
syscon rlimit RLIMIT_DATA 2 2 2 2 2 127 # max mmap() / brk() / sbrk() size in bytes; unix consensus
|
||||
syscon rlimit RLIMIT_STACK 3 3 3 3 3 127 # max stack size in bytes; see SIGXFSZ; unix consensus
|
||||
syscon rlimit RLIMIT_CORE 4 4 4 4 4 127 # max core file size in bytes; unix consensus
|
||||
syscon rlimit RLIMIT_RSS 5 5 5 5 5 127 # max physical memory size in bytes; see mmap()→ENOMEM; unix consensus
|
||||
syscon rlimit RLIMIT_NPROC 6 7 7 7 7 127 # max number of processes; see fork()→EAGAIN; bsd consensus
|
||||
syscon rlimit RLIMIT_NOFILE 7 8 8 8 8 127 # max number of open files; see accept()→EMFILE/ENFILE; bsd consensus
|
||||
syscon rlimit RLIMIT_MEMLOCK 8 6 6 6 6 127 # max locked-in-memory address space; bsd consensus
|
||||
syscon rlimit RLIMIT_AS 9 5 10 127 10 127 # max virtual memory size in bytes
|
||||
syscon rlimit RLIMIT_LOCKS 10 127 127 127 127 127 # max flock() / fcntl() locks; bsd consensus
|
||||
syscon rlimit RLIMIT_SIGPENDING 11 127 127 127 127 127 # max sigqueue() can enqueue; bsd consensus
|
||||
syscon rlimit RLIMIT_MSGQUEUE 12 127 127 127 127 127 # meh posix message queues; bsd consensus
|
||||
syscon rlimit RLIMIT_NICE 13 127 127 127 127 127 # max scheduling priority; 𝑥 ∈ [1,40]; niceness is traditionally displayed as as 𝟸𝟶-𝑥, therefore 𝑥=1 (lowest priority) prints as 19 and 𝑥=40 (highest priority) prints as -20; bsd consensus
|
||||
syscon rlimit RLIMIT_RTPRIO 14 127 127 127 127 127 # bsd consensus
|
||||
syscon compat RLIMIT_VMEM 9 5 10 127 10 127 # same as RLIMIT_AS
|
||||
|
||||
# resource limit special values
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon rlim RLIM_NLIMITS 16 9 15 9 12 0 # no clue why we need it
|
||||
syscon rlim RLIM_INFINITY 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0
|
||||
syscon rlim RLIM_SAVED_CUR 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0
|
||||
syscon rlim RLIM_SAVED_MAX 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0
|
||||
|
||||
# sigaction() codes
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon sigact SA_RESTORER 0x04000000 0 0 0 0 0
|
||||
syscon sigact SA_ONSTACK 0x08000000 1 1 1 1 0 # bsd consensus
|
||||
syscon sigact SA_RESTART 0x10000000 2 2 2 2 0 # bsd consensus
|
||||
syscon sigact SA_NOCLDSTOP 1 8 8 8 8 0 # bsd consensus
|
||||
syscon sigact SA_NOCLDWAIT 2 0x20 0x20 0x20 0x20 0 # bsd consensus
|
||||
syscon sigact SA_SIGINFO 4 0x40 0x40 0x40 0x40 0 # bsd consensus
|
||||
syscon sigact SA_NODEFER 0x40000000 0x10 0x10 0x10 0x10 0 # bsd consensus
|
||||
syscon sigact SA_NOMASK 0x40000000 0x10 0x10 0x10 0x10 0 # linux/obsolete
|
||||
syscon sigact SA_RESETHAND 0x80000000 4 4 4 4 0 # bsd consensus
|
||||
syscon sigact SA_ONESHOT 0x80000000 0 0 0 0 0
|
||||
syscon sigact SA_NOCLDSTOP 1 8 8 8 8 1 # lets you set SIGCHLD handler that's only notified on exit/termination and not notified on SIGSTOP/SIGTSTP/SIGTTIN/SIGTTOU/SIGCONT lool; bsd consensus
|
||||
syscon sigact SA_NOCLDWAIT 2 32 32 32 32 2 # changes SIGCHLD so the zombie is gone and you can't call wait(2) anymore; similar to SIGCHLD+SIG_IGN but may still deliver the SIGCHLD; bsd consensus
|
||||
syscon sigact SA_SIGINFO 4 64 64 64 64 4 # asks kernel to provide ucontext_t argument, which has mutable cpu/fpu state of signalled process; and it is polyfilled by cosmopolitan; bsd consensus
|
||||
syscon sigact SA_ONSTACK 0x08000000 1 1 1 1 0x08000000 # causes signal handler to be called on stack provided by sigaltstack(2); bsd consensus
|
||||
syscon sigact SA_RESTART 0x10000000 2 2 2 2 0x10000000 # prevents signal delivery from triggering EINTR on i/o calls (e.g. read/write/open/wait/accept) but doesn't impact non-i/o blocking calls (e.g. poll, sigsuspend, nanosleep) which will still EINTR; bsd consensus
|
||||
syscon sigact SA_NODEFER 0x40000000 16 16 16 16 0x40000000 # blocks signal delivery during signal handling (i.e. lets you use longjmp() in the signal handler); bsd consensus
|
||||
syscon sigact SA_RESETHAND 0x80000000 4 4 4 4 0x80000000 # causes signal handler to be called at most once and then set to SIG_DFL automatically; bsd consensus
|
||||
syscon compat SA_NOMASK 0x40000000 16 16 16 16 0x40000000 # same as SA_NODEFER
|
||||
syscon compat SA_ONESHOT 0x80000000 4 4 4 4 0x80000000 # same as SA_RESETHAND
|
||||
|
||||
# siginfo::si_code values
|
||||
#
|
||||
# Windows NT is polyfilled as Linux.
|
||||
# Unsupported values are encoded as 0x80000000.
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon sicode SI_USER 0 0x010001 0x010001 0 0 0 # sent by kill(2); openbsd defines si_code<=0 as originating from user
|
||||
syscon sicode SI_QUEUE -1 0x010002 0x010002 -2 -1 -1 # sent by sigqueue(2)
|
||||
syscon sicode SI_TIMER -2 0x010003 0x010003 -3 -2 -2 # sent by setitimer(2) or clock_settime(2)
|
||||
syscon sicode SI_TKILL -6 0x80000000 0x010007 -1 -5 -6 # sent by tkill(2) or tgkill(2) or thr_kill(2) or lwp_kill(2) or _lwp_kill(2); cries
|
||||
syscon sicode SI_MESGQ -3 0x010005 0x010005 0x80000000 -4 -3 # sent by mq_notify(2); lool
|
||||
syscon sicode SI_ASYNCIO -4 0x010004 0x010004 0x80000000 -3 -4 # aio completion; no thank you
|
||||
syscon sicode SI_ASYNCNL -60 0x80000000 0x80000000 0x80000000 0x80000000 0x80000000 # aio completion for dns; the horror
|
||||
syscon sicode SI_KERNEL 0x80 0x80000000 0x010006 0x80000000 0x80000000 0x80 # wut; openbsd defines as si_code>0
|
||||
syscon sicode SI_NOINFO 32767 0x80000000 0 32767 32767 32767 # no signal specific info available
|
||||
syscon sicode CLD_EXITED 1 1 1 1 1 1 # SIGCHLD; child exited; unix consensus
|
||||
syscon sicode CLD_KILLED 2 2 2 2 2 2 # SIGCHLD; child terminated w/o core; unix consensus
|
||||
syscon sicode CLD_DUMPED 3 3 3 3 3 3 # SIGCHLD; child terminated w/ core; unix consensus
|
||||
syscon sicode CLD_TRAPPED 4 4 4 4 4 4 # SIGCHLD; traced child trapped; unix consensus
|
||||
syscon sicode CLD_STOPPED 5 5 5 5 5 5 # SIGCHLD; child stopped; unix consensus
|
||||
syscon sicode CLD_CONTINUED 6 6 6 6 6 6 # SIGCHLD; stopped child continued; unix consensus
|
||||
syscon sicode TRAP_BRKPT 1 1 1 1 1 1 # SIGTRAP; unix consensus
|
||||
syscon sicode TRAP_TRACE 2 2 2 2 2 2 # SIGTRAP; unix consensus
|
||||
syscon sicode SEGV_MAPERR 1 1 1 1 1 1 # SIGSEGV; unix consensus
|
||||
syscon sicode SEGV_ACCERR 2 2 2 2 2 2 # SIGSEGV; unix consensus
|
||||
syscon sicode FPE_INTDIV 1 7 2 1 1 1 # SIGFPE; integer divide by zero
|
||||
syscon sicode FPE_INTOVF 2 8 1 2 2 2 # SIGFPE; integer overflow
|
||||
syscon sicode FPE_FLTDIV 3 1 3 3 3 3 # SIGFPE; floating point divide by zero
|
||||
syscon sicode FPE_FLTOVF 4 2 4 4 4 4 # SIGFPE; floating point overflow
|
||||
syscon sicode FPE_FLTUND 5 3 5 5 5 5 # SIGFPE; floating point underflow
|
||||
syscon sicode FPE_FLTRES 6 4 6 6 6 6 # SIGFPE; floating point inexact
|
||||
syscon sicode FPE_FLTINV 7 5 7 7 7 7 # SIGFPE; invalid floating point operation
|
||||
syscon sicode FPE_FLTSUB 8 6 8 8 8 8 # SIGFPE; subscript out of range
|
||||
syscon sicode ILL_ILLOPC 1 1 1 1 1 1 # SIGILL; illegal opcode; unix consensus
|
||||
syscon sicode ILL_ILLOPN 2 4 2 2 2 2 # SIGILL; illegal operand
|
||||
syscon sicode ILL_ILLADR 3 5 3 3 3 3 # SIGILL; illegal addressing mode
|
||||
syscon sicode ILL_ILLTRP 4 2 4 4 4 4 # SIGILL; illegal trap
|
||||
syscon sicode ILL_PRVOPC 5 3 5 5 5 5 # SIGILL; privileged opcode
|
||||
syscon sicode ILL_PRVREG 6 6 6 6 6 6 # SIGILL; privileged register; unix consensus
|
||||
syscon sicode ILL_COPROC 7 7 7 7 7 7 # SIGILL; coprocessor error; unix consensus
|
||||
syscon sicode ILL_BADSTK 8 8 8 8 8 8 # SIGILL; internal stack error; unix consensus
|
||||
syscon sicode BUS_ADRALN 1 1 1 1 1 1 # SIGBUS; invalid address alignment; unix consensus
|
||||
syscon sicode BUS_ADRERR 2 2 2 2 2 2 # SIGBUS; non-existent physical address; unix consensus
|
||||
syscon sicode BUS_OBJERR 3 3 3 3 3 3 # SIGBUS; object specific hardware error; unix consensus
|
||||
syscon sicode BUS_MCEERR_AR 4 0x80000000 0x80000000 0x80000000 0x80000000 0x80000000 # SIGBUS; Linux 2.6.32+
|
||||
syscon sicode BUS_MCEERR_AO 5 0x80000000 0x80000000 0x80000000 0x80000000 0x80000000 # SIGBUS; Linux 2.6.32+
|
||||
syscon sicode POLL_IN 1 1 1 1 1 1 # SIGIO; data input available; unix consensus
|
||||
syscon sicode POLL_OUT 2 2 2 2 2 2 # SIGIO; output buffer available; unix consensus
|
||||
syscon sicode POLL_MSG 3 3 3 3 3 3 # SIGIO; input message available; unix consensus
|
||||
syscon sicode POLL_ERR 4 4 4 4 4 4 # SIGIO; i/o error; unix consensus
|
||||
syscon sicode POLL_PRI 5 5 5 5 5 5 # SIGIO; high priority input available; unix consensus
|
||||
syscon sicode POLL_HUP 6 6 6 6 6 6 # SIGIO; device disconnected; unix consensus
|
||||
|
||||
# sigalstack() values
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon ss SIGSTKSZ 0x2000 0x020000 0x8800 0x7000 0x7000 0x2000
|
||||
|
||||
# clock_{gettime,settime} timers
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon clock CLOCK_REALTIME 0 0 0 0 0 0 # consensus
|
||||
syscon clock CLOCK_MONOTONIC 1 1 4 3 3 1 # XNU/NT faked
|
||||
syscon clock CLOCK_PROCESS_CPUTIME_ID 2 0 15 2 0x40000000 0
|
||||
syscon clock CLOCK_THREAD_CPUTIME_ID 3 0 14 4 0x20000000 0
|
||||
syscon clock CLOCK_MONOTONIC_RAW 4 4 0x4000 0x4000 0x4000 4 # XNU/NT/FreeBSD/OpenBSD faked, not available on RHEL5
|
||||
syscon clock CLOCK_REALTIME_COARSE 5 0 0 0 0 0 # bsd consensus
|
||||
syscon clock CLOCK_MONOTONIC_COARSE 6 0 0 0 0 0 # bsd consensus
|
||||
syscon clock CLOCK_BOOTTIME 7 0 0 6 6 0
|
||||
syscon clock CLOCK_REALTIME_ALARM 8 0 0 0 0 0 # bsd consensus
|
||||
syscon clock CLOCK_BOOTTIME_ALARM 9 0 0 0 0 0 # bsd consensus
|
||||
syscon clock CLOCK_TAI 11 0 0 0 0 0 # bsd consensus
|
||||
syscon clock CLOCK_MONOTONIC 1 1 4 3 3 1 # XNU/NT faked; could move backwards if NTP introduces negative leap second
|
||||
syscon clock CLOCK_PROCESS_CPUTIME_ID 2 -1 15 2 0x40000000 -1
|
||||
syscon clock CLOCK_THREAD_CPUTIME_ID 3 -1 14 4 0x20000000 -1
|
||||
syscon clock CLOCK_MONOTONIC_RAW 4 4 0x4000 0x4000 0x4000 4 # actually monotonic; not subject to NTP adjustments; Linux 2.6.28+; XNU/NT/FreeBSD/OpenBSD faked; not available on RHEL5
|
||||
syscon clock CLOCK_REALTIME_COARSE 5 -1 -1 -1 -1 -1 # Linux 2.6.32+; bsd consensus; not available on RHEL5
|
||||
syscon clock CLOCK_MONOTONIC_COARSE 6 -1 -1 -1 -1 -1 # Linux 2.6.32+; bsd consensus; not available on RHEL5
|
||||
syscon clock CLOCK_BOOTTIME 7 -1 -1 6 6 -1
|
||||
syscon clock CLOCK_REALTIME_ALARM 8 -1 -1 -1 -1 -1 # bsd consensus
|
||||
syscon clock CLOCK_BOOTTIME_ALARM 9 -1 -1 -1 -1 -1 # bsd consensus
|
||||
syscon clock CLOCK_TAI 11 -1 -1 -1 -1 -1 # bsd consensus
|
||||
|
||||
# epoll
|
||||
#
|
||||
|
@ -586,7 +635,7 @@ syscon so SO_OOBINLINE 10 0x0100 0x0100 0x0100 0x0100 0x0100 # bs
|
|||
syscon so SO_SNDBUF 7 0x1001 0x1001 0x1001 0x1001 0x1001 # bsd consensus
|
||||
syscon so SO_RCVBUF 8 0x1002 0x1002 0x1002 0x1002 0x1002 # bsd consensus
|
||||
syscon so SO_RCVLOWAT 18 0x1004 0x1004 0x1004 0x1004 0x1004 # bsd consensus
|
||||
syscon so SO_RCVTIMEO 20 0x1006 0x1006 0x1006 0x100c 0x1006 # bsd consensus
|
||||
syscon so SO_RCVTIMEO 20 0x1006 0x1006 0x1006 0x100c 0x1006 # overrides SA_RESTART restoring EINTR behavior on recv/send/connect/accept/etc.; bsd consensus
|
||||
syscon so SO_EXCLUSIVEADDRUSE 0 0 0 0 0 0xfffffffb # hoo boy
|
||||
syscon so SO_SNDLOWAT 19 0x1003 0x1003 0x1003 0x1003 0x1003 # bsd consensus
|
||||
syscon so SO_SNDTIMEO 21 0x1005 0x1005 0x1005 0x100b 0x1005 # bsd consensus
|
||||
|
@ -699,6 +748,56 @@ syscon tcp TCP_REPAIR_OPTIONS 22 0 0 0 0 0 # what is it
|
|||
syscon tcp TCP_REPAIR_QUEUE 20 0 0 0 0 0 # what is it
|
||||
syscon tcp TCP_THIN_LINEAR_TIMEOUTS 16 0 0 0 0 0 # what is it
|
||||
|
||||
# ptrace() codes
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon ptrace PTRACE_TRACEME 0 0 0 0 -1 -1 # unix consensus a.k.a. PT_TRACE_ME
|
||||
syscon ptrace PTRACE_PEEKTEXT 1 1 1 1 -1 -1 # unix consensus a.k.a. PT_READ_I
|
||||
syscon ptrace PTRACE_PEEKDATA 2 2 2 2 -1 -1 # unix consensus a.k.a. PT_READ_D
|
||||
syscon ptrace PTRACE_PEEKUSER 3 3 -1 -1 -1 -1 # a.k.a. PT_READ_U
|
||||
syscon ptrace PTRACE_POKETEXT 4 4 4 4 -1 -1 # unix consensus a.k.a. PT_WRITE_I
|
||||
syscon ptrace PTRACE_POKEDATA 5 5 5 5 -1 -1 # unix consensus a.k.a. PT_WRITE_D
|
||||
syscon ptrace PTRACE_POKEUSER 6 6 -1 -1 -1 -1 # a.k.a. PT_WRITE_U
|
||||
syscon ptrace PTRACE_CONT 7 7 7 7 -1 -1 # unix consensus a.k.a. PT_CONTINUE
|
||||
syscon ptrace PTRACE_KILL 8 8 8 8 -1 -1 # unix consensus a.k.a. PT_KILL
|
||||
syscon ptrace PTRACE_SINGLESTEP 9 9 9 32 -1 -1 # a.k.a. PT_STEP
|
||||
syscon ptrace PTRACE_GETREGS 12 -1 33 33 -1 -1 # a.k.a. PT_GETREGS
|
||||
syscon ptrace PTRACE_SETREGS 13 -1 34 34 -1 -1 # a.k.a. PT_SETREGS
|
||||
syscon ptrace PTRACE_GETFPREGS 14 -1 35 35 -1 -1 # a.k.a. PT_GETFPREGS
|
||||
syscon ptrace PTRACE_SETFPREGS 15 -1 36 36 -1 -1 # a.k.a. PT_SETFPREGS
|
||||
syscon ptrace PTRACE_ATTACH 16 10 10 9 -1 -1 # a.k.a. PT_ATTACH
|
||||
syscon ptrace PTRACE_DETACH 17 11 11 10 -1 -1 # a.k.a. PT_DETACH
|
||||
syscon ptrace PTRACE_GETFPXREGS 18 -1 -1 -1 -1 -1 # a.k.a. PT_GETFPXREGS
|
||||
syscon ptrace PTRACE_SETFPXREGS 19 -1 -1 -1 -1 -1 # a.k.a. PT_SETFPXREGS
|
||||
syscon ptrace PTRACE_SYSCALL 24 -1 22 -1 -1 -1 # a.k.a. PT_SYSCALL
|
||||
syscon ptrace PTRACE_GETEVENTMSG 0x4201 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETSIGINFO 0x4202 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETOPTIONS 0x4200 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETSIGINFO 0x4203 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETREGSET 0x4204 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_GETSIGMASK 0x420a -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_INTERRUPT 0x4207 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_LISTEN 0x4208 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_PEEKSIGINFO 0x4209 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SECCOMP_GET_FILTER 0x420c -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SEIZE 0x4206 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETREGSET 0x4205 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_SETSIGMASK 0x420b -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACESYSGOOD 0x0001 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEFORK 0x0002 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEVFORK 0x0004 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACECLONE 0x0008 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEEXEC 0x0010 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEVFORKDONE 0x0020 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_TRACEEXIT 0x0040 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_O_MASK 0x007f -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_FORK 1 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_VFORK 2 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_CLONE 3 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_EXEC 4 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_VFORK_DONE 5 -1 -1 -1 -1 -1
|
||||
syscon ptrace PTRACE_EVENT_EXIT 6 -1 -1 -1 -1 -1
|
||||
|
||||
syscon iproto IPPROTO_IP 0 0 0 0 0 0 # consensus
|
||||
syscon iproto IPPROTO_ICMP 1 1 1 1 1 1 # consensus
|
||||
syscon iproto IPPROTO_TCP 6 6 6 6 6 6 # consensus
|
||||
|
@ -1318,13 +1417,6 @@ syscon poll POLLWRBAND 0x0200 0x0100 0x0100 0x0100 0x0100 0x20 #
|
|||
syscon poll POLLWRNORM 0x0100 4 4 4 4 0x10 # bsd consensus
|
||||
syscon poll POLLRDHUP 0x2000 0x10 0x10 0x10 0x10 2 # bsd consensus (POLLHUP on non-Linux)
|
||||
|
||||
syscon sigpoll POLL_ERR 4 4 4 0 0 0
|
||||
syscon sigpoll POLL_HUP 6 6 6 0 0 0
|
||||
syscon sigpoll POLL_IN 1 1 1 0 0 0
|
||||
syscon sigpoll POLL_MSG 3 3 3 0 0 0
|
||||
syscon sigpoll POLL_OUT 2 2 2 0 0 0
|
||||
syscon sigpoll POLL_PRI 5 5 5 0 0 0
|
||||
|
||||
syscon c C_IXOTH 0000001 0000001 0000001 0000001 0000001 0 # unix consensus
|
||||
syscon c C_IWOTH 0000002 0000002 0000002 0000002 0000002 0 # unix consensus
|
||||
syscon c C_IROTH 0000004 0000004 0000004 0000004 0000004 0 # unix consensus
|
||||
|
@ -1547,23 +1639,6 @@ syscon nd ND_ROUTER_ADVERT 134 134 134 134 134 0 # unix consensus
|
|||
syscon nd ND_ROUTER_SOLICIT 133 133 133 133 133 0 # unix consensus
|
||||
syscon nd ND_RA_FLAG_HOME_AGENT 0x20 0 0 0 0 0x20 # bsd consensus
|
||||
|
||||
syscon rlim RLIMIT_CPU 0 0 0 0 0 127 # unix consensus
|
||||
syscon rlim RLIMIT_FSIZE 1 1 1 1 1 127 # unix consensus
|
||||
syscon rlim RLIMIT_DATA 2 2 2 2 2 127 # unix consensus
|
||||
syscon rlim RLIMIT_STACK 3 3 3 3 3 127 # unix consensus
|
||||
syscon rlim RLIMIT_CORE 4 4 4 4 4 127 # unix consensus
|
||||
syscon rlim RLIMIT_RSS 5 5 5 5 5 127 # unix consensus
|
||||
syscon rlim RLIMIT_NPROC 6 7 7 7 7 127 # bsd consensus
|
||||
syscon rlim RLIMIT_NOFILE 7 8 8 8 8 127 # bsd consensus
|
||||
syscon rlim RLIMIT_MEMLOCK 8 6 6 6 6 127 # bsd consensus
|
||||
syscon rlim RLIMIT_AS 9 5 10 127 127 127
|
||||
syscon rlim RLIMIT_LOCKS 10 127 127 127 127 127 # bsd consensus
|
||||
syscon rlim RLIMIT_SIGPENDING 11 127 127 127 127 127 # bsd consensus
|
||||
syscon rlim RLIMIT_MSGQUEUE 12 127 127 127 127 127 # bsd consensus
|
||||
syscon rlim RLIMIT_NICE 13 127 127 127 127 127 # bsd consensus
|
||||
syscon rlim RLIMIT_RTPRIO 14 127 127 127 127 127 # bsd consensus
|
||||
syscon rlim RLIMIT_NLIMITS 16 127 127 127 127 127 # bsd consensus
|
||||
|
||||
syscon misc TCFLSH 0x540b 0 0 0 0 0
|
||||
syscon misc TCIFLUSH 0 1 1 1 1 0 # bsd consensus
|
||||
syscon misc TCIOFF 2 3 3 3 3 0 # bsd consensus
|
||||
|
@ -1771,13 +1846,7 @@ syscon misc SCSI_IOCTL_SYNC 4 0 0 0 0 0
|
|||
syscon misc SCSI_IOCTL_TAGGED_DISABLE 0x5384 0 0 0 0 0
|
||||
syscon misc SCSI_IOCTL_TAGGED_ENABLE 0x5383 0 0 0 0 0
|
||||
syscon misc SCSI_IOCTL_TEST_UNIT_READY 2 0 0 0 0 0
|
||||
|
||||
syscon misc CLD_CONTINUED 6 6 6 6 6 6 # unix consensus
|
||||
syscon misc CLD_DUMPED 3 3 3 3 3 3 # unix consensus
|
||||
syscon misc CLD_EXITED 1 1 1 1 1 1 # unix consensus
|
||||
syscon misc CLD_KILLED 2 2 2 2 2 2 # unix consensus
|
||||
syscon misc CLD_STOPPED 5 5 5 5 5 5 # unix consensus
|
||||
syscon misc CLD_TRAPPED 4 4 4 4 4 4 # unix consensus
|
||||
syscon misc BUS_DEVICE_RESET 12 0 0 0 0 0 # SIGBUS;
|
||||
|
||||
syscon misc READ_10 40 0 0 0 0 0
|
||||
syscon misc READ_12 168 0 0 0 0 0
|
||||
|
@ -1838,15 +1907,6 @@ syscon misc WRITE_SAME 65 0 0 0 0 0
|
|||
syscon misc WRITE_VERIFY 46 0 0 0 0 0
|
||||
syscon misc WRITE_VERIFY_12 174 0 0 0 0 0
|
||||
|
||||
syscon misc ILL_BADSTK 8 8 8 8 8 0 # unix consensus
|
||||
syscon misc ILL_COPROC 7 7 7 7 7 0 # unix consensus
|
||||
syscon misc ILL_ILLOPC 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc ILL_PRVREG 6 6 6 6 6 0 # unix consensus
|
||||
syscon misc ILL_ILLADR 3 5 3 3 3 0
|
||||
syscon misc ILL_ILLOPN 2 4 2 2 2 0
|
||||
syscon misc ILL_ILLTRP 4 2 4 4 4 0
|
||||
syscon misc ILL_PRVOPC 5 3 5 5 5 0
|
||||
|
||||
syscon lock LOCK_UNLOCK_CACHE 54 0 0 0 0 0 # wut
|
||||
|
||||
syscon misc ARPHRD_ETHER 1 1 1 1 1 0 # unix consensus
|
||||
|
@ -1858,13 +1918,6 @@ syscon misc ARPHRD_IEEE802154 804 0 0 0 0 0
|
|||
syscon misc ARPHRD_IEEE802_TR 800 0 0 0 0 0
|
||||
syscon misc ARPHRD_LOCALTLK 773 0 0 0 0 0
|
||||
|
||||
syscon misc BUS_ADRALN 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc BUS_ADRERR 2 2 2 2 2 0 # unix consensus
|
||||
syscon misc BUS_OBJERR 3 3 3 3 3 0 # unix consensus
|
||||
syscon misc BUS_DEVICE_RESET 12 0 0 0 0 0
|
||||
syscon misc BUS_MCEERR_AO 5 0 0 0 0 0
|
||||
syscon misc BUS_MCEERR_AR 4 0 0 0 0 0
|
||||
|
||||
syscon misc IP6F_MORE_FRAG 0x0100 0x0100 0x0100 0x0100 0x0100 0x0100 # consensus
|
||||
syscon misc IP6F_OFF_MASK 0xf8ff 0xf8ff 0xf8ff 0xf8ff 0xf8ff 0xf8ff # consensus
|
||||
syscon misc IP6F_RESERVED_MASK 0x0600 0x0600 0x0600 0x0600 0x0600 0x0600 # consensus
|
||||
|
@ -1954,17 +2007,6 @@ syscon misc SEARCH_HIGH_12 176 0 0 0 0 0
|
|||
syscon misc SEARCH_LOW 50 0 0 0 0 0
|
||||
syscon misc SEARCH_LOW_12 178 0 0 0 0 0
|
||||
|
||||
syscon misc SI_QUEUE -1 0x010002 0x010002 -2 -2 0
|
||||
syscon misc SI_TIMER -2 0x010003 0x010003 -3 -3 0
|
||||
syscon misc SI_ASYNCIO -4 0x010004 0x010004 0 0 0
|
||||
syscon misc SI_MESGQ -3 0x010005 0x010005 0 0 0
|
||||
syscon misc SI_KERNEL 0x80 0 0x010006 0 0 0
|
||||
syscon misc SI_USER 0 0x010001 0x010001 0 0 0
|
||||
syscon misc SI_ASYNCNL -60 0 0 0 0 0
|
||||
syscon misc SI_LOAD_SHIFT 0x10 0 0 0 0 0
|
||||
syscon misc SI_SIGIO -5 0 0 0 0 0
|
||||
syscon misc SI_TKILL -6 0 0 0 0 0
|
||||
|
||||
syscon misc STRU_F 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc STRU_P 3 3 3 3 3 0 # unix consensus
|
||||
syscon misc STRU_R 2 2 2 2 2 0 # unix consensus
|
||||
|
@ -2050,12 +2092,6 @@ syscon misc SCHED_BATCH 3 0 0 0 0 0
|
|||
syscon misc SCHED_IDLE 5 0 0 0 0 0
|
||||
syscon misc SCHED_RESET_ON_FORK 0x40000000 0 0 0 0 0
|
||||
|
||||
syscon misc SEGV_ACCERR 2 2 2 2 2 0 # unix consensus
|
||||
syscon misc SEGV_MAPERR 1 1 1 1 1 0 # unix consensus
|
||||
|
||||
syscon misc TRAP_BRKPT 1 1 1 1 1 0 # unix consensus
|
||||
syscon misc TRAP_TRACE 2 2 2 2 2 0 # unix consensus
|
||||
|
||||
syscon misc WRDE_APPEND 0 1 1 0 0 0
|
||||
syscon misc WRDE_BADCHAR 0 1 1 0 0 0
|
||||
syscon misc WRDE_BADVAL 0 2 2 0 0 0
|
||||
|
@ -2112,14 +2148,6 @@ syscon misc TFD_NONBLOCK 0x0800 0 0 0 0 0
|
|||
syscon misc TFD_TIMER_ABSTIME 1 0 0 0 0 0
|
||||
|
||||
syscon misc USRQUOTA 0 0 0 0 0 0
|
||||
syscon misc FPE_FLTDIV 3 1 3 3 3 0
|
||||
syscon misc FPE_FLTINV 7 5 7 7 7 0
|
||||
syscon misc FPE_FLTOVF 4 2 4 4 4 0
|
||||
syscon misc FPE_FLTRES 6 4 6 6 6 0
|
||||
syscon misc FPE_FLTSUB 8 6 8 8 8 0
|
||||
syscon misc FPE_FLTUND 5 3 5 5 5 0
|
||||
syscon misc FPE_INTDIV 1 7 2 1 1 0
|
||||
syscon misc FPE_INTOVF 2 8 1 2 2 0
|
||||
|
||||
syscon misc ABDAY_1 0x020000 14 14 13 13 0
|
||||
syscon misc ABDAY_2 0x020001 15 15 14 14 0
|
||||
|
@ -2287,11 +2315,6 @@ syscon misc BC_DIM_MAX 0x0800 0x0800 0x0800 0xffff 0xffff 0
|
|||
syscon misc BC_SCALE_MAX 99 99 99 0x7fffffff 0x7fffffff 0
|
||||
syscon misc BC_STRING_MAX 0x03e8 0x03e8 0x03e8 0x7fffffff 0x7fffffff 0
|
||||
|
||||
syscon misc RLIM_NLIMITS 0x10 9 15 9 9 0
|
||||
syscon misc RLIM_INFINITY -1 0 0x7fffffffffffffff 0 0 0
|
||||
syscon misc RLIM_SAVED_CUR -1 0 0x7fffffffffffffff 0 0 0
|
||||
syscon misc RLIM_SAVED_MAX -1 0 0x7fffffffffffffff 0 0 0
|
||||
|
||||
syscon misc ABORTED_COMMAND 11 0 0 0 0 0
|
||||
syscon misc ACORE 0 8 8 8 8 0 # bsd consensus
|
||||
syscon misc AFORK 0 1 1 1 1 0 # bsd consensus
|
||||
|
@ -2512,22 +2535,22 @@ syscon termios VDISCARD 13 15 15 15 15 0 # termios.c_cc[VDISCARD]
|
|||
syscon termios VWERASE 14 4 4 4 4 0 # termios.c_cc[VWERASE]=𝑥
|
||||
syscon termios VLNEXT 15 14 14 14 14 0 # termios.c_cc[VLNEXT]=𝑥
|
||||
|
||||
syscon termios TIOCSERGETLSR 0x5459 0 0 0 0 0 #
|
||||
syscon termios TIOCSERGETMULTI 0x545a 0 0 0 0 0 #
|
||||
syscon termios TIOCSERSETMULTI 0x545b 0 0 0 0 0 #
|
||||
syscon termios TIOCSER_TEMT 1 0 0 0 0 0 #
|
||||
syscon termios TIOCSERGETLSR 0x5459 0 0 0 0 0 #
|
||||
syscon termios TIOCSERGETMULTI 0x545a 0 0 0 0 0 #
|
||||
syscon termios TIOCSERSETMULTI 0x545b 0 0 0 0 0 #
|
||||
syscon termios TIOCSER_TEMT 1 0 0 0 0 0 #
|
||||
syscon termios VERIFY 47 0 0 0 0 0
|
||||
syscon termios PARENB 0x0100 0x1000 0x1000 0x1000 0x1000 0 #
|
||||
syscon termios PARODD 0x0200 0x2000 0x2000 0x2000 0x2000 0 #
|
||||
syscon termios PARENB 0x0100 0x1000 0x1000 0x1000 0x1000 0 #
|
||||
syscon termios PARODD 0x0200 0x2000 0x2000 0x2000 0x2000 0 #
|
||||
syscon termios CIBAUD 0x100f0000 0 0 0 0 0
|
||||
syscon termios CLOCAL 0x0800 0x8000 0x8000 0x8000 0x8000 0 #
|
||||
syscon termios CLOCAL 0x0800 0x8000 0x8000 0x8000 0x8000 0 #
|
||||
syscon termios CMSPAR 0x40000000 0 0 0 0 0
|
||||
syscon termios BUSY 4 0 0 0 0 0
|
||||
syscon termios CANBSIZ 255 0 0 0 0 0
|
||||
syscon termios CBAUD 0x100f 0 0 0 0 0
|
||||
syscon termios CBAUDEX 0x1000 0 0 0 0 0
|
||||
syscon termios CBRK 0 255 255 255 255 0 #
|
||||
syscon termios CEOL 0 255 255 255 255 0 #
|
||||
syscon termios CBRK 0 255 255 255 255 0 #
|
||||
syscon termios CEOL 0 255 255 255 255 0 #
|
||||
|
||||
# Pseudoteletypewriter Control
|
||||
#
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,BUS_ADRALN,1,1,1,1,1,0
|
||||
.syscon sicode,BUS_ADRALN,1,1,1,1,1,1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,BUS_ADRERR,2,2,2,2,2,0
|
||||
.syscon sicode,BUS_ADRERR,2,2,2,2,2,2
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,BUS_MCEERR_AO,5,0,0,0,0,0
|
||||
.syscon sicode,BUS_MCEERR_AO,5,0x80000000,0x80000000,0x80000000,0x80000000,0x80000000
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,BUS_MCEERR_AR,4,0,0,0,0,0
|
||||
.syscon sicode,BUS_MCEERR_AR,4,0x80000000,0x80000000,0x80000000,0x80000000,0x80000000
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,BUS_OBJERR,3,3,3,3,3,0
|
||||
.syscon sicode,BUS_OBJERR,3,3,3,3,3,3
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_CONTINUED,6,6,6,6,6,6
|
||||
.syscon sicode,CLD_CONTINUED,6,6,6,6,6,6
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_DUMPED,3,3,3,3,3,3
|
||||
.syscon sicode,CLD_DUMPED,3,3,3,3,3,3
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_EXITED,1,1,1,1,1,1
|
||||
.syscon sicode,CLD_EXITED,1,1,1,1,1,1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_KILLED,2,2,2,2,2,2
|
||||
.syscon sicode,CLD_KILLED,2,2,2,2,2,2
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_STOPPED,5,5,5,5,5,5
|
||||
.syscon sicode,CLD_STOPPED,5,5,5,5,5,5
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon misc,CLD_TRAPPED,4,4,4,4,4,4
|
||||
.syscon sicode,CLD_TRAPPED,4,4,4,4,4,4
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_BOOTTIME,7,0,0,6,6,0
|
||||
.syscon clock,CLOCK_BOOTTIME,7,-1,-1,6,6,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_BOOTTIME_ALARM,9,0,0,0,0,0
|
||||
.syscon clock,CLOCK_BOOTTIME_ALARM,9,-1,-1,-1,-1,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_MONOTONIC_COARSE,6,0,0,0,0,0
|
||||
.syscon clock,CLOCK_MONOTONIC_COARSE,6,-1,-1,-1,-1,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_PROCESS_CPUTIME_ID,2,0,15,2,0x40000000,0
|
||||
.syscon clock,CLOCK_PROCESS_CPUTIME_ID,2,-1,15,2,0x40000000,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_REALTIME_ALARM,8,0,0,0,0,0
|
||||
.syscon clock,CLOCK_REALTIME_ALARM,8,-1,-1,-1,-1,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_REALTIME_COARSE,5,0,0,0,0,0
|
||||
.syscon clock,CLOCK_REALTIME_COARSE,5,-1,-1,-1,-1,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_TAI,11,0,0,0,0,0
|
||||
.syscon clock,CLOCK_TAI,11,-1,-1,-1,-1,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon clock,CLOCK_THREAD_CPUTIME_ID,3,0,14,4,0x20000000,0
|
||||
.syscon clock,CLOCK_THREAD_CPUTIME_ID,3,-1,14,4,0x20000000,-1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EADV,68,0,0,0,0,0
|
||||
.syscon junkerr,EADV,68,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EBADE,52,0,0,0,0,0
|
||||
.syscon junkerr,EBADE,52,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EBADFD,77,9,9,9,9,6
|
||||
.syscon junkerr,EBADFD,77,9,9,9,9,6
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EBADR,53,0,0,0,0,0
|
||||
.syscon junkerr,EBADR,53,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EBADRQC,56,0,0,0,0,0
|
||||
.syscon junkerr,EBADRQC,56,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,EBADSLT,57,0,0,0,0,0
|
||||
.syscon junkerr,EBADSLT,57,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,ECHRNG,44,0,0,0,0,0
|
||||
.syscon junkerr,ECHRNG,44,0,0,0,0,0
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon errno,ECOMM,70,0,0,0,0,0
|
||||
.syscon junkerr,ECOMM,70,0,0,0,0,0
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue