| author | |
| committer | |
| log | e2b9c153bdfa2c5e4005d5957062e0eaf3b339a2 |
| tree | 24bf2b5a7283d37868026997712410eb0357438f |
| parent | 9a541c12140e8768fabbbd8834cd0e1570df344b |
Trivial program now compiles with now warnings.8 files changed, 2113 insertions(+), 6 deletions(-)
src/target.cpp+1-1| ... | @@ -738,6 +738,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -738,6 +738,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 738 | case OsLinux: | 738 | case OsLinux: |
| 739 | case OsMacOSX: | 739 | case OsMacOSX: |
| 740 | case OsZen: | 740 | case OsZen: |
| 741 | case OsFreeBSD: | ||
| 741 | case OsOpenBSD: | 742 | case OsOpenBSD: |
| 742 | switch (id) { | 743 | switch (id) { |
| 743 | case CIntTypeShort: | 744 | case CIntTypeShort: |
| ... | @@ -774,7 +775,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -774,7 +775,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 774 | case OsAnanas: | 775 | case OsAnanas: |
| 775 | case OsCloudABI: | 776 | case OsCloudABI: |
| 776 | case OsDragonFly: | 777 | case OsDragonFly: |
| 777 | case OsFreeBSD: | ||
| 778 | case OsIOS: | 778 | case OsIOS: |
| 779 | case OsKFreeBSD: | 779 | case OsKFreeBSD: |
| 780 | case OsLv2: | 780 | case OsLv2: |
std/os/freebsd.zig created+733| ... | @@ -0,0 +1,733 @@ | ||
| 1 | const assert = @import("../debug.zig").assert; | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = switch (builtin.arch) { | ||
| 4 | builtin.Arch.x86_64 => @import("freebsd_x86_64.zig"), | ||
| 5 | builtin.Arch.i386 => @import("freebsd_i386.zig"), | ||
| 6 | else => @compileError("unsupported arch"), | ||
| 7 | }; | ||
| 8 | pub use @import("freebsd_errno.zig"); | ||
| 9 | |||
| 10 | pub const PATH_MAX = 1024; | ||
| 11 | |||
| 12 | pub const STDIN_FILENO = 0; | ||
| 13 | pub const STDOUT_FILENO = 1; | ||
| 14 | pub const STDERR_FILENO = 2; | ||
| 15 | |||
| 16 | pub const PROT_NONE = 0; | ||
| 17 | pub const PROT_READ = 1; | ||
| 18 | pub const PROT_WRITE = 2; | ||
| 19 | pub const PROT_EXEC = 4; | ||
| 20 | |||
| 21 | pub const MAP_FAILED = @maxValue(usize); | ||
| 22 | pub const MAP_SHARED = 0x0001; | ||
| 23 | pub const MAP_PRIVATE = 0x0002; | ||
| 24 | pub const MAP_FIXED = 0x0010; | ||
| 25 | pub const MAP_STACK = 0x0400; | ||
| 26 | pub const MAP_NOSYNC = 0x0800; | ||
| 27 | pub const MAP_ANON = 0x1000; | ||
| 28 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 29 | pub const MAP_FILE = 0; | ||
| 30 | |||
| 31 | pub const MAP_GUARD = 0x00002000; | ||
| 32 | pub const MAP_EXCL = 0x00004000; | ||
| 33 | pub const MAP_NOCORE = 0x00020000; | ||
| 34 | pub const MAP_PREFAULT_READ = 0x00040000; | ||
| 35 | pub const MAP_32BIT = 0x00080000; | ||
| 36 | |||
| 37 | pub const WNOHANG = 1; | ||
| 38 | pub const WUNTRACED = 2; | ||
| 39 | pub const WSTOPPED = WUNTRACED; | ||
| 40 | pub const WCONTINUED = 4; | ||
| 41 | pub const WNOWAIT = 8; | ||
| 42 | pub const WEXITED = 16; | ||
| 43 | pub const WTRAPPED = 32; | ||
| 44 | |||
| 45 | pub const SA_ONSTACK = 0x0001; | ||
| 46 | pub const SA_RESTART = 0x0002; | ||
| 47 | pub const SA_RESETHAND = 0x0004; | ||
| 48 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 49 | pub const SA_NODEFER = 0x0010; | ||
| 50 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 51 | pub const SA_SIGINFO = 0x0040; | ||
| 52 | |||
| 53 | pub const SIGHUP = 1; | ||
| 54 | pub const SIGINT = 2; | ||
| 55 | pub const SIGQUIT = 3; | ||
| 56 | pub const SIGILL = 4; | ||
| 57 | pub const SIGTRAP = 5; | ||
| 58 | pub const SIGABRT = 6; | ||
| 59 | pub const SIGIOT = SIGABRT; | ||
| 60 | pub const SIGEMT = 7; | ||
| 61 | pub const SIGFPE = 8; | ||
| 62 | pub const SIGKILL = 9; | ||
| 63 | pub const SIGBUS = 10; | ||
| 64 | pub const SIGSEGV = 11; | ||
| 65 | pub const SIGSYS = 12; | ||
| 66 | pub const SIGPIPE = 13; | ||
| 67 | pub const SIGALRM = 14; | ||
| 68 | pub const SIGTERM = 15; | ||
| 69 | pub const SIGURG = 16; | ||
| 70 | pub const SIGSTOP = 17; | ||
| 71 | pub const SIGTSTP = 18; | ||
| 72 | pub const SIGCONT = 19; | ||
| 73 | pub const SIGCHLD = 20; | ||
| 74 | pub const SIGTTIN = 21; | ||
| 75 | pub const SIGTTOU = 22; | ||
| 76 | pub const SIGIO = 23; | ||
| 77 | pub const SIGXCPU = 24; | ||
| 78 | pub const SIGXFSZ = 25; | ||
| 79 | pub const SIGVTALRM = 26; | ||
| 80 | pub const SIGPROF = 27; | ||
| 81 | pub const SIGWINCH = 28; | ||
| 82 | pub const SIGINFO = 29; | ||
| 83 | pub const SIGUSR1 = 30; | ||
| 84 | pub const SIGUSR2 = 31; | ||
| 85 | pub const SIGTHR = 32; | ||
| 86 | pub const SIGLWP = SIGTHR; | ||
| 87 | pub const SIGLIBRT = 33; | ||
| 88 | |||
| 89 | pub const SIGRTMIN = 65; | ||
| 90 | pub const SIGRTMAX = 126; | ||
| 91 | |||
| 92 | pub const O_RDONLY = 0o0; | ||
| 93 | pub const O_WRONLY = 0o1; | ||
| 94 | pub const O_RDWR = 0o2; | ||
| 95 | pub const O_ACCMODE = 0o3; | ||
| 96 | |||
| 97 | pub const O_CREAT = arch.O_CREAT; | ||
| 98 | pub const O_EXCL = arch.O_EXCL; | ||
| 99 | pub const O_NOCTTY = arch.O_NOCTTY; | ||
| 100 | pub const O_TRUNC = arch.O_TRUNC; | ||
| 101 | pub const O_APPEND = arch.O_APPEND; | ||
| 102 | pub const O_NONBLOCK = arch.O_NONBLOCK; | ||
| 103 | pub const O_DSYNC = arch.O_DSYNC; | ||
| 104 | pub const O_SYNC = arch.O_SYNC; | ||
| 105 | pub const O_RSYNC = arch.O_RSYNC; | ||
| 106 | pub const O_DIRECTORY = arch.O_DIRECTORY; | ||
| 107 | pub const O_NOFOLLOW = arch.O_NOFOLLOW; | ||
| 108 | pub const O_CLOEXEC = arch.O_CLOEXEC; | ||
| 109 | |||
| 110 | pub const O_ASYNC = arch.O_ASYNC; | ||
| 111 | pub const O_DIRECT = arch.O_DIRECT; | ||
| 112 | pub const O_LARGEFILE = arch.O_LARGEFILE; | ||
| 113 | pub const O_NOATIME = arch.O_NOATIME; | ||
| 114 | pub const O_PATH = arch.O_PATH; | ||
| 115 | pub const O_TMPFILE = arch.O_TMPFILE; | ||
| 116 | pub const O_NDELAY = arch.O_NDELAY; | ||
| 117 | |||
| 118 | pub const SEEK_SET = 0; | ||
| 119 | pub const SEEK_CUR = 1; | ||
| 120 | pub const SEEK_END = 2; | ||
| 121 | |||
| 122 | pub const SIG_BLOCK = 1; | ||
| 123 | pub const SIG_UNBLOCK = 2; | ||
| 124 | pub const SIG_SETMASK = 3; | ||
| 125 | |||
| 126 | pub const SOCK_STREAM = 1; | ||
| 127 | pub const SOCK_DGRAM = 2; | ||
| 128 | pub const SOCK_RAW = 3; | ||
| 129 | pub const SOCK_RDM = 4; | ||
| 130 | pub const SOCK_SEQPACKET = 5; | ||
| 131 | |||
| 132 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 133 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 134 | |||
| 135 | // TODO: From here | ||
| 136 | pub const PROTO_ip = 0o000; | ||
| 137 | pub const PROTO_icmp = 0o001; | ||
| 138 | pub const PROTO_igmp = 0o002; | ||
| 139 | pub const PROTO_ggp = 0o003; | ||
| 140 | pub const PROTO_ipencap = 0o004; | ||
| 141 | pub const PROTO_st = 0o005; | ||
| 142 | pub const PROTO_tcp = 0o006; | ||
| 143 | pub const PROTO_egp = 0o010; | ||
| 144 | pub const PROTO_pup = 0o014; | ||
| 145 | pub const PROTO_udp = 0o021; | ||
| 146 | pub const PROTO_hmp = 0o024; | ||
| 147 | pub const PROTO_xns_idp = 0o026; | ||
| 148 | pub const PROTO_rdp = 0o033; | ||
| 149 | pub const PROTO_iso_tp4 = 0o035; | ||
| 150 | pub const PROTO_xtp = 0o044; | ||
| 151 | pub const PROTO_ddp = 0o045; | ||
| 152 | pub const PROTO_idpr_cmtp = 0o046; | ||
| 153 | pub const PROTO_ipv6 = 0o051; | ||
| 154 | pub const PROTO_ipv6_route = 0o053; | ||
| 155 | pub const PROTO_ipv6_frag = 0o054; | ||
| 156 | pub const PROTO_idrp = 0o055; | ||
| 157 | pub const PROTO_rsvp = 0o056; | ||
| 158 | pub const PROTO_gre = 0o057; | ||
| 159 | pub const PROTO_esp = 0o062; | ||
| 160 | pub const PROTO_ah = 0o063; | ||
| 161 | pub const PROTO_skip = 0o071; | ||
| 162 | pub const PROTO_ipv6_icmp = 0o072; | ||
| 163 | pub const PROTO_ipv6_nonxt = 0o073; | ||
| 164 | pub const PROTO_ipv6_opts = 0o074; | ||
| 165 | pub const PROTO_rspf = 0o111; | ||
| 166 | pub const PROTO_vmtp = 0o121; | ||
| 167 | pub const PROTO_ospf = 0o131; | ||
| 168 | pub const PROTO_ipip = 0o136; | ||
| 169 | pub const PROTO_encap = 0o142; | ||
| 170 | pub const PROTO_pim = 0o147; | ||
| 171 | pub const PROTO_raw = 0o377; | ||
| 172 | |||
| 173 | pub const PF_UNSPEC = 0; | ||
| 174 | pub const PF_LOCAL = 1; | ||
| 175 | pub const PF_UNIX = PF_LOCAL; | ||
| 176 | pub const PF_FILE = PF_LOCAL; | ||
| 177 | pub const PF_INET = 2; | ||
| 178 | pub const PF_AX25 = 3; | ||
| 179 | pub const PF_IPX = 4; | ||
| 180 | pub const PF_APPLETALK = 5; | ||
| 181 | pub const PF_NETROM = 6; | ||
| 182 | pub const PF_BRIDGE = 7; | ||
| 183 | pub const PF_ATMPVC = 8; | ||
| 184 | pub const PF_X25 = 9; | ||
| 185 | pub const PF_INET6 = 10; | ||
| 186 | pub const PF_ROSE = 11; | ||
| 187 | pub const PF_DECnet = 12; | ||
| 188 | pub const PF_NETBEUI = 13; | ||
| 189 | pub const PF_SECURITY = 14; | ||
| 190 | pub const PF_KEY = 15; | ||
| 191 | pub const PF_NETLINK = 16; | ||
| 192 | pub const PF_ROUTE = PF_NETLINK; | ||
| 193 | pub const PF_PACKET = 17; | ||
| 194 | pub const PF_ASH = 18; | ||
| 195 | pub const PF_ECONET = 19; | ||
| 196 | pub const PF_ATMSVC = 20; | ||
| 197 | pub const PF_RDS = 21; | ||
| 198 | pub const PF_SNA = 22; | ||
| 199 | pub const PF_IRDA = 23; | ||
| 200 | pub const PF_PPPOX = 24; | ||
| 201 | pub const PF_WANPIPE = 25; | ||
| 202 | pub const PF_LLC = 26; | ||
| 203 | pub const PF_IB = 27; | ||
| 204 | pub const PF_MPLS = 28; | ||
| 205 | pub const PF_CAN = 29; | ||
| 206 | pub const PF_TIPC = 30; | ||
| 207 | pub const PF_BLUETOOTH = 31; | ||
| 208 | pub const PF_IUCV = 32; | ||
| 209 | pub const PF_RXRPC = 33; | ||
| 210 | pub const PF_ISDN = 34; | ||
| 211 | pub const PF_PHONET = 35; | ||
| 212 | pub const PF_IEEE802154 = 36; | ||
| 213 | pub const PF_CAIF = 37; | ||
| 214 | pub const PF_ALG = 38; | ||
| 215 | pub const PF_NFC = 39; | ||
| 216 | pub const PF_VSOCK = 40; | ||
| 217 | pub const PF_MAX = 41; | ||
| 218 | |||
| 219 | pub const AF_UNSPEC = PF_UNSPEC; | ||
| 220 | pub const AF_LOCAL = PF_LOCAL; | ||
| 221 | pub const AF_UNIX = AF_LOCAL; | ||
| 222 | pub const AF_FILE = AF_LOCAL; | ||
| 223 | pub const AF_INET = PF_INET; | ||
| 224 | pub const AF_AX25 = PF_AX25; | ||
| 225 | pub const AF_IPX = PF_IPX; | ||
| 226 | pub const AF_APPLETALK = PF_APPLETALK; | ||
| 227 | pub const AF_NETROM = PF_NETROM; | ||
| 228 | pub const AF_BRIDGE = PF_BRIDGE; | ||
| 229 | pub const AF_ATMPVC = PF_ATMPVC; | ||
| 230 | pub const AF_X25 = PF_X25; | ||
| 231 | pub const AF_INET6 = PF_INET6; | ||
| 232 | pub const AF_ROSE = PF_ROSE; | ||
| 233 | pub const AF_DECnet = PF_DECnet; | ||
| 234 | pub const AF_NETBEUI = PF_NETBEUI; | ||
| 235 | pub const AF_SECURITY = PF_SECURITY; | ||
| 236 | pub const AF_KEY = PF_KEY; | ||
| 237 | pub const AF_NETLINK = PF_NETLINK; | ||
| 238 | pub const AF_ROUTE = PF_ROUTE; | ||
| 239 | pub const AF_PACKET = PF_PACKET; | ||
| 240 | pub const AF_ASH = PF_ASH; | ||
| 241 | pub const AF_ECONET = PF_ECONET; | ||
| 242 | pub const AF_ATMSVC = PF_ATMSVC; | ||
| 243 | pub const AF_RDS = PF_RDS; | ||
| 244 | pub const AF_SNA = PF_SNA; | ||
| 245 | pub const AF_IRDA = PF_IRDA; | ||
| 246 | pub const AF_PPPOX = PF_PPPOX; | ||
| 247 | pub const AF_WANPIPE = PF_WANPIPE; | ||
| 248 | pub const AF_LLC = PF_LLC; | ||
| 249 | pub const AF_IB = PF_IB; | ||
| 250 | pub const AF_MPLS = PF_MPLS; | ||
| 251 | pub const AF_CAN = PF_CAN; | ||
| 252 | pub const AF_TIPC = PF_TIPC; | ||
| 253 | pub const AF_BLUETOOTH = PF_BLUETOOTH; | ||
| 254 | pub const AF_IUCV = PF_IUCV; | ||
| 255 | pub const AF_RXRPC = PF_RXRPC; | ||
| 256 | pub const AF_ISDN = PF_ISDN; | ||
| 257 | pub const AF_PHONET = PF_PHONET; | ||
| 258 | pub const AF_IEEE802154 = PF_IEEE802154; | ||
| 259 | pub const AF_CAIF = PF_CAIF; | ||
| 260 | pub const AF_ALG = PF_ALG; | ||
| 261 | pub const AF_NFC = PF_NFC; | ||
| 262 | pub const AF_VSOCK = PF_VSOCK; | ||
| 263 | pub const AF_MAX = PF_MAX; | ||
| 264 | |||
| 265 | pub const DT_UNKNOWN = 0; | ||
| 266 | pub const DT_FIFO = 1; | ||
| 267 | pub const DT_CHR = 2; | ||
| 268 | pub const DT_DIR = 4; | ||
| 269 | pub const DT_BLK = 6; | ||
| 270 | pub const DT_REG = 8; | ||
| 271 | pub const DT_LNK = 10; | ||
| 272 | pub const DT_SOCK = 12; | ||
| 273 | pub const DT_WHT = 14; | ||
| 274 | |||
| 275 | |||
| 276 | pub const TCGETS = 0x5401; | ||
| 277 | pub const TCSETS = 0x5402; | ||
| 278 | pub const TCSETSW = 0x5403; | ||
| 279 | pub const TCSETSF = 0x5404; | ||
| 280 | pub const TCGETA = 0x5405; | ||
| 281 | pub const TCSETA = 0x5406; | ||
| 282 | pub const TCSETAW = 0x5407; | ||
| 283 | pub const TCSETAF = 0x5408; | ||
| 284 | pub const TCSBRK = 0x5409; | ||
| 285 | pub const TCXONC = 0x540A; | ||
| 286 | pub const TCFLSH = 0x540B; | ||
| 287 | pub const TIOCEXCL = 0x540C; | ||
| 288 | pub const TIOCNXCL = 0x540D; | ||
| 289 | pub const TIOCSCTTY = 0x540E; | ||
| 290 | pub const TIOCGPGRP = 0x540F; | ||
| 291 | pub const TIOCSPGRP = 0x5410; | ||
| 292 | pub const TIOCOUTQ = 0x5411; | ||
| 293 | pub const TIOCSTI = 0x5412; | ||
| 294 | pub const TIOCGWINSZ = 0x5413; | ||
| 295 | pub const TIOCSWINSZ = 0x5414; | ||
| 296 | pub const TIOCMGET = 0x5415; | ||
| 297 | pub const TIOCMBIS = 0x5416; | ||
| 298 | pub const TIOCMBIC = 0x5417; | ||
| 299 | pub const TIOCMSET = 0x5418; | ||
| 300 | pub const TIOCGSOFTCAR = 0x5419; | ||
| 301 | pub const TIOCSSOFTCAR = 0x541A; | ||
| 302 | pub const FIONREAD = 0x541B; | ||
| 303 | pub const TIOCINQ = FIONREAD; | ||
| 304 | pub const TIOCLINUX = 0x541C; | ||
| 305 | pub const TIOCCONS = 0x541D; | ||
| 306 | pub const TIOCGSERIAL = 0x541E; | ||
| 307 | pub const TIOCSSERIAL = 0x541F; | ||
| 308 | pub const TIOCPKT = 0x5420; | ||
| 309 | pub const FIONBIO = 0x5421; | ||
| 310 | pub const TIOCNOTTY = 0x5422; | ||
| 311 | pub const TIOCSETD = 0x5423; | ||
| 312 | pub const TIOCGETD = 0x5424; | ||
| 313 | pub const TCSBRKP = 0x5425; | ||
| 314 | pub const TIOCSBRK = 0x5427; | ||
| 315 | pub const TIOCCBRK = 0x5428; | ||
| 316 | pub const TIOCGSID = 0x5429; | ||
| 317 | pub const TIOCGRS485 = 0x542E; | ||
| 318 | pub const TIOCSRS485 = 0x542F; | ||
| 319 | pub const TIOCGPTN = 0x80045430; | ||
| 320 | pub const TIOCSPTLCK = 0x40045431; | ||
| 321 | pub const TIOCGDEV = 0x80045432; | ||
| 322 | pub const TCGETX = 0x5432; | ||
| 323 | pub const TCSETX = 0x5433; | ||
| 324 | pub const TCSETXF = 0x5434; | ||
| 325 | pub const TCSETXW = 0x5435; | ||
| 326 | pub const TIOCSIG = 0x40045436; | ||
| 327 | pub const TIOCVHANGUP = 0x5437; | ||
| 328 | pub const TIOCGPKT = 0x80045438; | ||
| 329 | pub const TIOCGPTLCK = 0x80045439; | ||
| 330 | pub const TIOCGEXCL = 0x80045440; | ||
| 331 | |||
| 332 | fn unsigned(s: i32) -> u32 { @bitCast(u32, s) } | ||
| 333 | fn signed(s: u32) -> i32 { @bitCast(i32, s) } | ||
| 334 | pub fn WEXITSTATUS(s: i32) -> i32 { signed((unsigned(s) & 0xff00) >> 8) } | ||
| 335 | pub fn WTERMSIG(s: i32) -> i32 { signed(unsigned(s) & 0x7f) } | ||
| 336 | pub fn WSTOPSIG(s: i32) -> i32 { WEXITSTATUS(s) } | ||
| 337 | pub fn WIFEXITED(s: i32) -> bool { WTERMSIG(s) == 0 } | ||
| 338 | pub fn WIFSTOPPED(s: i32) -> bool { (u16)(((unsigned(s)&0xffff)*%0x10001)>>8) > 0x7f00 } | ||
| 339 | pub fn WIFSIGNALED(s: i32) -> bool { (unsigned(s)&0xffff)-%1 < 0xff } | ||
| 340 | |||
| 341 | |||
| 342 | pub const winsize = extern struct { | ||
| 343 | ws_row: u16, | ||
| 344 | ws_col: u16, | ||
| 345 | ws_xpixel: u16, | ||
| 346 | ws_ypixel: u16, | ||
| 347 | }; | ||
| 348 | |||
| 349 | /// Get the errno from a syscall return value, or 0 for no error. | ||
| 350 | pub fn getErrno(r: usize) -> usize { | ||
| 351 | const signed_r = @bitCast(isize, r); | ||
| 352 | if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0 | ||
| 353 | } | ||
| 354 | |||
| 355 | pub fn dup2(old: i32, new: i32) -> usize { | ||
| 356 | arch.syscall2(arch.SYS_dup2, usize(old), usize(new)) | ||
| 357 | } | ||
| 358 | |||
| 359 | pub fn chdir(path: &const u8) -> usize { | ||
| 360 | arch.syscall1(arch.SYS_chdir, @ptrToInt(path)) | ||
| 361 | } | ||
| 362 | |||
| 363 | pub fn execve(path: &const u8, argv: &const ?&const u8, envp: &const ?&const u8) -> usize { | ||
| 364 | arch.syscall3(arch.SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp)) | ||
| 365 | } | ||
| 366 | |||
| 367 | pub fn fork() -> usize { | ||
| 368 | arch.syscall0(arch.SYS_fork) | ||
| 369 | } | ||
| 370 | |||
| 371 | pub fn getcwd(buf: &u8, size: usize) -> usize { | ||
| 372 | arch.syscall2(arch.SYS_getcwd, @ptrToInt(buf), size) | ||
| 373 | } | ||
| 374 | |||
| 375 | pub fn getdents(fd: i32, dirp: &u8, count: usize) -> usize { | ||
| 376 | arch.syscall3(arch.SYS_getdents, usize(fd), @ptrToInt(dirp), count) | ||
| 377 | } | ||
| 378 | |||
| 379 | pub fn isatty(fd: i32) -> bool { | ||
| 380 | var wsz: winsize = undefined; | ||
| 381 | return arch.syscall3(arch.SYS_ioctl, usize(fd), TIOCGWINSZ, @ptrToInt(&wsz)) == 0; | ||
| 382 | } | ||
| 383 | |||
| 384 | pub fn readlink(noalias path: &const u8, noalias buf_ptr: &u8, buf_len: usize) -> usize { | ||
| 385 | arch.syscall3(arch.SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len) | ||
| 386 | } | ||
| 387 | |||
| 388 | pub fn mkdir(path: &const u8, mode: u32) -> usize { | ||
| 389 | arch.syscall2(arch.SYS_mkdir, @ptrToInt(path), mode) | ||
| 390 | } | ||
| 391 | |||
| 392 | pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32, offset: isize) | ||
| 393 | -> usize | ||
| 394 | { | ||
| 395 | arch.syscall6(arch.SYS_mmap, @ptrToInt(address), length, prot, flags, usize(fd), | ||
| 396 | @bitCast(usize, offset)) | ||
| 397 | } | ||
| 398 | |||
| 399 | pub fn munmap(address: &u8, length: usize) -> usize { | ||
| 400 | arch.syscall2(arch.SYS_munmap, @ptrToInt(address), length) | ||
| 401 | } | ||
| 402 | |||
| 403 | pub fn read(fd: i32, buf: &u8, count: usize) -> usize { | ||
| 404 | arch.syscall3(arch.SYS_read, usize(fd), @ptrToInt(buf), count) | ||
| 405 | } | ||
| 406 | |||
| 407 | pub fn rmdir(path: &const u8) -> usize { | ||
| 408 | arch.syscall1(arch.SYS_rmdir, @ptrToInt(path)) | ||
| 409 | } | ||
| 410 | |||
| 411 | pub fn symlink(existing: &const u8, new: &const u8) -> usize { | ||
| 412 | arch.syscall2(arch.SYS_symlink, @ptrToInt(existing), @ptrToInt(new)) | ||
| 413 | } | ||
| 414 | |||
| 415 | pub fn pread(fd: i32, buf: &u8, count: usize, offset: usize) -> usize { | ||
| 416 | arch.syscall4(arch.SYS_pread, usize(fd), @ptrToInt(buf), count, offset) | ||
| 417 | } | ||
| 418 | |||
| 419 | pub fn pipe(fd: &[2]i32) -> usize { | ||
| 420 | pipe2(fd, 0) | ||
| 421 | } | ||
| 422 | |||
| 423 | pub fn pipe2(fd: &[2]i32, flags: usize) -> usize { | ||
| 424 | arch.syscall2(arch.SYS_pipe2, @ptrToInt(fd), flags) | ||
| 425 | } | ||
| 426 | |||
| 427 | pub fn write(fd: i32, buf: &const u8, count: usize) -> usize { | ||
| 428 | arch.syscall3(arch.SYS_write, usize(fd), @ptrToInt(buf), count) | ||
| 429 | } | ||
| 430 | |||
| 431 | pub fn pwrite(fd: i32, buf: &const u8, count: usize, offset: usize) -> usize { | ||
| 432 | arch.syscall4(arch.SYS_pwrite, usize(fd), @ptrToInt(buf), count, offset) | ||
| 433 | } | ||
| 434 | |||
| 435 | pub fn rename(old: &const u8, new: &const u8) -> usize { | ||
| 436 | arch.syscall2(arch.SYS_rename, @ptrToInt(old), @ptrToInt(new)) | ||
| 437 | } | ||
| 438 | |||
| 439 | pub fn open(path: &const u8, flags: u32, perm: usize) -> usize { | ||
| 440 | arch.syscall3(arch.SYS_open, @ptrToInt(path), flags, perm) | ||
| 441 | } | ||
| 442 | |||
| 443 | pub fn create(path: &const u8, perm: usize) -> usize { | ||
| 444 | arch.syscall2(arch.SYS_creat, @ptrToInt(path), perm) | ||
| 445 | } | ||
| 446 | |||
| 447 | pub fn openat(dirfd: i32, path: &const u8, flags: usize, mode: usize) -> usize { | ||
| 448 | arch.syscall4(arch.SYS_openat, usize(dirfd), @ptrToInt(path), flags, mode) | ||
| 449 | } | ||
| 450 | |||
| 451 | pub fn close(fd: i32) -> usize { | ||
| 452 | arch.syscall1(arch.SYS_close, usize(fd)) | ||
| 453 | } | ||
| 454 | |||
| 455 | pub fn lseek(fd: i32, offset: isize, ref_pos: usize) -> usize { | ||
| 456 | arch.syscall3(arch.SYS_lseek, usize(fd), @bitCast(usize, offset), ref_pos) | ||
| 457 | } | ||
| 458 | |||
| 459 | pub fn exit(status: i32) -> noreturn { | ||
| 460 | _ = arch.syscall1(arch.SYS_exit, @bitCast(usize, isize(status))); | ||
| 461 | unreachable | ||
| 462 | } | ||
| 463 | |||
| 464 | pub fn getrandom(buf: &u8, count: usize, flags: u32) -> usize { | ||
| 465 | arch.syscall3(arch.SYS_getrandom, @ptrToInt(buf), count, usize(flags)) | ||
| 466 | } | ||
| 467 | |||
| 468 | pub fn kill(pid: i32, sig: i32) -> usize { | ||
| 469 | arch.syscall2(arch.SYS_kill, @bitCast(usize, isize(pid)), usize(sig)) | ||
| 470 | } | ||
| 471 | |||
| 472 | pub fn unlink(path: &const u8) -> usize { | ||
| 473 | arch.syscall1(arch.SYS_unlink, @ptrToInt(path)) | ||
| 474 | } | ||
| 475 | |||
| 476 | pub fn waitpid(pid: i32, status: &i32, options: i32) -> usize { | ||
| 477 | arch.syscall4(arch.SYS_wait4, @bitCast(usize, isize(pid)), @ptrToInt(status), @bitCast(usize, isize(options)), 0) | ||
| 478 | } | ||
| 479 | |||
| 480 | pub fn nanosleep(req: &const timespec, rem: ?&timespec) -> usize { | ||
| 481 | arch.syscall2(arch.SYS_nanosleep, @ptrToInt(req), @ptrToInt(rem)) | ||
| 482 | } | ||
| 483 | |||
| 484 | pub fn setuid(uid: u32) -> usize { | ||
| 485 | arch.syscall1(arch.SYS_setuid, uid) | ||
| 486 | } | ||
| 487 | |||
| 488 | pub fn setgid(gid: u32) -> usize { | ||
| 489 | arch.syscall1(arch.SYS_setgid, gid) | ||
| 490 | } | ||
| 491 | |||
| 492 | pub fn setreuid(ruid: u32, euid: u32) -> usize { | ||
| 493 | arch.syscall2(arch.SYS_setreuid, ruid, euid) | ||
| 494 | } | ||
| 495 | |||
| 496 | pub fn setregid(rgid: u32, egid: u32) -> usize { | ||
| 497 | arch.syscall2(arch.SYS_setregid, rgid, egid) | ||
| 498 | } | ||
| 499 | |||
| 500 | pub fn sigprocmask(flags: u32, noalias set: &const sigset_t, noalias oldset: ?&sigset_t) -> usize { | ||
| 501 | arch.syscall4(arch.SYS_rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG/8) | ||
| 502 | } | ||
| 503 | |||
| 504 | pub fn sigaction(sig: u6, noalias act: &const Sigaction, noalias oact: ?&Sigaction) -> usize { | ||
| 505 | assert(sig >= 1); | ||
| 506 | assert(sig != SIGKILL); | ||
| 507 | assert(sig != SIGSTOP); | ||
| 508 | var ksa = k_sigaction { | ||
| 509 | .handler = act.handler, | ||
| 510 | .flags = act.flags | SA_RESTORER, | ||
| 511 | .mask = undefined, | ||
| 512 | .restorer = @ptrCast(extern fn(), arch.restore_rt), | ||
| 513 | }; | ||
| 514 | var ksa_old: k_sigaction = undefined; | ||
| 515 | @memcpy(@ptrCast(&u8, &ksa.mask), @ptrCast(&const u8, &act.mask), 8); | ||
| 516 | const result = arch.syscall4(arch.SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), @sizeOf(@typeOf(ksa.mask))); | ||
| 517 | const err = getErrno(result); | ||
| 518 | if (err != 0) { | ||
| 519 | return result; | ||
| 520 | } | ||
| 521 | if (oact) |old| { | ||
| 522 | old.handler = ksa_old.handler; | ||
| 523 | old.flags = @truncate(u32, ksa_old.flags); | ||
| 524 | @memcpy(@ptrCast(&u8, &old.mask), @ptrCast(&const u8, &ksa_old.mask), @sizeOf(@typeOf(ksa_old.mask))); | ||
| 525 | } | ||
| 526 | return 0; | ||
| 527 | } | ||
| 528 | |||
| 529 | const NSIG = 65; | ||
| 530 | const sigset_t = [128 / @sizeOf(usize)]usize; | ||
| 531 | const all_mask = []usize{@maxValue(usize)}; | ||
| 532 | const app_mask = []usize{0xfffffffc7fffffff}; | ||
| 533 | |||
| 534 | const k_sigaction = extern struct { | ||
| 535 | handler: extern fn(i32), | ||
| 536 | flags: usize, | ||
| 537 | restorer: extern fn(), | ||
| 538 | mask: [2]u32, | ||
| 539 | }; | ||
| 540 | |||
| 541 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 542 | pub const Sigaction = struct { | ||
| 543 | handler: extern fn(i32), | ||
| 544 | mask: sigset_t, | ||
| 545 | flags: u32, | ||
| 546 | }; | ||
| 547 | |||
| 548 | pub const SIG_ERR = @intToPtr(extern fn(i32), @maxValue(usize)); | ||
| 549 | pub const SIG_DFL = @intToPtr(extern fn(i32), 0); | ||
| 550 | pub const SIG_IGN = @intToPtr(extern fn(i32), 1); | ||
| 551 | pub const empty_sigset = []usize{0} ** sigset_t.len; | ||
| 552 | |||
| 553 | pub fn raise(sig: i32) -> usize { | ||
| 554 | // TODO implement, see linux equivalent for what we want to try and do | ||
| 555 | return 0; | ||
| 556 | } | ||
| 557 | |||
| 558 | fn blockAllSignals(set: &sigset_t) { | ||
| 559 | // TODO implement | ||
| 560 | } | ||
| 561 | |||
| 562 | fn blockAppSignals(set: &sigset_t) { | ||
| 563 | // TODO implement | ||
| 564 | } | ||
| 565 | |||
| 566 | fn restoreSignals(set: &sigset_t) { | ||
| 567 | // TODO implement | ||
| 568 | } | ||
| 569 | |||
| 570 | pub fn sigaddset(set: &sigset_t, sig: u6) { | ||
| 571 | const s = sig - 1; | ||
| 572 | (*set)[usize(s) / usize.bit_count] |= usize(1) << (s & (usize.bit_count - 1)); | ||
| 573 | } | ||
| 574 | |||
| 575 | pub fn sigismember(set: &const sigset_t, sig: u6) -> bool { | ||
| 576 | const s = sig - 1; | ||
| 577 | return ((*set)[usize(s) / usize.bit_count] & (usize(1) << (s & (usize.bit_count - 1)))) != 0; | ||
| 578 | } | ||
| 579 | |||
| 580 | |||
| 581 | pub const sa_family_t = u16; | ||
| 582 | pub const socklen_t = u32; | ||
| 583 | pub const in_addr = u32; | ||
| 584 | pub const in6_addr = [16]u8; | ||
| 585 | |||
| 586 | pub const sockaddr = extern struct { | ||
| 587 | family: sa_family_t, | ||
| 588 | port: u16, | ||
| 589 | data: [12]u8, | ||
| 590 | }; | ||
| 591 | |||
| 592 | pub const sockaddr_in = extern struct { | ||
| 593 | family: sa_family_t, | ||
| 594 | port: u16, | ||
| 595 | addr: in_addr, | ||
| 596 | zero: [8]u8, | ||
| 597 | }; | ||
| 598 | |||
| 599 | pub const sockaddr_in6 = extern struct { | ||
| 600 | family: sa_family_t, | ||
| 601 | port: u16, | ||
| 602 | flowinfo: u32, | ||
| 603 | addr: in6_addr, | ||
| 604 | scope_id: u32, | ||
| 605 | }; | ||
| 606 | |||
| 607 | pub const iovec = extern struct { | ||
| 608 | iov_base: &u8, | ||
| 609 | iov_len: usize, | ||
| 610 | }; | ||
| 611 | |||
| 612 | // | ||
| 613 | //const IF_NAMESIZE = 16; | ||
| 614 | // | ||
| 615 | //export struct ifreq { | ||
| 616 | // ifrn_name: [IF_NAMESIZE]u8, | ||
| 617 | // union { | ||
| 618 | // ifru_addr: sockaddr, | ||
| 619 | // ifru_dstaddr: sockaddr, | ||
| 620 | // ifru_broadaddr: sockaddr, | ||
| 621 | // ifru_netmask: sockaddr, | ||
| 622 | // ifru_hwaddr: sockaddr, | ||
| 623 | // ifru_flags: i16, | ||
| 624 | // ifru_ivalue: i32, | ||
| 625 | // ifru_mtu: i32, | ||
| 626 | // ifru_map: ifmap, | ||
| 627 | // ifru_slave: [IF_NAMESIZE]u8, | ||
| 628 | // ifru_newname: [IF_NAMESIZE]u8, | ||
| 629 | // ifru_data: &u8, | ||
| 630 | // } ifr_ifru; | ||
| 631 | //} | ||
| 632 | // | ||
| 633 | |||
| 634 | pub fn getsockname(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> usize { | ||
| 635 | arch.syscall3(arch.SYS_getsockname, usize(fd), @ptrToInt(addr), @ptrToInt(len)) | ||
| 636 | } | ||
| 637 | |||
| 638 | pub fn getpeername(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> usize { | ||
| 639 | arch.syscall3(arch.SYS_getpeername, usize(fd), @ptrToInt(addr), @ptrToInt(len)) | ||
| 640 | } | ||
| 641 | |||
| 642 | pub fn socket(domain: i32, socket_type: i32, protocol: i32) -> usize { | ||
| 643 | arch.syscall3(arch.SYS_socket, usize(domain), usize(socket_type), usize(protocol)) | ||
| 644 | } | ||
| 645 | |||
| 646 | pub fn setsockopt(fd: i32, level: i32, optname: i32, optval: &const u8, optlen: socklen_t) -> usize { | ||
| 647 | arch.syscall5(arch.SYS_setsockopt, usize(fd), usize(level), usize(optname), usize(optval), @ptrToInt(optlen)) | ||
| 648 | } | ||
| 649 | |||
| 650 | pub fn getsockopt(fd: i32, level: i32, optname: i32, noalias optval: &u8, noalias optlen: &socklen_t) -> usize { | ||
| 651 | arch.syscall5(arch.SYS_getsockopt, usize(fd), usize(level), usize(optname), @ptrToInt(optval), @ptrToInt(optlen)) | ||
| 652 | } | ||
| 653 | |||
| 654 | pub fn sendmsg(fd: i32, msg: &const arch.msghdr, flags: u32) -> usize { | ||
| 655 | arch.syscall3(arch.SYS_sendmsg, usize(fd), @ptrToInt(msg), flags) | ||
| 656 | } | ||
| 657 | |||
| 658 | pub fn connect(fd: i32, addr: &const sockaddr, len: socklen_t) -> usize { | ||
| 659 | arch.syscall3(arch.SYS_connect, usize(fd), @ptrToInt(addr), usize(len)) | ||
| 660 | } | ||
| 661 | |||
| 662 | pub fn recvmsg(fd: i32, msg: &arch.msghdr, flags: u32) -> usize { | ||
| 663 | arch.syscall3(arch.SYS_recvmsg, usize(fd), @ptrToInt(msg), flags) | ||
| 664 | } | ||
| 665 | |||
| 666 | pub fn recvfrom(fd: i32, noalias buf: &u8, len: usize, flags: u32, | ||
| 667 | noalias addr: ?&sockaddr, noalias alen: ?&socklen_t) -> usize | ||
| 668 | { | ||
| 669 | arch.syscall6(arch.SYS_recvfrom, usize(fd), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen)) | ||
| 670 | } | ||
| 671 | |||
| 672 | pub fn shutdown(fd: i32, how: i32) -> usize { | ||
| 673 | arch.syscall2(arch.SYS_shutdown, usize(fd), usize(how)) | ||
| 674 | } | ||
| 675 | |||
| 676 | pub fn bind(fd: i32, addr: &const sockaddr, len: socklen_t) -> usize { | ||
| 677 | arch.syscall3(arch.SYS_bind, usize(fd), @ptrToInt(addr), usize(len)) | ||
| 678 | } | ||
| 679 | |||
| 680 | pub fn listen(fd: i32, backlog: i32) -> usize { | ||
| 681 | arch.syscall2(arch.SYS_listen, usize(fd), usize(backlog)) | ||
| 682 | } | ||
| 683 | |||
| 684 | pub fn sendto(fd: i32, buf: &const u8, len: usize, flags: u32, addr: ?&const sockaddr, alen: socklen_t) -> usize { | ||
| 685 | arch.syscall6(arch.SYS_sendto, usize(fd), @ptrToInt(buf), len, flags, @ptrToInt(addr), usize(alen)) | ||
| 686 | } | ||
| 687 | |||
| 688 | pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) -> usize { | ||
| 689 | arch.syscall4(arch.SYS_socketpair, usize(domain), usize(socket_type), usize(protocol), @ptrToInt(&fd[0])) | ||
| 690 | } | ||
| 691 | |||
| 692 | pub fn accept(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> usize { | ||
| 693 | accept4(fd, addr, len, 0) | ||
| 694 | } | ||
| 695 | |||
| 696 | pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags: u32) -> usize { | ||
| 697 | arch.syscall4(arch.SYS_accept4, usize(fd), @ptrToInt(addr), @ptrToInt(len), flags) | ||
| 698 | } | ||
| 699 | |||
| 700 | // error NameTooLong; | ||
| 701 | // error SystemResources; | ||
| 702 | // error Io; | ||
| 703 | // | ||
| 704 | // pub fn if_nametoindex(name: []u8) -> %u32 { | ||
| 705 | // var ifr: ifreq = undefined; | ||
| 706 | // | ||
| 707 | // if (name.len >= ifr.ifr_name.len) { | ||
| 708 | // return error.NameTooLong; | ||
| 709 | // } | ||
| 710 | // | ||
| 711 | // const socket_ret = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0); | ||
| 712 | // const socket_err = getErrno(socket_ret); | ||
| 713 | // if (socket_err > 0) { | ||
| 714 | // return error.SystemResources; | ||
| 715 | // } | ||
| 716 | // const socket_fd = i32(socket_ret); | ||
| 717 | // @memcpy(&ifr.ifr_name[0], &name[0], name.len); | ||
| 718 | // ifr.ifr_name[name.len] = 0; | ||
| 719 | // const ioctl_ret = ioctl(socket_fd, SIOCGIFINDEX, &ifr); | ||
| 720 | // close(socket_fd); | ||
| 721 | // const ioctl_err = getErrno(ioctl_ret); | ||
| 722 | // if (ioctl_err > 0) { | ||
| 723 | // return error.Io; | ||
| 724 | // } | ||
| 725 | // return ifr.ifr_ifindex; | ||
| 726 | // } | ||
| 727 | |||
| 728 | pub const Stat = arch.Stat; | ||
| 729 | pub const timespec = arch.timespec; | ||
| 730 | |||
| 731 | pub fn fstat(fd: i32, stat_buf: &Stat) -> usize { | ||
| 732 | arch.syscall2(arch.SYS_fstat, usize(fd), @ptrToInt(stat_buf)) | ||
| 733 | } | ||
std/os/freebsd_errno.zig created+121| ... | @@ -0,0 +1,121 @@ | ||
| 1 | pub const EPERM = 1; // Operation not permitted | ||
| 2 | pub const ENOENT = 2; // No such file or directory | ||
| 3 | pub const ESRCH = 3; // No such process | ||
| 4 | pub const EINTR = 4; // Interrupted system call | ||
| 5 | pub const EIO = 5; // Input/output error | ||
| 6 | pub const ENXIO = 6; // Device not configured | ||
| 7 | pub const E2BIG = 7; // Argument list too long | ||
| 8 | pub const ENOEXEC = 8; // Exec format error | ||
| 9 | pub const EBADF = 9; // Bad file descriptor | ||
| 10 | pub const ECHILD = 10; // No child processes | ||
| 11 | pub const EDEADLK = 11; // Resource deadlock avoided | ||
| 12 | // 11 was EAGAIN | ||
| 13 | pub const ENOMEM = 12; // Cannot allocate memory | ||
| 14 | pub const EACCES = 13; // Permission denied | ||
| 15 | pub const EFAULT = 14; // Bad address | ||
| 16 | pub const ENOTBLK = 15; // Block device required | ||
| 17 | pub const EBUSY = 16; // Device busy | ||
| 18 | pub const EEXIST = 17; // File exists | ||
| 19 | pub const EXDEV = 18; // Cross-device link | ||
| 20 | pub const ENODEV = 19; // Operation not supported by device | ||
| 21 | pub const ENOTDIR = 20; // Not a directory | ||
| 22 | pub const EISDIR = 21; // Is a directory | ||
| 23 | pub const EINVAL = 22; // Invalid argument | ||
| 24 | pub const ENFILE = 23; // Too many open files in system | ||
| 25 | pub const EMFILE = 24; // Too many open files | ||
| 26 | pub const ENOTTY = 25; // Inappropriate ioctl for device | ||
| 27 | pub const ETXTBSY = 26; // Text file busy | ||
| 28 | pub const EFBIG = 27; // File too large | ||
| 29 | pub const ENOSPC = 28; // No space left on device | ||
| 30 | pub const ESPIPE = 29; // Illegal seek | ||
| 31 | pub const EROFS = 30; // Read-only filesystem | ||
| 32 | pub const EMLINK = 31; // Too many links | ||
| 33 | pub const EPIPE = 32; // Broken pipe | ||
| 34 | |||
| 35 | // math software | ||
| 36 | pub const EDOM = 33; // Numerical argument out of domain | ||
| 37 | pub const ERANGE = 34; // Result too large | ||
| 38 | |||
| 39 | // non-blocking and interrupt i/o | ||
| 40 | pub const EAGAIN = 35; // Resource temporarily unavailable | ||
| 41 | pub const EWOULDBLOCK = EAGAIN; // Operation would block | ||
| 42 | pub const EINPROGRESS = 36; // Operation now in progress | ||
| 43 | pub const EALREADY = 37; // Operation already in progress | ||
| 44 | |||
| 45 | // ipc/network software -- argument errors | ||
| 46 | pub const ENOTSOCK = 38; // Socket operation on non-socket | ||
| 47 | pub const EDESTADDRREQ = 39; // Destination address required | ||
| 48 | pub const EMSGSIZE = 40; // Message too long | ||
| 49 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket | ||
| 50 | pub const ENOPROTOOPT = 42; // Protocol not available | ||
| 51 | pub const EPROTONOSUPPORT = 43; // Protocol not supported | ||
| 52 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported | ||
| 53 | pub const EOPNOTSUPP = 45; // Operation not supported | ||
| 54 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported | ||
| 55 | pub const EPFNOSUPPORT = 46; // Protocol family not supported | ||
| 56 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family | ||
| 57 | pub const EADDRINUSE = 48; // Address already in use | ||
| 58 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address | ||
| 59 | |||
| 60 | // ipc/network software -- operational errors | ||
| 61 | pub const ENETDOWN = 50; // Network is down | ||
| 62 | pub const ENETUNREACH = 51; // Network is unreachable | ||
| 63 | pub const ENETRESET = 52; // Network dropped connection on reset | ||
| 64 | pub const ECONNABORTED = 53; // Software caused connection abort | ||
| 65 | pub const ECONNRESET = 54; // Connection reset by peer | ||
| 66 | pub const ENOBUFS = 55; // No buffer space available | ||
| 67 | pub const EISCONN = 56; // Socket is already connected | ||
| 68 | pub const ENOTCONN = 57; // Socket is not connected | ||
| 69 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown | ||
| 70 | pub const ETOOMANYREFS = 59; // Too many references: can't splice | ||
| 71 | pub const ETIMEDOUT = 60; // Operation timed out | ||
| 72 | pub const ECONNREFUSED = 61; // Connection refused | ||
| 73 | |||
| 74 | pub const ELOOP = 62; // Too many levels of symbolic links | ||
| 75 | pub const ENAMETOOLONG = 63; // File name too long | ||
| 76 | |||
| 77 | // should be rearranged | ||
| 78 | pub const EHOSTDOWN = 64; // Host is down | ||
| 79 | pub const EHOSTUNREACH = 65; // No route to host | ||
| 80 | pub const ENOTEMPTY = 66; // Directory not empty | ||
| 81 | |||
| 82 | // quotas & mush | ||
| 83 | pub const EPROCLIM = 67; // Too many processes | ||
| 84 | pub const EUSERS = 68; // Too many users | ||
| 85 | pub const EDQUOT = 69; // Disc quota exceeded | ||
| 86 | |||
| 87 | // Network File System | ||
| 88 | pub const ESTALE = 70; // Stale NFS file handle | ||
| 89 | pub const EREMOTE = 71; // Too many levels of remote in path | ||
| 90 | pub const EBADRPC = 72; // RPC struct is bad | ||
| 91 | pub const ERPCMISMATCH = 73; // RPC version wrong | ||
| 92 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail | ||
| 93 | pub const EPROGMISMATCH = 75; // Program version wrong | ||
| 94 | pub const EPROCUNAVAIL = 76; // Bad procedure for program | ||
| 95 | |||
| 96 | pub const ENOLCK = 77; // No locks available | ||
| 97 | pub const ENOSYS = 78; // Function not implemented | ||
| 98 | |||
| 99 | pub const EFTYPE = 79; // Inappropriate file type or format | ||
| 100 | pub const EAUTH = 80; // Authentication error | ||
| 101 | pub const ENEEDAUTH = 81; // Need authenticator | ||
| 102 | pub const EIDRM = 82; // Identifier removed | ||
| 103 | pub const ENOMSG = 83; // No message of desired type | ||
| 104 | pub const EOVERFLOW = 84; // Value too large to be stored in data type | ||
| 105 | pub const ECANCELED = 85; // Operation canceled | ||
| 106 | pub const EILSEQ = 86; // Illegal byte sequence | ||
| 107 | pub const ENOATTR = 87; // Attribute not found | ||
| 108 | |||
| 109 | pub const EDOOFUS = 88; // Programming error | ||
| 110 | |||
| 111 | pub const EBADMSG = 89; // Bad message | ||
| 112 | pub const EMULTIHOP = 90; // Multihop attempted | ||
| 113 | pub const ENOLINK = 91; // Link has been severed | ||
| 114 | pub const EPROTO = 92; // Protocol error | ||
| 115 | |||
| 116 | pub const ENOTCAPABLE = 93; // Capabilities insufficient | ||
| 117 | pub const ECAPMODE = 94; // Not permitted in capability mode | ||
| 118 | pub const ENOTRECOVERABLE = 95; // State not recoverable | ||
| 119 | pub const EOWNERDEAD = 96; // Previous owner died | ||
| 120 | |||
| 121 | pub const ELAST = 96; // Must be equal largest errno | ||
std/os/freebsd_i386.zig created+614| ... | @@ -0,0 +1,614 @@ | ||
| 1 | const freebsd = @import("freebsd.zig"); | ||
| 2 | const socklen_t = freebsd.socklen_t; | ||
| 3 | const iovec = freebsd.iovec; | ||
| 4 | |||
| 5 | pub const SYS_syscall = 0; | ||
| 6 | pub const SYS_exit = 1; | ||
| 7 | pub const SYS_fork = 2; | ||
| 8 | pub const SYS_read = 3; | ||
| 9 | pub const SYS_write = 4; | ||
| 10 | pub const SYS_open = 5; | ||
| 11 | pub const SYS_close = 6; | ||
| 12 | pub const SYS_wait4 = 7; | ||
| 13 | // 8 is old creat | ||
| 14 | pub const SYS_link = 9; | ||
| 15 | pub const SYS_unlink = 10; | ||
| 16 | // 11 is obsolete execv | ||
| 17 | pub const SYS_chdir = 12; | ||
| 18 | pub const SYS_fchdir = 13; | ||
| 19 | pub const SYS_freebsd11_mknod = 14; | ||
| 20 | pub const SYS_chmod = 15; | ||
| 21 | pub const SYS_chown = 16; | ||
| 22 | pub const SYS_break = 17; | ||
| 23 | // 18 is freebsd4 getfsstat | ||
| 24 | // 19 is old lseek | ||
| 25 | pub const SYS_getpid = 20; | ||
| 26 | pub const SYS_mount = 21; | ||
| 27 | pub const SYS_unmount = 22; | ||
| 28 | pub const SYS_setuid = 23; | ||
| 29 | pub const SYS_getuid = 24; | ||
| 30 | pub const SYS_geteuid = 25; | ||
| 31 | pub const SYS_ptrace = 26; | ||
| 32 | pub const SYS_recvmsg = 27; | ||
| 33 | pub const SYS_sendmsg = 28; | ||
| 34 | pub const SYS_recvfrom = 29; | ||
| 35 | pub const SYS_accept = 30; | ||
| 36 | pub const SYS_getpeername = 31; | ||
| 37 | pub const SYS_getsockname = 32; | ||
| 38 | pub const SYS_access = 33; | ||
| 39 | pub const SYS_chflags = 34; | ||
| 40 | pub const SYS_fchflags = 35; | ||
| 41 | pub const SYS_sync = 36; | ||
| 42 | pub const SYS_kill = 37; | ||
| 43 | // 38 is old stat | ||
| 44 | pub const SYS_getppid = 39; | ||
| 45 | // 40 is old lstat | ||
| 46 | pub const SYS_dup = 41; | ||
| 47 | pub const SYS_freebsd10_pipe = 42; | ||
| 48 | pub const SYS_getegid = 43; | ||
| 49 | pub const SYS_profil = 44; | ||
| 50 | pub const SYS_ktrace = 45; | ||
| 51 | // 46 is old sigaction | ||
| 52 | pub const SYS_getgid = 47; | ||
| 53 | // 48 is old sigprocmask | ||
| 54 | pub const SYS_getlogin = 49; | ||
| 55 | pub const SYS_setlogin = 50; | ||
| 56 | pub const SYS_acct = 51; | ||
| 57 | // 52 is old sigpending | ||
| 58 | pub const SYS_sigaltstack = 53; | ||
| 59 | pub const SYS_ioctl = 54; | ||
| 60 | pub const SYS_reboot = 55; | ||
| 61 | pub const SYS_revoke = 56; | ||
| 62 | pub const SYS_symlink = 57; | ||
| 63 | pub const SYS_readlink = 58; | ||
| 64 | pub const SYS_execve = 59; | ||
| 65 | pub const SYS_umask = 60; | ||
| 66 | pub const SYS_chroot = 61; | ||
| 67 | // 62 is old fstat | ||
| 68 | // 63 is old getkerninfo | ||
| 69 | // 64 is old getpagesize | ||
| 70 | pub const SYS_msync = 65; | ||
| 71 | pub const SYS_vfork = 66; | ||
| 72 | // 67 is obsolete vread | ||
| 73 | // 68 is obsolete vwrite | ||
| 74 | pub const SYS_sbrk = 69; | ||
| 75 | pub const SYS_sstk = 70; | ||
| 76 | // 71 is old mmap | ||
| 77 | pub const SYS_vadvise = 72; | ||
| 78 | pub const SYS_munmap = 73; | ||
| 79 | pub const SYS_mprotect = 74; | ||
| 80 | pub const SYS_madvise = 75; | ||
| 81 | // 76 is obsolete vhangup | ||
| 82 | // 77 is obsolete vlimit | ||
| 83 | pub const SYS_mincore = 78; | ||
| 84 | pub const SYS_getgroups = 79; | ||
| 85 | pub const SYS_setgroups = 80; | ||
| 86 | pub const SYS_getpgrp = 81; | ||
| 87 | pub const SYS_setpgid = 82; | ||
| 88 | pub const SYS_setitimer = 83; | ||
| 89 | // 84 is old wait | ||
| 90 | pub const SYS_swapon = 85; | ||
| 91 | pub const SYS_getitimer = 86; | ||
| 92 | // 87 is old gethostname | ||
| 93 | // 88 is old sethostname | ||
| 94 | pub const SYS_getdtablesize = 89; | ||
| 95 | pub const SYS_dup2 = 90; | ||
| 96 | pub const SYS_fcntl = 92; | ||
| 97 | pub const SYS_select = 93; | ||
| 98 | pub const SYS_fsync = 95; | ||
| 99 | pub const SYS_setpriority = 96; | ||
| 100 | pub const SYS_socket = 97; | ||
| 101 | pub const SYS_connect = 98; | ||
| 102 | // 99 is old accept | ||
| 103 | pub const SYS_getpriority = 100; | ||
| 104 | // 101 is old send | ||
| 105 | // 102 is old recv | ||
| 106 | // 103 is old sigreturn | ||
| 107 | pub const SYS_bind = 104; | ||
| 108 | pub const SYS_setsockopt = 105; | ||
| 109 | pub const SYS_listen = 106; | ||
| 110 | // 107 is obsolete vtimes | ||
| 111 | // 108 is old sigvec | ||
| 112 | // 109 is old sigblock | ||
| 113 | // 110 is old sigsetmask | ||
| 114 | // 111 is old sigsuspend | ||
| 115 | // 112 is old sigstack | ||
| 116 | // 113 is old recvmsg | ||
| 117 | // 114 is old sendmsg | ||
| 118 | // 115 is obsolete vtrace | ||
| 119 | pub const SYS_gettimeofday = 116; | ||
| 120 | pub const SYS_getrusage = 117; | ||
| 121 | pub const SYS_getsockopt = 118; | ||
| 122 | pub const SYS_readv = 120; | ||
| 123 | pub const SYS_writev = 121; | ||
| 124 | pub const SYS_settimeofday = 122; | ||
| 125 | pub const SYS_fchown = 123; | ||
| 126 | pub const SYS_fchmod = 124; | ||
| 127 | // 125 is old recvfrom | ||
| 128 | pub const SYS_setreuid = 126; | ||
| 129 | pub const SYS_setregid = 127; | ||
| 130 | pub const SYS_rename = 128; | ||
| 131 | // 129 is old truncate | ||
| 132 | // 130 is old ftruncate | ||
| 133 | pub const SYS_flock = 131; | ||
| 134 | pub const SYS_mkfifo = 132; | ||
| 135 | pub const SYS_sendto = 133; | ||
| 136 | pub const SYS_shutdown = 134; | ||
| 137 | pub const SYS_socketpair = 135; | ||
| 138 | pub const SYS_mkdir = 136; | ||
| 139 | pub const SYS_rmdir = 137; | ||
| 140 | pub const SYS_utimes = 138; | ||
| 141 | // 139 is obsolete 4.2 sigreturn | ||
| 142 | pub const SYS_adjtime = 140; | ||
| 143 | // 141 is old getpeername | ||
| 144 | // 142 is old gethostid | ||
| 145 | // 143 is old sethostid | ||
| 146 | // 144 is old getrlimit | ||
| 147 | // 145 is old setrlimit | ||
| 148 | // 146 is old killpg | ||
| 149 | pub const SYS_setsid = 147; | ||
| 150 | pub const SYS_quotactl = 148; | ||
| 151 | // 149 is old quota | ||
| 152 | // 150 is old getsockname | ||
| 153 | pub const SYS_nlm_syscall = 154; | ||
| 154 | pub const SYS_nfssvc = 155; | ||
| 155 | // 156 is old getdirentries | ||
| 156 | // 157 is freebsd4 statfs | ||
| 157 | // 158 is freebsd4 fstatfs | ||
| 158 | pub const SYS_lgetfh = 160; | ||
| 159 | pub const SYS_getfh = 161; | ||
| 160 | // 162 is freebsd4 getdomainname | ||
| 161 | // 163 is freebsd4 setdomainname | ||
| 162 | // 164 is freebsd4 uname | ||
| 163 | pub const SYS_sysarch = 165; | ||
| 164 | pub const SYS_rtprio = 166; | ||
| 165 | pub const SYS_semsys = 169; | ||
| 166 | pub const SYS_msgsys = 170; | ||
| 167 | pub const SYS_shmsys = 171; | ||
| 168 | // 173 is freebsd6 pread | ||
| 169 | // 174 is freebsd6 pwrite | ||
| 170 | pub const SYS_setfib = 175; | ||
| 171 | pub const SYS_ntp_adjtime = 176; | ||
| 172 | pub const SYS_setgid = 181; | ||
| 173 | pub const SYS_setegid = 182; | ||
| 174 | pub const SYS_seteuid = 183; | ||
| 175 | pub const SYS_freebsd11_stat = 188; | ||
| 176 | pub const SYS_freebsd11_fstat = 189; | ||
| 177 | pub const SYS_freebsd11_lstat = 190; | ||
| 178 | pub const SYS_pathconf = 191; | ||
| 179 | pub const SYS_fpathconf = 192; | ||
| 180 | pub const SYS_getrlimit = 194; | ||
| 181 | pub const SYS_setrlimit = 195; | ||
| 182 | pub const SYS_freebsd11_getdirentries = 196; | ||
| 183 | // 197 is freebsd6 mmap | ||
| 184 | pub const SYS___syscall = 198; | ||
| 185 | // 199 is freebsd6 lseek | ||
| 186 | // 200 is freebsd6 truncate | ||
| 187 | // 201 is freebsd6 ftruncate | ||
| 188 | pub const SYS___sysctl = 202; | ||
| 189 | pub const SYS_mlock = 203; | ||
| 190 | pub const SYS_munlock = 204; | ||
| 191 | pub const SYS_undelete = 205; | ||
| 192 | pub const SYS_futimes = 206; | ||
| 193 | pub const SYS_getpgid = 207; | ||
| 194 | pub const SYS_poll = 209; | ||
| 195 | pub const SYS_freebsd7___semctl = 220; | ||
| 196 | pub const SYS_semget = 221; | ||
| 197 | pub const SYS_semop = 222; | ||
| 198 | pub const SYS_freebsd7_msgctl = 224; | ||
| 199 | pub const SYS_msgget = 225; | ||
| 200 | pub const SYS_msgsnd = 226; | ||
| 201 | pub const SYS_msgrcv = 227; | ||
| 202 | pub const SYS_shmat = 228; | ||
| 203 | pub const SYS_freebsd7_shmctl = 229; | ||
| 204 | pub const SYS_shmdt = 230; | ||
| 205 | pub const SYS_shmget = 231; | ||
| 206 | pub const SYS_clock_gettime = 232; | ||
| 207 | pub const SYS_clock_settime = 233; | ||
| 208 | pub const SYS_clock_getres = 234; | ||
| 209 | pub const SYS_ktimer_create = 235; | ||
| 210 | pub const SYS_ktimer_delete = 236; | ||
| 211 | pub const SYS_ktimer_settime = 237; | ||
| 212 | pub const SYS_ktimer_gettime = 238; | ||
| 213 | pub const SYS_ktimer_getoverrun = 239; | ||
| 214 | pub const SYS_nanosleep = 240; | ||
| 215 | pub const SYS_ffclock_getcounter = 241; | ||
| 216 | pub const SYS_ffclock_setestimate = 242; | ||
| 217 | pub const SYS_ffclock_getestimate = 243; | ||
| 218 | pub const SYS_clock_nanosleep = 244; | ||
| 219 | pub const SYS_clock_getcpuclockid2 = 247; | ||
| 220 | pub const SYS_ntp_gettime = 248; | ||
| 221 | pub const SYS_minherit = 250; | ||
| 222 | pub const SYS_rfork = 251; | ||
| 223 | // 252 is obsolete openbsd_poll | ||
| 224 | pub const SYS_issetugid = 253; | ||
| 225 | pub const SYS_lchown = 254; | ||
| 226 | pub const SYS_aio_read = 255; | ||
| 227 | pub const SYS_aio_write = 256; | ||
| 228 | pub const SYS_lio_listio = 257; | ||
| 229 | pub const SYS_freebsd11_getdents = 272; | ||
| 230 | pub const SYS_lchmod = 274; | ||
| 231 | pub const SYS_netbsd_lchown = 275; | ||
| 232 | pub const SYS_lutimes = 276; | ||
| 233 | pub const SYS_netbsd_msync = 277; | ||
| 234 | pub const SYS_freebsd11_nstat = 278; | ||
| 235 | pub const SYS_freebsd11_nfstat = 279; | ||
| 236 | pub const SYS_freebsd11_nlstat = 280; | ||
| 237 | pub const SYS_preadv = 289; | ||
| 238 | pub const SYS_pwritev = 290; | ||
| 239 | // 297 is freebsd4 fhstatfs | ||
| 240 | pub const SYS_fhopen = 298; | ||
| 241 | pub const SYS_freebsd11_fhstat = 299; | ||
| 242 | pub const SYS_modnext = 300; | ||
| 243 | pub const SYS_modstat = 301; | ||
| 244 | pub const SYS_modfnext = 302; | ||
| 245 | pub const SYS_modfind = 303; | ||
| 246 | pub const SYS_kldload = 304; | ||
| 247 | pub const SYS_kldunload = 305; | ||
| 248 | pub const SYS_kldfind = 306; | ||
| 249 | pub const SYS_kldnext = 307; | ||
| 250 | pub const SYS_kldstat = 308; | ||
| 251 | pub const SYS_kldfirstmod = 309; | ||
| 252 | pub const SYS_getsid = 310; | ||
| 253 | pub const SYS_setresuid = 311; | ||
| 254 | pub const SYS_setresgid = 312; | ||
| 255 | // 313 is obsolete signanosleep | ||
| 256 | pub const SYS_aio_return = 314; | ||
| 257 | pub const SYS_aio_suspend = 315; | ||
| 258 | pub const SYS_aio_cancel = 316; | ||
| 259 | pub const SYS_aio_error = 317; | ||
| 260 | // 318 is freebsd6 aio_read | ||
| 261 | // 319 is freebsd6 aio_write | ||
| 262 | // 320 is freebsd6 lio_listio | ||
| 263 | pub const SYS_yield = 321; | ||
| 264 | // 322 is obsolete thr_sleep | ||
| 265 | // 323 is obsolete thr_wakeup | ||
| 266 | pub const SYS_mlockall = 324; | ||
| 267 | pub const SYS_munlockall = 325; | ||
| 268 | pub const SYS___getcwd = 326; | ||
| 269 | pub const SYS_sched_setparam = 327; | ||
| 270 | pub const SYS_sched_getparam = 328; | ||
| 271 | pub const SYS_sched_setscheduler = 329; | ||
| 272 | pub const SYS_sched_getscheduler = 330; | ||
| 273 | pub const SYS_sched_yield = 331; | ||
| 274 | pub const SYS_sched_get_priority_max = 332; | ||
| 275 | pub const SYS_sched_get_priority_min = 333; | ||
| 276 | pub const SYS_sched_rr_get_interval = 334; | ||
| 277 | pub const SYS_utrace = 335; | ||
| 278 | // 336 is freebsd4 sendfile | ||
| 279 | pub const SYS_kldsym = 337; | ||
| 280 | pub const SYS_jail = 338; | ||
| 281 | pub const SYS_nnpfs_syscall = 339; | ||
| 282 | pub const SYS_sigprocmask = 340; | ||
| 283 | pub const SYS_sigsuspend = 341; | ||
| 284 | // 342 is freebsd4 sigaction | ||
| 285 | pub const SYS_sigpending = 343; | ||
| 286 | // 344 is freebsd4 sigreturn | ||
| 287 | pub const SYS_sigtimedwait = 345; | ||
| 288 | pub const SYS_sigwaitinfo = 346; | ||
| 289 | pub const SYS___acl_get_file = 347; | ||
| 290 | pub const SYS___acl_set_file = 348; | ||
| 291 | pub const SYS___acl_get_fd = 349; | ||
| 292 | pub const SYS___acl_set_fd = 350; | ||
| 293 | pub const SYS___acl_delete_file = 351; | ||
| 294 | pub const SYS___acl_delete_fd = 352; | ||
| 295 | pub const SYS___acl_aclcheck_file = 353; | ||
| 296 | pub const SYS___acl_aclcheck_fd = 354; | ||
| 297 | pub const SYS_extattrctl = 355; | ||
| 298 | pub const SYS_extattr_set_file = 356; | ||
| 299 | pub const SYS_extattr_get_file = 357; | ||
| 300 | pub const SYS_extattr_delete_file = 358; | ||
| 301 | pub const SYS_aio_waitcomplete = 359; | ||
| 302 | pub const SYS_getresuid = 360; | ||
| 303 | pub const SYS_getresgid = 361; | ||
| 304 | pub const SYS_kqueue = 362; | ||
| 305 | pub const SYS_freebsd11_kevent = 363; | ||
| 306 | pub const SYS_extattr_set_fd = 371; | ||
| 307 | pub const SYS_extattr_get_fd = 372; | ||
| 308 | pub const SYS_extattr_delete_fd = 373; | ||
| 309 | pub const SYS___setugid = 374; | ||
| 310 | pub const SYS_eaccess = 376; | ||
| 311 | pub const SYS_afs3_syscall = 377; | ||
| 312 | pub const SYS_nmount = 378; | ||
| 313 | pub const SYS___mac_get_proc = 384; | ||
| 314 | pub const SYS___mac_set_proc = 385; | ||
| 315 | pub const SYS___mac_get_fd = 386; | ||
| 316 | pub const SYS___mac_get_file = 387; | ||
| 317 | pub const SYS___mac_set_fd = 388; | ||
| 318 | pub const SYS___mac_set_file = 389; | ||
| 319 | pub const SYS_kenv = 390; | ||
| 320 | pub const SYS_lchflags = 391; | ||
| 321 | pub const SYS_uuidgen = 392; | ||
| 322 | pub const SYS_sendfile = 393; | ||
| 323 | pub const SYS_mac_syscall = 394; | ||
| 324 | pub const SYS_freebsd11_getfsstat = 395; | ||
| 325 | pub const SYS_freebsd11_statfs = 396; | ||
| 326 | pub const SYS_freebsd11_fstatfs = 397; | ||
| 327 | pub const SYS_freebsd11_fhstatfs = 398; | ||
| 328 | pub const SYS_ksem_close = 400; | ||
| 329 | pub const SYS_ksem_post = 401; | ||
| 330 | pub const SYS_ksem_wait = 402; | ||
| 331 | pub const SYS_ksem_trywait = 403; | ||
| 332 | pub const SYS_ksem_init = 404; | ||
| 333 | pub const SYS_ksem_open = 405; | ||
| 334 | pub const SYS_ksem_unlink = 406; | ||
| 335 | pub const SYS_ksem_getvalue = 407; | ||
| 336 | pub const SYS_ksem_destroy = 408; | ||
| 337 | pub const SYS___mac_get_pid = 409; | ||
| 338 | pub const SYS___mac_get_link = 410; | ||
| 339 | pub const SYS___mac_set_link = 411; | ||
| 340 | pub const SYS_extattr_set_link = 412; | ||
| 341 | pub const SYS_extattr_get_link = 413; | ||
| 342 | pub const SYS_extattr_delete_link = 414; | ||
| 343 | pub const SYS___mac_execve = 415; | ||
| 344 | pub const SYS_sigaction = 416; | ||
| 345 | pub const SYS_sigreturn = 417; | ||
| 346 | pub const SYS_getcontext = 421; | ||
| 347 | pub const SYS_setcontext = 422; | ||
| 348 | pub const SYS_swapcontext = 423; | ||
| 349 | pub const SYS_swapoff = 424; | ||
| 350 | pub const SYS___acl_get_link = 425; | ||
| 351 | pub const SYS___acl_set_link = 426; | ||
| 352 | pub const SYS___acl_delete_link = 427; | ||
| 353 | pub const SYS___acl_aclcheck_link = 428; | ||
| 354 | pub const SYS_sigwait = 429; | ||
| 355 | pub const SYS_thr_create = 430; | ||
| 356 | pub const SYS_thr_exit = 431; | ||
| 357 | pub const SYS_thr_self = 432; | ||
| 358 | pub const SYS_thr_kill = 433; | ||
| 359 | pub const SYS_jail_attach = 436; | ||
| 360 | pub const SYS_extattr_list_fd = 437; | ||
| 361 | pub const SYS_extattr_list_file = 438; | ||
| 362 | pub const SYS_extattr_list_link = 439; | ||
| 363 | pub const SYS_ksem_timedwait = 441; | ||
| 364 | pub const SYS_thr_suspend = 442; | ||
| 365 | pub const SYS_thr_wake = 443; | ||
| 366 | pub const SYS_kldunloadf = 444; | ||
| 367 | pub const SYS_audit = 445; | ||
| 368 | pub const SYS_auditon = 446; | ||
| 369 | pub const SYS_getauid = 447; | ||
| 370 | pub const SYS_setauid = 448; | ||
| 371 | pub const SYS_getaudit = 449; | ||
| 372 | pub const SYS_setaudit = 450; | ||
| 373 | pub const SYS_getaudit_addr = 451; | ||
| 374 | pub const SYS_setaudit_addr = 452; | ||
| 375 | pub const SYS_auditctl = 453; | ||
| 376 | pub const SYS__umtx_op = 454; | ||
| 377 | pub const SYS_thr_new = 455; | ||
| 378 | pub const SYS_sigqueue = 456; | ||
| 379 | pub const SYS_kmq_open = 457; | ||
| 380 | pub const SYS_kmq_setattr = 458; | ||
| 381 | pub const SYS_kmq_timedreceive = 459; | ||
| 382 | pub const SYS_kmq_timedsend = 460; | ||
| 383 | pub const SYS_kmq_notify = 461; | ||
| 384 | pub const SYS_kmq_unlink = 462; | ||
| 385 | pub const SYS_abort2 = 463; | ||
| 386 | pub const SYS_thr_set_name = 464; | ||
| 387 | pub const SYS_aio_fsync = 465; | ||
| 388 | pub const SYS_rtprio_thread = 466; | ||
| 389 | pub const SYS_sctp_peeloff = 471; | ||
| 390 | pub const SYS_sctp_generic_sendmsg = 472; | ||
| 391 | pub const SYS_sctp_generic_sendmsg_iov = 473; | ||
| 392 | pub const SYS_sctp_generic_recvmsg = 474; | ||
| 393 | pub const SYS_pread = 475; | ||
| 394 | pub const SYS_pwrite = 476; | ||
| 395 | pub const SYS_mmap = 477; | ||
| 396 | pub const SYS_lseek = 478; | ||
| 397 | pub const SYS_truncate = 479; | ||
| 398 | pub const SYS_ftruncate = 480; | ||
| 399 | pub const SYS_thr_kill2 = 481; | ||
| 400 | pub const SYS_shm_open = 482; | ||
| 401 | pub const SYS_shm_unlink = 483; | ||
| 402 | pub const SYS_cpuset = 484; | ||
| 403 | pub const SYS_cpuset_setid = 485; | ||
| 404 | pub const SYS_cpuset_getid = 486; | ||
| 405 | pub const SYS_cpuset_getaffinity = 487; | ||
| 406 | pub const SYS_cpuset_setaffinity = 488; | ||
| 407 | pub const SYS_faccessat = 489; | ||
| 408 | pub const SYS_fchmodat = 490; | ||
| 409 | pub const SYS_fchownat = 491; | ||
| 410 | pub const SYS_fexecve = 492; | ||
| 411 | pub const SYS_freebsd11_fstatat = 493; | ||
| 412 | pub const SYS_futimesat = 494; | ||
| 413 | pub const SYS_linkat = 495; | ||
| 414 | pub const SYS_mkdirat = 496; | ||
| 415 | pub const SYS_mkfifoat = 497; | ||
| 416 | pub const SYS_freebsd11_mknodat = 498; | ||
| 417 | pub const SYS_openat = 499; | ||
| 418 | pub const SYS_readlinkat = 500; | ||
| 419 | pub const SYS_renameat = 501; | ||
| 420 | pub const SYS_symlinkat = 502; | ||
| 421 | pub const SYS_unlinkat = 503; | ||
| 422 | pub const SYS_posix_openpt = 504; | ||
| 423 | pub const SYS_gssd_syscall = 505; | ||
| 424 | pub const SYS_jail_get = 506; | ||
| 425 | pub const SYS_jail_set = 507; | ||
| 426 | pub const SYS_jail_remove = 508; | ||
| 427 | pub const SYS_closefrom = 509; | ||
| 428 | pub const SYS___semctl = 510; | ||
| 429 | pub const SYS_msgctl = 511; | ||
| 430 | pub const SYS_shmctl = 512; | ||
| 431 | pub const SYS_lpathconf = 513; | ||
| 432 | // 514 is obsolete cap_new | ||
| 433 | pub const SYS___cap_rights_get = 515; | ||
| 434 | pub const SYS_cap_enter = 516; | ||
| 435 | pub const SYS_cap_getmode = 517; | ||
| 436 | pub const SYS_pdfork = 518; | ||
| 437 | pub const SYS_pdkill = 519; | ||
| 438 | pub const SYS_pdgetpid = 520; | ||
| 439 | pub const SYS_pselect = 522; | ||
| 440 | pub const SYS_getloginclass = 523; | ||
| 441 | pub const SYS_setloginclass = 524; | ||
| 442 | pub const SYS_rctl_get_racct = 525; | ||
| 443 | pub const SYS_rctl_get_rules = 526; | ||
| 444 | pub const SYS_rctl_get_limits = 527; | ||
| 445 | pub const SYS_rctl_add_rule = 528; | ||
| 446 | pub const SYS_rctl_remove_rule = 529; | ||
| 447 | pub const SYS_posix_fallocate = 530; | ||
| 448 | pub const SYS_posix_fadvise = 531; | ||
| 449 | pub const SYS_wait6 = 532; | ||
| 450 | pub const SYS_cap_rights_limit = 533; | ||
| 451 | pub const SYS_cap_ioctls_limit = 534; | ||
| 452 | pub const SYS_cap_ioctls_get = 535; | ||
| 453 | pub const SYS_cap_fcntls_limit = 536; | ||
| 454 | pub const SYS_cap_fcntls_get = 537; | ||
| 455 | pub const SYS_bindat = 538; | ||
| 456 | pub const SYS_connectat = 539; | ||
| 457 | pub const SYS_chflagsat = 540; | ||
| 458 | pub const SYS_accept4 = 541; | ||
| 459 | pub const SYS_pipe2 = 542; | ||
| 460 | pub const SYS_aio_mlock = 543; | ||
| 461 | pub const SYS_procctl = 544; | ||
| 462 | pub const SYS_ppoll = 545; | ||
| 463 | pub const SYS_futimens = 546; | ||
| 464 | pub const SYS_utimensat = 547; | ||
| 465 | pub const SYS_numa_getaffinity = 548; | ||
| 466 | pub const SYS_numa_setaffinity = 549; | ||
| 467 | pub const SYS_fdatasync = 550; | ||
| 468 | pub const SYS_fstat = 551; | ||
| 469 | pub const SYS_fstatat = 552; | ||
| 470 | pub const SYS_fhstat = 553; | ||
| 471 | pub const SYS_getdirentries = 554; | ||
| 472 | pub const SYS_statfs = 555; | ||
| 473 | pub const SYS_fstatfs = 556; | ||
| 474 | pub const SYS_getfsstat = 557; | ||
| 475 | pub const SYS_fhstatfs = 558; | ||
| 476 | pub const SYS_mknodat = 559; | ||
| 477 | pub const SYS_kevent = 560; | ||
| 478 | pub const SYS_MAXSYSCALL = 561; | ||
| 479 | |||
| 480 | // From here | ||
| 481 | pub const O_CREAT = 0o100; | ||
| 482 | pub const O_EXCL = 0o200; | ||
| 483 | pub const O_NOCTTY = 0o400; | ||
| 484 | pub const O_TRUNC = 0o1000; | ||
| 485 | pub const O_APPEND = 0o2000; | ||
| 486 | pub const O_NONBLOCK = 0o4000; | ||
| 487 | pub const O_DSYNC = 0o10000; | ||
| 488 | pub const O_SYNC = 0o4010000; | ||
| 489 | pub const O_RSYNC = 0o4010000; | ||
| 490 | pub const O_DIRECTORY = 0o200000; | ||
| 491 | pub const O_NOFOLLOW = 0o400000; | ||
| 492 | pub const O_CLOEXEC = 0o2000000; | ||
| 493 | |||
| 494 | pub const O_ASYNC = 0o20000; | ||
| 495 | pub const O_DIRECT = 0o40000; | ||
| 496 | pub const O_LARGEFILE = 0o100000; | ||
| 497 | pub const O_NOATIME = 0o1000000; | ||
| 498 | pub const O_PATH = 0o10000000; | ||
| 499 | pub const O_TMPFILE = 0o20200000; | ||
| 500 | pub const O_NDELAY = O_NONBLOCK; | ||
| 501 | |||
| 502 | pub const F_DUPFD = 0; | ||
| 503 | pub const F_GETFD = 1; | ||
| 504 | pub const F_SETFD = 2; | ||
| 505 | pub const F_GETFL = 3; | ||
| 506 | pub const F_SETFL = 4; | ||
| 507 | |||
| 508 | pub const F_SETOWN = 8; | ||
| 509 | pub const F_GETOWN = 9; | ||
| 510 | pub const F_SETSIG = 10; | ||
| 511 | pub const F_GETSIG = 11; | ||
| 512 | |||
| 513 | pub const F_GETLK = 12; | ||
| 514 | pub const F_SETLK = 13; | ||
| 515 | pub const F_SETLKW = 14; | ||
| 516 | |||
| 517 | pub const F_SETOWN_EX = 15; | ||
| 518 | pub const F_GETOWN_EX = 16; | ||
| 519 | |||
| 520 | pub const F_GETOWNER_UIDS = 17; | ||
| 521 | |||
| 522 | pub inline fn syscall0(number: usize) -> usize { | ||
| 523 | asm volatile ("int $0x80" | ||
| 524 | : [ret] "={eax}" (-> usize) | ||
| 525 | : [number] "{eax}" (number)) | ||
| 526 | } | ||
| 527 | |||
| 528 | pub inline fn syscall1(number: usize, arg1: usize) -> usize { | ||
| 529 | asm volatile ("int $0x80" | ||
| 530 | : [ret] "={eax}" (-> usize) | ||
| 531 | : [number] "{eax}" (number), | ||
| 532 | [arg1] "{ebx}" (arg1)) | ||
| 533 | } | ||
| 534 | |||
| 535 | pub inline fn syscall2(number: usize, arg1: usize, arg2: usize) -> usize { | ||
| 536 | asm volatile ("int $0x80" | ||
| 537 | : [ret] "={eax}" (-> usize) | ||
| 538 | : [number] "{eax}" (number), | ||
| 539 | [arg1] "{ebx}" (arg1), | ||
| 540 | [arg2] "{ecx}" (arg2)) | ||
| 541 | } | ||
| 542 | |||
| 543 | pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize { | ||
| 544 | asm volatile ("int $0x80" | ||
| 545 | : [ret] "={eax}" (-> usize) | ||
| 546 | : [number] "{eax}" (number), | ||
| 547 | [arg1] "{ebx}" (arg1), | ||
| 548 | [arg2] "{ecx}" (arg2), | ||
| 549 | [arg3] "{edx}" (arg3)) | ||
| 550 | } | ||
| 551 | |||
| 552 | pub inline fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize { | ||
| 553 | asm volatile ("int $0x80" | ||
| 554 | : [ret] "={eax}" (-> usize) | ||
| 555 | : [number] "{eax}" (number), | ||
| 556 | [arg1] "{ebx}" (arg1), | ||
| 557 | [arg2] "{ecx}" (arg2), | ||
| 558 | [arg3] "{edx}" (arg3), | ||
| 559 | [arg4] "{esi}" (arg4)) | ||
| 560 | } | ||
| 561 | |||
| 562 | pub inline fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, | ||
| 563 | arg4: usize, arg5: usize) -> usize | ||
| 564 | { | ||
| 565 | asm volatile ("int $0x80" | ||
| 566 | : [ret] "={eax}" (-> usize) | ||
| 567 | : [number] "{eax}" (number), | ||
| 568 | [arg1] "{ebx}" (arg1), | ||
| 569 | [arg2] "{ecx}" (arg2), | ||
| 570 | [arg3] "{edx}" (arg3), | ||
| 571 | [arg4] "{esi}" (arg4), | ||
| 572 | [arg5] "{edi}" (arg5)) | ||
| 573 | } | ||
| 574 | |||
| 575 | pub inline fn syscall6(number: usize, arg1: usize, arg2: usize, arg3: usize, | ||
| 576 | arg4: usize, arg5: usize, arg6: usize) -> usize | ||
| 577 | { | ||
| 578 | asm volatile ("int $0x80" | ||
| 579 | : [ret] "={eax}" (-> usize) | ||
| 580 | : [number] "{eax}" (number), | ||
| 581 | [arg1] "{ebx}" (arg1), | ||
| 582 | [arg2] "{ecx}" (arg2), | ||
| 583 | [arg3] "{edx}" (arg3), | ||
| 584 | [arg4] "{esi}" (arg4), | ||
| 585 | [arg5] "{edi}" (arg5), | ||
| 586 | [arg6] "{ebp}" (arg6)) | ||
| 587 | } | ||
| 588 | |||
| 589 | pub nakedcc fn restore() { | ||
| 590 | asm volatile ( | ||
| 591 | \\popl %%eax | ||
| 592 | \\movl $119, %%eax | ||
| 593 | \\int $0x80 | ||
| 594 | : | ||
| 595 | : | ||
| 596 | : "rcx", "r11") | ||
| 597 | } | ||
| 598 | |||
| 599 | pub nakedcc fn restore_rt() { | ||
| 600 | asm volatile ("int $0x80" | ||
| 601 | : | ||
| 602 | : [number] "{eax}" (usize(SYS_rt_sigreturn)) | ||
| 603 | : "rcx", "r11") | ||
| 604 | } | ||
| 605 | |||
| 606 | export struct msghdr { | ||
| 607 | msg_name: &u8, | ||
| 608 | msg_namelen: socklen_t, | ||
| 609 | msg_iov: &iovec, | ||
| 610 | msg_iovlen: i32, | ||
| 611 | msg_control: &u8, | ||
| 612 | msg_controllen: socklen_t, | ||
| 613 | msg_flags: i32, | ||
| 614 | } | ||
std/os/freebsd_x86_64.zig created+637| ... | @@ -0,0 +1,637 @@ | ||
| 1 | const freebsd = @import("freebsd.zig"); | ||
| 2 | const socklen_t = freebsd.socklen_t; | ||
| 3 | const iovec = freebsd.iovec; | ||
| 4 | |||
| 5 | pub const SYS_syscall = 0; | ||
| 6 | pub const SYS_exit = 1; | ||
| 7 | pub const SYS_fork = 2; | ||
| 8 | pub const SYS_read = 3; | ||
| 9 | pub const SYS_write = 4; | ||
| 10 | pub const SYS_open = 5; | ||
| 11 | pub const SYS_close = 6; | ||
| 12 | pub const SYS_wait4 = 7; | ||
| 13 | // 8 is old creat | ||
| 14 | pub const SYS_link = 9; | ||
| 15 | pub const SYS_unlink = 10; | ||
| 16 | // 11 is obsolete execv | ||
| 17 | pub const SYS_chdir = 12; | ||
| 18 | pub const SYS_fchdir = 13; | ||
| 19 | pub const SYS_freebsd11_mknod = 14; | ||
| 20 | pub const SYS_chmod = 15; | ||
| 21 | pub const SYS_chown = 16; | ||
| 22 | pub const SYS_break = 17; | ||
| 23 | // 18 is freebsd4 getfsstat | ||
| 24 | // 19 is old lseek | ||
| 25 | pub const SYS_getpid = 20; | ||
| 26 | pub const SYS_mount = 21; | ||
| 27 | pub const SYS_unmount = 22; | ||
| 28 | pub const SYS_setuid = 23; | ||
| 29 | pub const SYS_getuid = 24; | ||
| 30 | pub const SYS_geteuid = 25; | ||
| 31 | pub const SYS_ptrace = 26; | ||
| 32 | pub const SYS_recvmsg = 27; | ||
| 33 | pub const SYS_sendmsg = 28; | ||
| 34 | pub const SYS_recvfrom = 29; | ||
| 35 | pub const SYS_accept = 30; | ||
| 36 | pub const SYS_getpeername = 31; | ||
| 37 | pub const SYS_getsockname = 32; | ||
| 38 | pub const SYS_access = 33; | ||
| 39 | pub const SYS_chflags = 34; | ||
| 40 | pub const SYS_fchflags = 35; | ||
| 41 | pub const SYS_sync = 36; | ||
| 42 | pub const SYS_kill = 37; | ||
| 43 | // 38 is old stat | ||
| 44 | pub const SYS_getppid = 39; | ||
| 45 | // 40 is old lstat | ||
| 46 | pub const SYS_dup = 41; | ||
| 47 | pub const SYS_freebsd10_pipe = 42; | ||
| 48 | pub const SYS_getegid = 43; | ||
| 49 | pub const SYS_profil = 44; | ||
| 50 | pub const SYS_ktrace = 45; | ||
| 51 | // 46 is old sigaction | ||
| 52 | pub const SYS_getgid = 47; | ||
| 53 | // 48 is old sigprocmask | ||
| 54 | pub const SYS_getlogin = 49; | ||
| 55 | pub const SYS_setlogin = 50; | ||
| 56 | pub const SYS_acct = 51; | ||
| 57 | // 52 is old sigpending | ||
| 58 | pub const SYS_sigaltstack = 53; | ||
| 59 | pub const SYS_ioctl = 54; | ||
| 60 | pub const SYS_reboot = 55; | ||
| 61 | pub const SYS_revoke = 56; | ||
| 62 | pub const SYS_symlink = 57; | ||
| 63 | pub const SYS_readlink = 58; | ||
| 64 | pub const SYS_execve = 59; | ||
| 65 | pub const SYS_umask = 60; | ||
| 66 | pub const SYS_chroot = 61; | ||
| 67 | // 62 is old fstat | ||
| 68 | // 63 is old getkerninfo | ||
| 69 | // 64 is old getpagesize | ||
| 70 | pub const SYS_msync = 65; | ||
| 71 | pub const SYS_vfork = 66; | ||
| 72 | // 67 is obsolete vread | ||
| 73 | // 68 is obsolete vwrite | ||
| 74 | pub const SYS_sbrk = 69; | ||
| 75 | pub const SYS_sstk = 70; | ||
| 76 | // 71 is old mmap | ||
| 77 | pub const SYS_vadvise = 72; | ||
| 78 | pub const SYS_munmap = 73; | ||
| 79 | pub const SYS_mprotect = 74; | ||
| 80 | pub const SYS_madvise = 75; | ||
| 81 | // 76 is obsolete vhangup | ||
| 82 | // 77 is obsolete vlimit | ||
| 83 | pub const SYS_mincore = 78; | ||
| 84 | pub const SYS_getgroups = 79; | ||
| 85 | pub const SYS_setgroups = 80; | ||
| 86 | pub const SYS_getpgrp = 81; | ||
| 87 | pub const SYS_setpgid = 82; | ||
| 88 | pub const SYS_setitimer = 83; | ||
| 89 | // 84 is old wait | ||
| 90 | pub const SYS_swapon = 85; | ||
| 91 | pub const SYS_getitimer = 86; | ||
| 92 | // 87 is old gethostname | ||
| 93 | // 88 is old sethostname | ||
| 94 | pub const SYS_getdtablesize = 89; | ||
| 95 | pub const SYS_dup2 = 90; | ||
| 96 | pub const SYS_fcntl = 92; | ||
| 97 | pub const SYS_select = 93; | ||
| 98 | pub const SYS_fsync = 95; | ||
| 99 | pub const SYS_setpriority = 96; | ||
| 100 | pub const SYS_socket = 97; | ||
| 101 | pub const SYS_connect = 98; | ||
| 102 | // 99 is old accept | ||
| 103 | pub const SYS_getpriority = 100; | ||
| 104 | // 101 is old send | ||
| 105 | // 102 is old recv | ||
| 106 | // 103 is old sigreturn | ||
| 107 | pub const SYS_bind = 104; | ||
| 108 | pub const SYS_setsockopt = 105; | ||
| 109 | pub const SYS_listen = 106; | ||
| 110 | // 107 is obsolete vtimes | ||
| 111 | // 108 is old sigvec | ||
| 112 | // 109 is old sigblock | ||
| 113 | // 110 is old sigsetmask | ||
| 114 | // 111 is old sigsuspend | ||
| 115 | // 112 is old sigstack | ||
| 116 | // 113 is old recvmsg | ||
| 117 | // 114 is old sendmsg | ||
| 118 | // 115 is obsolete vtrace | ||
| 119 | pub const SYS_gettimeofday = 116; | ||
| 120 | pub const SYS_getrusage = 117; | ||
| 121 | pub const SYS_getsockopt = 118; | ||
| 122 | pub const SYS_readv = 120; | ||
| 123 | pub const SYS_writev = 121; | ||
| 124 | pub const SYS_settimeofday = 122; | ||
| 125 | pub const SYS_fchown = 123; | ||
| 126 | pub const SYS_fchmod = 124; | ||
| 127 | // 125 is old recvfrom | ||
| 128 | pub const SYS_setreuid = 126; | ||
| 129 | pub const SYS_setregid = 127; | ||
| 130 | pub const SYS_rename = 128; | ||
| 131 | // 129 is old truncate | ||
| 132 | // 130 is old ftruncate | ||
| 133 | pub const SYS_flock = 131; | ||
| 134 | pub const SYS_mkfifo = 132; | ||
| 135 | pub const SYS_sendto = 133; | ||
| 136 | pub const SYS_shutdown = 134; | ||
| 137 | pub const SYS_socketpair = 135; | ||
| 138 | pub const SYS_mkdir = 136; | ||
| 139 | pub const SYS_rmdir = 137; | ||
| 140 | pub const SYS_utimes = 138; | ||
| 141 | // 139 is obsolete 4.2 sigreturn | ||
| 142 | pub const SYS_adjtime = 140; | ||
| 143 | // 141 is old getpeername | ||
| 144 | // 142 is old gethostid | ||
| 145 | // 143 is old sethostid | ||
| 146 | // 144 is old getrlimit | ||
| 147 | // 145 is old setrlimit | ||
| 148 | // 146 is old killpg | ||
| 149 | pub const SYS_setsid = 147; | ||
| 150 | pub const SYS_quotactl = 148; | ||
| 151 | // 149 is old quota | ||
| 152 | // 150 is old getsockname | ||
| 153 | pub const SYS_nlm_syscall = 154; | ||
| 154 | pub const SYS_nfssvc = 155; | ||
| 155 | // 156 is old getdirentries | ||
| 156 | // 157 is freebsd4 statfs | ||
| 157 | // 158 is freebsd4 fstatfs | ||
| 158 | pub const SYS_lgetfh = 160; | ||
| 159 | pub const SYS_getfh = 161; | ||
| 160 | // 162 is freebsd4 getdomainname | ||
| 161 | // 163 is freebsd4 setdomainname | ||
| 162 | // 164 is freebsd4 uname | ||
| 163 | pub const SYS_sysarch = 165; | ||
| 164 | pub const SYS_rtprio = 166; | ||
| 165 | pub const SYS_semsys = 169; | ||
| 166 | pub const SYS_msgsys = 170; | ||
| 167 | pub const SYS_shmsys = 171; | ||
| 168 | // 173 is freebsd6 pread | ||
| 169 | // 174 is freebsd6 pwrite | ||
| 170 | pub const SYS_setfib = 175; | ||
| 171 | pub const SYS_ntp_adjtime = 176; | ||
| 172 | pub const SYS_setgid = 181; | ||
| 173 | pub const SYS_setegid = 182; | ||
| 174 | pub const SYS_seteuid = 183; | ||
| 175 | pub const SYS_freebsd11_stat = 188; | ||
| 176 | pub const SYS_freebsd11_fstat = 189; | ||
| 177 | pub const SYS_freebsd11_lstat = 190; | ||
| 178 | pub const SYS_pathconf = 191; | ||
| 179 | pub const SYS_fpathconf = 192; | ||
| 180 | pub const SYS_getrlimit = 194; | ||
| 181 | pub const SYS_setrlimit = 195; | ||
| 182 | pub const SYS_freebsd11_getdirentries = 196; | ||
| 183 | // 197 is freebsd6 mmap | ||
| 184 | pub const SYS___syscall = 198; | ||
| 185 | // 199 is freebsd6 lseek | ||
| 186 | // 200 is freebsd6 truncate | ||
| 187 | // 201 is freebsd6 ftruncate | ||
| 188 | pub const SYS___sysctl = 202; | ||
| 189 | pub const SYS_mlock = 203; | ||
| 190 | pub const SYS_munlock = 204; | ||
| 191 | pub const SYS_undelete = 205; | ||
| 192 | pub const SYS_futimes = 206; | ||
| 193 | pub const SYS_getpgid = 207; | ||
| 194 | pub const SYS_poll = 209; | ||
| 195 | pub const SYS_freebsd7___semctl = 220; | ||
| 196 | pub const SYS_semget = 221; | ||
| 197 | pub const SYS_semop = 222; | ||
| 198 | pub const SYS_freebsd7_msgctl = 224; | ||
| 199 | pub const SYS_msgget = 225; | ||
| 200 | pub const SYS_msgsnd = 226; | ||
| 201 | pub const SYS_msgrcv = 227; | ||
| 202 | pub const SYS_shmat = 228; | ||
| 203 | pub const SYS_freebsd7_shmctl = 229; | ||
| 204 | pub const SYS_shmdt = 230; | ||
| 205 | pub const SYS_shmget = 231; | ||
| 206 | pub const SYS_clock_gettime = 232; | ||
| 207 | pub const SYS_clock_settime = 233; | ||
| 208 | pub const SYS_clock_getres = 234; | ||
| 209 | pub const SYS_ktimer_create = 235; | ||
| 210 | pub const SYS_ktimer_delete = 236; | ||
| 211 | pub const SYS_ktimer_settime = 237; | ||
| 212 | pub const SYS_ktimer_gettime = 238; | ||
| 213 | pub const SYS_ktimer_getoverrun = 239; | ||
| 214 | pub const SYS_nanosleep = 240; | ||
| 215 | pub const SYS_ffclock_getcounter = 241; | ||
| 216 | pub const SYS_ffclock_setestimate = 242; | ||
| 217 | pub const SYS_ffclock_getestimate = 243; | ||
| 218 | pub const SYS_clock_nanosleep = 244; | ||
| 219 | pub const SYS_clock_getcpuclockid2 = 247; | ||
| 220 | pub const SYS_ntp_gettime = 248; | ||
| 221 | pub const SYS_minherit = 250; | ||
| 222 | pub const SYS_rfork = 251; | ||
| 223 | // 252 is obsolete openbsd_poll | ||
| 224 | pub const SYS_issetugid = 253; | ||
| 225 | pub const SYS_lchown = 254; | ||
| 226 | pub const SYS_aio_read = 255; | ||
| 227 | pub const SYS_aio_write = 256; | ||
| 228 | pub const SYS_lio_listio = 257; | ||
| 229 | pub const SYS_freebsd11_getdents = 272; | ||
| 230 | pub const SYS_lchmod = 274; | ||
| 231 | pub const SYS_netbsd_lchown = 275; | ||
| 232 | pub const SYS_lutimes = 276; | ||
| 233 | pub const SYS_netbsd_msync = 277; | ||
| 234 | pub const SYS_freebsd11_nstat = 278; | ||
| 235 | pub const SYS_freebsd11_nfstat = 279; | ||
| 236 | pub const SYS_freebsd11_nlstat = 280; | ||
| 237 | pub const SYS_preadv = 289; | ||
| 238 | pub const SYS_pwritev = 290; | ||
| 239 | // 297 is freebsd4 fhstatfs | ||
| 240 | pub const SYS_fhopen = 298; | ||
| 241 | pub const SYS_freebsd11_fhstat = 299; | ||
| 242 | pub const SYS_modnext = 300; | ||
| 243 | pub const SYS_modstat = 301; | ||
| 244 | pub const SYS_modfnext = 302; | ||
| 245 | pub const SYS_modfind = 303; | ||
| 246 | pub const SYS_kldload = 304; | ||
| 247 | pub const SYS_kldunload = 305; | ||
| 248 | pub const SYS_kldfind = 306; | ||
| 249 | pub const SYS_kldnext = 307; | ||
| 250 | pub const SYS_kldstat = 308; | ||
| 251 | pub const SYS_kldfirstmod = 309; | ||
| 252 | pub const SYS_getsid = 310; | ||
| 253 | pub const SYS_setresuid = 311; | ||
| 254 | pub const SYS_setresgid = 312; | ||
| 255 | // 313 is obsolete signanosleep | ||
| 256 | pub const SYS_aio_return = 314; | ||
| 257 | pub const SYS_aio_suspend = 315; | ||
| 258 | pub const SYS_aio_cancel = 316; | ||
| 259 | pub const SYS_aio_error = 317; | ||
| 260 | // 318 is freebsd6 aio_read | ||
| 261 | // 319 is freebsd6 aio_write | ||
| 262 | // 320 is freebsd6 lio_listio | ||
| 263 | pub const SYS_yield = 321; | ||
| 264 | // 322 is obsolete thr_sleep | ||
| 265 | // 323 is obsolete thr_wakeup | ||
| 266 | pub const SYS_mlockall = 324; | ||
| 267 | pub const SYS_munlockall = 325; | ||
| 268 | pub const SYS___getcwd = 326; | ||
| 269 | pub const SYS_sched_setparam = 327; | ||
| 270 | pub const SYS_sched_getparam = 328; | ||
| 271 | pub const SYS_sched_setscheduler = 329; | ||
| 272 | pub const SYS_sched_getscheduler = 330; | ||
| 273 | pub const SYS_sched_yield = 331; | ||
| 274 | pub const SYS_sched_get_priority_max = 332; | ||
| 275 | pub const SYS_sched_get_priority_min = 333; | ||
| 276 | pub const SYS_sched_rr_get_interval = 334; | ||
| 277 | pub const SYS_utrace = 335; | ||
| 278 | // 336 is freebsd4 sendfile | ||
| 279 | pub const SYS_kldsym = 337; | ||
| 280 | pub const SYS_jail = 338; | ||
| 281 | pub const SYS_nnpfs_syscall = 339; | ||
| 282 | pub const SYS_sigprocmask = 340; | ||
| 283 | pub const SYS_sigsuspend = 341; | ||
| 284 | // 342 is freebsd4 sigaction | ||
| 285 | pub const SYS_sigpending = 343; | ||
| 286 | // 344 is freebsd4 sigreturn | ||
| 287 | pub const SYS_sigtimedwait = 345; | ||
| 288 | pub const SYS_sigwaitinfo = 346; | ||
| 289 | pub const SYS___acl_get_file = 347; | ||
| 290 | pub const SYS___acl_set_file = 348; | ||
| 291 | pub const SYS___acl_get_fd = 349; | ||
| 292 | pub const SYS___acl_set_fd = 350; | ||
| 293 | pub const SYS___acl_delete_file = 351; | ||
| 294 | pub const SYS___acl_delete_fd = 352; | ||
| 295 | pub const SYS___acl_aclcheck_file = 353; | ||
| 296 | pub const SYS___acl_aclcheck_fd = 354; | ||
| 297 | pub const SYS_extattrctl = 355; | ||
| 298 | pub const SYS_extattr_set_file = 356; | ||
| 299 | pub const SYS_extattr_get_file = 357; | ||
| 300 | pub const SYS_extattr_delete_file = 358; | ||
| 301 | pub const SYS_aio_waitcomplete = 359; | ||
| 302 | pub const SYS_getresuid = 360; | ||
| 303 | pub const SYS_getresgid = 361; | ||
| 304 | pub const SYS_kqueue = 362; | ||
| 305 | pub const SYS_freebsd11_kevent = 363; | ||
| 306 | pub const SYS_extattr_set_fd = 371; | ||
| 307 | pub const SYS_extattr_get_fd = 372; | ||
| 308 | pub const SYS_extattr_delete_fd = 373; | ||
| 309 | pub const SYS___setugid = 374; | ||
| 310 | pub const SYS_eaccess = 376; | ||
| 311 | pub const SYS_afs3_syscall = 377; | ||
| 312 | pub const SYS_nmount = 378; | ||
| 313 | pub const SYS___mac_get_proc = 384; | ||
| 314 | pub const SYS___mac_set_proc = 385; | ||
| 315 | pub const SYS___mac_get_fd = 386; | ||
| 316 | pub const SYS___mac_get_file = 387; | ||
| 317 | pub const SYS___mac_set_fd = 388; | ||
| 318 | pub const SYS___mac_set_file = 389; | ||
| 319 | pub const SYS_kenv = 390; | ||
| 320 | pub const SYS_lchflags = 391; | ||
| 321 | pub const SYS_uuidgen = 392; | ||
| 322 | pub const SYS_sendfile = 393; | ||
| 323 | pub const SYS_mac_syscall = 394; | ||
| 324 | pub const SYS_freebsd11_getfsstat = 395; | ||
| 325 | pub const SYS_freebsd11_statfs = 396; | ||
| 326 | pub const SYS_freebsd11_fstatfs = 397; | ||
| 327 | pub const SYS_freebsd11_fhstatfs = 398; | ||
| 328 | pub const SYS_ksem_close = 400; | ||
| 329 | pub const SYS_ksem_post = 401; | ||
| 330 | pub const SYS_ksem_wait = 402; | ||
| 331 | pub const SYS_ksem_trywait = 403; | ||
| 332 | pub const SYS_ksem_init = 404; | ||
| 333 | pub const SYS_ksem_open = 405; | ||
| 334 | pub const SYS_ksem_unlink = 406; | ||
| 335 | pub const SYS_ksem_getvalue = 407; | ||
| 336 | pub const SYS_ksem_destroy = 408; | ||
| 337 | pub const SYS___mac_get_pid = 409; | ||
| 338 | pub const SYS___mac_get_link = 410; | ||
| 339 | pub const SYS___mac_set_link = 411; | ||
| 340 | pub const SYS_extattr_set_link = 412; | ||
| 341 | pub const SYS_extattr_get_link = 413; | ||
| 342 | pub const SYS_extattr_delete_link = 414; | ||
| 343 | pub const SYS___mac_execve = 415; | ||
| 344 | pub const SYS_sigaction = 416; | ||
| 345 | pub const SYS_sigreturn = 417; | ||
| 346 | pub const SYS_getcontext = 421; | ||
| 347 | pub const SYS_setcontext = 422; | ||
| 348 | pub const SYS_swapcontext = 423; | ||
| 349 | pub const SYS_swapoff = 424; | ||
| 350 | pub const SYS___acl_get_link = 425; | ||
| 351 | pub const SYS___acl_set_link = 426; | ||
| 352 | pub const SYS___acl_delete_link = 427; | ||
| 353 | pub const SYS___acl_aclcheck_link = 428; | ||
| 354 | pub const SYS_sigwait = 429; | ||
| 355 | pub const SYS_thr_create = 430; | ||
| 356 | pub const SYS_thr_exit = 431; | ||
| 357 | pub const SYS_thr_self = 432; | ||
| 358 | pub const SYS_thr_kill = 433; | ||
| 359 | pub const SYS_jail_attach = 436; | ||
| 360 | pub const SYS_extattr_list_fd = 437; | ||
| 361 | pub const SYS_extattr_list_file = 438; | ||
| 362 | pub const SYS_extattr_list_link = 439; | ||
| 363 | pub const SYS_ksem_timedwait = 441; | ||
| 364 | pub const SYS_thr_suspend = 442; | ||
| 365 | pub const SYS_thr_wake = 443; | ||
| 366 | pub const SYS_kldunloadf = 444; | ||
| 367 | pub const SYS_audit = 445; | ||
| 368 | pub const SYS_auditon = 446; | ||
| 369 | pub const SYS_getauid = 447; | ||
| 370 | pub const SYS_setauid = 448; | ||
| 371 | pub const SYS_getaudit = 449; | ||
| 372 | pub const SYS_setaudit = 450; | ||
| 373 | pub const SYS_getaudit_addr = 451; | ||
| 374 | pub const SYS_setaudit_addr = 452; | ||
| 375 | pub const SYS_auditctl = 453; | ||
| 376 | pub const SYS__umtx_op = 454; | ||
| 377 | pub const SYS_thr_new = 455; | ||
| 378 | pub const SYS_sigqueue = 456; | ||
| 379 | pub const SYS_kmq_open = 457; | ||
| 380 | pub const SYS_kmq_setattr = 458; | ||
| 381 | pub const SYS_kmq_timedreceive = 459; | ||
| 382 | pub const SYS_kmq_timedsend = 460; | ||
| 383 | pub const SYS_kmq_notify = 461; | ||
| 384 | pub const SYS_kmq_unlink = 462; | ||
| 385 | pub const SYS_abort2 = 463; | ||
| 386 | pub const SYS_thr_set_name = 464; | ||
| 387 | pub const SYS_aio_fsync = 465; | ||
| 388 | pub const SYS_rtprio_thread = 466; | ||
| 389 | pub const SYS_sctp_peeloff = 471; | ||
| 390 | pub const SYS_sctp_generic_sendmsg = 472; | ||
| 391 | pub const SYS_sctp_generic_sendmsg_iov = 473; | ||
| 392 | pub const SYS_sctp_generic_recvmsg = 474; | ||
| 393 | pub const SYS_pread = 475; | ||
| 394 | pub const SYS_pwrite = 476; | ||
| 395 | pub const SYS_mmap = 477; | ||
| 396 | pub const SYS_lseek = 478; | ||
| 397 | pub const SYS_truncate = 479; | ||
| 398 | pub const SYS_ftruncate = 480; | ||
| 399 | pub const SYS_thr_kill2 = 481; | ||
| 400 | pub const SYS_shm_open = 482; | ||
| 401 | pub const SYS_shm_unlink = 483; | ||
| 402 | pub const SYS_cpuset = 484; | ||
| 403 | pub const SYS_cpuset_setid = 485; | ||
| 404 | pub const SYS_cpuset_getid = 486; | ||
| 405 | pub const SYS_cpuset_getaffinity = 487; | ||
| 406 | pub const SYS_cpuset_setaffinity = 488; | ||
| 407 | pub const SYS_faccessat = 489; | ||
| 408 | pub const SYS_fchmodat = 490; | ||
| 409 | pub const SYS_fchownat = 491; | ||
| 410 | pub const SYS_fexecve = 492; | ||
| 411 | pub const SYS_freebsd11_fstatat = 493; | ||
| 412 | pub const SYS_futimesat = 494; | ||
| 413 | pub const SYS_linkat = 495; | ||
| 414 | pub const SYS_mkdirat = 496; | ||
| 415 | pub const SYS_mkfifoat = 497; | ||
| 416 | pub const SYS_freebsd11_mknodat = 498; | ||
| 417 | pub const SYS_openat = 499; | ||
| 418 | pub const SYS_readlinkat = 500; | ||
| 419 | pub const SYS_renameat = 501; | ||
| 420 | pub const SYS_symlinkat = 502; | ||
| 421 | pub const SYS_unlinkat = 503; | ||
| 422 | pub const SYS_posix_openpt = 504; | ||
| 423 | pub const SYS_gssd_syscall = 505; | ||
| 424 | pub const SYS_jail_get = 506; | ||
| 425 | pub const SYS_jail_set = 507; | ||
| 426 | pub const SYS_jail_remove = 508; | ||
| 427 | pub const SYS_closefrom = 509; | ||
| 428 | pub const SYS___semctl = 510; | ||
| 429 | pub const SYS_msgctl = 511; | ||
| 430 | pub const SYS_shmctl = 512; | ||
| 431 | pub const SYS_lpathconf = 513; | ||
| 432 | // 514 is obsolete cap_new | ||
| 433 | pub const SYS___cap_rights_get = 515; | ||
| 434 | pub const SYS_cap_enter = 516; | ||
| 435 | pub const SYS_cap_getmode = 517; | ||
| 436 | pub const SYS_pdfork = 518; | ||
| 437 | pub const SYS_pdkill = 519; | ||
| 438 | pub const SYS_pdgetpid = 520; | ||
| 439 | pub const SYS_pselect = 522; | ||
| 440 | pub const SYS_getloginclass = 523; | ||
| 441 | pub const SYS_setloginclass = 524; | ||
| 442 | pub const SYS_rctl_get_racct = 525; | ||
| 443 | pub const SYS_rctl_get_rules = 526; | ||
| 444 | pub const SYS_rctl_get_limits = 527; | ||
| 445 | pub const SYS_rctl_add_rule = 528; | ||
| 446 | pub const SYS_rctl_remove_rule = 529; | ||
| 447 | pub const SYS_posix_fallocate = 530; | ||
| 448 | pub const SYS_posix_fadvise = 531; | ||
| 449 | pub const SYS_wait6 = 532; | ||
| 450 | pub const SYS_cap_rights_limit = 533; | ||
| 451 | pub const SYS_cap_ioctls_limit = 534; | ||
| 452 | pub const SYS_cap_ioctls_get = 535; | ||
| 453 | pub const SYS_cap_fcntls_limit = 536; | ||
| 454 | pub const SYS_cap_fcntls_get = 537; | ||
| 455 | pub const SYS_bindat = 538; | ||
| 456 | pub const SYS_connectat = 539; | ||
| 457 | pub const SYS_chflagsat = 540; | ||
| 458 | pub const SYS_accept4 = 541; | ||
| 459 | pub const SYS_pipe2 = 542; | ||
| 460 | pub const SYS_aio_mlock = 543; | ||
| 461 | pub const SYS_procctl = 544; | ||
| 462 | pub const SYS_ppoll = 545; | ||
| 463 | pub const SYS_futimens = 546; | ||
| 464 | pub const SYS_utimensat = 547; | ||
| 465 | pub const SYS_numa_getaffinity = 548; | ||
| 466 | pub const SYS_numa_setaffinity = 549; | ||
| 467 | pub const SYS_fdatasync = 550; | ||
| 468 | pub const SYS_fstat = 551; | ||
| 469 | pub const SYS_fstatat = 552; | ||
| 470 | pub const SYS_fhstat = 553; | ||
| 471 | pub const SYS_getdirentries = 554; | ||
| 472 | pub const SYS_statfs = 555; | ||
| 473 | pub const SYS_fstatfs = 556; | ||
| 474 | pub const SYS_getfsstat = 557; | ||
| 475 | pub const SYS_fhstatfs = 558; | ||
| 476 | pub const SYS_mknodat = 559; | ||
| 477 | pub const SYS_kevent = 560; | ||
| 478 | pub const SYS_MAXSYSCALL = 561; | ||
| 479 | |||
| 480 | pub const O_CREAT = 0o100; | ||
| 481 | pub const O_EXCL = 0o200; | ||
| 482 | pub const O_NOCTTY = 0o400; | ||
| 483 | pub const O_TRUNC = 0o1000; | ||
| 484 | pub const O_APPEND = 0o2000; | ||
| 485 | pub const O_NONBLOCK = 0o4000; | ||
| 486 | pub const O_DSYNC = 0o10000; | ||
| 487 | pub const O_SYNC = 0o4010000; | ||
| 488 | pub const O_RSYNC = 0o4010000; | ||
| 489 | pub const O_DIRECTORY = 0o200000; | ||
| 490 | pub const O_NOFOLLOW = 0o400000; | ||
| 491 | pub const O_CLOEXEC = 0o2000000; | ||
| 492 | |||
| 493 | pub const O_ASYNC = 0o20000; | ||
| 494 | pub const O_DIRECT = 0o40000; | ||
| 495 | pub const O_LARGEFILE = 0; | ||
| 496 | pub const O_NOATIME = 0o1000000; | ||
| 497 | pub const O_PATH = 0o10000000; | ||
| 498 | pub const O_TMPFILE = 0o20200000; | ||
| 499 | pub const O_NDELAY = O_NONBLOCK; | ||
| 500 | |||
| 501 | pub const F_DUPFD = 0; | ||
| 502 | pub const F_GETFD = 1; | ||
| 503 | pub const F_SETFD = 2; | ||
| 504 | pub const F_GETFL = 3; | ||
| 505 | pub const F_SETFL = 4; | ||
| 506 | |||
| 507 | pub const F_SETOWN = 8; | ||
| 508 | pub const F_GETOWN = 9; | ||
| 509 | pub const F_SETSIG = 10; | ||
| 510 | pub const F_GETSIG = 11; | ||
| 511 | |||
| 512 | pub const F_GETLK = 5; | ||
| 513 | pub const F_SETLK = 6; | ||
| 514 | pub const F_SETLKW = 7; | ||
| 515 | |||
| 516 | pub const F_SETOWN_EX = 15; | ||
| 517 | pub const F_GETOWN_EX = 16; | ||
| 518 | |||
| 519 | pub const F_GETOWNER_UIDS = 17; | ||
| 520 | |||
| 521 | pub fn syscall0(number: usize) -> usize { | ||
| 522 | asm volatile ("syscall" | ||
| 523 | : [ret] "={rax}" (-> usize) | ||
| 524 | : [number] "{rax}" (number) | ||
| 525 | : "rcx", "r11") | ||
| 526 | } | ||
| 527 | |||
| 528 | pub fn syscall1(number: usize, arg1: usize) -> usize { | ||
| 529 | asm volatile ("syscall" | ||
| 530 | : [ret] "={rax}" (-> usize) | ||
| 531 | : [number] "{rax}" (number), | ||
| 532 | [arg1] "{rdi}" (arg1) | ||
| 533 | : "rcx", "r11") | ||
| 534 | } | ||
| 535 | |||
| 536 | pub fn syscall2(number: usize, arg1: usize, arg2: usize) -> usize { | ||
| 537 | asm volatile ("syscall" | ||
| 538 | : [ret] "={rax}" (-> usize) | ||
| 539 | : [number] "{rax}" (number), | ||
| 540 | [arg1] "{rdi}" (arg1), | ||
| 541 | [arg2] "{rsi}" (arg2) | ||
| 542 | : "rcx", "r11") | ||
| 543 | } | ||
| 544 | |||
| 545 | pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize { | ||
| 546 | asm volatile ("syscall" | ||
| 547 | : [ret] "={rax}" (-> usize) | ||
| 548 | : [number] "{rax}" (number), | ||
| 549 | [arg1] "{rdi}" (arg1), | ||
| 550 | [arg2] "{rsi}" (arg2), | ||
| 551 | [arg3] "{rdx}" (arg3) | ||
| 552 | : "rcx", "r11") | ||
| 553 | } | ||
| 554 | |||
| 555 | pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize { | ||
| 556 | asm volatile ("syscall" | ||
| 557 | : [ret] "={rax}" (-> usize) | ||
| 558 | : [number] "{rax}" (number), | ||
| 559 | [arg1] "{rdi}" (arg1), | ||
| 560 | [arg2] "{rsi}" (arg2), | ||
| 561 | [arg3] "{rdx}" (arg3), | ||
| 562 | [arg4] "{r10}" (arg4) | ||
| 563 | : "rcx", "r11") | ||
| 564 | } | ||
| 565 | |||
| 566 | pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) -> usize { | ||
| 567 | asm volatile ("syscall" | ||
| 568 | : [ret] "={rax}" (-> usize) | ||
| 569 | : [number] "{rax}" (number), | ||
| 570 | [arg1] "{rdi}" (arg1), | ||
| 571 | [arg2] "{rsi}" (arg2), | ||
| 572 | [arg3] "{rdx}" (arg3), | ||
| 573 | [arg4] "{r10}" (arg4), | ||
| 574 | [arg5] "{r8}" (arg5) | ||
| 575 | : "rcx", "r11") | ||
| 576 | } | ||
| 577 | |||
| 578 | pub fn syscall6(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, | ||
| 579 | arg5: usize, arg6: usize) -> usize | ||
| 580 | { | ||
| 581 | asm volatile ("syscall" | ||
| 582 | : [ret] "={rax}" (-> usize) | ||
| 583 | : [number] "{rax}" (number), | ||
| 584 | [arg1] "{rdi}" (arg1), | ||
| 585 | [arg2] "{rsi}" (arg2), | ||
| 586 | [arg3] "{rdx}" (arg3), | ||
| 587 | [arg4] "{r10}" (arg4), | ||
| 588 | [arg5] "{r8}" (arg5), | ||
| 589 | [arg6] "{r9}" (arg6) | ||
| 590 | : "rcx", "r11") | ||
| 591 | } | ||
| 592 | |||
| 593 | pub nakedcc fn restore_rt() { | ||
| 594 | asm volatile ("syscall" | ||
| 595 | : | ||
| 596 | : [number] "{rax}" (usize(SYS_rt_sigreturn)) | ||
| 597 | : "rcx", "r11") | ||
| 598 | } | ||
| 599 | |||
| 600 | |||
| 601 | pub const msghdr = extern struct { | ||
| 602 | msg_name: &u8, | ||
| 603 | msg_namelen: socklen_t, | ||
| 604 | msg_iov: &iovec, | ||
| 605 | msg_iovlen: i32, | ||
| 606 | __pad1: i32, | ||
| 607 | msg_control: &u8, | ||
| 608 | msg_controllen: socklen_t, | ||
| 609 | __pad2: socklen_t, | ||
| 610 | msg_flags: i32, | ||
| 611 | }; | ||
| 612 | |||
| 613 | /// Renamed to Stat to not conflict with the stat function. | ||
| 614 | pub const Stat = extern struct { | ||
| 615 | dev: u64, | ||
| 616 | ino: u64, | ||
| 617 | nlink: usize, | ||
| 618 | |||
| 619 | mode: u32, | ||
| 620 | uid: u32, | ||
| 621 | gid: u32, | ||
| 622 | __pad0: u32, | ||
| 623 | rdev: u64, | ||
| 624 | size: i64, | ||
| 625 | blksize: isize, | ||
| 626 | blocks: i64, | ||
| 627 | |||
| 628 | atim: timespec, | ||
| 629 | mtim: timespec, | ||
| 630 | ctim: timespec, | ||
| 631 | __unused: [3]isize, | ||
| 632 | }; | ||
| 633 | |||
| 634 | pub const timespec = extern struct { | ||
| 635 | tv_sec: isize, | ||
| 636 | tv_nsec: isize, | ||
| 637 | }; | ||
std/os/get_user_id.zig+1-1| ... | @@ -11,7 +11,7 @@ pub const UserInfo = struct.{ | ... | @@ -11,7 +11,7 @@ pub const UserInfo = struct.{ |
| 11 | /// POSIX function which gets a uid from username. | 11 | /// POSIX function which gets a uid from username. |
| 12 | pub fn getUserInfo(name: []const u8) !UserInfo { | 12 | pub fn getUserInfo(name: []const u8) !UserInfo { |
| 13 | return switch (builtin.os) { | 13 | return switch (builtin.os) { |
| 14 | Os.linux, Os.macosx, Os.ios => posixGetUserInfo(name), | 14 | Os.linux, Os.macosx, Os.ios, Os.freebsd => posixGetUserInfo(name), |
| 15 | else => @compileError("Unsupported OS"), | 15 | else => @compileError("Unsupported OS"), |
| 16 | }; | 16 | }; |
| 17 | } | 17 | } |
std/os/index.zig+4-2| ... | @@ -24,10 +24,12 @@ test "std.os" { | ... | @@ -24,10 +24,12 @@ test "std.os" { |
| 24 | pub const windows = @import("windows/index.zig"); | 24 | pub const windows = @import("windows/index.zig"); |
| 25 | pub const darwin = @import("darwin.zig"); | 25 | pub const darwin = @import("darwin.zig"); |
| 26 | pub const linux = @import("linux/index.zig"); | 26 | pub const linux = @import("linux/index.zig"); |
| 27 | pub const freebsd = @import("freebsd.zig"); | ||
| 27 | pub const zen = @import("zen.zig"); | 28 | pub const zen = @import("zen.zig"); |
| 28 | pub const posix = switch (builtin.os) { | 29 | pub const posix = switch (builtin.os) { |
| 29 | Os.linux => linux, | 30 | Os.linux => linux, |
| 30 | Os.macosx, Os.ios => darwin, | 31 | Os.macosx, Os.ios => darwin, |
| 32 | Os.freebsd => freebsd, | ||
| 31 | Os.zen => zen, | 33 | Os.zen => zen, |
| 32 | else => @compileError("Unsupported OS"), | 34 | else => @compileError("Unsupported OS"), |
| 33 | }; | 35 | }; |
| ... | @@ -174,7 +176,7 @@ pub fn abort() noreturn { | ... | @@ -174,7 +176,7 @@ pub fn abort() noreturn { |
| 174 | c.abort(); | 176 | c.abort(); |
| 175 | } | 177 | } |
| 176 | switch (builtin.os) { | 178 | switch (builtin.os) { |
| 177 | Os.linux, Os.macosx, Os.ios => { | 179 | Os.linux, Os.macosx, Os.ios, Os.freebsd => { |
| 178 | _ = posix.raise(posix.SIGABRT); | 180 | _ = posix.raise(posix.SIGABRT); |
| 179 | _ = posix.raise(posix.SIGKILL); | 181 | _ = posix.raise(posix.SIGKILL); |
| 180 | while (true) {} | 182 | while (true) {} |
| ... | @@ -196,7 +198,7 @@ pub fn exit(status: u8) noreturn { | ... | @@ -196,7 +198,7 @@ pub fn exit(status: u8) noreturn { |
| 196 | c.exit(status); | 198 | c.exit(status); |
| 197 | } | 199 | } |
| 198 | switch (builtin.os) { | 200 | switch (builtin.os) { |
| 199 | Os.linux, Os.macosx, Os.ios => { | 201 | Os.linux, Os.macosx, Os.ios, Os.freebsd => { |
| 200 | posix.exit(status); | 202 | posix.exit(status); |
| 201 | }, | 203 | }, |
| 202 | Os.windows => { | 204 | Os.windows => { |
std/os/path.zig+2-2| ... | @@ -1161,7 +1161,7 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro | ... | @@ -1161,7 +1161,7 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro |
| 1161 | const pathname_w = try windows_util.cStrToPrefixedFileW(pathname); | 1161 | const pathname_w = try windows_util.cStrToPrefixedFileW(pathname); |
| 1162 | return realW(out_buffer, pathname_w); | 1162 | return realW(out_buffer, pathname_w); |
| 1163 | }, | 1163 | }, |
| 1164 | Os.macosx, Os.ios => { | 1164 | Os.macosx, Os.ios, Os.freebsd => { |
| 1165 | // TODO instead of calling the libc function here, port the implementation to Zig | 1165 | // TODO instead of calling the libc function here, port the implementation to Zig |
| 1166 | const err = posix.getErrno(posix.realpath(pathname, out_buffer)); | 1166 | const err = posix.getErrno(posix.realpath(pathname, out_buffer)); |
| 1167 | switch (err) { | 1167 | switch (err) { |
| ... | @@ -1202,7 +1202,7 @@ pub fn real(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: []const u8) RealError! | ... | @@ -1202,7 +1202,7 @@ pub fn real(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: []const u8) RealError! |
| 1202 | const pathname_w = try windows_util.sliceToPrefixedFileW(pathname); | 1202 | const pathname_w = try windows_util.sliceToPrefixedFileW(pathname); |
| 1203 | return realW(out_buffer, &pathname_w); | 1203 | return realW(out_buffer, &pathname_w); |
| 1204 | }, | 1204 | }, |
| 1205 | Os.macosx, Os.ios, Os.linux => { | 1205 | Os.macosx, Os.ios, Os.linux, Os.freebsd => { |
| 1206 | const pathname_c = try os.toPosixPath(pathname); | 1206 | const pathname_c = try os.toPosixPath(pathname); |
| 1207 | return realC(out_buffer, &pathname_c); | 1207 | return realC(out_buffer, &pathname_c); |
| 1208 | }, | 1208 | }, |