2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
|
2021-02-08 17:19:00 +00:00
|
|
|
#include "libc/calls/struct/dirent.h"
|
2021-02-07 14:11:44 +00:00
|
|
|
#include "libc/calls/struct/iovec.h"
|
|
|
|
#include "libc/calls/struct/rlimit.h"
|
|
|
|
#include "libc/calls/struct/rusage.h"
|
2020-10-11 04:18:53 +00:00
|
|
|
#include "libc/calls/struct/sigaction.h"
|
2021-10-14 00:27:13 +00:00
|
|
|
#include "libc/calls/struct/sigset.h"
|
2021-04-18 18:34:59 +00:00
|
|
|
#include "libc/calls/struct/sigval.h"
|
2021-02-07 14:11:44 +00:00
|
|
|
#include "libc/calls/struct/stat.h"
|
|
|
|
#include "libc/calls/struct/sysinfo.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/calls/struct/timespec.h"
|
2021-02-07 14:11:44 +00:00
|
|
|
#include "libc/calls/struct/tms.h"
|
|
|
|
#include "libc/calls/struct/utsname.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/dce.h"
|
|
|
|
#include "libc/fmt/pflink.h"
|
|
|
|
#include "libc/sysv/consts/s.h"
|
|
|
|
#include "libc/sysv/consts/sig.h"
|
|
|
|
|
|
|
|
#define EOF -1 /* end of file */
|
|
|
|
#define WEOF -1u /* end of file (multibyte) */
|
|
|
|
#define _IOFBF 0 /* fully buffered */
|
|
|
|
#define _IOLBF 1 /* line buffered */
|
|
|
|
#define _IONBF 2 /* no buffering */
|
|
|
|
#define SEEK_SET 0 /* relative to beginning */
|
|
|
|
#define SEEK_CUR 1 /* relative to current position */
|
|
|
|
#define SEEK_END 2 /* relative to end */
|
|
|
|
|
|
|
|
#define SIG_ERR ((void (*)(int))(-1))
|
|
|
|
#define SIG_DFL ((void *)0)
|
|
|
|
#define SIG_IGN ((void *)1)
|
|
|
|
|
2021-04-21 02:14:21 +00:00
|
|
|
#define MAP_FAILED ((void *)-1)
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#define ARCH_SET_GS 0x1001
|
|
|
|
#define ARCH_SET_FS 0x1002
|
|
|
|
#define ARCH_GET_FS 0x1003
|
|
|
|
#define ARCH_GET_GS 0x1004
|
|
|
|
|
|
|
|
#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) ((s)&0x80)
|
|
|
|
#define WEXITSTATUS(s) (((s)&0xff00) >> 8)
|
|
|
|
#define WIFCONTINUED(s) ((s) == 0xffff)
|
|
|
|
#define WIFEXITED(s) (!WTERMSIG(s))
|
2021-01-25 21:08:05 +00:00
|
|
|
#define WIFSIGNALED(s) (((s)&0xffff) - 1u < 0xffu)
|
2020-06-15 14:18:57 +00:00
|
|
|
#define WIFSTOPPED(s) ((short)((((s)&0xffff) * 0x10001) >> 8) > 0x7f00)
|
|
|
|
#define WSTOPSIG(s) WEXITSTATUS(s)
|
|
|
|
#define WTERMSIG(s) ((s)&0x7f)
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
#define W_STOPCODE(s) ((s) << 8 | 0177)
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ cosmopolitan § system calls ─╬─│┼
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
|
|
|
typedef int sig_atomic_t;
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
DIR *fdopendir(int) dontdiscard;
|
|
|
|
DIR *opendir(const char *) dontdiscard;
|
2020-06-15 14:18:57 +00:00
|
|
|
bool fileexists(const char *);
|
|
|
|
bool isdirectory(const char *);
|
|
|
|
bool isexecutable(const char *);
|
|
|
|
bool isregularfile(const char *);
|
2021-08-18 21:21:30 +00:00
|
|
|
bool issymlink(const char *);
|
2020-06-15 14:18:57 +00:00
|
|
|
bool32 isatty(int) nosideeffect;
|
|
|
|
bool32 ischardev(int) nosideeffect;
|
2020-11-09 23:41:11 +00:00
|
|
|
char *commandv(const char *, char[hasatleast PATH_MAX]);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
char *get_current_dir_name(void) dontdiscard;
|
2020-08-25 11:23:25 +00:00
|
|
|
char *getcwd(char *, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
char *realpath(const char *, char *);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
char *replaceuser(const char *) dontdiscard;
|
2020-06-15 14:18:57 +00:00
|
|
|
char *ttyname(int);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
int access(const char *, int) dontthrow;
|
2020-06-15 14:18:57 +00:00
|
|
|
int arch_prctl();
|
2020-08-25 11:23:25 +00:00
|
|
|
int chdir(const char *);
|
2020-06-15 14:18:57 +00:00
|
|
|
int chmod(const char *, uint32_t);
|
2020-08-25 11:23:25 +00:00
|
|
|
int chown(const char *, uint32_t, uint32_t);
|
2021-08-12 07:42:14 +00:00
|
|
|
int chroot(const char *);
|
2020-06-15 14:18:57 +00:00
|
|
|
int close(int);
|
|
|
|
int closedir(DIR *);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int creat(const char *, uint32_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
int dirfd(DIR *);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int dup(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int dup2(int, int);
|
|
|
|
int dup3(int, int, int);
|
|
|
|
int execl(const char *, const char *, ...) nullterminated();
|
|
|
|
int execle(const char *, const char *, ...) nullterminated((1));
|
|
|
|
int execlp(const char *, const char *, ...) nullterminated();
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int execv(const char *, char *const[]);
|
|
|
|
int execve(const char *, char *const[], char *const[]);
|
|
|
|
int execvp(const char *, char *const[]);
|
|
|
|
int execvpe(const char *, char *const[], char *const[]);
|
2020-06-15 14:18:57 +00:00
|
|
|
int faccessat(int, const char *, int, uint32_t);
|
|
|
|
int fadvise(int, uint64_t, uint64_t, int);
|
2021-08-12 07:42:14 +00:00
|
|
|
int fchdir(int);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
int fchmod(int, uint32_t) dontthrow;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int fchmodat(int, const char *, uint32_t, int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int fchown(int, uint32_t, uint32_t);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int fchownat(int, const char *, uint32_t, uint32_t, int);
|
2020-10-27 10:39:46 +00:00
|
|
|
int fcntl(int, int, ...);
|
2020-06-15 14:18:57 +00:00
|
|
|
int fdatasync(int);
|
|
|
|
int filecmp(const char *, const char *);
|
|
|
|
int flock(int, int);
|
|
|
|
int fork(void);
|
2020-08-25 11:23:25 +00:00
|
|
|
int fstat(int, struct stat *);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int fstatat(int, const char *, struct stat *, int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int fsync(int);
|
|
|
|
int ftruncate(int, int64_t);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int getdents(unsigned, void *, unsigned, long *);
|
2020-11-09 23:41:11 +00:00
|
|
|
int getdomainname(char *, size_t);
|
|
|
|
int gethostname(char *, size_t);
|
2021-08-16 22:26:31 +00:00
|
|
|
int getpgid(int);
|
2021-08-12 07:42:14 +00:00
|
|
|
int getpid(void);
|
2022-04-12 12:20:17 +00:00
|
|
|
int gettid(void);
|
2020-06-15 14:18:57 +00:00
|
|
|
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);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
int link(const char *, const char *) dontthrow;
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
int linkat(int, const char *, int, const char *, int);
|
2020-08-25 11:23:25 +00:00
|
|
|
int lstat(const char *, struct stat *);
|
2021-08-18 21:21:30 +00:00
|
|
|
int lutimes(const char *, const struct timeval[2]);
|
2020-06-15 14:18:57 +00:00
|
|
|
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);
|
2021-08-12 07:42:14 +00:00
|
|
|
int mkfifoat(int, const char *, uint32_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
int mknod(const char *, uint32_t, uint64_t);
|
|
|
|
int mknodat(int, const char *, int32_t, uint64_t);
|
|
|
|
int mlock(const void *, size_t);
|
|
|
|
int mlock2(const void *, size_t, int);
|
|
|
|
int mlockall(int);
|
|
|
|
int munlock(const void *, size_t);
|
|
|
|
int munlockall(void);
|
|
|
|
int nice(int);
|
2021-05-14 12:36:58 +00:00
|
|
|
int open(const char *, int, ...);
|
2020-08-25 11:23:25 +00:00
|
|
|
int openat(int, const char *, int, ...);
|
2020-06-15 14:18:57 +00:00
|
|
|
int pause(void);
|
|
|
|
int personality(uint64_t);
|
2021-01-25 21:08:05 +00:00
|
|
|
int pipe(int[hasatleast 2]);
|
|
|
|
int pipe2(int[hasatleast 2], int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int posix_fadvise(int, uint64_t, uint64_t, int);
|
|
|
|
int posix_madvise(void *, uint64_t, int);
|
2022-04-18 07:01:26 +00:00
|
|
|
int prctl(int, ...);
|
2020-06-15 14:18:57 +00:00
|
|
|
int raise(int);
|
2021-08-16 22:26:31 +00:00
|
|
|
int reboot(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int remove(const char *);
|
|
|
|
int rename(const char *, const char *);
|
|
|
|
int renameat(int, const char *, int, const char *);
|
|
|
|
int renameat2(long, const char *, long, const char *, int);
|
|
|
|
int rmdir(const char *);
|
|
|
|
int sched_getaffinity(int, uint64_t, void *);
|
|
|
|
int sched_setaffinity(int, uint64_t, const void *);
|
|
|
|
int sched_yield(void);
|
2020-11-09 23:41:11 +00:00
|
|
|
int setegid(uint32_t);
|
|
|
|
int seteuid(uint32_t);
|
2022-04-15 06:39:48 +00:00
|
|
|
int setgid(int);
|
2022-04-20 16:56:53 +00:00
|
|
|
int setpgrp(void);
|
2020-06-15 14:18:57 +00:00
|
|
|
int setpgid(int, int);
|
|
|
|
int setpriority(int, unsigned, int);
|
2020-11-09 23:41:11 +00:00
|
|
|
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);
|
2020-06-15 14:18:57 +00:00
|
|
|
int setrlimit(int, const struct rlimit *);
|
|
|
|
int setsid(void);
|
2022-04-15 06:39:48 +00:00
|
|
|
int setuid(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int sigignore(int);
|
2021-08-18 21:21:30 +00:00
|
|
|
int siginterrupt(int, int);
|
2020-06-15 14:18:57 +00:00
|
|
|
int sigprocmask(int, const struct sigset *, struct sigset *);
|
2021-08-12 07:42:14 +00:00
|
|
|
int sigqueue(int, int, const union sigval);
|
2020-06-15 14:18:57 +00:00
|
|
|
int sigsuspend(const struct sigset *);
|
2020-08-25 11:23:25 +00:00
|
|
|
int stat(const char *, struct stat *);
|
2020-06-15 14:18:57 +00:00
|
|
|
int symlink(const char *, const char *);
|
|
|
|
int symlinkat(const char *, int, const char *);
|
|
|
|
int sync_file_range(int, int64_t, int64_t, unsigned);
|
2021-08-12 07:42:14 +00:00
|
|
|
int sysctl(const int *, unsigned, void *, size_t *, void *, size_t);
|
2021-05-14 12:36:58 +00:00
|
|
|
int sysinfo(struct sysinfo *);
|
2020-06-15 14:18:57 +00:00
|
|
|
int touch(const char *, uint32_t);
|
|
|
|
int truncate(const char *, uint64_t);
|
|
|
|
int ttyname_r(int, char *, size_t);
|
|
|
|
int uname(struct utsname *);
|
|
|
|
int unlink(const char *);
|
|
|
|
int unlink_s(const char **);
|
|
|
|
int unlinkat(int, const char *, int);
|
2020-10-27 10:39:46 +00:00
|
|
|
int vfork(void) returnstwice;
|
2020-06-15 14:18:57 +00:00
|
|
|
int wait(int *);
|
|
|
|
int wait3(int *, int, struct rusage *);
|
|
|
|
int wait4(int, int *, int, struct rusage *);
|
|
|
|
int waitpid(int, int *, int);
|
2021-02-07 14:11:44 +00:00
|
|
|
intptr_t syscall(int, ...);
|
2022-03-24 15:00:21 +00:00
|
|
|
long ptrace(int, ...);
|
2020-06-15 14:18:57 +00:00
|
|
|
long telldir(DIR *);
|
|
|
|
long times(struct tms *);
|
|
|
|
size_t GetFileSize(const char *);
|
2022-04-20 16:56:53 +00:00
|
|
|
ssize_t getfiledescriptorsize(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
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);
|
2021-08-12 07:42:14 +00:00
|
|
|
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);
|
2020-06-15 14:18:57 +00:00
|
|
|
ssize_t read(int, void *, size_t);
|
2020-10-11 04:18:53 +00:00
|
|
|
ssize_t readansi(int, char *, size_t);
|
2021-08-18 21:21:30 +00:00
|
|
|
ssize_t readlink(const char *, char *, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
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 *);
|
|
|
|
uint32_t getegid(void) nosideeffect;
|
|
|
|
uint32_t geteuid(void) nosideeffect;
|
|
|
|
uint32_t getgid(void) nosideeffect;
|
|
|
|
uint32_t getpgrp(void) nosideeffect;
|
|
|
|
uint32_t getsid(int) nosideeffect;
|
|
|
|
uint32_t getuid(void) nosideeffect;
|
2022-04-13 15:49:17 +00:00
|
|
|
uint32_t umask(uint32_t);
|
2021-08-12 07:42:14 +00:00
|
|
|
void rewinddir(DIR *);
|
|
|
|
void sync(void);
|
2022-03-19 04:37:41 +00:00
|
|
|
int getloadavg(double *, int);
|
2022-04-18 07:01:26 +00:00
|
|
|
int seccomp(unsigned, unsigned, void *);
|
2022-04-20 16:56:53 +00:00
|
|
|
int clone(int (*)(void *), void *, size_t, int, void *, int *, void *, size_t,
|
|
|
|
int *);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
│ 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__)
|
|
|
|
|
2021-02-26 02:30:17 +00:00
|
|
|
#define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__)
|
|
|
|
#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA)
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#endif /* GNU && !ANSI */
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ */
|