Undiamond Python headers

This change gets the Python codebase into a state where it conforms to
the conventions of this codebase. It's now possible to include headers
from Python, without worrying about ordering. Python has traditionally
solved that problem by "diamonding" everything in Python.h, but that's
problematic since it means any change to any Python header invalidates
all the build artifacts. Lastly it makes tooling not work. Since it is
hard to explain to Emacs when I press C-c C-h to add an import line it
shouldn't add the header that actually defines the symbol, and instead
do follow the nonstandard Python convention.

Progress has been made on letting Python load source code from the zip
executable structure via the standard C library APIs. System calss now
recognizes zip!FILENAME alternative URIs as equivalent to zip:FILENAME
since Python uses colon as its delimiter.

Some progress has been made on embedding the notice license terms into
the Python object code. This is easier said than done since Python has
an extremely complicated ownership story.

- Some termios APIs have been added
- Implement rewinddir() dirstream API
- GetCpuCount() API added to Cosmopolitan Libc
- More bugs in Cosmopolitan Libc have been fixed
- zipobj.com now has flags for mangling the path
- Fixed bug a priori with sendfile() on certain BSDs
- Polyfill F_DUPFD and F_DUPFD_CLOEXEC across platforms
- FIOCLEX / FIONCLEX now polyfilled for fast O_CLOEXEC changes
- APE now supports a hybrid solution to no-self-modify for builds
- Many BSD-only magnums added, e.g. O_SEARCH, O_SHLOCK, SF_NODISKIO
This commit is contained in:
Justine Tunney 2021-08-12 00:42:14 -07:00
parent 20bb8db9f8
commit b420ed8248
762 changed files with 18410 additions and 53772 deletions

View file

@ -545,6 +545,22 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
// We prefer this because it's a tiny constant one time cost.
// We simply printf a 64-byte header and call execve() again.
.ascii "o=\"$(command -v \"$0\")\"\n"
#ifdef APE_BUILDSAFE
// This code is intended for binaries in build/bootstrap/. It
// causes them to not self-modify since they're checked-in to
// version control. It assumes cosmopolitan's build prefix is
// being used by convention and that the program has the noop
// flag -n which is used to prime the binary.
.ascii "if [ ${o##o/} = $o ]; then\n"
.ascii " if ! [ o/$o -nt $o ]; then\n"
.ascii " mkdir -p o/${o%/*} || exit\n"
.ascii " cp -f $o o/$o.$$ || exit\n"
.ascii " o/$o.$$ -n || exit\n"
.ascii " mv -f o/$o.$$ o/$o || exit\n"
.ascii " fi\n"
.ascii " exec o/$o \"$@\"\n"
.ascii "fi\n"
#endif
#else
// The alternative behavior is to copy to $TMPDIR and edit.
// This imposes a variety of caveats of its own that should

View file

@ -201,6 +201,8 @@ SECTIONS {
/* Real Mode */
KEEP(*(.head))
KEEP(*(.apesh))
KEEP(*(.head2))
KEEP(*(.text.head))
/* Executable & Linkable Format */

View file

@ -19,6 +19,11 @@ APE = $(APE_DEPS) \
$(APE_OBJS) \
o/$(MODE)/ape/ape.lds
APE_BUILDSAFE = \
$(APE_DEPS) \
o/$(MODE)/ape/ape-buildsafe.o \
o/$(MODE)/ape/ape.lds
APELINK = \
$(COMPILE) \
-ALINK.ape \
@ -49,6 +54,9 @@ $(APE_OBJS): $(BUILD_FILES) \
o/$(MODE)/ape/ape-no-modify-self.o: ape/ape.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_NO_MODIFY_SELF $<
o/$(MODE)/ape/ape-buildsafe.o: ape/ape.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_BUILDSAFE $<
.PHONY: o/$(MODE)/ape
o/$(MODE)/ape: $(APE) \
$(APE_CHECKS) \

Binary file not shown.

Binary file not shown.

25
examples/getcpucount.c Normal file
View file

@ -0,0 +1,25 @@
#if 0
/*─────────────────────────────────────────────────────────────────╗
To the extent possible under law, Justine Tunney has waived
all copyright and related or neighboring rights to this file,
as it is written in the following disclaimers:
http://unlicense.org/ │
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/calls/calls.h"
#include "libc/fmt/itoa.h"
#include "libc/runtime/sysconf.h"
#include "libc/stdio/stdio.h"
int main(int argc, char *argv[]) {
int c, n;
char a[22];
if ((c = GetCpuCount())) {
n = int64toarray_radix10(c, a);
a[n++] = '\n';
return write(1, a, n) == n ? 0 : 1;
} else {
return 1;
}
}

View file

@ -84,6 +84,7 @@ int arch_prctl();
int chdir(const char *);
int chmod(const char *, uint32_t);
int chown(const char *, uint32_t, uint32_t);
int chroot(const char *);
int close(int);
int closedir(DIR *);
int creat(const char *, uint32_t) nodiscard;
@ -100,6 +101,7 @@ int execvp(const char *, char *const[]) paramsnonnull();
int execvpe(const char *, char *const[], char *const[]) paramsnonnull();
int faccessat(int, const char *, int, uint32_t);
int fadvise(int, uint64_t, uint64_t, int);
int fchdir(int);
int fchmod(int, uint32_t) nothrow;
int fchmodat(int, const char *, uint32_t, uint32_t);
int fchown(int, uint32_t, uint32_t);
@ -115,13 +117,13 @@ int fsync(int);
int ftruncate(int, int64_t);
int getdomainname(char *, size_t);
int gethostname(char *, size_t);
int getpid(void);
int getppid(void);
int getpriority(int, unsigned);
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 *);
@ -129,6 +131,7 @@ int madvise(void *, uint64_t, int);
int mkdir(const char *, uint32_t);
int mkdirat(int, const char *, uint32_t);
int mkfifo(const char *, uint32_t);
int mkfifoat(int, const char *, uint32_t);
int mknod(const char *, uint32_t, uint64_t);
int mknodat(int, const char *, int32_t, uint64_t);
int mlock(const void *, size_t);
@ -146,6 +149,7 @@ int pipe(int[hasatleast 2]);
int pipe2(int[hasatleast 2], int);
int posix_fadvise(int, uint64_t, uint64_t, int);
int posix_madvise(void *, uint64_t, int);
int prctl();
int raise(int);
int readlink(const char *, char *, size_t);
int remove(const char *);
@ -171,11 +175,13 @@ int setuid(uint32_t);
int sigaction(int, const struct sigaction *, struct sigaction *);
int sigignore(int);
int sigprocmask(int, const struct sigset *, struct sigset *);
int sigqueue(int, int, const union sigval);
int sigsuspend(const struct sigset *);
int stat(const char *, struct stat *);
int symlink(const char *, const char *);
int symlinkat(const char *, int, const char *);
int sync_file_range(int, int64_t, int64_t, unsigned);
int sysctl(const int *, unsigned, void *, size_t *, void *, size_t);
int sysinfo(struct sysinfo *);
int touch(const char *, uint32_t);
int truncate(const char *, uint64_t);
@ -189,21 +195,20 @@ int wait(int *);
int wait3(int *, int, struct rusage *);
int wait4(int, int *, int, struct rusage *);
int waitpid(int, int *, int);
ssize_t lseek(int, int64_t, unsigned);
ssize_t pread(int, void *, size_t, int64_t);
ssize_t preadv(int, struct iovec *, int, int64_t);
ssize_t pwrite(int, const void *, size_t, int64_t);
ssize_t pwritev(int, const struct iovec *, int, int64_t);
intptr_t syscall(int, ...);
void sync(void);
long ptrace(int, int, void *, void *);
long telldir(DIR *);
int getpid(void);
long times(struct tms *);
sighandler_t signal(int, sighandler_t);
size_t GetFileSize(const char *);
size_t getfiledescriptorsize(int);
ssize_t copy_file_range(int, long *, int, long *, size_t, uint32_t);
ssize_t copyfd(int, int64_t *, int, int64_t *, size_t, uint32_t);
ssize_t lseek(int, int64_t, unsigned);
ssize_t pread(int, void *, size_t, int64_t);
ssize_t preadv(int, struct iovec *, int, int64_t);
ssize_t pwrite(int, const void *, size_t, int64_t);
ssize_t pwritev(int, const struct iovec *, int, int64_t);
ssize_t read(int, void *, size_t);
ssize_t readansi(int, char *, size_t);
ssize_t readlinkat(int, const char *, char *, size_t);
@ -219,11 +224,8 @@ uint32_t getsid(int) nosideeffect;
uint32_t gettid(void) nosideeffect;
uint32_t getuid(void) nosideeffect;
uint32_t umask(int32_t);
long ptrace(int, int, void *, void *);
int chroot(const char *);
int prctl();
int sysctl(const int *, unsigned, void *, size_t *, void *, size_t);
int fchdir(int);
void rewinddir(DIR *);
void sync(void);
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § system calls » formatting

25
libc/calls/cfgetispeed.c Normal file
View file

@ -0,0 +1,25 @@
/*-*- 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/termios.h"
#include "libc/sysv/consts/termios.h"
uint32_t cfgetispeed(const struct termios *t) {
/* return t->c_cflag & CBAUD; */ /* ??? */
return t->c_ispeed;
}

