mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Reduce makefile dependencies by 10%
The includes in libc/calls/calls.h have now been refactored so that functions with struct parameters are declared in libc/calls/struct/
This commit is contained in:
parent
4e7ce1538c
commit
adac64a52b
202 changed files with 372 additions and 319 deletions
|
@ -19,7 +19,6 @@
|
|||
#include "dsp/tty/tty.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/termios.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/bits/atomic.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
struct stat st;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/errno.h"
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
|
@ -142,6 +141,7 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
#include "libc/sysv/consts/rlim.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/musl/ftw.h"
|
||||
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/sysinfo.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/tms.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/pflink.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
#define _POSIX_VERSION 200809L
|
||||
#define _POSIX2_VERSION _POSIX_VERSION
|
||||
|
@ -46,14 +30,6 @@
|
|||
#define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT)
|
||||
#define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT)
|
||||
|
||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(mode) (((mode)&S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(mode) (((mode)&S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(mode) (((mode)&S_IFMT) == S_IFSOCK)
|
||||
|
||||
#define WCOREDUMP(s) (0x80 & (s))
|
||||
#define WEXITSTATUS(s) ((0xff00 & (s)) >> 8)
|
||||
#define WIFCONTINUED(s) ((s) == 0xffff)
|
||||
|
@ -72,8 +48,6 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
DIR *fdopendir(int) dontdiscard;
|
||||
DIR *opendir(const char *) dontdiscard;
|
||||
bool fileexists(const char *);
|
||||
bool isdirectory(const char *);
|
||||
bool isexecutable(const char *);
|
||||
|
@ -94,9 +68,7 @@ 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);
|
||||
int dirfd(DIR *);
|
||||
int dup(int);
|
||||
int dup2(int, int);
|
||||
int dup3(int, int, int);
|
||||
|
@ -119,8 +91,6 @@ int fdatasync(int);
|
|||
int filecmp(const char *, const char *);
|
||||
int flock(int, int);
|
||||
int fork(void);
|
||||
int fstat(int, struct stat *);
|
||||
int fstatat(int, const char *, struct stat *, int);
|
||||
int fsync(int);
|
||||
int ftruncate(int, int64_t);
|
||||
int getdents(unsigned, void *, unsigned, long *);
|
||||
|
@ -137,8 +107,6 @@ int getppid(void);
|
|||
int getpriority(int, unsigned);
|
||||
int getresgid(uint32_t *, uint32_t *, uint32_t *);
|
||||
int getresuid(uint32_t *, uint32_t *, uint32_t *);
|
||||
int getrlimit(int, struct rlimit *);
|
||||
int getrusage(int, struct rusage *);
|
||||
int getsid(int) nosideeffect libcesque;
|
||||
int gettid(void) libcesque;
|
||||
int getuid(void) nosideeffect libcesque;
|
||||
|
@ -146,8 +114,6 @@ int kill(int, int);
|
|||
int killpg(int, int);
|
||||
int link(const char *, const char *) dontthrow;
|
||||
int linkat(int, const char *, int, const char *, int);
|
||||
int lstat(const char *, struct stat *);
|
||||
int lutimes(const char *, const struct timeval[2]);
|
||||
int madvise(void *, uint64_t, int);
|
||||
int mincore(void *, size_t, unsigned char *);
|
||||
int mkdir(const char *, uint32_t);
|
||||
|
@ -193,79 +159,46 @@ int setregid(uint32_t, uint32_t);
|
|||
int setresgid(uint32_t, uint32_t, uint32_t);
|
||||
int setresuid(uint32_t, uint32_t, uint32_t);
|
||||
int setreuid(uint32_t, uint32_t);
|
||||
int setrlimit(int, const struct rlimit *);
|
||||
int setsid(void);
|
||||
int setuid(int);
|
||||
int sigignore(int);
|
||||
int siginterrupt(int, 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 tgkill(int, int, int);
|
||||
int tkill(int, int);
|
||||
int touch(const char *, uint32_t);
|
||||
int truncate(const char *, uint64_t);
|
||||
int ttyname_r(int, char *, size_t);
|
||||
int umask(int);
|
||||
int uname(struct utsname *);
|
||||
int unlink(const char *);
|
||||
int unlink_s(const char **);
|
||||
int unlinkat(int, const char *, int);
|
||||
int vfork(void) returnstwice;
|
||||
int wait(int *);
|
||||
int wait3(int *, int, struct rusage *);
|
||||
int wait4(int, int *, int, struct rusage *);
|
||||
int waitpid(int, int *, int);
|
||||
intptr_t syscall(int, ...);
|
||||
long ptrace(int, ...);
|
||||
long telldir(DIR *);
|
||||
long times(struct tms *);
|
||||
size_t GetFileSize(const char *);
|
||||
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 getfiledescriptorsize(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);
|
||||
ssize_t read(int, void *, size_t);
|
||||
ssize_t readansi(int, char *, size_t);
|
||||
ssize_t readlink(const char *, char *, size_t);
|
||||
ssize_t readlinkat(int, const char *, char *, size_t);
|
||||
ssize_t splice(int, int64_t *, int, int64_t *, size_t, uint32_t);
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t);
|
||||
ssize_t write(int, const void *, size_t);
|
||||
struct dirent *readdir(DIR *);
|
||||
void rewinddir(DIR *);
|
||||
void sync(void);
|
||||
|
||||
int clone(int (*)(void *), void *, size_t, int, void *, int *, void *, size_t,
|
||||
int *);
|
||||
int futex(uint32_t *, int, int, const struct timespec *, uint32_t *);
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § system calls » formatting ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2));
|
||||
int vdprintf(int, const char *, va_list) paramsnonnull();
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § system calls » link-time optimizations ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
|
||||
#define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA)
|
||||
|
||||
#endif /* GNU && !ANSI */
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ */
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/files.h"
|
||||
|
|
|
@ -16,13 +16,12 @@
|
|||
│ 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/errno.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_close_nt(struct Fd *fd) {
|
||||
int e;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
|
@ -48,7 +49,7 @@
|
|||
*/
|
||||
int close(int fd) {
|
||||
int rc;
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if (fd == -1) {
|
||||
rc = 0;
|
||||
} else if (fd < 0) {
|
||||
|
@ -80,7 +81,7 @@ int close(int fd) {
|
|||
__releasefd_unlocked(fd);
|
||||
}
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
STRACE("%s(%d) → %d% m", "close", fd, rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/struct/filetime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/madv.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/popcnt.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
|
|
@ -19,18 +19,15 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/nt/enum/filemapflags.h"
|
||||
#include "libc/nt/enum/pageflags.h"
|
||||
#include "libc/nt/memory.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/struct/processmemorycounters.h"
|
||||
#include "libc/nt/struct/securityattributes.h"
|
||||
#include "libc/runtime/directmap.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
textwindows struct DirectMap sys_mmap_nt(void *addr, size_t size, int prot,
|
||||
int flags, int fd, int64_t off) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
|
||||
/**
|
||||
* Formats string directly to file descriptor.
|
||||
|
|
18
libc/calls/dprintf.h
Normal file
18
libc/calls/dprintf.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_
|
||||
#include "libc/fmt/pflink.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2));
|
||||
int vdprintf(int, const char *, va_list) paramsnonnull();
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
|
||||
#define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA)
|
||||
|
||||
#endif /* GNU && !ANSI */
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ */
|
|
@ -16,15 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
@ -41,12 +37,12 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) {
|
|||
if (oldfd < 0) return ebadf();
|
||||
if (flags & ~O_CLOEXEC) return einval();
|
||||
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
|
||||
if (oldfd >= g_fds.n ||
|
||||
(g_fds.p[oldfd].kind != kFdFile && g_fds.p[oldfd].kind != kFdSocket &&
|
||||
g_fds.p[oldfd].kind != kFdConsole)) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return ebadf();
|
||||
}
|
||||
|
||||
|
@ -54,19 +50,19 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) {
|
|||
for (;;) {
|
||||
if (newfd == -1) {
|
||||
if ((newfd = __reservefd_unlocked(start)) == -1) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
if (__ensurefds_unlocked(newfd) == -1) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return -1;
|
||||
}
|
||||
if (g_fds.p[newfd].kind) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
close(newfd);
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
}
|
||||
if (!g_fds.p[newfd].kind) {
|
||||
g_fds.p[newfd].kind = kFdReserved;
|
||||
|
@ -96,6 +92,6 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) {
|
|||
rc = __winerr();
|
||||
}
|
||||
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/paths.h"
|
||||
|
|
|
@ -17,18 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/nt/createfile.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/nt/enum/filesharemode.h"
|
||||
#include "libc/nt/enum/status.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/nt/file.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/struct/fileaccessinformation.h"
|
||||
#include "libc/nt/struct/filebasicinformation.h"
|
||||
#include "libc/nt/struct/iostatusblock.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/madv.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -36,7 +30,7 @@
|
|||
textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len,
|
||||
int advice) {
|
||||
int64_t h1, h2;
|
||||
int flags, mode;
|
||||
int rc, flags, mode;
|
||||
uint32_t perm, share, attr;
|
||||
if (!__isfdkind(fd, kFdFile)) return ebadf();
|
||||
h1 = g_fds.p[fd].handle;
|
||||
|
@ -49,6 +43,7 @@ textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len,
|
|||
case MADV_RANDOM:
|
||||
flags |= O_RANDOM;
|
||||
break;
|
||||
case MADV_WILLNEED:
|
||||
case MADV_SEQUENTIAL:
|
||||
flags |= O_SEQUENTIAL;
|
||||
break;
|
||||
|
@ -56,14 +51,19 @@ textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len,
|
|||
return einval();
|
||||
}
|
||||
if (GetNtOpenFlags(flags, mode, &perm, &share, 0, &attr) == -1) return -1;
|
||||
|
||||
__fds_lock();
|
||||
if ((h2 = ReOpenFile(h1, perm, share, attr)) != -1) {
|
||||
if (h2 != h1) {
|
||||
CloseHandle(h1);
|
||||
g_fds.p[fd].handle = h2;
|
||||
}
|
||||
g_fds.p[fd].flags = flags;
|
||||
return 0;
|
||||
rc = 0;
|
||||
} else {
|
||||
return __winerr();
|
||||
rc = __winerr();
|
||||
}
|
||||
__fds_unlock();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/struct/sigval.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/sysinfo.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/nt/iphlpapi.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
|
|
|
@ -42,7 +42,7 @@ textwindows int ioctl_tiocgwinsz_nt(struct Fd *fd, struct winsize *ws) {
|
|||
rc = -1;
|
||||
e = errno;
|
||||
if (ws) {
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
fds[0] = fd, fds[1] = g_fds.p + 1, fds[2] = g_fds.p + 0;
|
||||
GetStartupInfo(&startinfo);
|
||||
for (i = 0; i < ARRAYLEN(fds); ++i) {
|
||||
|
@ -76,7 +76,7 @@ textwindows int ioctl_tiocgwinsz_nt(struct Fd *fd, struct winsize *ws) {
|
|||
ebadf();
|
||||
}
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
} else {
|
||||
efault();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
|
||||
/**
|
||||
* Returns true if file descriptor is backed by character i/o.
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/ntmagicpaths.internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "libc/nt/createfile.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
|
@ -79,7 +81,7 @@ textwindows int sys_open_nt(int dirfd, const char *file, uint32_t flags,
|
|||
int32_t mode) {
|
||||
int fd;
|
||||
ssize_t rc;
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if ((rc = fd = __reservefd_unlocked(-1)) != -1) {
|
||||
if ((flags & O_ACCMODE) == O_RDWR && !strcmp(file, kNtMagicPaths.devtty)) {
|
||||
rc = sys_open_nt_console(dirfd, &kNtMagicPaths, flags, mode, fd);
|
||||
|
@ -89,7 +91,7 @@ textwindows int sys_open_nt(int dirfd, const char *file, uint32_t flags,
|
|||
if (rc == -1) {
|
||||
__releasefd_unlocked(fd);
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) {
|
|||
int reader, writer;
|
||||
char16_t pipename[64];
|
||||
CreatePipeName(pipename);
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if ((reader = __reservefd_unlocked(-1)) == -1) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return -1;
|
||||
}
|
||||
if ((writer = __reservefd_unlocked(-1)) == -1) {
|
||||
__releasefd_unlocked(reader);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return -1;
|
||||
}
|
||||
if (~flags & O_DIRECT) {
|
||||
|
@ -51,10 +51,10 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) {
|
|||
} else {
|
||||
mode = kNtPipeTypeMessage | kNtPipeReadmodeMessage;
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
hin = CreateNamedPipe(pipename, kNtPipeAccessInbound | kNtFileFlagOverlapped,
|
||||
mode, 1, PIPE_BUF, PIPE_BUF, 0, &kNtIsInheritable);
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if (hin != -1) {
|
||||
if ((hout = CreateFile(pipename, kNtGenericWrite, 0, &kNtIsInheritable,
|
||||
kNtOpenExisting, kNtFileFlagOverlapped, 0)) != -1) {
|
||||
|
@ -68,7 +68,7 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) {
|
|||
g_fds.p[writer].handle = hout;
|
||||
pipefd[0] = reader;
|
||||
pipefd[1] = writer;
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return 0;
|
||||
} else {
|
||||
CloseHandle(hin);
|
||||
|
@ -76,6 +76,6 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) {
|
|||
}
|
||||
__releasefd_unlocked(writer);
|
||||
__releasefd_unlocked(reader);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
|
@ -69,7 +68,7 @@ textwindows int sys_poll_nt(struct pollfd *fds, uint64_t nfds, uint64_t *ms) {
|
|||
// we need to read static variables
|
||||
// we might need to spawn threads and open pipes
|
||||
_spinlock(&poll_lock);
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
for (gotinvals = failed = sn = pn = i = 0; i < nfds; ++i) {
|
||||
if (fds[i].fd < 0) continue;
|
||||
if (__isfdopen(fds[i].fd)) {
|
||||
|
@ -115,7 +114,7 @@ textwindows int sys_poll_nt(struct pollfd *fds, uint64_t nfds, uint64_t *ms) {
|
|||
++gotinvals;
|
||||
}
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
_spunlock(&poll_lock);
|
||||
if (failed) {
|
||||
// failed to create a polling solution
|
||||
|
|
|
@ -46,7 +46,7 @@ static const char *__fdkind2str(int x) {
|
|||
|
||||
void __printfds(void) {
|
||||
int i;
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
for (i = 0; i < g_fds.n; ++i) {
|
||||
if (!g_fds.p[i].kind) continue;
|
||||
kprintf("%3d %s", i, __fdkind2str(g_fds.p[i].kind));
|
||||
|
@ -57,5 +57,5 @@ void __printfds(void) {
|
|||
if (g_fds.p[i].extra) kprintf(" extra=%ld", g_fds.p[i].extra);
|
||||
kprintf("\n");
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/termios.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
|
|
@ -69,9 +69,9 @@ int __ensurefds_unlocked(int fd) {
|
|||
* Grows file descriptor array memory if needed.
|
||||
*/
|
||||
int __ensurefds(int fd) {
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
fd = __ensurefds_unlocked(fd);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -96,9 +96,9 @@ int __reservefd_unlocked(int start) {
|
|||
*/
|
||||
int __reservefd(int start) {
|
||||
int fd;
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
fd = __reservefd_unlocked(start);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -108,12 +108,12 @@ int __reservefd(int start) {
|
|||
static void FreeFds(void) {
|
||||
int i, keep = 3;
|
||||
STRACE("FreeFds()");
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
for (i = keep; i < g_fds.n; ++i) {
|
||||
if (g_fds.p[i].kind) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
close(i);
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
}
|
||||
}
|
||||
if (g_fds.p != g_fds.__init_p) {
|
||||
|
@ -125,7 +125,7 @@ static void FreeFds(void) {
|
|||
g_fds.p = g_fds.__init_p;
|
||||
g_fds.n = ARRAYLEN(g_fds.__init_p);
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
}
|
||||
|
||||
static textstartup void FreeFdsInit(void) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall-nt.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
/**
|
||||
* Sets nice value of thing.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
|
@ -28,6 +27,7 @@
|
|||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigaction-freebsd.internal.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int sigaddset(sigset_t *, int) paramsnonnull();
|
||||
int sigdelset(sigset_t *, int) paramsnonnull();
|
||||
int sigemptyset(sigset_t *) paramsnonnull();
|
||||
int sigfillset(sigset_t *) paramsnonnull();
|
||||
int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_ */
|
|
@ -41,9 +41,9 @@ void _check_sigchld(void) {
|
|||
int pids[64];
|
||||
uint32_t i, n;
|
||||
int64_t handles[64];
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
n = __sample_pids(pids, handles, true);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
if (!n) return;
|
||||
i = WaitForMultipleObjects(n, handles, false, 0);
|
||||
if (i == kNtWaitTimeout) return;
|
||||
|
@ -61,8 +61,8 @@ void _check_sigchld(void) {
|
|||
CloseHandle(handles[i]);
|
||||
__releasefd(pids[i]);
|
||||
}
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
g_fds.p[pids[i]].zombie = true;
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
__sig_add(SIGCHLD, CLD_EXITED);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
int sys_sigprocmask(int how, const sigset_t *opt_set,
|
||||
sigset_t *opt_out_oldset) {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
|
||||
hidden extern int __vforked;
|
||||
hidden extern int __fds_lock;
|
||||
hidden extern int __fds_lock_obj;
|
||||
hidden extern int __sig_lock_obj;
|
||||
hidden extern bool __time_critical;
|
||||
hidden extern unsigned __sighandrvas[NSIG];
|
||||
hidden extern unsigned __sighandflags[NSIG];
|
||||
hidden extern const struct NtSecurityAttributes kNtIsInheritable;
|
||||
|
||||
void __fds_lock(void);
|
||||
void __fds_unlock(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ */
|
||||
|
|
|
@ -13,5 +13,13 @@ struct dirent { /* linux getdents64 abi */
|
|||
struct dirstream;
|
||||
typedef struct dirstream DIR;
|
||||
|
||||
DIR *fdopendir(int) dontdiscard;
|
||||
DIR *opendir(const char *) dontdiscard;
|
||||
int closedir(DIR *);
|
||||
int dirfd(DIR *);
|
||||
long telldir(DIR *);
|
||||
struct dirent *readdir(DIR *);
|
||||
void rewinddir(DIR *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ */
|
||||
|
|
|
@ -7,5 +7,9 @@ struct iovec {
|
|||
size_t iov_len;
|
||||
};
|
||||
|
||||
ssize_t preadv(int, struct iovec *, int, int64_t);
|
||||
ssize_t pwritev(int, const struct iovec *, int, int64_t);
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ */
|
||||
|
|
|
@ -7,5 +7,8 @@ struct rlimit {
|
|||
uint64_t rlim_max; /* maximum limit in bytes */
|
||||
};
|
||||
|
||||
int getrlimit(int, struct rlimit *);
|
||||
int setrlimit(int, const struct rlimit *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ */
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct rusage {
|
||||
union {
|
||||
struct {
|
||||
struct timeval ru_utime; /* user CPU time used */
|
||||
struct timeval ru_stime; /* system CPU time used */
|
||||
int64_t ru_maxrss; /* maximum resident set size in (kb) */
|
||||
|
@ -23,9 +21,10 @@ struct rusage {
|
|||
int64_t ru_nvcsw; /* voluntary context switches */
|
||||
int64_t ru_nivcsw; /* involuntary context switches */
|
||||
};
|
||||
uint8_t __conservatism[1024];
|
||||
};
|
||||
};
|
||||
|
||||
int getrusage(int, struct rusage *);
|
||||
int wait3(int *, int, struct rusage *);
|
||||
int wait4(int, int *, int, struct rusage *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "libc/calls/typedef/sigaction_f.h"
|
||||
#include "libc/calls/typedef/sighandler_t.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct sigaction { /* cosmo abi */
|
||||
|
|
|
@ -6,5 +6,14 @@ typedef struct sigset {
|
|||
uint64_t __bits[2];
|
||||
} sigset_t;
|
||||
|
||||
int sigprocmask(int, const sigset_t *, sigset_t *);
|
||||
int sigsuspend(const sigset_t *);
|
||||
|
||||
int sigaddset(sigset_t *, int) paramsnonnull();
|
||||
int sigdelset(sigset_t *, int) paramsnonnull();
|
||||
int sigemptyset(sigset_t *) paramsnonnull();
|
||||
int sigfillset(sigset_t *) paramsnonnull();
|
||||
int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect;
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ */
|
||||
|
|
|
@ -7,5 +7,7 @@ union sigval {
|
|||
void *sival_ptr;
|
||||
};
|
||||
|
||||
int sigqueue(int, int, const union sigval);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ */
|
||||
|
|
|
@ -22,5 +22,10 @@ struct stat { /* cosmo abi */
|
|||
uint64_t st_gen; /* xnu/bsd only */
|
||||
};
|
||||
|
||||
int stat(const char *, struct stat *);
|
||||
int lstat(const char *, struct stat *);
|
||||
int fstat(int, struct stat *);
|
||||
int fstatat(int, const char *, struct stat *, int);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_ */
|
||||
|
|
|
@ -18,5 +18,7 @@ struct sysinfo {
|
|||
uint32_t mem_unit; /* ram stuff above is multiples of this */
|
||||
};
|
||||
|
||||
int sysinfo(struct sysinfo *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ */
|
||||
|
|
|
@ -7,5 +7,7 @@ struct timespec {
|
|||
int64_t tv_nsec; /* nanoseconds */
|
||||
};
|
||||
|
||||
int futex(uint32_t *, int, int, const struct timespec *, uint32_t *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ */
|
||||
|
|
|
@ -7,5 +7,7 @@ struct timeval {
|
|||
int64_t tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
int lutimes(const char *, const struct timeval[2]);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ */
|
||||
|
|
|
@ -9,5 +9,7 @@ struct tms {
|
|||
int64_t tms_cstime; /* children kernelspace time */
|
||||
};
|
||||
|
||||
long times(struct tms *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ */
|
||||
|
|
|
@ -14,5 +14,7 @@ struct utsname {
|
|||
char domainname[SYS_NMLN];
|
||||
};
|
||||
|
||||
int uname(struct utsname *);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_ */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
|
||||
/**
|
||||
* Waits for status to change on any child process.
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
|
@ -60,7 +59,7 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus,
|
|||
struct NtProcessMemoryCountersEx memcount;
|
||||
struct NtFileTime createfiletime, exitfiletime, kernelfiletime, userfiletime;
|
||||
if (_check_interrupts(true, g_fds.p)) return eintr();
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if (pid != -1 && pid != 0) {
|
||||
if (pid < 0) {
|
||||
/* XXX: this is sloppy */
|
||||
|
@ -76,12 +75,12 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus,
|
|||
g_fds.p[pid].handle = handle;
|
||||
g_fds.p[pid].flags = O_CLOEXEC;
|
||||
} else {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
CloseHandle(handle);
|
||||
return echild();
|
||||
}
|
||||
} else {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return echild();
|
||||
}
|
||||
}
|
||||
|
@ -91,11 +90,11 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus,
|
|||
} else {
|
||||
count = __sample_pids(pids, handles, false);
|
||||
if (!count) {
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return echild();
|
||||
}
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
for (;;) {
|
||||
if (_check_interrupts(true, 0)) return eintr();
|
||||
dwExitCode = kNtStillActive;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rusage.h"
|
||||
|
||||
/**
|
||||
* Waits for status to change on process.
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/typedef/sigaction_f.h"
|
||||
|
|
24
libc/intrin/_spinlock_gettid.S
Normal file
24
libc/intrin/_spinlock_gettid.S
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- 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 2022 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/macros.internal.h"
|
||||
.privileged
|
||||
|
||||
_spinlock_gettid:
|
||||
jmp gettid
|
||||
.endfn _spinlock_gettid,globl
|
24
libc/intrin/_spinlock_yield.S
Normal file
24
libc/intrin/_spinlock_yield.S
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- 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 2022 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/macros.internal.h"
|
||||
.privileged
|
||||
|
||||
_spinlock_yield:
|
||||
jmp sched_yield
|
||||
.endfn _spinlock_yield,globl
|
|
@ -27,7 +27,7 @@
|
|||
privileged int _trylock_debug_4(int *lock, const char *lockname,
|
||||
const char *file, int line, const char *func) {
|
||||
int owner = 0;
|
||||
int me = gettid();
|
||||
int me = _spinlock_gettid();
|
||||
if (_lockcmpxchgp(lock, &owner, me)) {
|
||||
return 0;
|
||||
} else if (owner != me) {
|
||||
|
|
|
@ -19,13 +19,22 @@
|
|||
#include "libc/bits/pushpop.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
STATIC_YOINK("_init_g_fds");
|
||||
|
||||
struct Fds g_fds;
|
||||
_Alignas(64) int __fds_lock;
|
||||
_Alignas(64) int __fds_lock_obj;
|
||||
|
||||
void __fds_lock(void) {
|
||||
_spinlock(&__fds_lock_obj);
|
||||
}
|
||||
|
||||
void __fds_unlock(void) {
|
||||
_spunlock(&__fds_lock_obj);
|
||||
}
|
||||
|
||||
textstartup void InitializeFileDescriptors(void) {
|
||||
struct Fds *fds;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
|
||||
void __releasefd(int fd) {
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
__releasefd_unlocked(fd);
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/lockcmpxchg.h"
|
||||
#include "libc/intrin/lockcmpxchgp.h"
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § spinlocks ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│─╝
|
||||
privileged unsophisticated locking subroutines */
|
||||
|
||||
#if IsModeDbg() && !defined(_SPINLOCK_DEBUG)
|
||||
#if defined(MODE_DBG) && !defined(_SPINLOCK_DEBUG)
|
||||
#define _SPINLOCK_DEBUG
|
||||
#endif
|
||||
|
||||
|
@ -17,7 +13,7 @@
|
|||
#define _spinlock(lock) _spinlock_ndebug(lock)
|
||||
#define _spinlock_ndebug(lock) _spinlock_cooperative(lock)
|
||||
#define _trylock(lock) _trylock_debug(lock)
|
||||
#define _seizelock(lock) _seizelock_impl(lock, gettid())
|
||||
#define _seizelock(lock) _seizelock_impl(lock, _spinlock_gettid())
|
||||
#elif defined(TINY)
|
||||
#define _spinlock(lock) _spinlock_tiny(lock)
|
||||
#define _spinlock_ndebug(lock) _spinlock_tiny(lock)
|
||||
|
@ -72,12 +68,14 @@
|
|||
} else if (++__tries & 7) { \
|
||||
__builtin_ia32_pause(); \
|
||||
} else { \
|
||||
sched_yield(); \
|
||||
_spinlock_yield(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int _spinlock_gettid(void);
|
||||
int _trylock_debug_4(int *, const char *, const char *, int, const char *);
|
||||
void _spinlock_debug_4(int *, const char *, const char *, int, const char *);
|
||||
void _spinlock_yield(void);
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ */
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_SIGNAL_H_
|
||||
#define LIBC_ISYSTEM_SIGNAL_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef LIBC_ISYSTEM_SYS_UTSNAME_H_
|
||||
#define LIBC_ISYSTEM_SYS_UTSNAME_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/syscall_support-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/lockcmpxchg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigaltstack.h"
|
||||
#include "libc/log/internal.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/dprintf.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_
|
||||
#define COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_
|
||||
#include "libc/bits/asmflag.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
|
@ -16,16 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
static int thepid;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/runtime/clktck.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
struct clockinfo_netbsd {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "libc/nt/thread.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/clone.h"
|
||||
#include "libc/sysv/consts/futex.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/rlim.h"
|
||||
|
||||
long GetResourceLimit(int resource) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define ShouldUseMsabiAttribute() 1
|
||||
#include "libc/bits/asmflag.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -16,14 +16,10 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/clktck.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/rlim.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,7 +52,7 @@ textwindows int sys_accept_nt(struct Fd *fd, void *addr, uint32_t *addrsize,
|
|||
if ((!(flags & SOCK_NONBLOCK) ||
|
||||
__sys_ioctlsocket_nt(h, FIONBIO, (uint32_t[]){1}) != -1) &&
|
||||
(sockfd2 = calloc(1, sizeof(struct SockFd)))) {
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
if ((client = __reservefd_unlocked(-1)) != -1) {
|
||||
sockfd2->family = sockfd->family;
|
||||
sockfd2->type = sockfd->type;
|
||||
|
@ -62,10 +62,10 @@ textwindows int sys_accept_nt(struct Fd *fd, void *addr, uint32_t *addrsize,
|
|||
g_fds.p[client].mode = 0140666;
|
||||
g_fds.p[client].handle = h;
|
||||
g_fds.p[client].extra = (uintptr_t)sockfd2;
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return client;
|
||||
}
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
free(sockfd2);
|
||||
}
|
||||
__sys_closesocket_nt(h);
|
||||
|
|
|
@ -1342,12 +1342,12 @@ static textwindows dontinline int sys_epoll_create1_nt(uint32_t flags) {
|
|||
__releasefd(fd);
|
||||
return -1;
|
||||
}
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
g_fds.p[fd].kind = kFdEpoll;
|
||||
g_fds.p[fd].handle = ephnd;
|
||||
g_fds.p[fd].flags = flags;
|
||||
g_fds.p[fd].mode = 0140666;
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,13 +64,13 @@ textwindows int sys_socket_nt(int family, int type, int protocol) {
|
|||
sockfd->family = family;
|
||||
sockfd->type = truetype;
|
||||
sockfd->protocol = protocol;
|
||||
_spinlock(&__fds_lock);
|
||||
__fds_lock();
|
||||
g_fds.p[fd].kind = kFdSocket;
|
||||
g_fds.p[fd].flags = oflags;
|
||||
g_fds.p[fd].mode = 0140666;
|
||||
g_fds.p[fd].handle = h;
|
||||
g_fds.p[fd].extra = (uintptr_t)sockfd;
|
||||
_spunlock(&__fds_lock);
|
||||
__fds_unlock();
|
||||
return fd;
|
||||
} else {
|
||||
__releasefd(fd);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue