Write tests for new APE loader and fix bugs

- Add FreeBSD-specific mmap() flags
- Reduce size of the APE loader from 8kb to 4kb
- Work towards fixing the Makefile build on WSL
- Automate testing of APE no-modify-self behaviors
- Make the ape.S shell script code cleaner and tinier
- Improve the APE sanity check to test behavior better
- Fixed issue with ShowCrashReports() sigaltstack() on BSDs
- Delete symbols for S_MODE magnums which wasted compile time

If you checked out yesterday's APE commit, please run:

    rm -f /usr/bin/ape o/tmp/ape /tmp/ape "${TMPDIR:-/tmp}/ape"

Because this change fixes certain aspects of the new ABI. We don't have
automated migrations for APE loader versions yet. Thanks! You can also
download prebuilt binaries here:

- https://justine.lol/ape.elf    (Linux/FreeBSD/NetBSD/OpenBSD)
- https://justine.lol/ape.macho  (Apple)

Install the appropriate one as `/usr/bin/ape`.
This commit is contained in:
Justine Tunney 2022-05-22 04:51:02 -07:00
parent 056dc5f554
commit 4e9662cbc7
75 changed files with 759 additions and 443 deletions

View file

@ -34,12 +34,22 @@
char program_executable_name[PATH_MAX];
static inline char *StrCat(char buf[PATH_MAX], const char *a, const char *b) {
char *p, *e;
p = buf;
e = buf + PATH_MAX;
while (*a && p < e) *p++ = *a++;
while (*b && p < e) *p++ = *b++;
return buf;
}
static inline void GetProgramExecutableNameImpl(char *p, char *e) {
char *q;
ssize_t rc;
size_t i, n;
union {
int cmd[4];
char path[PATH_MAX];
char16_t path16[PATH_MAX];
} u;
@ -61,7 +71,11 @@ static inline void GetProgramExecutableNameImpl(char *p, char *e) {
return;
}
if (__argc && (q = __argv[0]) && !sys_faccessat(AT_FDCWD, q, F_OK, 0)) {
// if argv[0] exists then turn it into an absolute path. we also try
// adding a .com suffix since the ape auto-appends it when resolving
if (__argc && (((q = __argv[0]) && !sys_faccessat(AT_FDCWD, q, F_OK, 0)) ||
((q = StrCat(u.path, __argv[0], ".com")) &&
!sys_faccessat(AT_FDCWD, q, F_OK, 0)))) {
if (*q != '/') {
if (q[0] == '.' && q[1] == '/') {
q += 2;
@ -78,12 +92,12 @@ static inline void GetProgramExecutableNameImpl(char *p, char *e) {
return;
}
// if argv[0] doesn't exist, then fallback to interpreter name
if ((rc = sys_readlinkat(AT_FDCWD, "/proc/self/exe", p, e - p - 1)) > 0 ||
(rc = sys_readlinkat(AT_FDCWD, "/proc/curproc/file", p, e - p - 1)) > 0) {
p[rc] = 0;
return;
}
if (IsFreebsd() || IsNetbsd()) {
u.cmd[0] = CTL_KERN;
u.cmd[1] = KERN_PROC;
@ -101,7 +115,7 @@ static inline void GetProgramExecutableNameImpl(char *p, char *e) {
}
/**
* Returns absolute path of executable.
* Returns absolute path of program.
*/
char *GetProgramExecutableName(void) {
int e;

View file

@ -58,7 +58,7 @@ int __ensurefds_unlocked(int fd) {
if (!(p2 = weaken(malloc)(n2 * sizeof(*p1)))) return -1;
__cxa_atexit(FreeOldFdsArray, p1, 0);
memcpy(p2, p1, n1 * sizeof(*p1));
bzero(p2 + n1, (p2 + n2) - (p2 + n1));
bzero(p2 + n1, (n2 - n1) * sizeof(*p1));
g_fds.p = p2;
g_fds.n = n2;
return fd;

View file

@ -16,10 +16,15 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/weaken.h"
#include "libc/calls/internal.h"
#include "libc/calls/sig.internal.h"
#include "libc/calls/strace.internal.h"
#include "libc/errno.h"
#include "libc/nt/errors.h"
#include "libc/nt/runtime.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sysv/consts/sicode.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/errfuns.h"
@ -37,12 +42,18 @@ static textwindows ssize_t sys_write_nt_impl(int fd, void *data, size_t size,
// return ebadf(); /* handled by consts.sh */
// case kNtErrorNotEnoughQuota:
// return edquot(); /* handled by consts.sh */
case kNtErrorBrokenPipe: // broken pipe
case kNtErrorNoData: // closing named pipe
__sig_raise(SIGPIPE, SI_KERNEL); //
return epipe(); //
case kNtErrorAccessDenied: // write doesn't return EACCESS
return ebadf(); //
case kNtErrorBrokenPipe: // broken pipe
case kNtErrorNoData: // closing named pipe
if (weaken(__sig_raise)) {
weaken(__sig_raise)(SIGPIPE, SI_KERNEL);
return epipe();
} else {
STRACE("broken pipe");
__restorewintty();
_Exit(128 + EPIPE);
}
case kNtErrorAccessDenied: // write doesn't return EACCESS
return ebadf(); //
default:
return __winerr();
}

View file

@ -27,7 +27,7 @@
.long \systemv - kDos2Errno
.endm
.section .rodata
.section .rodata,"a",@progbits
.underrun
kDos2Errno:
// .e kNtErrorInvalidFunction,ENOSYS # in consts.sh

View file

@ -106,8 +106,10 @@ void ShowCrashReports(void) {
bzero(&ss, sizeof(ss));
ss.ss_flags = 0;
ss.ss_size = SIGSTKSZ;
// FreeBSD sigaltstack() will EFAULT if we use MAP_STACK here
// OpenBSD sigaltstack() auto-applies MAP_STACK to the memory
if ((ss.ss_sp = mmap(0, GetStackSize(), PROT_READ | PROT_WRITE,
MAP_STACK | MAP_ANONYMOUS, -1, 0))) {
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0))) {
if (!sigaltstack(&ss, &g_oldsigaltstack)) {
__cxa_atexit(FreeSigAltStack, ss.ss_sp, 0);
} else {

View file

@ -51,6 +51,9 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
if (n < 2) {
errno = ENAMETOOLONG;
} else if (IsWindows() || IsXnu()) {
// TODO(jart): Does XNU guarantee argv[0] is legit?
// Otherwise we should return NULL.
// What about OpenBSD?
if (strlen(GetProgramExecutableName()) < n) {
strcpy(p, GetProgramExecutableName());
return p;

View file

@ -96,7 +96,13 @@ static struct SymbolTable *GetSymbolTableFromZip(struct Zipos *zipos) {
* @note This code can't depend on dlmalloc()
*/
static struct SymbolTable *GetSymbolTableFromElf(void) {
return OpenSymbolTable(FindDebugBinary());
int e;
const char *s;
if ((s = FindDebugBinary())) {
return OpenSymbolTable(s);
} else {
return 0;
}
}
/**
@ -117,7 +123,7 @@ static struct SymbolTable *GetSymbolTableFromElf(void) {
* Function tracing is disabled throughout the duration of this call.
* Backtraces and other core runtime functionality depend on this.
*
* @return symbol table, or NULL w/ errno on first call
* @return symbol table, or NULL if not found
*/
struct SymbolTable *GetSymbolTable(void) {
struct Zipos *z;

View file

@ -323,7 +323,7 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags,
clashes = OverlapsImageSpace(p, size) || OverlapsExistingMapping(p, size);
if ((flags & MAP_FIXED_NOREPLACE) && clashes) {
if ((flags & MAP_FIXED_NOREPLACE) == MAP_FIXED_NOREPLACE && clashes) {
STRACE("noreplace overlaps existing");
return VIP(eexist());
}
@ -464,14 +464,21 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags,
* compile-time checks to ensure some char[8192] vars will not
* create an undetectable overflow into another thread's stack
* Your `flags` may optionally bitwise or any of the following:
* - `MAP_FIXED` in which case `addr` becomes more than a hint
* - `MAP_FIXED_NOREPLACE` to protect existing maps (Linux-only)
* - `MAP_ANONYMOUS` in which case `fd == -1` should be the case
* - `MAP_FIXED` in which case `addr` becomes more than a hint
* - `MAP_FIXED_NOREPLACE` to protect existing mappings; this is
* always polyfilled by mmap() which tracks its own memory and
* removed before passing to the kernel, in order to support
* old versions; if you believe mappings exist which only the
* kernel knows, then this flag may be passed to sys_mmap() on
* Linux 4.17+ and FreeBSD (where it has multiple bits)
* - `MAP_CONCEAL` is FreeBSD/NetBSD/OpenBSD-only
* - `MAP_NORESERVE` is Linux/XNU/NetBSD-only
* - `MAP_LOCKED` is Linux-only
* - `MAP_POPULATE` is Linux-only
* - `MAP_POPULATE` is Linux/FreeBSD-only
* - `MAP_NONBLOCK` is Linux-only
* - `MAP_NOSYNC` is FreeBSD-only
* - `MAP_INHERIT` is NetBSD-only
* - `MAP_LOCKED` is Linux-only
* @param fd is an open()'d file descriptor, whose contents shall be
* made available w/ automatic reading at the chosen address and
* must be -1 if MAP_ANONYMOUS is specified

View file

@ -224,22 +224,25 @@ syscon mmap MAP_PRIVATE 2 2 2 2 2 2 # forced consensus & faked nt
syscon mmap MAP_STACK 6 6 6 6 6 6 # our definition
syscon mmap MAP_TYPE 15 15 15 15 15 15 # mask for type of mapping
syscon mmap MAP_FIXED 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 # unix consensus; openbsd appears to forbid; faked nt
syscon mmap MAP_FIXED_NOREPLACE 0x08000000 0x08000000 0x08000000 0x08000000 0x08000000 0x08000000 # handled and defined by cosmo runtime; 0x100000 on linux 4.7+
syscon mmap MAP_FIXED_NOREPLACE 0x08000000 0x00004010 0x08000000 0x08000000 0x08000000 0x08000000 # handled and defined by cosmo runtime; 0x100000 on linux 4.7+; MAP_FIXED|MAP_EXCL on FreeBSD
syscon mmap MAP_ANONYMOUS 0x00000020 0x00001000 0x00001000 0x00001000 0x00001000 0x00000020 # bsd consensus; faked nt
syscon mmap MAP_GROWSDOWN 0x00000100 0 0 0 0 0 # use MAP_STACK; abstracted by MAP_STACK; may be passed to __sys_mmap() for low-level Linux fiddling
syscon mmap MAP_CONCEAL 0 0 0x00020000 0x00008000 0x00008000 0 # omit from core dumps; MAP_NOCORE on FreeBSD
syscon mmap MAP_LOCKED 0x00002000 0 0 0 0 0
syscon mmap MAP_NORESERVE 0x00004000 0x00000040 0 0 0x00000040 0 # Linux calls it "reserve"; NT calls it "commit"? which is default?
syscon mmap MAP_POPULATE 0x00008000 0 0 0 0 0 # can avoid madvise(MADV_WILLNEED) on private file mapping
syscon mmap MAP_POPULATE 0x00008000 0 0x00040000 0 0 0 # MAP_PREFAULT_READ on FreeBSD; can avoid madvise(MADV_WILLNEED) on private file mapping
syscon mmap MAP_NONBLOCK 0x00010000 0 0 0 0 0
syscon mmap MAP_HUGETLB 0x00040000 0 0 0 0 0x80000000 # kNtSecLargePages
syscon mmap MAP_INHERIT -1 -1 -1 -1 0x00000080 -1 # make it inherit across execve()
syscon mmap MAP_HASSEMAPHORE 0 0x00000200 0x00000200 0 0x00000200 0 # does it matter on x86?
syscon mmap MAP_NOSYNC 0 0 0x00000800 0 0 0 # flush to physical media only when necessary rather than gratuitously; be sure to use write() rather than ftruncate() with this!
syscon mmap MAP_CONCEAL 0 0 0x00020000 0x00008000 0x00008000 0 # omit from core dumps; MAP_NOCORE on FreeBSD
syscon mmap MAP_HUGE_MASK 63 0 0 0 0 0
syscon mmap MAP_HUGE_SHIFT 26 0 0 0 0 0
syscon compat MAP_NOCORE 0 0 0x0020000 0x8000 0x8000 0 # use MAP_CONCEAL
syscon compat MAP_ANON 0x20 0x1000 0x0001000 0x1000 0x1000 0x20 # bsd consensus; faked nt
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
syscon compat MAP_NOCORE 0 0 0x00020000 0x00008000 0x00008000 0 # use MAP_CONCEAL
syscon compat MAP_ANON 0x00000020 0x00001000 0x00001000 0x00001000 0x00001000 0x00000020 # bsd consensus; faked nt
syscon compat MAP_EXECUTABLE 0x00001000 0 0 0 0 0 # ignored
syscon compat MAP_DENYWRITE 0x00000800 0 0 0 0 0
syscon compat MAP_32BIT 0x00000040 0 0x00080000 0 0 0 # iffy
# madvise() flags
#
@ -337,36 +340,6 @@ syscon waitid WEXITED 4 4 0x10 0 32 0
syscon waitid WSTOPPED 2 8 2 0 2 0
syscon waitid WNOWAIT 0x01000000 0x20 8 0 0x10000 0
# stat::st_mode constants
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
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()
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
@ -605,7 +578,8 @@ syscon sicode SYS_USER_DISPATCH 2 -1 -1 -1 -1 -1 # SIGSYS; syscall
# sigaltstack() values
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon ss SIGSTKSZ 0x2000 0x020000 0x8800 0x7000 0x7000 0x2000
syscon ss SIGSTKSZ 8192 131072 34816 28672 28672 8192 # overlayed with STACKSIZE; you need to #undef SIGSTKSZ to access this symbol
syscon ss MINSIGSTKSZ 2048 32768 2048 12288 8192 2048 # overlayed with 32768; you need to #undef MINSIGSTKSZ to access this symbol
syscon ss SS_ONSTACK 1 1 1 1 1 1 # unix consensus
syscon ss SS_DISABLE 2 4 4 4 4 2 # bsd consensus
@ -3131,7 +3105,6 @@ syscon misc CSTATUS 0 20 20 255 255 0
syscon misc DEAD_PROCESS 8 8 7 0 0 0
syscon misc FNM_NOSYS -1 -1 -1 2 2 0
syscon misc INIT_PROCESS 5 5 5 0 0 0
syscon misc MINSIGSTKSZ 0x0800 0x8000 0x0800 0x3000 0x2000 0
syscon misc MQ_PRIO_MAX 0x8000 0 0x40 0 0 0
syscon misc MTERASE 13 0 12 9 9 0
syscon misc MTLOAD 30 0 19 0 0 0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_32BIT,0x40,0,0x080000,0,0,0
.syscon compat,MAP_32BIT,0x00000040,0,0x00080000,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_ANON,0x20,0x1000,0x0001000,0x1000,0x1000,0x20
.syscon compat,MAP_ANON,0x00000020,0x00001000,0x00001000,0x00001000,0x00001000,0x00000020

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_DENYWRITE,0x0800,0,0,0,0,0
.syscon compat,MAP_DENYWRITE,0x00000800,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_EXECUTABLE,0x1000,0,0,0,0,0
.syscon compat,MAP_EXECUTABLE,0x00001000,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_FILE,0,0,0,0,0,0
.syscon mmap,MAP_FILE,0,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon mmap,MAP_FIXED_NOREPLACE,0x08000000,0x08000000,0x08000000,0x08000000,0x08000000,0x08000000
.syscon mmap,MAP_FIXED_NOREPLACE,0x08000000,0x00004010,0x08000000,0x08000000,0x08000000,0x08000000

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon mmap,MAP_HASSEMAPHORE,0,0x00000200,0x00000200,0,0x00000200,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon mmap,MAP_INHERIT,-1,-1,-1,-1,0x00000080,-1

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,MAP_NOCORE,0,0,0x0020000,0x8000,0x8000,0
.syscon compat,MAP_NOCORE,0,0,0x00020000,0x00008000,0x00008000,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon mmap,MAP_NOSYNC,0,0,0x00000800,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon mmap,MAP_POPULATE,0x00008000,0,0,0,0,0
.syscon mmap,MAP_POPULATE,0x00008000,0,0x00040000,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,MINSIGSTKSZ,0x0800,0x8000,0x0800,0x3000,0x2000,0
.syscon ss,MINSIGSTKSZ,2048,32768,2048,12288,8192,2048

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ss,SIGSTKSZ,0x2000,0x020000,0x8800,0x7000,0x7000,0x2000
.syscon ss,SIGSTKSZ,8192,131072,34816,28672,28672,8192

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_MANDLOCK,0x40,0,0,0,0,0
.syscon statvfs,ST_MANDLOCK,0x0040,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_SYNCHRONOUS,0x10,0,0,0,2,0
.syscon statvfs,ST_SYNCHRONOUS,16,0,0,0,2,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon statvfs,ST_WRITE,0x80,0,0,0,0,0
.syscon statvfs,ST_WRITE,0x0080,0,0,0,0,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IEXEC,0000100,0000100,0000100,0000100,0000100,0000100

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFBLK,0060000,0060000,0060000,0060000,0060000,0060000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFCHR,0020000,0020000,0020000,0020000,0020000,0020000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFDIR,0040000,0040000,0040000,0040000,0040000,0040000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFIFO,0010000,0010000,0010000,0010000,0010000,0010000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFLNK,0120000,0120000,0120000,0120000,0120000,0120000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFMT,0170000,0170000,0170000,0170000,0170000,0170000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFREG,0100000,0100000,0100000,0100000,0100000,0100000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IFSOCK,0140000,0140000,0140000,0140000,0140000,0140000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IREAD,0000400,0000400,0000400,0000400,0000400,0000400

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IRGRP,0000040,0000040,0000040,0000040,0000040,0000040

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IROTH,0000004,0000004,0000004,0000004,0000004,0000004

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IRUSR,0000400,0000400,0000400,0000400,0000400,0000400

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IRWXG,0000070,0000070,0000070,0000070,0000070,0000070

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IRWXO,0000007,0000007,0000007,0000007,0000007,0000007

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IRWXU,0000700,0000700,0000700,0000700,0000700,0000700

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_ISGID,0002000,0002000,0002000,0002000,0002000,0002000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_ISUID,0004000,0004000,0004000,0004000,0004000,0004000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_ISVTX,0001000,0001000,0001000,0001000,0001000,0001000

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IWGRP,0000020,0000020,0000020,0000020,0000020,0000020

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IWOTH,0000002,0000002,0000002,0000002,0000002,0000002

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IWRITE,0000200,0000200,0000200,0000200,0000200,0000200

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IWUSR,0000200,0000200,0000200,0000200,0000200,0000200

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IXGRP,0000010,0000010,0000010,0000010,0000010,0000010

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IXOTH,0000001,0000001,0000001,0000001,0000001,0000001

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon stat,S_IXUSR,0000100,0000100,0000100,0000100,0000100,0000100

View file

@ -12,13 +12,17 @@ extern const long MAP_DENYWRITE;
extern const long MAP_EXECUTABLE;
extern const long MAP_FILE;
extern const long MAP_FIXED;
extern const long MAP_FIXED_NOREPLACE;
extern const long MAP_GROWSDOWN;
extern const long MAP_HASSEMAPHORE;
extern const long MAP_HUGETLB;
extern const long MAP_HUGE_MASK;
extern const long MAP_HUGE_SHIFT;
extern const long MAP_INHERIT;
extern const long MAP_LOCKED;
extern const long MAP_NONBLOCK;
extern const long MAP_NORESERVE;
extern const long MAP_NOSYNC;
extern const long MAP_POPULATE;
extern const long MAP_PRIVATE;
extern const long MAP_SHARED;
@ -26,28 +30,30 @@ extern const long MAP_SHARED;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#define MAP_FILE 0
#define MAP_SHARED 1
#define MAP_PRIVATE 2
#define MAP_STACK 6
#define MAP_TYPE 15
#define MAP_FIXED 16
#define MAP_FIXED_NOREPLACE 0x8000000
#define MAP_FILE 0
#define MAP_SHARED 1
#define MAP_PRIVATE 2
#define MAP_STACK 6
#define MAP_TYPE 15
#define MAP_FIXED 16
#define MAP_32BIT SYMBOLIC(MAP_32BIT)
#define MAP_ANONYMOUS SYMBOLIC(MAP_ANONYMOUS)
#define MAP_CONCEAL SYMBOLIC(MAP_CONCEAL)
#define MAP_CONCEAL SYMBOLIC(MAP_CONCEAL)
#define MAP_DENYWRITE SYMBOLIC(MAP_DENYWRITE)
#define MAP_EXECUTABLE SYMBOLIC(MAP_EXECUTABLE)
#define MAP_GROWSDOWN SYMBOLIC(MAP_GROWSDOWN)
#define MAP_HUGETLB SYMBOLIC(MAP_HUGETLB)
#define MAP_HUGE_MASK SYMBOLIC(MAP_HUGE_MASK)
#define MAP_HUGE_SHIFT SYMBOLIC(MAP_HUGE_SHIFT)
#define MAP_LOCKED SYMBOLIC(MAP_LOCKED)
#define MAP_NONBLOCK SYMBOLIC(MAP_NONBLOCK)
#define MAP_NORESERVE SYMBOLIC(MAP_NORESERVE)
#define MAP_POPULATE SYMBOLIC(MAP_POPULATE)
#define MAP_32BIT SYMBOLIC(MAP_32BIT)
#define MAP_ANONYMOUS SYMBOLIC(MAP_ANONYMOUS)
#define MAP_CONCEAL SYMBOLIC(MAP_CONCEAL)
#define MAP_DENYWRITE SYMBOLIC(MAP_DENYWRITE)
#define MAP_EXECUTABLE SYMBOLIC(MAP_EXECUTABLE)
#define MAP_FIXED_NOREPLACE SYMBOLIC(MAP_FIXED_NOREPLACE)
#define MAP_GROWSDOWN SYMBOLIC(MAP_GROWSDOWN)
#define MAP_HASSEMAPHORE SYMBOLIC(MAP_HASSEMAPHORE)
#define MAP_HUGETLB SYMBOLIC(MAP_HUGETLB)
#define MAP_HUGE_MASK SYMBOLIC(MAP_HUGE_MASK)
#define MAP_HUGE_SHIFT SYMBOLIC(MAP_HUGE_SHIFT)
#define MAP_INHERIT SYMBOLIC(MAP_INHERIT)
#define MAP_LOCKED SYMBOLIC(MAP_LOCKED)
#define MAP_NONBLOCK SYMBOLIC(MAP_NONBLOCK)
#define MAP_NORESERVE SYMBOLIC(MAP_NORESERVE)
#define MAP_NOSYNC SYMBOLIC(MAP_NOSYNC)
#define MAP_POPULATE SYMBOLIC(MAP_POPULATE)
#define MAP_ANON MAP_ANONYMOUS
#define MAP_NOCORE MAP_CONCEAL

View file

@ -3,13 +3,16 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const long SIGSTKSZ;
extern const long MINSIGSTKSZ;
extern const long SS_DISABLE;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#define SIGSTKSZ STACKSIZE
#define SS_ONSTACK 1
#define SS_DISABLE SS_DISABLE
#define SIGSTKSZ STACKSIZE
#define MINSIGSTKSZ 32768
#define SS_ONSTACK 1
#define SS_DISABLE SS_DISABLE
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_SS_H_ */