25
libc/calls/cfgetospeed.c Normal file
View file

@ -0,0 +1,25 @@
/*-*- 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/termios.h"
#include "libc/sysv/consts/termios.h"
uint32_t cfgetospeed(const struct termios *t) {
/* return t->c_cflag & CBAUD; */ /* ??? */
return t->c_ospeed;
}

31
libc/calls/cfmakeraw.c Normal file
View 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/termios.h"
#include "libc/sysv/consts/termios.h"
void cfmakeraw(struct termios *t) {
t->c_iflag &=
~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
t->c_oflag &= ~OPOST;
t->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
t->c_cflag &= ~(CSIZE | PARENB);
t->c_cflag |= CS8;
t->c_cc[VMIN] = 1;
t->c_cc[VTIME] = 0;
}

33
libc/calls/cfsetispeed.c Normal file
View file

@ -0,0 +1,33 @@
/*-*- 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/termios.h"
#include "libc/sysv/errfuns.h"
int cfsetispeed(struct termios *t, int speed) {
if (speed) {
if (CBAUD) {
if (speed & ~CBAUD) return einval();
t->c_cflag &= ~CBAUD;
t->c_cflag |= speed;
} else {
t->c_ispeed = speed;
}
}
return 0;
}

32
libc/calls/cfsetospeed.c Normal file
View file

@ -0,0 +1,32 @@
/*-*- 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/termios.h"
#include "libc/sysv/consts/termios.h"
#include "libc/sysv/errfuns.h"
int cfsetospeed(struct termios *t, int speed) {
if (CBAUD) {
if (speed & ~CBAUD) return einval();
t->c_cflag &= ~CBAUD;
t->c_cflag |= speed;
} else {
t->c_ospeed = speed;
}
return 0;
}

View file

@ -16,6 +16,7 @@
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/calls/internal.h"
#include "libc/calls/struct/flock.h"
@ -37,6 +38,40 @@
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
static textwindows int sys_fcntl_nt_reservefd(int start) {
int fd;
for (;;) {
fd = start;
if (fd >= g_fds.n) {
if (__ensurefds(fd) == -1) return -1;
}
cmpxchg(&g_fds.f, fd, fd + 1);
if (cmpxchg(&g_fds.p[fd].kind, kFdEmpty, kFdReserved)) {
return fd;
}
}
}
static textwindows int sys_fcntl_nt_dupfd(int oldfd, int cmd, int start) {
int newfd;
int64_t proc;
if ((newfd = sys_fcntl_nt_reservefd(start)) != -1) {
proc = GetCurrentProcess();
if (DuplicateHandle(proc, g_fds.p[oldfd].handle, proc,
&g_fds.p[newfd].handle, 0, true,
kNtDuplicateSameAccess)) {
g_fds.p[newfd].kind = g_fds.p[oldfd].kind;
g_fds.p[newfd].flags = cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0;
return newfd;
} else {
__releasefd(newfd);
return __winerr();
}
} else {
return -1;
}
}
static textwindows int sys_fcntl_nt_lock(struct Fd *f, int cmd, uintptr_t arg) {
struct flock *l;
uint32_t flags, err;
@ -123,6 +158,8 @@ textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) {
}
} else if (cmd == F_SETLK || cmd == F_SETLKW) {
return sys_fcntl_nt_lock(g_fds.p + fd, cmd, arg);
} else if (cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC) {
return sys_fcntl_nt_dupfd(fd, cmd, arg);
} else {
return einval();
}

View file

@ -63,6 +63,7 @@ textwindows int sys_fstat_nt(int64_t handle, struct stat *st) {
st->st_size = (uint64_t)wst.nFileSizeHigh << 32 | wst.nFileSizeLow;
st->st_blksize = PAGESIZE;
st->st_dev = wst.dwVolumeSerialNumber;
st->st_rdev = wst.dwVolumeSerialNumber;
st->st_ino = (uint64_t)wst.nFileIndexHigh << 32 | wst.nFileIndexLow;
st->st_nlink = wst.nNumberOfLinks;
if (GetFileInformationByHandleEx(handle, kNtFileCompressionInfo, &fci,

View file

@ -146,7 +146,7 @@ i32 sys_getppid(void) hidden;
i32 sys_getpriority(i32, u32) hidden;
i32 sys_getrlimit(i32, struct rlimit *) hidden;
i32 sys_getrusage(i32, struct rusage *) hidden;
i32 sys_ioctl(i32, u64, void *) hidden;
i32 sys_ioctl(i32, u64, ...) hidden;
i32 sys_kill(i32, i32, i32) hidden;
i32 sys_linkat(i32, const char *, i32, const char *, i32) hidden;
i32 sys_lseek(i32, i64, i64, i64) hidden;
@ -233,6 +233,14 @@ ssize_t WritevUninterruptible(int, struct iovec *, int);
void flock2cosmo(uintptr_t);
void cosmo2flock(uintptr_t);
int sys_sendfile_xnu(int32_t infd, int32_t outfd, int64_t offset,
int64_t *out_opt_sbytes, const void *opt_hdtr,
int32_t flags) asm("sys_sendfile") hidden;
int sys_sendfile_freebsd(int32_t infd, int32_t outfd, int64_t offset,
size_t nbytes, const void *opt_hdtr,
int64_t *out_opt_sbytes,
int32_t flags) asm("sys_sendfile") hidden;
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § syscalls » windows nt » veneers
*/

View file

@ -27,7 +27,11 @@
* Controls settings on device.
* @vforksafe
*/
int(ioctl)(int fd, uint64_t request, void *memory) {
__IOCTL_DISPATCH(EQUAL, fd, request, memory);
return ioctl_default(fd, request, memory);
int(ioctl)(int fd, uint64_t request, ...) {
void *arg;
va_list va;
va_start(va, request);
arg = va_arg(va, void *);
va_end(va);
return __IOCTL_DISPATCH(EQUAL, -1, fd, request, arg);
}

View file

@ -1,8 +1,9 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_IOCTL_H_
#define COSMOPOLITAN_LIBC_CALLS_IOCTL_H_
#include "libc/macros.internal.h"
#include "libc/sysv/consts/termios.h"
#include "libc/sysv/consts/fio.h"
#include "libc/sysv/consts/sio.h"
#include "libc/sysv/consts/termios.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@ -10,35 +11,55 @@ COSMOPOLITAN_C_START_
cosmopolitan § system calls » ioctl
*/
int ioctl(int, uint64_t, void *);
int ioctl(int, uint64_t, ...);
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § system calls » ioctl » undiamonding (size optimization)
*/
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define ioctl(FD, REQUEST, MEMORY) ioctl_dispatch(FD, REQUEST, MEMORY)
#define ioctl(FD, REQUEST, ...) \
__IOCTL_DISPATCH(__EQUIVALENT, ioctl_default(FD, REQUEST, ##__VA_ARGS__), \
FD, REQUEST, ##__VA_ARGS__)
#define __EQUIVALENT(X, Y) (__builtin_constant_p((X) == (Y)) && ((X) == (Y)))
#define __IOCTL_DISPATCH(CMP, FD, REQUEST, MEMORY) \
do { \
if (CMP(request, TIOCGWINSZ)) return ioctl_tiocgwinsz(FD, MEMORY); \
if (CMP(request, TIOCSWINSZ)) return ioctl_tiocswinsz(FD, MEMORY); \
if (CMP(request, TCGETS)) return ioctl_tcgets(FD, MEMORY); \
if (CMP(request, TCSETS)) return ioctl_tcsets(FD, REQUEST, MEMORY); \
if (CMP(request, TCSETSW)) return ioctl_tcsets(FD, REQUEST, MEMORY); \
if (CMP(request, TCSETSF)) return ioctl_tcsets(FD, REQUEST, MEMORY); \
if (CMP(request, SIOCGIFCONF)) return ioctl_siocgifconf(FD, MEMORY); \
if (CMP(request, SIOCGIFADDR)) return ioctl_siocgifaddr(FD, MEMORY); \
if (CMP(request, SIOCGIFNETMASK)) return ioctl_siocgifnetmask(FD, MEMORY); \
if (CMP(request, SIOCGIFBRDADDR)) return ioctl_siocgifbrdaddr(FD, MEMORY); \
if (CMP(request, SIOCGIFDSTADDR)) return ioctl_siocgifdstaddr(FD, MEMORY); \
if (CMP(request, SIOCGIFFLAGS)) return ioctl_siocgifflags(FD, MEMORY); \
} while (0)
/*
if (CMP(request, SIOCGIFFLAGS)) return ioctl_siocgifflags(FD, REQUEST, MEMORY); \
*/
#define __IOCTL_DISPATCH(CMP, DEFAULT, FD, REQUEST, ...) \
({ \
int ReZ; \
if (CMP(REQUEST, TIOCGWINSZ)) { \
ReZ = ioctl_tiocgwinsz(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TIOCSWINSZ)) { \
ReZ = ioctl_tiocswinsz(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TCGETS)) { \
ReZ = ioctl_tcgets(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETS)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETSW)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, TCSETSF)) { \
ReZ = ioctl_tcsets(FD, REQUEST, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFCONF)) { \
ReZ = ioctl_siocgifconf(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFADDR)) { \
ReZ = ioctl_siocgifaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFNETMASK)) { \
ReZ = ioctl_siocgifnetmask(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFBRDADDR)) { \
ReZ = ioctl_siocgifbrdaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFDSTADDR)) { \
ReZ = ioctl_siocgifdstaddr(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, SIOCGIFFLAGS)) { \
ReZ = ioctl_siocgifflags(FD, __VA_ARGS__); \
} else if (CMP(REQUEST, FIOCLEX)) { \
ReZ = ioctl_fioclex(FD); \
} else if (CMP(REQUEST, FIONCLEX)) { \
ReZ = ioctl_fionclex(FD); \
} else { \
ReZ = DEFAULT; \
} \
ReZ; \
})
int ioctl_tcgets(int, void *);
int ioctl_tcgets_nt(int, void *);
@ -55,11 +76,8 @@ int ioctl_siocgifnetmask(int, void *);
int ioctl_siocgifbrdaddr(int, void *);
int ioctl_siocgifflags(int, void *);
int ioctl_default(int, uint64_t, void *);
forceinline int ioctl_dispatch(int fd, uint64_t request, void *memory) {
__IOCTL_DISPATCH(__EQUIVALENT, fd, request, memory);
return ioctl_default(fd, request, memory);
}
int ioctl_fioclex(int);
int ioctl_fionclex(int);
#endif /* GNUC && !ANSI */
COSMOPOLITAN_C_END_

