zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

blob e213b816 (6160B) - Raw


      1 const std = @import("../std.zig");
      2 const maxInt = std.math.maxInt;
      3 const emscripten = std.os.emscripten;
      4 
      5 pub const AF = emscripten.AF;
      6 pub const AT = emscripten.AT;
      7 pub const CLOCK = emscripten.CLOCK;
      8 pub const CPU_COUNT = emscripten.CPU_COUNT;
      9 pub const E = emscripten.E;
     10 pub const F = emscripten.F;
     11 pub const FD_CLOEXEC = emscripten.FD_CLOEXEC;
     12 pub const F_OK = emscripten.F_OK;
     13 pub const Flock = emscripten.Flock;
     14 pub const IFNAMESIZE = emscripten.IFNAMESIZE;
     15 pub const IOV_MAX = emscripten.IOV_MAX;
     16 pub const IPPROTO = emscripten.IPPROTO;
     17 pub const LOCK = emscripten.LOCK;
     18 pub const MADV = emscripten.MADV;
     19 pub const MAP = struct {
     20     pub usingnamespace emscripten.MAP;
     21     /// Only used by libc to communicate failure.
     22     pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
     23 };
     24 pub const MSF = emscripten.MSF;
     25 pub const MSG = emscripten.MSG;
     26 pub const NAME_MAX = emscripten.NAME_MAX;
     27 pub const O = emscripten.O;
     28 pub const PATH_MAX = emscripten.PATH_MAX;
     29 pub const POLL = emscripten.POLL;
     30 pub const PROT = emscripten.PROT;
     31 pub const REG = emscripten.REG;
     32 pub const RLIM = emscripten.RLIM;
     33 pub const R_OK = emscripten.R_OK;
     34 pub const S = emscripten.S;
     35 pub const SA = emscripten.SA;
     36 pub const SEEK = emscripten.SEEK;
     37 pub const SHUT = emscripten.SHUT;
     38 pub const SIG = emscripten.SIG;
     39 pub const SIOCGIFINDEX = emscripten.SIOCGIFINDEX;
     40 pub const SO = emscripten.SO;
     41 pub const SOCK = emscripten.SOCK;
     42 pub const SOL = emscripten.SOL;
     43 pub const STDERR_FILENO = emscripten.STDERR_FILENO;
     44 pub const STDIN_FILENO = emscripten.STDIN_FILENO;
     45 pub const STDOUT_FILENO = emscripten.STDOUT_FILENO;
     46 pub const Sigaction = emscripten.Sigaction;
     47 pub const TCP = emscripten.TCP;
     48 pub const TCSA = emscripten.TCSA;
     49 pub const W = emscripten.W;
     50 pub const W_OK = emscripten.W_OK;
     51 pub const X_OK = emscripten.X_OK;
     52 pub const addrinfo = emscripten.addrinfo;
     53 pub const blkcnt_t = emscripten.blkcnt_t;
     54 pub const blksize_t = emscripten.blksize_t;
     55 pub const clock_t = emscripten.clock_t;
     56 pub const cpu_set_t = emscripten.cpu_set_t;
     57 pub const dev_t = emscripten.dev_t;
     58 pub const dl_phdr_info = emscripten.dl_phdr_info;
     59 pub const empty_sigset = emscripten.empty_sigset;
     60 pub const fd_t = emscripten.fd_t;
     61 pub const gid_t = emscripten.gid_t;
     62 pub const ifreq = emscripten.ifreq;
     63 pub const ino_t = emscripten.ino_t;
     64 pub const mcontext_t = emscripten.mcontext_t;
     65 pub const mode_t = emscripten.mode_t;
     66 pub const msghdr = emscripten.msghdr;
     67 pub const msghdr_const = emscripten.msghdr_const;
     68 pub const nfds_t = emscripten.nfds_t;
     69 pub const nlink_t = emscripten.nlink_t;
     70 pub const off_t = emscripten.off_t;
     71 pub const pid_t = emscripten.pid_t;
     72 pub const pollfd = emscripten.pollfd;
     73 pub const rlim_t = emscripten.rlim_t;
     74 pub const rlimit = emscripten.rlimit;
     75 pub const rlimit_resource = emscripten.rlimit_resource;
     76 pub const rusage = emscripten.rusage;
     77 pub const siginfo_t = emscripten.siginfo_t;
     78 pub const sigset_t = emscripten.sigset_t;
     79 pub const sockaddr = emscripten.sockaddr;
     80 pub const socklen_t = emscripten.socklen_t;
     81 pub const stack_t = emscripten.stack_t;
     82 pub const tcflag_t = emscripten.tcflag_t;
     83 pub const termios = emscripten.termios;
     84 pub const time_t = emscripten.time_t;
     85 pub const timespec = emscripten.timespec;
     86 pub const timeval = emscripten.timeval;
     87 pub const timezone = emscripten.timezone;
     88 pub const ucontext_t = emscripten.ucontext_t;
     89 pub const uid_t = emscripten.uid_t;
     90 pub const utsname = emscripten.utsname;
     91 
     92 pub const _errno = struct {
     93     extern "c" fn __errno_location() *c_int;
     94 }.__errno_location;
     95 
     96 pub const Stat = emscripten.Stat;
     97 
     98 pub const AI = struct {
     99     pub const PASSIVE = 0x01;
    100     pub const CANONNAME = 0x02;
    101     pub const NUMERICHOST = 0x04;
    102     pub const V4MAPPED = 0x08;
    103     pub const ALL = 0x10;
    104     pub const ADDRCONFIG = 0x20;
    105     pub const NUMERICSERV = 0x400;
    106 };
    107 
    108 pub const NI = struct {
    109     pub const NUMERICHOST = 0x01;
    110     pub const NUMERICSERV = 0x02;
    111     pub const NOFQDN = 0x04;
    112     pub const NAMEREQD = 0x08;
    113     pub const DGRAM = 0x10;
    114     pub const NUMERICSCOPE = 0x100;
    115     pub const MAXHOST = 255;
    116     pub const MAXSERV = 32;
    117 };
    118 
    119 pub const EAI = enum(c_int) {
    120     BADFLAGS = -1,
    121     NONAME = -2,
    122     AGAIN = -3,
    123     FAIL = -4,
    124     FAMILY = -6,
    125     SOCKTYPE = -7,
    126     SERVICE = -8,
    127     MEMORY = -10,
    128     SYSTEM = -11,
    129     OVERFLOW = -12,
    130 
    131     NODATA = -5,
    132     ADDRFAMILY = -9,
    133     INPROGRESS = -100,
    134     CANCELED = -101,
    135     NOTCANCELED = -102,
    136     ALLDONE = -103,
    137     INTR = -104,
    138     IDN_ENCODE = -105,
    139 
    140     _,
    141 };
    142 
    143 pub const fopen64 = std.c.fopen;
    144 pub const fstat64 = std.c.fstat;
    145 pub const fstatat64 = std.c.fstatat;
    146 pub const ftruncate64 = std.c.ftruncate;
    147 pub const getrlimit64 = std.c.getrlimit;
    148 pub const lseek64 = std.c.lseek;
    149 pub const mmap64 = std.c.mmap;
    150 pub const open64 = std.c.open;
    151 pub const openat64 = std.c.openat;
    152 pub const pread64 = std.c.pread;
    153 pub const preadv64 = std.c.preadv;
    154 pub const pwrite64 = std.c.pwrite;
    155 pub const pwritev64 = std.c.pwritev;
    156 pub const setrlimit64 = std.c.setrlimit;
    157 
    158 pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
    159 pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
    160 pub extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int;
    161 
    162 pub const pthread_attr_t = extern struct {
    163     __size: [56]u8,
    164     __align: c_long,
    165 };
    166 
    167 pub const pthread_mutex_t = extern struct {
    168     size: [__SIZEOF_PTHREAD_MUTEX_T]u8 align(4) = [_]u8{0} ** __SIZEOF_PTHREAD_MUTEX_T,
    169 };
    170 pub const pthread_cond_t = extern struct {
    171     size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T,
    172 };
    173 pub const pthread_rwlock_t = extern struct {
    174     size: [32]u8 align(4) = [_]u8{0} ** 32,
    175 };
    176 
    177 const __SIZEOF_PTHREAD_COND_T = 48;
    178 const __SIZEOF_PTHREAD_MUTEX_T = 24;
    179 
    180 pub const pthread_key_t = c_uint;
    181 pub const sem_t = extern struct {
    182     __size: [__SIZEOF_SEM_T]u8 align(@alignOf(usize)),
    183 };
    184 
    185 const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
    186 
    187 pub const RTLD = struct {
    188     pub const LAZY = 1;
    189     pub const NOW = 2;
    190     pub const NOLOAD = 4;
    191     pub const NODELETE = 4096;
    192     pub const GLOBAL = 256;
    193     pub const LOCAL = 0;
    194 };
    195 
    196 pub const dirent = struct {
    197     d_ino: c_uint,
    198     d_off: c_uint,
    199     d_reclen: c_ushort,
    200     d_type: u8,
    201     d_name: [256]u8,
    202 };