Initial import

This commit is contained in:
Justine Tunney 2020-06-15 07:18:57 -07:00
commit c91b3c5006
14915 changed files with 590219 additions and 0 deletions

View file

@ -0,0 +1,14 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct dirent {
uint64_t d_ino; /* inode number */
int64_t d_off; /* implementation-dependent location number */
uint16_t d_reclen; /* byte length of this whole struct and string */
uint8_t d_type; /* DT_UNKNOWN, DT_BLK, DT_DIR, etc. it's flaky */
char d_name[1]; /* NUL-terminated basename */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ */

14
libc/calls/struct/flock.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct flock {
short l_type;
short l_whence;
int64_t l_start;
int64_t l_len;
int l_pid;
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_ */

View file

@ -0,0 +1,24 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERFIXEDSCREENINFO_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERFIXEDSCREENINFO_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct FrameBufferFixedScreenInfo {
char id[16];
uint64_t smem_start;
uint32_t smem_len;
uint32_t type;
uint32_t type_aux;
uint32_t visual;
uint16_t xpanstep;
uint16_t ypanstep;
uint16_t ywrapstep;
uint32_t line_length;
uint64_t mmio_start;
uint32_t mmio_len;
uint32_t accel;
uint16_t capabilities;
uint16_t reserved[2];
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERFIXEDSCREENINFO_H_ */

View file

@ -0,0 +1,44 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERVIRTUALSCREENINFO_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERVIRTUALSCREENINFO_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct FrameBufferBitField {
uint32_t offset;
uint32_t length;
uint32_t msb_right;
};
struct FrameBufferVirtualScreenInfo {
uint32_t xres;
uint32_t yres;
uint32_t xres_virtual;
uint32_t yres_virtual;
uint32_t xoffset;
uint32_t yoffset;
uint32_t bits_per_pixel;
uint32_t grayscale;
struct FrameBufferBitField red;
struct FrameBufferBitField green;
struct FrameBufferBitField blue;
struct FrameBufferBitField transp;
uint32_t nonstd;
uint32_t activate;
uint32_t height;
uint32_t width;
uint32_t accel_flags;
uint32_t pixclock;
uint32_t left_margin;
uint32_t right_margin;
uint32_t upper_margin;
uint32_t lower_margin;
uint32_t hsync_len;
uint32_t vsync_len;
uint32_t sync;
uint32_t vmode;
uint32_t rotate;
uint32_t colorspace;
uint32_t reserved[4];
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERVIRTUALSCREENINFO_H_ */

11
libc/calls/struct/iovec.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct iovec {
void *iov_base;
size_t iov_len;
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ */

View file

@ -0,0 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_
#include "libc/calls/struct/timeval.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct itimerval {
struct timeval it_interval; /* {0,0} means singleshot */
struct timeval it_value; /* {0,0} means disarm */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_ */

View file

@ -0,0 +1,55 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_
#include "libc/calls/struct/stat.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
union metastat {
struct stat linux;
struct stat$xnu {
int32_t st_dev;
uint16_t st_mode, st_nlink;
uint64_t st_ino;
uint32_t st_uid, st_gid;
int32_t st_rdev;
struct timespec st_atim, st_mtim, st_ctim, st_birthtim;
int64_t st_size, st_blocks;
int32_t st_blksize;
uint32_t st_flags, st_gen;
int32_t st_lspare;
int64_t st_qspare[2];
} xnu;
struct stat$freebsd {
uint64_t st_dev, st_ino, st_nlink;
uint16_t st_mode;
int16_t st_padding0;
uint32_t st_uid, st_gid;
int32_t st_padding1;
uint64_t st_rdev;
struct timespec st_atim, st_mtim, st_ctim, st_birthtim;
int64_t st_size, st_blocks;
int32_t st_blksize;
uint32_t st_flags;
uint64_t st_gen;
unsigned long st_spare[10];
} freebsd;
struct stat$openbsd {
uint32_t st_mode;
int32_t st_dev;
uint64_t st_ino;
uint32_t st_nlink, st_uid, st_gid;
int32_t st_rdev;
struct timespec st_atim, st_mtim, st_ctim;
int64_t st_size, st_blocks;
int32_t st_blksize;
uint32_t st_flags, st_gen;
struct timespec __st_birthtim;
} openbsd;
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_ */

View file

@ -0,0 +1,35 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_METATERMIOS_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_METATERMIOS_H_
#include "libc/calls/struct/termios.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct termios$xnu {
uint64_t c_iflag;
uint64_t c_oflag;
uint64_t c_cflag;
uint64_t c_lflag;
uint8_t c_cc[20];
uint64_t c_ispeed;
uint64_t c_ospeed;
};
struct termios$bsd {
uint32_t c_iflag;
uint32_t c_oflag;
uint32_t c_cflag;
uint32_t c_lflag;
uint8_t c_cc[20];
uint32_t c_ispeed;
uint32_t c_ospeed;
};
union metatermios {
struct termios linux;
struct termios$xnu xnu;
struct termios$bsd bsd;
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_METATERMIOS_H_ */

View file

@ -0,0 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct rlimit {
int64_t rlim_cur;
int64_t rlim_max;
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ */

View file

@ -0,0 +1,31 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_
#include "libc/calls/struct/timeval.h"
#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 */
int64_t ru_ixrss; /* integral shared memory size */
int64_t ru_idrss; /* integral unshared data size */
int64_t ru_isrss; /* integral unshared stack size */
int64_t ru_minflt; /* page reclaims (soft page faults) */
int64_t ru_majflt; /* page faults (hard page faults) */
int64_t ru_nswap; /* swaps */
int64_t ru_inblock; /* block input operations */
int64_t ru_oublock; /* block output operations */
int64_t ru_msgsnd; /* IPC messages sent */
int64_t ru_msgrcv; /* IPC messages received */
int64_t ru_nsignals; /* signals received */
int64_t ru_nvcsw; /* voluntary context switches */
int64_t ru_nivcsw; /* involuntary context switches */
};
uint8_t __conservatism[1024];
};
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */

View file

@ -0,0 +1,10 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct sched_param {
int32_t sched_priority;
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_ */

View file

@ -0,0 +1,20 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_
#include "libc/calls/struct/sigset.h"
#include "libc/calls/typedef/sigaction_f.h"
#include "libc/calls/typedef/sighandler_t.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct sigaction { /* cosmo abi */
union {
sighandler_t sa_handler;
sigaction_f sa_sigaction;
};
uint64_t sa_flags;
void (*sa_restorer)(void);
struct sigset sa_mask;
int64_t __pad;
} aligned(8);
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_ */

View file

@ -0,0 +1,16 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
};
typedef struct sigaltstack stack_t;
static_assert(sizeof(stack_t) == 24);
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_H_ */

View file

@ -0,0 +1,57 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_
#include "libc/calls/struct/sigval.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct siginfo {
int32_t si_signo;
int32_t si_errno;
int32_t si_code;
union {
struct {
union {
struct {
int32_t si_pid;
uint32_t si_uid;
};
struct {
int32_t si_timerid;
int32_t si_overrun;
};
};
union {
union sigval si_value;
struct {
int32_t si_status;
int64_t si_utime, si_stime;
};
};
};
struct {
void *si_addr;
int16_t si_addr_lsb;
union {
struct {
void *si_lower;
void *si_upper;
};
uint32_t si_pkey;
};
};
struct {
int64_t si_band;
int32_t si_fd;
};
struct {
void *si_call_addr;
int32_t si_syscall;
uint32_t si_arch;
};
char __ignoreme[128 - 2 * sizeof(int32_t) - sizeof(int64_t)];
};
} aligned(8);
typedef struct siginfo siginfo_t;
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_ */

View file

@ -0,0 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct sigset {
uint32_t sig[4]; /* ignore sig[2] and sig[3] (for freebsd) */
} aligned(8);
typedef struct sigset sigset_t;
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ */

View file

@ -0,0 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
union sigval {
int32_t sival_int;
void *sival_ptr;
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ */

28
libc/calls/struct/stat.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_
#include "libc/calls/struct/timespec.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct stat {
int64_t st_dev; /* 0: id of device with file */
int64_t st_ino; /* 8: inode number in disk b-tree */
int64_t st_nlink; /* 16: hard link count */
int32_t st_mode; /* 24: octal file mask thing */
int32_t st_uid; /* 28: user id of owner */
int32_t st_gid; /* group id of owning group */
int32_t __pad; /* ignore this */
int64_t st_rdev; /* id of device if a special file */
int64_t st_size; /* bytes in file */
int64_t st_blksize; /* preferred chunking for underlying filesystem */
int64_t st_blocks; /* number of 512-byte pages allocated to file */
struct timespec st_atim; /* access time (consider noatime) */
struct timespec st_mtim; /* modified time */
struct timespec st_ctim; /* complicated time */
int64_t __future[3 + 10]; /* reserved for future use */
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_ */

View file

@ -0,0 +1,22 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct sysinfo {
int64_t uptime; /* seconds since boot */
uint64_t loads[3]; /* 1-5-15 min active process averages */
uint64_t totalram; /* system physical memory */
uint64_t freeram; /* amount of ram currently going to waste */
uint64_t sharedram; /* bytes w/ pages mapped into multiple progs */
uint64_t bufferram; /* lingering disk pages; see fadvise */
uint64_t totalswap; /* size of emergency memory */
uint64_t freeswap; /* hopefully equal to totalswap */
int16_t procs; /* number of processes */
int16_t __ignore; /* padding */
uint64_t totalhigh; /* wut */
uint64_t freehigh; /* wut */
uint32_t mem_unit; /* ram stuff above is multiples of this */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ */

View file

@ -0,0 +1,18 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TERMIOS_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TERMIOS_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct termios { /* GNU/Systemd ABI */
uint32_t c_iflag; /* input modes */
uint32_t c_oflag; /* output modes */
uint32_t c_cflag; /* control modes */
uint32_t c_lflag; /* local modes */
uint8_t c_cc[32]; /* code mappings */
uint32_t c_ispeed; /* input speed */
uint32_t c_ospeed; /* output speed */
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TERMIOS_H_ */

View file

@ -0,0 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct timespec {
int64_t tv_sec;
int64_t tv_nsec; /* nanoseconds */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ */

View file

@ -0,0 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct timeval {
int64_t tv_sec;
int64_t tv_usec; /* microseconds */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ */

13
libc/calls/struct/tms.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct tms {
int64_t tms_utime; /* userspace time */
int64_t tms_stime; /* kernelspace time */
int64_t tms_cutime; /* children userspace time */
int64_t tms_cstime; /* children kernelspace time */
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ */

View file

@ -0,0 +1,18 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_
#define SYS_NMLN 321
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct utsname {
char sysname[SYS_NMLN];
char nodename[SYS_NMLN];
char release[SYS_NMLN];
char version[SYS_NMLN];
char machine[SYS_NMLN];
char domainname[SYS_NMLN];
};
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_ */

View file

@ -0,0 +1,15 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_H_
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct winsize {
uint16_t ws_row;
uint16_t ws_col;
uint16_t ws_xpixel;
uint16_t ws_ypixel;
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_H_ */