View 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/internal.h"
#include "libc/calls/ioctl.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
textwindows int ioctl_fioclex_nt(int fd) {
if (__isfdopen(fd)) {
g_fds.p[fd].flags |= O_CLOEXEC;
return 0;
} else {
return ebadf();
}
}

View file

@ -0,0 +1,36 @@
/*-*- 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/internal.h"
#include "libc/calls/ioctl.h"
#include "libc/dce.h"
int ioctl_fioclex_nt(int);
/**
* Sets "close on exec" on file descriptor the fast way.
*
* @see ioctl(fd, FIOCLEX, 0) dispatches here
*/
int ioctl_fioclex(int fd) {
if (!IsWindows()) {
return sys_ioctl(fd, FIOCLEX, 0);
} else {
return ioctl_fioclex_nt(fd);
}
}

View 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/internal.h"
#include "libc/calls/ioctl.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
textwindows int ioctl_fionclex_nt(int fd) {
if (__isfdopen(fd)) {
g_fds.p[fd].flags &= ~O_CLOEXEC;
return 0;
} else {
return ebadf();
}
}

View file

@ -0,0 +1,36 @@
/*-*- 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/internal.h"
#include "libc/calls/ioctl.h"
#include "libc/dce.h"
int ioctl_fionclex_nt(int);
/**
* Clears "close on exec" on file descriptor the fast way.
*
* @see ioctl(fd, FIONCLEX, 0) dispatches here
*/
int ioctl_fionclex(int fd) {
if (!IsWindows()) {
return sys_ioctl(fd, FIONCLEX, 0);
} else {
return ioctl_fionclex_nt(fd);
}
}

24
libc/calls/tcdrain.c Normal file
View file

@ -0,0 +1,24 @@
/*-*- 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/internal.h"
#include "libc/calls/termios.h"
int tcdrain(int fd) {
return ioctl(fd, TCSBRK, (void *)(intptr_t)1);
}

26
libc/calls/tcflow.c Normal file
View file

@ -0,0 +1,26 @@
/*-*- 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/internal.h"
#include "libc/calls/termios.h"
#include "libc/sysv/consts/termios.h"
int tcflow(int fd, int action) {
/* TODO(jart): BSD support */
return sys_ioctl(fd, TCXONC, (void *)(intptr_t)action);
}

26
libc/calls/tcflush.c Normal file
View file

@ -0,0 +1,26 @@
/*-*- 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/internal.h"
#include "libc/calls/termios.h"
#include "libc/sysv/consts/termios.h"
int tcflush(int fd, int x) {
/* TODO(jart): BSD Support */
return sys_ioctl(fd, TCFLSH, x);
}

View file

@ -28,4 +28,6 @@
* @return -1 w/ errno on error
* @asyncsignalsafe
*/
int(tcgetattr)(int fd, struct termios *tio) { return ioctl(fd, TCGETS, tio); }
int(tcgetattr)(int fd, struct termios *tio) {
return ioctl(fd, TCGETS, tio);
}

27
libc/calls/tcgetsid.c Normal file
View file

@ -0,0 +1,27 @@
/*-*- 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/internal.h"
#include "libc/calls/termios.h"
#include "libc/sysv/consts/termios.h"
int tcgetsid(int fd) {
int sid;
if (sys_ioctl(fd, TIOCGSID, &sid) < 0) return -1;
return sid;
}

34
libc/calls/tcsendbreak.c Normal file
View file

@ -0,0 +1,34 @@
/*-*- 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/internal.h"
#include "libc/calls/termios.h"
#include "libc/dce.h"
#include "libc/sysv/consts/termios.h"
#include "libc/time/time.h"
int tcsendbreak(int fd, int len) {
if (!IsBsd()) {
return sys_ioctl(fd, TCSBRK, 0);
} else {
if (sys_ioctl(fd, TIOCSBRK, 0) == -1) return -1;
usleep(400000);
if (sys_ioctl(fd, TIOCCBRK, 0) == -1) return -1;
return 0;
}
}

View file

@ -26,6 +26,17 @@ int grantpt(int);
int unlockpt(int);
int posix_openpt(int) nodiscard;
int tcdrain(int);
int tcgetsid(int);
int tcflow(int, int);
int tcflush(int, int);
int tcsendbreak(int, int);
void cfmakeraw(struct termios *);
int cfsetospeed(struct termios *, int);
int cfsetispeed(struct termios *, int);
uint32_t cfgetospeed(const struct termios *);
uint32_t cfgetispeed(const struct termios *);
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § teletypewriter » undiamonding
*/

View file

@ -2,11 +2,6 @@
#define COSMOPOLITAN_LIBC_LOG_CHECK_H_
#include "libc/dce.h"
#include "libc/macros.internal.h"
/**
* @fileoverview Modern assertions, courtesy of Elgoog.
*/
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@ -47,9 +42,6 @@ COSMOPOLITAN_C_START_
VAR = (typeof(VAR))__builtin_assume_aligned(VAR, BYTES); \
} while (0)
#if defined(__VSCODE_INTELLISENSE__)
#define __CHK(...)
#else
#define __CHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, ...) \
do { \
autotype(GOT) Got = (GOT); \
@ -64,11 +56,7 @@ COSMOPOLITAN_C_START_
unreachable; \
} \
} while (0)
#endif /* defined(__VSCODE_INTELLISENSE__) */
#if defined(__VSCODE_INTELLISENSE__)
#define __DCHK(...)
#else
#ifdef NDEBUG
#define __DCHK(SUFFIX, OP, WANT, WANTSTR, GOT, ...) \
do { \
@ -82,7 +70,6 @@ COSMOPOLITAN_C_START_
#define __DCHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, ...) \
__CHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, __VA_ARGS__)
#endif /* NDEBUG */
#endif /* defined(__VSCODE_INTELLISENSE__) */
#ifdef NDEBUG
#define __DCHK_ALIGNED(BYTES, VAR)
@ -102,6 +89,13 @@ void __check_fail_ge(uint64_t, uint64_t) relegated wontreturn;
void __check_fail_gt(uint64_t, uint64_t) relegated wontreturn;
void __check_fail_aligned(unsigned, uint64_t) relegated wontreturn;
#ifdef __VSCODE_INTELLISENSE__
#undef __CHK
#define __CHK(...)
#undef __DCHK
#define __DCHK(...)
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_LOG_CHECK_H_ */

10
libc/log/traceme.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef COSMOPOLITAN_LIBC_LOG_TRACEME_H_
#define COSMOPOLITAN_LIBC_LOG_TRACEME_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern int traceme;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_LOG_TRACEME_H_ */

View file

@ -18,7 +18,6 @@
*/
#include "libc/macros.internal.h"
.text.startup
.align 8
// Identity maps 256-byte translation table.
//

