2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_
|
2022-08-13 20:11:56 +00:00
|
|
|
#include "libc/calls/struct/fd.internal.h"
|
2021-04-18 18:34:59 +00:00
|
|
|
#include "libc/calls/struct/sigval.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/dce.h"
|
2021-03-01 07:42:35 +00:00
|
|
|
#include "libc/macros.internal.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#define kSigactionMinRva 8 /* >SIG_{ERR,DFL,IGN,...} */
|
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
#define kIoMotion ((const int8_t[3]){1, 0, 0})
|
|
|
|
|
2022-11-08 19:39:50 +00:00
|
|
|
_Hide extern struct Fds g_fds;
|
|
|
|
_Hide extern const struct Fd kEmptyFd;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-11-08 19:39:50 +00:00
|
|
|
int __reservefd(int) _Hide;
|
|
|
|
int __reservefd_unlocked(int) _Hide;
|
|
|
|
void __releasefd(int) _Hide;
|
|
|
|
int __ensurefds(int) _Hide;
|
|
|
|
int __ensurefds_unlocked(int) _Hide;
|
|
|
|
void __printfds(void) _Hide;
|
2021-01-28 03:34:02 +00:00
|
|
|
|
2022-05-18 23:41:29 +00:00
|
|
|
forceinline int64_t __getfdhandleactual(int fd) {
|
|
|
|
return g_fds.p[fd].handle;
|
|
|
|
}
|
|
|
|
|
2021-01-28 03:34:02 +00:00
|
|
|
forceinline bool __isfdopen(int fd) {
|
|
|
|
return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind != kFdEmpty;
|
|
|
|
}
|
|
|
|
|
2021-02-02 16:14:45 +00:00
|
|
|
forceinline bool __isfdkind(int fd, int kind) {
|
2021-01-28 03:34:02 +00:00
|
|
|
return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind == kind;
|
|
|
|
}
|
2020-06-15 14:18:57 +00:00
|
|
|
|
2022-04-08 03:30:04 +00:00
|
|
|
forceinline size_t _clampio(size_t size) {
|
2020-06-15 14:18:57 +00:00
|
|
|
if (!IsTrustworthy()) {
|
|
|
|
return MIN(size, 0x7ffff000);
|
|
|
|
} else {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-08 19:39:50 +00:00
|
|
|
int sys_close_nt(struct Fd *, int) _Hide;
|
|
|
|
int _check_interrupts(bool, struct Fd *) _Hide;
|
2021-02-26 02:30:17 +00:00
|
|
|
int sys_openat_metal(int, const char *, int, unsigned);
|
2020-11-28 20:01:51 +00:00
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ */
|