View file

@ -18,23 +18,17 @@
*/
#include "libc/macros.internal.h"
.initbss 300,_init_kToLower
// ASCII uppercase lowercase translation tables.
//
// char kToLower[256];
// char16_t kToLower16[256];
//
// @note kToLower16 saves 128kb; CMOVcc can't even 8-bit
.initbss 300,_init_kToLower
// @see kToUpper
kToLower:
.rept 256
.byte 0
.endr
.endobj kToLower,globl,hidden
kToLower16:
.rept 256
.short 0
.endr
.endobj kToLower16,globl,hidden
.previous
.init.start 300,_init_kToLower
@ -44,17 +38,11 @@ kToLower16:
xor %ecx,%ecx
0: inc %ecx
addb $0x20,'A'-1(%rsi,%rcx)
cmp $'Z'-'A',%ecx
cmp $'Z'-'A'+1,%ecx
jne 0b
xor %eax,%eax
mov $256,%ecx
0: lodsb
stosw
.loop 0b
pop %rsi
.init.end 300,_init_kToLower
.type gperf_downcase,@object
.globl gperf_downcase
gperf_downcase = kToLower
.source __FILE__

View file

@ -1,5 +1,5 @@
/*-*- 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
vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
@ -18,17 +18,27 @@
*/
#include "libc/macros.internal.h"
// Sets memory to zero.
.initbss 300,_init_kToUpper
// ASCII lowercase uppercase translation tables.
//
// C code should always favor memset(), since that's the one we've
// prototyped with the best optimizations. This definition is used
// by old code and sometimes code generators, as a thunk.
// char kToUpper[256];
//
// @param rdi is dest
// @param rsi is the number of bytes to set
// @see memset(), explicit_bzero()
bzero: mov %rsi,%rdx
xor %esi,%esi
jmp MemSet
.endfn bzero,globl
.source __FILE__
// @see kToLower
kToUpper:
.rept 256
.byte 0
.endr
.endobj kToUpper,globl,hidden
.previous
.init.start 300,_init_kToUpper
push %rdi
call imapxlatab
xchg %rsi,(%rsp)
xor %ecx,%ecx
0: inc %ecx
subb $0x20,'a'-1(%rsi,%rcx)
cmp $'z'-'a'+1,%ecx
jne 0b
pop %rsi
.init.end 300,_init_kToUpper

View file

@ -31,6 +31,7 @@ COSMOPOLITAN_C_START_
cosmopolitan § new technology » accounting
*/
uint32_t GetMaximumProcessorCount(uint16_t GroupNumber);
int GetUserName(char16_t (*buf)[257], uint32_t *in_out_size);
bool32 GlobalMemoryStatusEx(struct NtMemoryStatusEx *lpBuffer);
int32_t GetExitCodeProcess(int64_t hProcess, uint32_t *lpExitCode);

View file

@ -1,2 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp kernel32,__imp_GetMaximumProcessorCount,GetMaximumProcessorCount,627
.text.windows
GetMaximumProcessorCount:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_GetMaximumProcessorCount(%rip)
leave
ret
.endfn GetMaximumProcessorCount,globl
.previous

View file

@ -2280,7 +2280,7 @@ imp 'GetManagedApplications' GetManagedApplications advapi32 1337
imp 'GetMapMode' GetMapMode gdi32 1671
imp 'GetMappedFileNameA' GetMappedFileNameA KernelBase 594
imp 'GetMappedFileName' GetMappedFileNameW KernelBase 595
imp 'GetMaximumProcessorCount' GetMaximumProcessorCount kernel32 627
imp 'GetMaximumProcessorCount' GetMaximumProcessorCount kernel32 627 1 # Windows 7+
imp 'GetMaximumProcessorGroupCount' GetMaximumProcessorGroupCount kernel32 628
imp 'GetMemoryErrorHandlingCapabilities' GetMemoryErrorHandlingCapabilities kernel32 0 # KernelBase
imp 'GetMenu' GetMenu user32 1881 1

View file

@ -0,0 +1,84 @@
/*-*- 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/assert.h"
#include "libc/bits/popcnt.h"
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/dce.h"
#include "libc/macros.internal.h"
#include "libc/nt/dll.h"
#include "libc/nt/struct/systeminfo.h"
#include "libc/nt/systeminfo.h"
#include "libc/runtime/runtime.h"
#define CTL_HW 6
#define HW_NCPU 3
#define HW_NCPUONLINE_OPENBSD 25
#define HW_NCPUONLINE_NETBSD 16
#define ALL_PROCESSOR_GROUPS 0xffff
/**
* Returns number of CPUs in system.
*
* On Intel systems with HyperThreading this will return the number of
* cores multiplied by two.
*
* @return cpu count or 0 if it couldn't be determined
*/
unsigned GetCpuCount(void) {
size_t len;
int i, c, n, cmd[2];
uint64_t cpuset[16];
uint32_t (*f)(uint16_t);
struct NtSystemInfo sysinfo;
if (IsWindows()) {
if ((f = GetProcAddress(GetModuleHandle("KERNEL32"),
"GetMaximumProcessorCount"))) {
return f(ALL_PROCESSOR_GROUPS);
} else {
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
}
} else if (IsBsd()) {
len = sizeof(c);
cmd[0] = CTL_HW;
if (IsOpenbsd()) {
cmd[1] = HW_NCPUONLINE_OPENBSD;
} else if (IsNetbsd()) {
cmd[1] = HW_NCPUONLINE_NETBSD;
} else {
cmd[1] = HW_NCPU;
}
if (!sysctl(cmd, 2, &c, &len, 0, 0)) {
return c;
} else {
return 0;
}
} else {
if ((n = sched_getaffinity(0, sizeof(cpuset), cpuset)) > 0) {
assert(!(n & 7));
for (n >>= 3, c = i = 0; i < ARRAYLEN(cpuset); ++i) {
c += popcnt(cpuset[i]);
}
return c;
} else {
return 0;
}
}
}

View file

@ -33,6 +33,7 @@ LIBC_RUNTIME_A_CHECKS = \
$(LIBC_RUNTIME_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_RUNTIME_A_DIRECTDEPS = \
LIBC_BITS \
LIBC_CALLS \
LIBC_ELF \
LIBC_FMT \

View file

@ -27,13 +27,15 @@
* - `_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
* - `_SC_NPROCESSORS_ONLN` returns number of CPUs in the system
*
* You are encouraged to undiamond calls to this API as follows:
* Some suggestions:
*
* - Use `CLK_TCK` instead of `getconf(_SC_CLK_TCK)`
* - `CLK_TCK` should be favored over `getconf(_SC_CLK_TCK)`
* - Use `PAGESIZE` or `FRAMESIZE` instead of `getconf(_SC_PAGESIZE)`
*/
long sysconf(int name) {
int n;
switch (name) {
case _SC_ARG_MAX:
return ARG_MAX;
@ -41,6 +43,9 @@ long sysconf(int name) {
return CLK_TCK;
case _SC_PAGESIZE:
return FRAMESIZE;
case _SC_NPROCESSORS_ONLN:
n = GetCpuCount();
return n > 0 ? n : -1;
default:
return -1;
}

View file

@ -5,11 +5,13 @@
#define _SC_CLK_TCK 2
#define _SC_PAGESIZE 30
#define _SC_PAGE_SIZE 30
#define _SC_NPROCESSORS_ONLN 1002
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
long sysconf(int);
unsigned GetCpuCount(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

View file

@ -48,13 +48,9 @@ static textwindows ssize_t sendfile_linux2nt(int outfd, int infd,
}
}
static ssize_t sendfile_linux2netflix(int outfd, int infd,
static ssize_t sendfile_linux2bsd(int outfd, int infd,
int64_t *inout_opt_inoffset,
size_t uptobytes) {
int sys_sendfile_netflix(int32_t infd, int32_t outfd, int64_t offset,
size_t nbytes, const void *opt_hdtr,
int64_t *out_opt_sbytes,
int32_t flags) asm("sys_sendfile") hidden;
int rc;
int64_t offset, sbytes;
if (inout_opt_inoffset) {
@ -62,8 +58,12 @@ static ssize_t sendfile_linux2netflix(int outfd, int infd,
} else if ((offset = lseek(infd, 0, SEEK_CUR)) == -1) {
return -1;
}
if ((rc = sys_sendfile_netflix(infd, outfd, offset, uptobytes, NULL, &sbytes,
0)) != -1) {
if (IsFreebsd()) {
rc = sys_sendfile_freebsd(infd, outfd, offset, uptobytes, 0, &sbytes, 0);
} else {
rc = sys_sendfile_xnu(infd, outfd, offset, &sbytes, 0, 0);
}
if (rc != -1) {
if (inout_opt_inoffset) *inout_opt_inoffset += sbytes;
return sbytes;
} else {
@ -92,7 +92,7 @@ ssize_t sendfile(int outfd, int infd, int64_t *inout_opt_inoffset,
if (IsLinux()) {
return sys_sendfile(outfd, infd, inout_opt_inoffset, uptobytes);
} else if (IsFreebsd() || IsXnu()) {
return sendfile_linux2netflix(outfd, infd, inout_opt_inoffset, uptobytes);
return sendfile_linux2bsd(outfd, infd, inout_opt_inoffset, uptobytes);
} else if (IsWindows()) {
return sendfile_linux2nt(outfd, infd, inout_opt_inoffset, uptobytes);
} else {

View file

@ -31,6 +31,7 @@
#include "libc/nt/runtime.h"
#include "libc/nt/struct/win32finddata.h"
#include "libc/nt/synchronization.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/dt.h"
#include "libc/sysv/consts/o.h"
@ -70,6 +71,7 @@ struct dirstream {
};
struct {
bool isdone;
char16_t *name;
struct NtWin32FindData windata;
};
};
@ -110,7 +112,7 @@ struct dirent_netbsd {
char d_name[512];
};
static textwindows DIR *opendir_nt_impl(char16_t name[PATH_MAX], size_t len) {
static textwindows DIR *opendir_nt_impl(char16_t *name, size_t len) {
DIR *res;
if (len + 2 + 1 <= PATH_MAX) {
if (len > 1 && name[len - 1] != u'\\') {
@ -134,22 +136,34 @@ static textwindows DIR *opendir_nt_impl(char16_t name[PATH_MAX], size_t len) {
static textwindows noinline DIR *opendir_nt(const char *path) {
int len;
char16_t name[PATH_MAX];
if ((len = __mkntpath(path, name)) == -1) return NULL;
return opendir_nt_impl(name, len);
DIR *res;
char16_t *name;
if ((name = malloc(PATH_MAX * 2))) {
if ((len = __mkntpath(path, name)) != -1 &&
(res = opendir_nt_impl(name, len))) {
res->name = name;
return res;
}
free(name);
}
return NULL;
}
static textwindows noinline DIR *fdopendir_nt(int fd) {
DIR *res;
char16_t name[PATH_MAX];
char16_t *name;
if (__isfdkind(fd, kFdFile)) {
if ((name = malloc(PATH_MAX * 2))) {
if ((res = opendir_nt_impl(
name, GetFinalPathNameByHandle(
g_fds.p[fd].handle, name, ARRAYLEN(name),
g_fds.p[fd].handle, name, PATH_MAX,
kNtFileNameNormalized | kNtVolumeNameDos)))) {
res->name = name;
close(fd);
return res;
}
free(name);
}
} else {
ebadf();
}
@ -217,6 +231,7 @@ DIR *opendir(const char *name) {
struct Zipos *zip;
struct ZiposUri zipname;
if (weaken(__zipos_get) && weaken(__zipos_parseuri)(name, &zipname) != -1) {
ZTRACE("__zipos_opendir(%`'s)", name);
zip = weaken(__zipos_get)();
res = calloc(1, sizeof(DIR));
res->iszip = true;
@ -369,6 +384,7 @@ int closedir(DIR *dir) {
} else if (!IsWindows()) {
rc = close(dir->fd);
} else {
free(dir->name);
rc = FindClose(dir->fd) ? 0 : __winerr();
}
free(dir);
@ -393,3 +409,26 @@ int dirfd(DIR *dir) {
if (IsWindows()) return eopnotsupp();
return dir->fd;
}
/**
* Seeks to beginning of directory stream.
*/
void rewinddir(DIR *dir) {
if (dir->iszip) {
dir->tell = 0;
dir->zip.offset = GetZipCdirOffset(weaken(__zipos_get)()->cdir);
} else if (!IsWindows()) {
if (!lseek(dir->fd, 0, SEEK_SET)) {
dir->buf_pos = dir->buf_end = 0;
dir->tell = 0;
}
} else {
FindClose(dir->fd);
if ((dir->fd = FindFirstFile(dir->name, &dir->windata)) != -1) {
dir->isdone = false;
dir->tell = 0;
} else {
dir->isdone = true;
}
}
}

71
libc/str/bzero.c Normal file
View file

@ -0,0 +1,71 @@
/*-*- 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/str/str.h"
typedef long long xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
/**
* Sets memory to zero.
*/
void bzero(void *p, size_t n) {
char *b;
uint64_t x;
x = 0;
b = p;
switch (n) {
case 0:
break;
case 1:
__builtin_memcpy(b, &x, 1);
break;
case 2:
__builtin_memcpy(b, &x, 2);
break;
case 3:
__builtin_memcpy(b, &x, 2);
__builtin_memcpy(b + 1, &x, 2);
break;
case 4:
__builtin_memcpy(b, &x, 4);
break;
case 5 ... 7:
__builtin_memcpy(b, &x, 4);
__builtin_memcpy(b + n - 4, &x, 4);
break;
case 8:
__builtin_memcpy(b, &x, 8);
break;
case 9 ... 15:
__builtin_memcpy(b, &x, 8);
__builtin_memcpy(b + n - 8, &x, 8);
break;
case 16:
*(xmm_t *)b = (xmm_t){0};
break;
default:
while (n > 32) {
*(xmm_t *)(b + n - 16) = (xmm_t){0};
*(xmm_t *)(b + n - 32) = (xmm_t){0};
n -= 32;
}
if (n > 16) *(xmm_t *)(b + n - 16) = (xmm_t){0};
*(xmm_t *)b = (xmm_t){0};
break;
}
}

View file

@ -1,7 +1,7 @@
/*-*- 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 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
@ -20,30 +20,10 @@
// Sets memory to zero w/ accompanying non-optimizing macro.
//
// This is intended for security-conscious applications. This
// implementation also hoses every register the abi allows. A
// concomitant prototype (str.h) countermands compiler magic.
// This is intended for security-conscious applications.
//
// @param rdi is dest
// @param rsi is the number of bytes to set
explicit_bzero:
.leafprologue
mov %rsi,%rcx
xor %eax,%eax
rep stosb
xor %edx,%edx
xor %edi,%edi
xor %esi,%esi
xor %r8,%r8
xor %r9,%r9
xor %r10,%r10
xor %r11,%r11
pxor %xmm0,%xmm0
pxor %xmm1,%xmm1
pxor %xmm2,%xmm2
pxor %xmm3,%xmm3
pxor %xmm4,%xmm4
pxor %xmm5,%xmm5
.leafepilogue
jmp bzero
.endfn explicit_bzero,globl
.source __FILE__

View file

@ -9,7 +9,7 @@ COSMOPOLITAN_C_START_
extern const uint8_t gperf_downcase[256];
extern const uint8_t kToLower[256];
extern const uint16_t kToLower16[256];
extern const uint8_t kToUpper[256];
extern const uint8_t kBase36[256];
extern const char16_t kCp437[256];
@ -80,12 +80,14 @@ wint_t towupper(wint_t);
cosmopolitan § strings
*/
void bzero(void *, size_t) libcesque;
void *memset(void *, int, size_t) memcpyesque;
void *memcpy(void *restrict, const void *restrict, size_t) memcpyesque;
void *mempcpy(void *restrict, const void *restrict, size_t) memcpyesque;
void *memccpy(void *restrict, const void *restrict, int, size_t) memcpyesque;
void *memmove(void *, const void *, size_t) memcpyesque;
void *memeqmask(void *, const void *, const void *, size_t) memcpyesque;
void explicit_bzero(void *, size_t);
size_t strlen(const char *) strlenesque;
size_t strnlen(const char *, size_t) strlenesque;
@ -95,8 +97,6 @@ char *index(const char *, int) strlenesque;
void *memchr(const void *, int, size_t) strlenesque;
char *strchrnul(const char *, int) strlenesque returnsnonnull;
void *rawmemchr(const void *, int) strlenesque returnsnonnull;
void bzero(void *, size_t) paramsnonnull() libcesque;
void explicit_bzero(void *, size_t) paramsnonnull() libcesque;
size_t strlen16(const char16_t *) strlenesque;
size_t strnlen16(const char16_t *, size_t) strlenesque;
size_t strnlen16_s(const char16_t *, size_t);
@ -161,6 +161,8 @@ char *strcpy(char *, const char *) memcpyesque;
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
wchar_t *wcscpy(wchar_t *, const wchar_t *) memcpyesque;
char *strncat(char *, const char *, size_t) memcpyesque;
char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque;
wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t) memcpyesque;
char *strncpy(char *, const char *, size_t) memcpyesque;
char *strtok(char *, const char *) paramsnonnull((2)) libcesque;
char *strtok_r(char *, const char *, char **) paramsnonnull((2, 3));
@ -183,8 +185,7 @@ compatfn wchar_t *wmempcpy(wchar_t *, const wchar_t *, size_t) memcpyesque;
compatfn wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t) memcpyesque;
int timingsafe_memcmp(const void *, const void *, size_t);
void *tinymemccpy(void *, const void *, int, size_t) memcpyesque;
void *memmem(const void *, size_t, const void *, size_t)
paramsnonnull() nothrow nocallback nosideeffect;
void *memmem(const void *, size_t, const void *, size_t) libcesque nosideeffect;
char *strerror(int) returnsnonnull nothrow nocallback;
long a64l(const char *);
char *l64a(long);
@ -325,17 +326,6 @@ char *strsignal(int) returnsnonnull libcesque;
DeSt; \
})
#define explicit_bzero(STR, BYTES) \
do { \
void *Str; \
size_t Bytes; \
asm volatile("call\texplicit_bzero" \
: "=D"(Str), "=S"(Bytes) \
: "0"(STR), "1"(BYTES) \
: "rax", "rcx", "rdx", "r8", "r9", "r10", "r11", "memory", \
"cc", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5"); \
} while (0)
#else /* hosted+sse2 */
#define mempcpy(DEST, SRC, SIZE) \

View file

@ -62,6 +62,10 @@ o/$(MODE)/libc/str/getziplfileuncompressedsize.o: \
OVERRIDE_CFLAGS += \
-Os
o//libc/str/bzero.o: \
OVERRIDE_CFLAGS += \
-O2
o/$(MODE)/libc/str/iswpunct.o \
o/$(MODE)/libc/str/iswupper.o \
o/$(MODE)/libc/str/iswlower.o: \

39
libc/str/strncat16.c Normal file
View file

@ -0,0 +1,39 @@
/*-*- 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/str/str.h"
/**
* Appends at most 𝑛 shorts from 𝑠 to 𝑑.
*
* @param 𝑑 is both a NUL-terminated string and a buffer, needing
* an ARRAYLEN() of at least strlen16(𝑑)+strnlen16(𝑠,𝑛)+1
* @param 𝑠 is character array which needn't be NUL-terminated
* @param 𝑛 is maximum number of characters from s to copy
* @return 𝑑
* @note 𝑑 and 𝑠 can't overlap
* @asyncsignaslenafe
*/
char16_t *strncat16(char16_t *d, const char16_t *s, size_t n) {
size_t i;
char16_t *r = d;
d += strlen16(d);
for (i = 0; i < n && s[i]; ++i) d[i] = s[i];
d[i] = 0;
return r;
}

39
libc/str/wcsncat.c Normal file
View file

@ -0,0 +1,39 @@
/*-*- 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/str/str.h"
/**
* Appends at most 𝑛 wides from 𝑠 to 𝑑.
*
* @param 𝑑 is both a NUL-terminated string and a buffer, needing
* an ARRAYLEN() of at least wcslen(𝑑)+wcsnlen(𝑠,𝑛)+1
* @param 𝑠 is character array which needn't be NUL-terminated
* @param 𝑛 is maximum number of characters from s to copy
* @return 𝑑
* @note 𝑑 and 𝑠 can't overlap
* @asyncsignaslenafe
*/
wchar_t *wcsncat(wchar_t *d, const wchar_t *s, size_t n) {
size_t i;
wchar_t *r = d;
d += wcslen(d);
for (i = 0; i < n && s[i]; ++i) d[i] = s[i];
d[i] = 0;
return r;
}

View file

@ -184,9 +184,12 @@ syscon open O_SYNC 0x00101000 0x00000080 0x00000080 0x00000080 0x0000008
syscon open O_NOCTTY 0x00000100 0x00020000 0x00008000 0x00008000 0x00008000 0 # used for remote viewing (default behavior on freebsd)
syscon open O_NOATIME 0x00040000 0 0 0 0 0 # optimize away access time update
syscon open O_EXEC 0 0 0x00040000 0 0x04000000 0 # it's specified by posix what does it mean
syscon open O_SEARCH 0 0 0x00040000 0 0x00800000 0 # it's specified by posix what does it mean
syscon open O_DSYNC 0x00001000 0x00400000 0 0x00000080 0x00010000 0
syscon open O_RSYNC 0x00101000 0 0 0x00000080 0x00020000 0
syscon open O_PATH 0x00200000 0 0 0 0 0
syscon open O_SHLOCK 0 0x00000010 0x00000010 0x00000010 0x00000010 0
syscon open O_EXLOCK 0 0x00000020 0x00000020 0x00000020 0x00000020 0
syscon open O_TTY_INIT 0 0 0x00080000 0 0 0
syscon compat O_LARGEFILE 0 0 0 0 0 0
@ -352,7 +355,7 @@ syscon fcntl2 F_DUPFD 0 0 0 0 0 0 # consensus
syscon fcntl2 F_GETFD 1 1 1 1 1 1 # unix consensus & faked nt
syscon fcntl2 F_SETFD 2 2 2 2 2 2 # unix consensus & faked nt
syscon fcntl3 FD_CLOEXEC 1 1 1 1 1 1 # unix consensus & faked nt
syscon fcntl F_DUPFD_CLOEXEC 0x0406 67 17 10 12 0
syscon fcntl F_DUPFD_CLOEXEC 0x0406 67 17 10 12 0x0406 # faked nt
syscon fcntl2 F_GETFL 3 3 3 3 3 3 # unix consensus & faked nt
syscon fcntl2 F_SETFL 4 4 4 4 4 4 # unix consensus & faked nt
@ -398,6 +401,8 @@ syscon fcntl F_ULOCK 0 0 0 0 0 0 # TODO: specified by posix but
syscon ioctl FIONBIO 0x5421 0x8004667e 0x8004667e 0x8004667e 0x8004667e 0x8004667e # BSD-The New Technology consensus; FIONBIO is traditional O_NONBLOCK; see F_SETFL for re-imagined api
syscon ioctl FIOASYNC 0x5452 0x8004667d 0x8004667d 0x8004667d 0x8004667d 0x8004667d # BSD-The New Technology consensus
syscon ioctl FIONREAD 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # BSD-The New Technology consensus; bytes waiting in FD's input buffer
syscon ioctl FIOCLEX 0x5451 0x20006601 0x20006601 0x20006601 0x20006601 0x5451 # sets "close on exec" on file descriptor the fast way; faked nt
syscon ioctl FIONCLEX 0x5450 0x20006602 0x20006602 0x20006602 0x20006602 0x5450 # clears "close on exec" on file descriptor the fast way; faked nt
#syscon ioctl FIONWRITE 0x0 0x0 0x40046677 0x0 0x0 -1 # [FreeBSD Generalization] bytes queued in FD's output buffer (same as TIOCOUTQ for TTY FDs; see also SO_SNDBUF)
#syscon ioctl FIONSPACE 0x0 0x0 0x40046676 0x0 0x0 -1 # [FreeBSD Generalization] capacity of FD's output buffer, e.g. equivalent to TIOCGSERIAL w/ UART
syscon ioctl TIOCINQ 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # [Linuxism] same as FIONREAD
@ -480,7 +485,11 @@ syscon rlimit RLIMIT_LOCKS 10 127 127 127 127 127 # max flock() /
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 rlimit RLIMIT_RTPRIO 14 127 127 127 127 127 # woop
syscon rlimit RLIMIT_RTTIME 15 127 127 127 127 127 # woop
syscon rlimit RLIMIT_SWAP 127 127 12 127 127 127 # swap used
syscon rlimit RLIMIT_SBSIZE 127 127 9 127 127 127 # max size of all socket buffers
syscon rlimit RLIMIT_NPTS 127 127 11 127 127 127 # pseudoteletypewriters
syscon compat RLIMIT_VMEM 9 5 10 127 10 127 # same as RLIMIT_AS
# resource limit special values
@ -1208,14 +1217,21 @@ syscon statvfs ST_RDONLY 1 1 1 1 1 0 # unix consensus
syscon statvfs ST_APPEND 0x0100 0 0 0 0 0
syscon statvfs ST_IMMUTABLE 0x0200 0 0 0 0 0
syscon statvfs ST_MANDLOCK 0x40 0 0 0 0 0
syscon statvfs ST_NOATIME 0x0400 0 0 0 0 0
syscon statvfs ST_NODEV 4 0 0 0 0 0
syscon statvfs ST_NOATIME 0x0400 0 0 0x04000000 0 0
syscon statvfs ST_NODEV 4 0 0 0 0x00000010 0
syscon statvfs ST_NODIRATIME 0x0800 0 0 0 0 0
syscon statvfs ST_NOEXEC 8 0 0 0 0 0
syscon statvfs ST_RELATIME 0x1000 0 0 0 0 0
syscon statvfs ST_SYNCHRONOUS 0x10 0 0 0 0 0
syscon statvfs ST_NOEXEC 8 0 0 0 4 0
syscon statvfs ST_RELATIME 0x1000 0 0 0 0x00020000 0
syscon statvfs ST_SYNCHRONOUS 0x10 0 0 0 2 0
syscon statvfs ST_WRITE 0x80 0 0 0 0 0
# sendfile() flags
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon sf SF_NODISKIO 0 0 1 0 0 0
syscon sf SF_MNOWAIT 0 0 2 0 0 0
syscon sf SF_SYNC 0 0 4 0 0 0
# mount flags
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
@ -1331,11 +1347,14 @@ syscon termios TIOCSIG 0x40045436 0x2000745f 0x2004745f 0x8004745f 0x800
syscon termios TIOCSPGRP 0x5410 0x80047476 0x80047476 0x80047476 0x80047476 0 # boop
syscon termios TIOCSTI 0x5412 0x80017472 0x80017472 0 0 0 # boop
syscon termios TIOCGPTN 0x80045430 0 0x4004740f 0 0 0 # boop
syscon termios TIOCGSID 0x5429 0 0x40047463 0x40047463 0x40047463 0 # boop
syscon termios TIOCGSID 0x5429 0x40047463 0x40047463 0x40047463 0x40047463 0 # boop
syscon termios TABLDISC 0 0x3 0 0x3 0x3 0 # boop
syscon termios SLIPDISC 0 0x4 0x4 0x4 0x4 0 # boop
syscon termios PPPDISC 0 0x5 0x5 0x5 0x5 0 # boop
syscon termios TIOCDRAIN 0 0x2000745e 0x2000745e 0x2000745e 0x2000745e 0 # boop
syscon termios TCFLSH 0x540B 0 0 0 0 0 # boop
syscon termios TCSBRK 0x5409 0x2000745e 0x2000745e 0x2000745e 0x2000745e 0 # TIOCDRAIN on BSD
syscon termios TCXONC 0x540A 0 0 0 0 0 # boop
syscon termios TIOCDRAIN 0x5409 0x2000745e 0x2000745e 0x2000745e 0x2000745e 0 # TCSBRK on Linux
syscon termios TIOCSTAT 0 0x20007465 0x20007465 0x20007465 0x20007465 0 # boop
syscon termios TIOCSTART 0 0x2000746e 0x2000746e 0x2000746e 0x2000746e 0 # boop
syscon termios TIOCCDTR 0 0x20007478 0x20007478 0x20007478 0x20007478 0 # boop
@ -1428,6 +1447,7 @@ syscon termios VT1 0b0100000000000000 0b010000000000000000 0b0100000000000
syscon termios FFDLY 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag
syscon termios FF0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag
syscon termios FF1 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag
syscon termios CS5 0 0 0 0 0 0 # consensus
syscon termios CS6 0b0000000000010000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000000010000 # termios.c_cflag flag for 6-bit characters
syscon termios CS7 0b0000000000100000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000000000100000 # termios.c_cflag flag for 7-bit characters
syscon termios CS8 0b0000000000110000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000000000110000 # termios.c_cflag flag for 8-bit characters
@ -1478,6 +1498,13 @@ syscon termios TCION 3 4 4 4 4 0 # bsd consensus
syscon termios TCOFLUSH 1 2 2 2 2 0 # bsd consensus
syscon termios TCOOFF 0 1 1 1 1 0 # bsd consensus
syscon termios TCOON 1 2 2 2 2 0 # bsd consensus
syscon termios CREAD 0x80 0x0800 0x0800 0x0800 0x0800 0 # bsd consensus
syscon termios CSTOPB 0x40 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus
syscon termios HUPCL 0x0400 0x4000 0x4000 0x4000 0x4000 0 # bsd consensus
syscon termios CSTART 17 17 17 17 17 0 # unix consensus
syscon termios CSTOP 19 19 19 19 19 0 # unix consensus
syscon termios CSUSP 26 26 26 26 26 0 # unix consensus
syscon termios CWERASE 23 23 23 23 23 0 # unix consensus
# Pseudoteletypewriter Control
#
@ -1721,6 +1748,7 @@ syscon misc NL_SETD 1 1 0 1 1 0
syscon rusage RUSAGE_SELF 0 0 0 0 0 0 # unix consensus & faked nt
syscon rusage RUSAGE_CHILDREN -1 -1 -1 -1 -1 99 # unix consensus & unavailable on nt
syscon rusage RUSAGE_BOTH -2 99 99 99 99 99 # woop
syscon rusage RUSAGE_THREAD 1 99 1 1 1 1 # faked nt & unavailable on xnu
syscon misc FSETLOCKING_QUERY 0 0 0 0 0 0 # consensus
@ -1807,8 +1835,6 @@ syscon misc MCAST_EXCLUDE 0 2 2 0 0 0
syscon misc MCAST_MSFILTER 48 0 0 0 0 0
syscon misc AREGTYPE 0 0 0 0 0 0 # consensus
syscon misc B0 0 0 0 0 0 0 # consensus
syscon misc CS5 0 0 0 0 0 0 # consensus
syscon misc CTIME 0 0 0 0 0 0 # consensus
syscon misc EFD_CLOEXEC 0x080000 0 0 0 0 0
syscon misc EFD_NONBLOCK 0x0800 0 0 0 0 0
@ -1897,10 +1923,6 @@ syscon misc COPY_VERIFY 58 0 0 0 0 0
syscon misc CQUIT 28 28 28 28 28 0 # unix consensus
syscon misc CREPRINT 18 18 18 18 18 0 # unix consensus
syscon misc CRPRNT 18 18 18 18 18 0 # unix consensus
syscon misc CSTART 17 17 17 17 17 0 # unix consensus
syscon misc CSTOP 19 19 19 19 19 0 # unix consensus
syscon misc CSUSP 26 26 26 26 26 0 # unix consensus
syscon misc CWERASE 23 23 23 23 23 0 # unix consensus
syscon misc DATA 3 3 3 3 3 0 # unix consensus
syscon misc DEV_BSIZE 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus
syscon misc DIRTYPE 53 53 53 53 53 0 # unix consensus
@ -2980,46 +3002,46 @@ syscon misc AIO_ALLDONE 2 1 3 0 0 0
syscon misc AIO_NOTCANCELED 1 4 2 0 0 0
syscon misc AIO_CANCELED 0 2 1 0 0 0
syscon baud B0 0 0 0 0 0 0 # consensus
syscon baud B50 1 50 50 50 50 0 # bsd consensus
syscon baud B75 2 75 75 75 75 0 # bsd consensus
syscon baud B110 3 110 110 110 110 0 # bsd consensus
syscon baud B134 4 134 134 134 134 0 # bsd consensus
syscon baud B150 5 150 150 150 150 0 # bsd consensus
syscon baud B200 6 200 200 200 200 0 # bsd consensus
syscon baud B300 7 300 300 300 300 0 # bsd consensus
syscon baud B600 8 600 600 600 600 0 # bsd consensus
syscon baud B1200 9 0x04b0 0x04b0 0x04b0 0x04b0 0 # bsd consensus
syscon baud B1800 10 0x0708 0x0708 0x0708 0x0708 0 # bsd consensus
syscon baud B2400 11 0x0960 0x0960 0x0960 0x0960 0 # bsd consensus
syscon baud B4800 12 0x12c0 0x12c0 0x12c0 0x12c0 0 # bsd consensus
syscon baud B9600 13 0x2580 0x2580 0x2580 0x2580 0 # bsd consensus
syscon baud B19200 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus
syscon baud B38400 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus
syscon baud B57600 0x1001 0xe100 0xe100 0xe100 0xe100 0 # bsd consensus
syscon baud B115200 0x1002 0x01c200 0x01c200 0x01c200 0x01c200 0 # bsd consensus
syscon baud B230400 0x1003 0x038400 0x038400 0x038400 0x038400 0 # bsd consensus
syscon baud B500000 0x1005 0 0 0 0 0
syscon baud B576000 0x1006 0 0 0 0 0
syscon baud B1000000 0x1008 0 0 0 0 0
syscon baud B1152000 0x1009 0 0 0 0 0
syscon baud B1500000 0x100a 0 0 0 0 0
syscon baud B2000000 0x100b 0 0 0 0 0
syscon baud B2500000 0x100c 0 0 0 0 0
syscon baud B3000000 0x100d 0 0 0 0 0
syscon baud B3500000 0x100e 0 0 0 0 0
syscon baud B4000000 0x100f 0 0 0 0 0
syscon misc ALLOW_MEDIUM_REMOVAL 30 0 0 0 0 0
syscon misc ASU 0 2 2 2 2 0 # bsd consensus
syscon misc ATF_NETMASK 0x20 0 0 0 0 0
syscon misc AXSIG 0 0x10 0x10 0x10 0x10 0 # bsd consensus
syscon misc B1000000 0x1008 0 0 0 0 0
syscon misc B110 3 110 110 110 110 0 # bsd consensus
syscon misc B115200 0x1002 0x01c200 0x01c200 0x01c200 0x01c200 0 # bsd consensus
syscon misc B1152000 0x1009 0 0 0 0 0
syscon misc B1200 9 0x04b0 0x04b0 0x04b0 0x04b0 0 # bsd consensus
syscon misc B134 4 134 134 134 134 0 # bsd consensus
syscon misc B150 5 150 150 150 150 0 # bsd consensus
syscon misc B1500000 0x100a 0 0 0 0 0
syscon misc B1800 10 0x0708 0x0708 0x0708 0x0708 0 # bsd consensus
syscon misc B19200 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus
syscon misc B200 6 200 200 200 200 0 # bsd consensus
syscon misc B2000000 0x100b 0 0 0 0 0
syscon misc B230400 0x1003 0x038400 0x038400 0x038400 0x038400 0 # bsd consensus
syscon misc B2400 11 0x0960 0x0960 0x0960 0x0960 0 # bsd consensus
syscon misc B2500000 0x100c 0 0 0 0 0
syscon misc B300 7 300 300 300 300 0 # bsd consensus
syscon misc B3000000 0x100d 0 0 0 0 0
syscon misc B3500000 0x100e 0 0 0 0 0
syscon misc B38400 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus
syscon misc B4000000 0x100f 0 0 0 0 0
syscon misc B4800 12 0x12c0 0x12c0 0x12c0 0x12c0 0 # bsd consensus
syscon misc B50 1 50 50 50 50 0 # bsd consensus
syscon misc B500000 0x1005 0 0 0 0 0
syscon misc B57600 0x1001 0xe100 0xe100 0xe100 0xe100 0 # bsd consensus
syscon misc B576000 0x1006 0 0 0 0 0
syscon misc B600 8 600 600 600 600 0 # bsd consensus
syscon misc B75 2 75 75 75 75 0 # bsd consensus
syscon misc B9600 13 0x2580 0x2580 0x2580 0x2580 0 # bsd consensus
syscon misc BITSPERBYTE 8 0 0 0 0 0
syscon misc BLANK_CHECK 8 0 0 0 0 0
syscon misc CHANGE_DEFINITION 0x40 0 0 0 0 0
syscon misc CHARBITS 8 0 0 0 0 0
syscon misc CHECK_CONDITION 1 0 0 0 0 0
syscon misc CONDITION_GOOD 2 0 0 0 0 0
syscon misc CREAD 0x80 0x0800 0x0800 0x0800 0x0800 0 # bsd consensus
syscon misc CSTOPB 0x40 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus
syscon misc DATA_PROTECT 7 0 0 0 0 0
syscon misc DELAYTIMER_MAX 0x7fffffff 0 0 0 0 0
syscon misc DMAXEXP 0x0400 0 0 0 0 0
@ -3044,7 +3066,6 @@ syscon misc FOPEN_MAX 0x10 20 20 20 20 0 # bsd consensus
syscon misc FORMAT_UNIT 4 0 0 0 0 0
syscon misc HARDWARE_ERROR 4 0 0 0 0 0
syscon misc HEAD_OF_QUEUE_TAG 33 0 0 0 0 0
syscon misc HUPCL 0x0400 0x4000 0x4000 0x4000 0x4000 0 # bsd consensus
syscon misc IGMP_MEMBERSHIP_QUERY 17 0 0 0 0 0
syscon misc ILLEGAL_REQUEST 5 0 0 0 0 0
syscon misc INITIATE_RECOVERY 15 0 0 0 0 0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B0,0,0,0,0,0,0
.syscon baud,B0,0,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B1000000,0x1008,0,0,0,0,0
.syscon baud,B1000000,0x1008,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B110,3,110,110,110,110,0
.syscon baud,B110,3,110,110,110,110,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B115200,0x1002,0x01c200,0x01c200,0x01c200,0x01c200,0
.syscon baud,B115200,0x1002,0x01c200,0x01c200,0x01c200,0x01c200,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B1152000,0x1009,0,0,0,0,0
.syscon baud,B1152000,0x1009,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B1200,9,0x04b0,0x04b0,0x04b0,0x04b0,0
.syscon baud,B1200,9,0x04b0,0x04b0,0x04b0,0x04b0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B134,4,134,134,134,134,0
.syscon baud,B134,4,134,134,134,134,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B150,5,150,150,150,150,0
.syscon baud,B150,5,150,150,150,150,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B1500000,0x100a,0,0,0,0,0
.syscon baud,B1500000,0x100a,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B1800,10,0x0708,0x0708,0x0708,0x0708,0
.syscon baud,B1800,10,0x0708,0x0708,0x0708,0x0708,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B19200,14,0x4b00,0x4b00,0x4b00,0x4b00,0
.syscon baud,B19200,14,0x4b00,0x4b00,0x4b00,0x4b00,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B200,6,200,200,200,200,0
.syscon baud,B200,6,200,200,200,200,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B2000000,0x100b,0,0,0,0,0
.syscon baud,B2000000,0x100b,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B230400,0x1003,0x038400,0x038400,0x038400,0x038400,0
.syscon baud,B230400,0x1003,0x038400,0x038400,0x038400,0x038400,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B2400,11,0x0960,0x0960,0x0960,0x0960,0
.syscon baud,B2400,11,0x0960,0x0960,0x0960,0x0960,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B2500000,0x100c,0,0,0,0,0
.syscon baud,B2500000,0x100c,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B300,7,300,300,300,300,0
.syscon baud,B300,7,300,300,300,300,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B3000000,0x100d,0,0,0,0,0
.syscon baud,B3000000,0x100d,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B3500000,0x100e,0,0,0,0,0
.syscon baud,B3500000,0x100e,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B38400,15,0x9600,0x9600,0x9600,0x9600,0
.syscon baud,B38400,15,0x9600,0x9600,0x9600,0x9600,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B4000000,0x100f,0,0,0,0,0
.syscon baud,B4000000,0x100f,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B4800,12,0x12c0,0x12c0,0x12c0,0x12c0,0
.syscon baud,B4800,12,0x12c0,0x12c0,0x12c0,0x12c0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B50,1,50,50,50,50,0
.syscon baud,B50,1,50,50,50,50,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B500000,0x1005,0,0,0,0,0
.syscon baud,B500000,0x1005,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B57600,0x1001,0xe100,0xe100,0xe100,0xe100,0
.syscon baud,B57600,0x1001,0xe100,0xe100,0xe100,0xe100,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B576000,0x1006,0,0,0,0,0
.syscon baud,B576000,0x1006,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B600,8,600,600,600,600,0
.syscon baud,B600,8,600,600,600,600,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B75,2,75,75,75,75,0
.syscon baud,B75,2,75,75,75,75,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,B9600,13,0x2580,0x2580,0x2580,0x2580,0
.syscon baud,B9600,13,0x2580,0x2580,0x2580,0x2580,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CREAD,0x80,0x0800,0x0800,0x0800,0x0800,0
.syscon termios,CREAD,0x80,0x0800,0x0800,0x0800,0x0800,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CS5,0,0,0,0,0,0
.syscon termios,CS5,0,0,0,0,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CSTART,17,17,17,17,17,0
.syscon termios,CSTART,17,17,17,17,17,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CSTOP,19,19,19,19,19,0
.syscon termios,CSTOP,19,19,19,19,19,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CSTOPB,0x40,0x0400,0x0400,0x0400,0x0400,0
.syscon termios,CSTOPB,0x40,0x0400,0x0400,0x0400,0x0400,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CSUSP,26,26,26,26,26,0
.syscon termios,CSUSP,26,26,26,26,26,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,CWERASE,23,23,23,23,23,0
.syscon termios,CWERASE,23,23,23,23,23,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ioctl,FIOCLEX,0x5451,0x20006601,0x20006601,0x20006601,0x20006601,0x5451

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ioctl,FIONCLEX,0x5450,0x20006602,0x20006602,0x20006602,0x20006602,0x5450

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon fcntl,F_DUPFD_CLOEXEC,0x0406,67,17,10,12,0
.syscon fcntl,F_DUPFD_CLOEXEC,0x0406,67,17,10,12,0x0406

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,HUPCL,0x0400,0x4000,0x4000,0x4000,0x4000,0
.syscon termios,HUPCL,0x0400,0x4000,0x4000,0x4000,0x4000,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon open,O_EXLOCK,0,0x00000020,0x00000020,0x00000020,0x00000020,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon open,O_SEARCH,0,0,0x00040000,0,0x00800000,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon open,O_SHLOCK,0,0x00000010,0x00000010,0x00000010,0x00000010,0

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon rlimit,RLIMIT_NPTS,127,127,11,127,127,127

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon rlimit,RLIMIT_RTTIME,15,127,127,127,127,127

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon rlimit,RLIMIT_SBSIZE,127,127,9,127,127,127

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon rlimit,RLIMIT_SWAP,127,127,12,127,127,127

View file

@ -0,0 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon rusage,RUSAGE_BOTH,-2,99,99,99,99,99

Some files were not shown because too many files have changed in this diff Show more