| author | |
| committer | |
| log | 66ed7a5eb51580fb8f02e16f16ccad31abe0bcc1 |
| tree | 1cd1dbe583a884695fa168cfeab79d30eefdd1bd |
| parent | 7f589c0cab105a79ff6d71233538dca8a39f8152 |
8 files changed, 889 insertions(+), 33 deletions(-)
CMakeLists.txt+1| ... | ... | @@ -203,6 +203,7 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/test_runner.zig" DESTINATION "${ZIG_STD_D |
| 203 | 203 | install(FILES "${CMAKE_SOURCE_DIR}/std/test_runner_libc.zig" DESTINATION "${ZIG_STD_DEST}") |
| 204 | 204 | install(FILES "${CMAKE_SOURCE_DIR}/std/test_runner_nolibc.zig" DESTINATION "${ZIG_STD_DEST}") |
| 205 | 205 | install(FILES "${CMAKE_SOURCE_DIR}/std/io.zig" DESTINATION "${ZIG_STD_DEST}") |
| 206 | install(FILES "${CMAKE_SOURCE_DIR}/std/net.zig" DESTINATION "${ZIG_STD_DEST}") | |
| 206 | 207 | install(FILES "${CMAKE_SOURCE_DIR}/std/os.zig" DESTINATION "${ZIG_STD_DEST}") |
| 207 | 208 | install(FILES "${CMAKE_SOURCE_DIR}/std/str.zig" DESTINATION "${ZIG_STD_DEST}") |
| 208 | 209 | install(FILES "${CMAKE_SOURCE_DIR}/std/linux.zig" DESTINATION "${ZIG_STD_DEST}") |
src/analyze.cpp+33-28| ... | ... | @@ -1728,25 +1728,28 @@ static void add_global_const_expr(CodeGen *g, AstNode *expr_node) { |
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | 1730 | static bool num_lit_fits_in_other_type(CodeGen *g, AstNode *literal_node, TypeTableEntry *other_type) { |
| 1731 | if (other_type->id == TypeTableEntryIdInvalid) { | |
| 1731 | TypeTableEntry *other_type_underlying = get_underlying_type(other_type); | |
| 1732 | ||
| 1733 | if (other_type_underlying->id == TypeTableEntryIdInvalid) { | |
| 1732 | 1734 | return false; |
| 1733 | 1735 | } |
| 1736 | ||
| 1734 | 1737 | Expr *expr = get_resolved_expr(literal_node); |
| 1735 | 1738 | ConstExprValue *const_val = &expr->const_val; |
| 1736 | 1739 | assert(const_val->ok); |
| 1737 | if (other_type->id == TypeTableEntryIdFloat) { | |
| 1740 | if (other_type_underlying->id == TypeTableEntryIdFloat) { | |
| 1738 | 1741 | return true; |
| 1739 | } else if (other_type->id == TypeTableEntryIdInt && | |
| 1742 | } else if (other_type_underlying->id == TypeTableEntryIdInt && | |
| 1740 | 1743 | const_val->data.x_bignum.kind == BigNumKindInt) |
| 1741 | 1744 | { |
| 1742 | if (bignum_fits_in_bits(&const_val->data.x_bignum, other_type->data.integral.bit_count, | |
| 1743 | other_type->data.integral.is_signed)) | |
| 1745 | if (bignum_fits_in_bits(&const_val->data.x_bignum, other_type_underlying->data.integral.bit_count, | |
| 1746 | other_type_underlying->data.integral.is_signed)) | |
| 1744 | 1747 | { |
| 1745 | 1748 | return true; |
| 1746 | 1749 | } |
| 1747 | } else if ((other_type->id == TypeTableEntryIdNumLitFloat && | |
| 1750 | } else if ((other_type_underlying->id == TypeTableEntryIdNumLitFloat && | |
| 1748 | 1751 | const_val->data.x_bignum.kind == BigNumKindFloat) || |
| 1749 | (other_type->id == TypeTableEntryIdNumLitInt && | |
| 1752 | (other_type_underlying->id == TypeTableEntryIdNumLitInt && | |
| 1750 | 1753 | const_val->data.x_bignum.kind == BigNumKindInt)) |
| 1751 | 1754 | { |
| 1752 | 1755 | return true; |
| ... | ... | @@ -4032,9 +4035,11 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B |
| 4032 | 4035 | AstNode *expr_node = node->data.fn_call_expr.params.at(0); |
| 4033 | 4036 | TypeTableEntry *wanted_type = resolve_type(g, fn_ref_expr); |
| 4034 | 4037 | TypeTableEntry *actual_type = analyze_expression(g, import, context, nullptr, expr_node); |
| 4038 | TypeTableEntry *wanted_type_canon = get_underlying_type(wanted_type); | |
| 4039 | TypeTableEntry *actual_type_canon = get_underlying_type(actual_type); | |
| 4035 | 4040 | |
| 4036 | if (wanted_type->id == TypeTableEntryIdInvalid || | |
| 4037 | actual_type->id == TypeTableEntryIdInvalid) | |
| 4041 | if (wanted_type_canon->id == TypeTableEntryIdInvalid || | |
| 4042 | actual_type_canon->id == TypeTableEntryIdInvalid) | |
| 4038 | 4043 | { |
| 4039 | 4044 | return g->builtin_types.entry_invalid; |
| 4040 | 4045 | } |
| ... | ... | @@ -4045,46 +4050,46 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B |
| 4045 | 4050 | } |
| 4046 | 4051 | |
| 4047 | 4052 | // explicit cast from bool to int |
| 4048 | if (wanted_type->id == TypeTableEntryIdInt && | |
| 4049 | actual_type->id == TypeTableEntryIdBool) | |
| 4053 | if (wanted_type_canon->id == TypeTableEntryIdInt && | |
| 4054 | actual_type_canon->id == TypeTableEntryIdBool) | |
| 4050 | 4055 | { |
| 4051 | 4056 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpBoolToInt, false); |
| 4052 | 4057 | } |
| 4053 | 4058 | |
| 4054 | 4059 | // explicit cast from pointer to isize or usize |
| 4055 | if ((wanted_type == g->builtin_types.entry_isize || wanted_type == g->builtin_types.entry_usize) && | |
| 4056 | actual_type->id == TypeTableEntryIdPointer) | |
| 4060 | if ((wanted_type_canon == g->builtin_types.entry_isize || wanted_type_canon == g->builtin_types.entry_usize) && | |
| 4061 | actual_type_canon->id == TypeTableEntryIdPointer) | |
| 4057 | 4062 | { |
| 4058 | 4063 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpPtrToInt, false); |
| 4059 | 4064 | } |
| 4060 | 4065 | |
| 4061 | 4066 | |
| 4062 | 4067 | // explicit cast from isize or usize to pointer |
| 4063 | if (wanted_type->id == TypeTableEntryIdPointer && | |
| 4064 | (actual_type == g->builtin_types.entry_isize || actual_type == g->builtin_types.entry_usize)) | |
| 4068 | if (wanted_type_canon->id == TypeTableEntryIdPointer && | |
| 4069 | (actual_type_canon == g->builtin_types.entry_isize || actual_type_canon == g->builtin_types.entry_usize)) | |
| 4065 | 4070 | { |
| 4066 | 4071 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpIntToPtr, false); |
| 4067 | 4072 | } |
| 4068 | 4073 | |
| 4069 | 4074 | // explicit widening or shortening cast |
| 4070 | if ((wanted_type->id == TypeTableEntryIdInt && | |
| 4071 | actual_type->id == TypeTableEntryIdInt) || | |
| 4072 | (wanted_type->id == TypeTableEntryIdFloat && | |
| 4073 | actual_type->id == TypeTableEntryIdFloat)) | |
| 4075 | if ((wanted_type_canon->id == TypeTableEntryIdInt && | |
| 4076 | actual_type_canon->id == TypeTableEntryIdInt) || | |
| 4077 | (wanted_type_canon->id == TypeTableEntryIdFloat && | |
| 4078 | actual_type_canon->id == TypeTableEntryIdFloat)) | |
| 4074 | 4079 | { |
| 4075 | 4080 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpWidenOrShorten, false); |
| 4076 | 4081 | } |
| 4077 | 4082 | |
| 4078 | 4083 | // explicit cast from int to float |
| 4079 | if (wanted_type->id == TypeTableEntryIdFloat && | |
| 4080 | actual_type->id == TypeTableEntryIdInt) | |
| 4084 | if (wanted_type_canon->id == TypeTableEntryIdFloat && | |
| 4085 | actual_type_canon->id == TypeTableEntryIdInt) | |
| 4081 | 4086 | { |
| 4082 | 4087 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpIntToFloat, false); |
| 4083 | 4088 | } |
| 4084 | 4089 | |
| 4085 | 4090 | // explicit cast from float to int |
| 4086 | if (wanted_type->id == TypeTableEntryIdInt && | |
| 4087 | actual_type->id == TypeTableEntryIdFloat) | |
| 4091 | if (wanted_type_canon->id == TypeTableEntryIdInt && | |
| 4092 | actual_type_canon->id == TypeTableEntryIdFloat) | |
| 4088 | 4093 | { |
| 4089 | 4094 | return resolve_cast(g, context, node, expr_node, wanted_type, CastOpFloatToInt, false); |
| 4090 | 4095 | } |
| ... | ... | @@ -4164,17 +4169,17 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B |
| 4164 | 4169 | if (actual_type->id == TypeTableEntryIdNumLitFloat || |
| 4165 | 4170 | actual_type->id == TypeTableEntryIdNumLitInt) |
| 4166 | 4171 | { |
| 4167 | if (num_lit_fits_in_other_type(g, expr_node, wanted_type)) { | |
| 4172 | if (num_lit_fits_in_other_type(g, expr_node, wanted_type_canon)) { | |
| 4168 | 4173 | CastOp op; |
| 4169 | 4174 | if ((actual_type->id == TypeTableEntryIdNumLitFloat && |
| 4170 | wanted_type->id == TypeTableEntryIdFloat) || | |
| 4175 | wanted_type_canon->id == TypeTableEntryIdFloat) || | |
| 4171 | 4176 | (actual_type->id == TypeTableEntryIdNumLitInt && |
| 4172 | wanted_type->id == TypeTableEntryIdInt)) | |
| 4177 | wanted_type_canon->id == TypeTableEntryIdInt)) | |
| 4173 | 4178 | { |
| 4174 | 4179 | op = CastOpNoop; |
| 4175 | } else if (wanted_type->id == TypeTableEntryIdInt) { | |
| 4180 | } else if (wanted_type_canon->id == TypeTableEntryIdInt) { | |
| 4176 | 4181 | op = CastOpFloatToInt; |
| 4177 | } else if (wanted_type->id == TypeTableEntryIdFloat) { | |
| 4182 | } else if (wanted_type_canon->id == TypeTableEntryIdFloat) { | |
| 4178 | 4183 | op = CastOpIntToFloat; |
| 4179 | 4184 | } else { |
| 4180 | 4185 | zig_unreachable(); |
src/codegen.cpp+6-2| ... | ... | @@ -594,10 +594,14 @@ static LLVMValueRef gen_enum_value_expr(CodeGen *g, AstNode *node, TypeTableEntr |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | static LLVMValueRef gen_widen_or_shorten(CodeGen *g, AstNode *source_node, TypeTableEntry *actual_type, | |
| 598 | TypeTableEntry *wanted_type, LLVMValueRef expr_val) | |
| 597 | static LLVMValueRef gen_widen_or_shorten(CodeGen *g, AstNode *source_node, TypeTableEntry *actual_type_non_canon, | |
| 598 | TypeTableEntry *wanted_type_non_canon, LLVMValueRef expr_val) | |
| 599 | 599 | { |
| 600 | TypeTableEntry *actual_type = get_underlying_type(actual_type_non_canon); | |
| 601 | TypeTableEntry *wanted_type = get_underlying_type(wanted_type_non_canon); | |
| 602 | ||
| 600 | 603 | assert(actual_type->id == wanted_type->id); |
| 604 | ||
| 601 | 605 | uint64_t actual_bits; |
| 602 | 606 | uint64_t wanted_bits; |
| 603 | 607 | if (actual_type->id == TypeTableEntryIdFloat) { |
std/index.zig+1| ... | ... | @@ -3,6 +3,7 @@ pub const io = @import("io.zig"); |
| 3 | 3 | pub const os = @import("os.zig"); |
| 4 | 4 | pub const math = @import("math.zig"); |
| 5 | 5 | pub const str = @import("str.zig"); |
| 6 | pub const net = @import("net.zig"); | |
| 6 | 7 | |
| 7 | 8 | pub fn assert(b: bool) { |
| 8 | 9 | if (!b) unreachable{} |
std/linux.zig+97| ... | ... | @@ -3,6 +3,7 @@ const arch = switch (@compile_var("arch")) { |
| 3 | 3 | i386 => @import("linux_i386.zig"), |
| 4 | 4 | else => unreachable{}, |
| 5 | 5 | }; |
| 6 | const errno = @import("errno.zig"); | |
| 6 | 7 | |
| 7 | 8 | pub const MMAP_PROT_NONE = 0; |
| 8 | 9 | pub const MMAP_PROT_READ = 1; |
| ... | ... | @@ -79,6 +80,22 @@ const SIG_BLOCK = 0; |
| 79 | 80 | const SIG_UNBLOCK = 1; |
| 80 | 81 | const SIG_SETMASK = 2; |
| 81 | 82 | |
| 83 | const SOCK_STREAM = 1; | |
| 84 | const SOCK_DGRAM = 2; | |
| 85 | const SOCK_RAW = 3; | |
| 86 | pub const SOCK_RDM = 4; | |
| 87 | pub const SOCK_SEQPACKET = 5; | |
| 88 | pub const SOCK_DCCP = 6; | |
| 89 | pub const SOCK_PACKET = 10; | |
| 90 | pub const SOCK_CLOEXEC = 0o2000000; | |
| 91 | pub const SOCK_NONBLOCK = 0o4000; | |
| 92 | ||
| 93 | ||
| 94 | /// Get the errno from a syscall return value, or 0 for no error. | |
| 95 | pub fn get_errno(r: isize) -> isize { | |
| 96 | if (r > -4096) -r else 0 | |
| 97 | } | |
| 98 | ||
| 82 | 99 | pub fn mmap(address: ?&u8, length: isize, prot: isize, flags: isize, fd: isize, offset: isize) -> isize { |
| 83 | 100 | // TODO ability to cast maybe pointer to isize |
| 84 | 101 | const addr = if (const unwrapped ?= address) isize(unwrapped) else 0; |
| ... | ... | @@ -164,3 +181,83 @@ fn block_app_signals(set: &sigset_t) { |
| 164 | 181 | fn restore_signals(set: &sigset_t) { |
| 165 | 182 | arch.syscall4(arch.SYS_rt_sigprocmask, SIG_SETMASK, isize(set), 0, NSIG/8); |
| 166 | 183 | } |
| 184 | ||
| 185 | ||
| 186 | pub type sa_family_t = u16; | |
| 187 | pub type socklen_t = u32; | |
| 188 | ||
| 189 | export struct sockaddr { | |
| 190 | sa_family: sa_family_t, | |
| 191 | sa_data: [14]u8, | |
| 192 | } | |
| 193 | ||
| 194 | export struct iovec { | |
| 195 | iov_base: &u8, | |
| 196 | iov_len: usize, | |
| 197 | } | |
| 198 | ||
| 199 | pub fn getsockname(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> isize { | |
| 200 | arch.syscall3(arch.SYS_getsockname, fd, isize(addr), isize(len)) | |
| 201 | } | |
| 202 | ||
| 203 | pub fn getpeername(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> isize { | |
| 204 | arch.syscall3(arch.SYS_getpeername, fd, isize(addr), isize(len)) | |
| 205 | } | |
| 206 | ||
| 207 | pub fn socket(domain: i32, socket_type: i32, protocol: i32) -> isize { | |
| 208 | arch.syscall3(arch.SYS_socket, domain, socket_type, protocol) | |
| 209 | } | |
| 210 | ||
| 211 | pub fn setsockopt(fd: i32, level: i32, optname: i32, optval: &const u8, optlen: socklen_t) -> isize { | |
| 212 | arch.syscall5(arch.SYS_setsockopt, fd, level, optname, isize(optval), isize(optlen)) | |
| 213 | } | |
| 214 | ||
| 215 | pub fn getsockopt(fd: i32, level: i32, optname: i32, noalias optval: &u8, noalias optlen: &socklen_t) -> isize { | |
| 216 | arch.syscall5(arch.SYS_getsockopt, fd, level, optname, isize(optval), isize(optlen)) | |
| 217 | } | |
| 218 | ||
| 219 | pub fn sendmsg(fd: i32, msg: &const arch.msghdr, flags: i32) -> isize { | |
| 220 | arch.syscall3(arch.SYS_sendmsg, fd, isize(msg), flags) | |
| 221 | } | |
| 222 | ||
| 223 | pub fn connect(fd: i32, addr: &const sockaddr, len: socklen_t) -> isize { | |
| 224 | arch.syscall3(arch.SYS_connect, fd, isize(addr), isize(len)) | |
| 225 | } | |
| 226 | ||
| 227 | pub fn accept(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> isize { | |
| 228 | arch.syscall3(arch.SYS_accept, fd, isize(addr), isize(len)) | |
| 229 | } | |
| 230 | ||
| 231 | pub fn recvmsg(fd: i32, msg: &arch.msghdr, flags: i32) -> isize { | |
| 232 | arch.syscall3(arch.SYS_recvmsg, fd, isize(msg), flags) | |
| 233 | } | |
| 234 | ||
| 235 | pub fn recvfrom(fd: i32, noalias buf: &u8, len: isize, flags: i32, | |
| 236 | noalias addr: &sockaddr, noalias alen: &socklen_t) -> isize | |
| 237 | { | |
| 238 | arch.syscall6(arch.SYS_recvfrom, fd, isize(buf), len, flags, isize(addr), isize(alen)) | |
| 239 | } | |
| 240 | ||
| 241 | pub fn shutdown(fd: i32, how: i32) -> isize { | |
| 242 | arch.syscall2(arch.SYS_shutdown, fd, how) | |
| 243 | } | |
| 244 | ||
| 245 | pub fn bind(fd: i32, addr: &const sockaddr, len: socklen_t) { | |
| 246 | arch.syscall3(arch.SYS_bind, fd, isize(addr), isize(len)); | |
| 247 | } | |
| 248 | ||
| 249 | pub fn listen(fd: i32, backlog: i32) -> isize { | |
| 250 | arch.syscall2(arch.SYS_listen, fd, backlog) | |
| 251 | } | |
| 252 | ||
| 253 | pub fn sendto(fd: i32, buf: &const u8, len: isize, flags: i32, addr: &const sockaddr, alen: socklen_t) -> isize { | |
| 254 | arch.syscall6(arch.SYS_sendto, fd, isize(buf), len, flags, isize(addr), isize(alen)) | |
| 255 | } | |
| 256 | ||
| 257 | pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) -> isize { | |
| 258 | arch.syscall4(arch.SYS_socketpair, domain, socket_type, protocol, isize(&fd[0])) | |
| 259 | } | |
| 260 | ||
| 261 | pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags: i32) -> isize { | |
| 262 | arch.syscall4(arch.SYS_accept4, fd, isize(addr), isize(len), flags) | |
| 263 | } |
std/linux_i386.zig+406-1| ... | ... | @@ -1,3 +1,383 @@ |
| 1 | const linux = @import("linux.zig"); | |
| 2 | const socklen_t = linux.socklen_t; | |
| 3 | const iovec = linux.iovec; | |
| 4 | ||
| 5 | pub const SYS_restart_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_waitpid = 7; | |
| 13 | pub const SYS_creat = 8; | |
| 14 | pub const SYS_link = 9; | |
| 15 | pub const SYS_unlink = 10; | |
| 16 | pub const SYS_execve = 11; | |
| 17 | pub const SYS_chdir = 12; | |
| 18 | pub const SYS_time = 13; | |
| 19 | pub const SYS_mknod = 14; | |
| 20 | pub const SYS_chmod = 15; | |
| 21 | pub const SYS_lchown = 16; | |
| 22 | pub const SYS_break = 17; | |
| 23 | pub const SYS_oldstat = 18; | |
| 24 | pub const SYS_lseek = 19; | |
| 25 | pub const SYS_getpid = 20; | |
| 26 | pub const SYS_mount = 21; | |
| 27 | pub const SYS_umount = 22; | |
| 28 | pub const SYS_setuid = 23; | |
| 29 | pub const SYS_getuid = 24; | |
| 30 | pub const SYS_stime = 25; | |
| 31 | pub const SYS_ptrace = 26; | |
| 32 | pub const SYS_alarm = 27; | |
| 33 | pub const SYS_oldfstat = 28; | |
| 34 | pub const SYS_pause = 29; | |
| 35 | pub const SYS_utime = 30; | |
| 36 | pub const SYS_stty = 31; | |
| 37 | pub const SYS_gtty = 32; | |
| 38 | pub const SYS_access = 33; | |
| 39 | pub const SYS_nice = 34; | |
| 40 | pub const SYS_ftime = 35; | |
| 41 | pub const SYS_sync = 36; | |
| 42 | pub const SYS_kill = 37; | |
| 43 | pub const SYS_rename = 38; | |
| 44 | pub const SYS_mkdir = 39; | |
| 45 | pub const SYS_rmdir = 40; | |
| 46 | pub const SYS_dup = 41; | |
| 47 | pub const SYS_pipe = 42; | |
| 48 | pub const SYS_times = 43; | |
| 49 | pub const SYS_prof = 44; | |
| 50 | pub const SYS_brk = 45; | |
| 51 | pub const SYS_setgid = 46; | |
| 52 | pub const SYS_getgid = 47; | |
| 53 | pub const SYS_signal = 48; | |
| 54 | pub const SYS_geteuid = 49; | |
| 55 | pub const SYS_getegid = 50; | |
| 56 | pub const SYS_acct = 51; | |
| 57 | pub const SYS_umount2 = 52; | |
| 58 | pub const SYS_lock = 53; | |
| 59 | pub const SYS_ioctl = 54; | |
| 60 | pub const SYS_fcntl = 55; | |
| 61 | pub const SYS_mpx = 56; | |
| 62 | pub const SYS_setpgid = 57; | |
| 63 | pub const SYS_ulimit = 58; | |
| 64 | pub const SYS_oldolduname = 59; | |
| 65 | pub const SYS_umask = 60; | |
| 66 | pub const SYS_chroot = 61; | |
| 67 | pub const SYS_ustat = 62; | |
| 68 | pub const SYS_dup2 = 63; | |
| 69 | pub const SYS_getppid = 64; | |
| 70 | pub const SYS_getpgrp = 65; | |
| 71 | pub const SYS_setsid = 66; | |
| 72 | pub const SYS_sigaction = 67; | |
| 73 | pub const SYS_sgetmask = 68; | |
| 74 | pub const SYS_ssetmask = 69; | |
| 75 | pub const SYS_setreuid = 70; | |
| 76 | pub const SYS_setregid = 71; | |
| 77 | pub const SYS_sigsuspend = 72; | |
| 78 | pub const SYS_sigpending = 73; | |
| 79 | pub const SYS_sethostname = 74; | |
| 80 | pub const SYS_setrlimit = 75; | |
| 81 | pub const SYS_getrlimit = 76; | |
| 82 | pub const SYS_getrusage = 77; | |
| 83 | pub const SYS_gettimeofday = 78; | |
| 84 | pub const SYS_settimeofday = 79; | |
| 85 | pub const SYS_getgroups = 80; | |
| 86 | pub const SYS_setgroups = 81; | |
| 87 | pub const SYS_select = 82; | |
| 88 | pub const SYS_symlink = 83; | |
| 89 | pub const SYS_oldlstat = 84; | |
| 90 | pub const SYS_readlink = 85; | |
| 91 | pub const SYS_uselib = 86; | |
| 92 | pub const SYS_swapon = 87; | |
| 93 | pub const SYS_reboot = 88; | |
| 94 | pub const SYS_readdir = 89; | |
| 95 | pub const SYS_mmap = 90; | |
| 96 | pub const SYS_munmap = 91; | |
| 97 | pub const SYS_truncate = 92; | |
| 98 | pub const SYS_ftruncate = 93; | |
| 99 | pub const SYS_fchmod = 94; | |
| 100 | pub const SYS_fchown = 95; | |
| 101 | pub const SYS_getpriority = 96; | |
| 102 | pub const SYS_setpriority = 97; | |
| 103 | pub const SYS_profil = 98; | |
| 104 | pub const SYS_statfs = 99; | |
| 105 | pub const SYS_fstatfs = 100; | |
| 106 | pub const SYS_ioperm = 101; | |
| 107 | pub const SYS_socketcall = 102; | |
| 108 | pub const SYS_syslog = 103; | |
| 109 | pub const SYS_setitimer = 104; | |
| 110 | pub const SYS_getitimer = 105; | |
| 111 | pub const SYS_stat = 106; | |
| 112 | pub const SYS_lstat = 107; | |
| 113 | pub const SYS_fstat = 108; | |
| 114 | pub const SYS_olduname = 109; | |
| 115 | pub const SYS_iopl = 110; | |
| 116 | pub const SYS_vhangup = 111; | |
| 117 | pub const SYS_idle = 112; | |
| 118 | pub const SYS_vm86old = 113; | |
| 119 | pub const SYS_wait4 = 114; | |
| 120 | pub const SYS_swapoff = 115; | |
| 121 | pub const SYS_sysinfo = 116; | |
| 122 | pub const SYS_ipc = 117; | |
| 123 | pub const SYS_fsync = 118; | |
| 124 | pub const SYS_sigreturn = 119; | |
| 125 | pub const SYS_clone = 120; | |
| 126 | pub const SYS_setdomainname = 121; | |
| 127 | pub const SYS_uname = 122; | |
| 128 | pub const SYS_modify_ldt = 123; | |
| 129 | pub const SYS_adjtimex = 124; | |
| 130 | pub const SYS_mprotect = 125; | |
| 131 | pub const SYS_sigprocmask = 126; | |
| 132 | pub const SYS_create_module = 127; | |
| 133 | pub const SYS_init_module = 128; | |
| 134 | pub const SYS_delete_module = 129; | |
| 135 | pub const SYS_get_kernel_syms = 130; | |
| 136 | pub const SYS_quotactl = 131; | |
| 137 | pub const SYS_getpgid = 132; | |
| 138 | pub const SYS_fchdir = 133; | |
| 139 | pub const SYS_bdflush = 134; | |
| 140 | pub const SYS_sysfs = 135; | |
| 141 | pub const SYS_personality = 136; | |
| 142 | pub const SYS_afs_syscall = 137; | |
| 143 | pub const SYS_setfsuid = 138; | |
| 144 | pub const SYS_setfsgid = 139; | |
| 145 | pub const SYS__llseek = 140; | |
| 146 | pub const SYS_getdents = 141; | |
| 147 | pub const SYS__newselect = 142; | |
| 148 | pub const SYS_flock = 143; | |
| 149 | pub const SYS_msync = 144; | |
| 150 | pub const SYS_readv = 145; | |
| 151 | pub const SYS_writev = 146; | |
| 152 | pub const SYS_getsid = 147; | |
| 153 | pub const SYS_fdatasync = 148; | |
| 154 | pub const SYS__sysctl = 149; | |
| 155 | pub const SYS_mlock = 150; | |
| 156 | pub const SYS_munlock = 151; | |
| 157 | pub const SYS_mlockall = 152; | |
| 158 | pub const SYS_munlockall = 153; | |
| 159 | pub const SYS_sched_setparam = 154; | |
| 160 | pub const SYS_sched_getparam = 155; | |
| 161 | pub const SYS_sched_setscheduler = 156; | |
| 162 | pub const SYS_sched_getscheduler = 157; | |
| 163 | pub const SYS_sched_yield = 158; | |
| 164 | pub const SYS_sched_get_priority_max = 159; | |
| 165 | pub const SYS_sched_get_priority_min = 160; | |
| 166 | pub const SYS_sched_rr_get_interval = 161; | |
| 167 | pub const SYS_nanosleep = 162; | |
| 168 | pub const SYS_mremap = 163; | |
| 169 | pub const SYS_setresuid = 164; | |
| 170 | pub const SYS_getresuid = 165; | |
| 171 | pub const SYS_vm86 = 166; | |
| 172 | pub const SYS_query_module = 167; | |
| 173 | pub const SYS_poll = 168; | |
| 174 | pub const SYS_nfsservctl = 169; | |
| 175 | pub const SYS_setresgid = 170; | |
| 176 | pub const SYS_getresgid = 171; | |
| 177 | pub const SYS_prctl = 172; | |
| 178 | pub const SYS_rt_sigreturn = 173; | |
| 179 | pub const SYS_rt_sigaction = 174; | |
| 180 | pub const SYS_rt_sigprocmask = 175; | |
| 181 | pub const SYS_rt_sigpending = 176; | |
| 182 | pub const SYS_rt_sigtimedwait = 177; | |
| 183 | pub const SYS_rt_sigqueueinfo = 178; | |
| 184 | pub const SYS_rt_sigsuspend = 179; | |
| 185 | pub const SYS_pread64 = 180; | |
| 186 | pub const SYS_pwrite64 = 181; | |
| 187 | pub const SYS_chown = 182; | |
| 188 | pub const SYS_getcwd = 183; | |
| 189 | pub const SYS_capget = 184; | |
| 190 | pub const SYS_capset = 185; | |
| 191 | pub const SYS_sigaltstack = 186; | |
| 192 | pub const SYS_sendfile = 187; | |
| 193 | pub const SYS_getpmsg = 188; | |
| 194 | pub const SYS_putpmsg = 189; | |
| 195 | pub const SYS_vfork = 190; | |
| 196 | pub const SYS_ugetrlimit = 191; | |
| 197 | pub const SYS_mmap2 = 192; | |
| 198 | pub const SYS_truncate64 = 193; | |
| 199 | pub const SYS_ftruncate64 = 194; | |
| 200 | pub const SYS_stat64 = 195; | |
| 201 | pub const SYS_lstat64 = 196; | |
| 202 | pub const SYS_fstat64 = 197; | |
| 203 | pub const SYS_lchown32 = 198; | |
| 204 | pub const SYS_getuid32 = 199; | |
| 205 | pub const SYS_getgid32 = 200; | |
| 206 | pub const SYS_geteuid32 = 201; | |
| 207 | pub const SYS_getegid32 = 202; | |
| 208 | pub const SYS_setreuid32 = 203; | |
| 209 | pub const SYS_setregid32 = 204; | |
| 210 | pub const SYS_getgroups32 = 205; | |
| 211 | pub const SYS_setgroups32 = 206; | |
| 212 | pub const SYS_fchown32 = 207; | |
| 213 | pub const SYS_setresuid32 = 208; | |
| 214 | pub const SYS_getresuid32 = 209; | |
| 215 | pub const SYS_setresgid32 = 210; | |
| 216 | pub const SYS_getresgid32 = 211; | |
| 217 | pub const SYS_chown32 = 212; | |
| 218 | pub const SYS_setuid32 = 213; | |
| 219 | pub const SYS_setgid32 = 214; | |
| 220 | pub const SYS_setfsuid32 = 215; | |
| 221 | pub const SYS_setfsgid32 = 216; | |
| 222 | pub const SYS_pivot_root = 217; | |
| 223 | pub const SYS_mincore = 218; | |
| 224 | pub const SYS_madvise = 219; | |
| 225 | pub const SYS_madvise1 = 219; | |
| 226 | pub const SYS_getdents64 = 220; | |
| 227 | pub const SYS_fcntl64 = 221; | |
| 228 | pub const SYS_gettid = 224; | |
| 229 | pub const SYS_readahead = 225; | |
| 230 | pub const SYS_setxattr = 226; | |
| 231 | pub const SYS_lsetxattr = 227; | |
| 232 | pub const SYS_fsetxattr = 228; | |
| 233 | pub const SYS_getxattr = 229; | |
| 234 | pub const SYS_lgetxattr = 230; | |
| 235 | pub const SYS_fgetxattr = 231; | |
| 236 | pub const SYS_listxattr = 232; | |
| 237 | pub const SYS_llistxattr = 233; | |
| 238 | pub const SYS_flistxattr = 234; | |
| 239 | pub const SYS_removexattr = 235; | |
| 240 | pub const SYS_lremovexattr = 236; | |
| 241 | pub const SYS_fremovexattr = 237; | |
| 242 | pub const SYS_tkill = 238; | |
| 243 | pub const SYS_sendfile64 = 239; | |
| 244 | pub const SYS_futex = 240; | |
| 245 | pub const SYS_sched_setaffinity = 241; | |
| 246 | pub const SYS_sched_getaffinity = 242; | |
| 247 | pub const SYS_set_thread_area = 243; | |
| 248 | pub const SYS_get_thread_area = 244; | |
| 249 | pub const SYS_io_setup = 245; | |
| 250 | pub const SYS_io_destroy = 246; | |
| 251 | pub const SYS_io_getevents = 247; | |
| 252 | pub const SYS_io_submit = 248; | |
| 253 | pub const SYS_io_cancel = 249; | |
| 254 | pub const SYS_fadvise64 = 250; | |
| 255 | pub const SYS_exit_group = 252; | |
| 256 | pub const SYS_lookup_dcookie = 253; | |
| 257 | pub const SYS_epoll_create = 254; | |
| 258 | pub const SYS_epoll_ctl = 255; | |
| 259 | pub const SYS_epoll_wait = 256; | |
| 260 | pub const SYS_remap_file_pages = 257; | |
| 261 | pub const SYS_set_tid_address = 258; | |
| 262 | pub const SYS_timer_create = 259; | |
| 263 | pub const SYS_timer_settime = SYS_timer_create+1; | |
| 264 | pub const SYS_timer_gettime = SYS_timer_create+2; | |
| 265 | pub const SYS_timer_getoverrun = SYS_timer_create+3; | |
| 266 | pub const SYS_timer_delete = SYS_timer_create+4; | |
| 267 | pub const SYS_clock_settime = SYS_timer_create+5; | |
| 268 | pub const SYS_clock_gettime = SYS_timer_create+6; | |
| 269 | pub const SYS_clock_getres = SYS_timer_create+7; | |
| 270 | pub const SYS_clock_nanosleep = SYS_timer_create+8; | |
| 271 | pub const SYS_statfs64 = 268; | |
| 272 | pub const SYS_fstatfs64 = 269; | |
| 273 | pub const SYS_tgkill = 270; | |
| 274 | pub const SYS_utimes = 271; | |
| 275 | pub const SYS_fadvise64_64 = 272; | |
| 276 | pub const SYS_vserver = 273; | |
| 277 | pub const SYS_mbind = 274; | |
| 278 | pub const SYS_get_mempolicy = 275; | |
| 279 | pub const SYS_set_mempolicy = 276; | |
| 280 | pub const SYS_mq_open = 277; | |
| 281 | pub const SYS_mq_unlink = SYS_mq_open+1; | |
| 282 | pub const SYS_mq_timedsend = SYS_mq_open+2; | |
| 283 | pub const SYS_mq_timedreceive = SYS_mq_open+3; | |
| 284 | pub const SYS_mq_notify = SYS_mq_open+4; | |
| 285 | pub const SYS_mq_getsetattr = SYS_mq_open+5; | |
| 286 | pub const SYS_kexec_load = 283; | |
| 287 | pub const SYS_waitid = 284; | |
| 288 | pub const SYS_add_key = 286; | |
| 289 | pub const SYS_request_key = 287; | |
| 290 | pub const SYS_keyctl = 288; | |
| 291 | pub const SYS_ioprio_set = 289; | |
| 292 | pub const SYS_ioprio_get = 290; | |
| 293 | pub const SYS_inotify_init = 291; | |
| 294 | pub const SYS_inotify_add_watch = 292; | |
| 295 | pub const SYS_inotify_rm_watch = 293; | |
| 296 | pub const SYS_migrate_pages = 294; | |
| 297 | pub const SYS_openat = 295; | |
| 298 | pub const SYS_mkdirat = 296; | |
| 299 | pub const SYS_mknodat = 297; | |
| 300 | pub const SYS_fchownat = 298; | |
| 301 | pub const SYS_futimesat = 299; | |
| 302 | pub const SYS_fstatat64 = 300; | |
| 303 | pub const SYS_unlinkat = 301; | |
| 304 | pub const SYS_renameat = 302; | |
| 305 | pub const SYS_linkat = 303; | |
| 306 | pub const SYS_symlinkat = 304; | |
| 307 | pub const SYS_readlinkat = 305; | |
| 308 | pub const SYS_fchmodat = 306; | |
| 309 | pub const SYS_faccessat = 307; | |
| 310 | pub const SYS_pselect6 = 308; | |
| 311 | pub const SYS_ppoll = 309; | |
| 312 | pub const SYS_unshare = 310; | |
| 313 | pub const SYS_set_robust_list = 311; | |
| 314 | pub const SYS_get_robust_list = 312; | |
| 315 | pub const SYS_splice = 313; | |
| 316 | pub const SYS_sync_file_range = 314; | |
| 317 | pub const SYS_tee = 315; | |
| 318 | pub const SYS_vmsplice = 316; | |
| 319 | pub const SYS_move_pages = 317; | |
| 320 | pub const SYS_getcpu = 318; | |
| 321 | pub const SYS_epoll_pwait = 319; | |
| 322 | pub const SYS_utimensat = 320; | |
| 323 | pub const SYS_signalfd = 321; | |
| 324 | pub const SYS_timerfd_create = 322; | |
| 325 | pub const SYS_eventfd = 323; | |
| 326 | pub const SYS_fallocate = 324; | |
| 327 | pub const SYS_timerfd_settime = 325; | |
| 328 | pub const SYS_timerfd_gettime = 326; | |
| 329 | pub const SYS_signalfd4 = 327; | |
| 330 | pub const SYS_eventfd2 = 328; | |
| 331 | pub const SYS_epoll_create1 = 329; | |
| 332 | pub const SYS_dup3 = 330; | |
| 333 | pub const SYS_pipe2 = 331; | |
| 334 | pub const SYS_inotify_init1 = 332; | |
| 335 | pub const SYS_preadv = 333; | |
| 336 | pub const SYS_pwritev = 334; | |
| 337 | pub const SYS_rt_tgsigqueueinfo = 335; | |
| 338 | pub const SYS_perf_event_open = 336; | |
| 339 | pub const SYS_recvmmsg = 337; | |
| 340 | pub const SYS_fanotify_init = 338; | |
| 341 | pub const SYS_fanotify_mark = 339; | |
| 342 | pub const SYS_prlimit64 = 340; | |
| 343 | pub const SYS_name_to_handle_at = 341; | |
| 344 | pub const SYS_open_by_handle_at = 342; | |
| 345 | pub const SYS_clock_adjtime = 343; | |
| 346 | pub const SYS_syncfs = 344; | |
| 347 | pub const SYS_sendmmsg = 345; | |
| 348 | pub const SYS_setns = 346; | |
| 349 | pub const SYS_process_vm_readv = 347; | |
| 350 | pub const SYS_process_vm_writev = 348; | |
| 351 | pub const SYS_kcmp = 349; | |
| 352 | pub const SYS_finit_module = 350; | |
| 353 | pub const SYS_sched_setattr = 351; | |
| 354 | pub const SYS_sched_getattr = 352; | |
| 355 | pub const SYS_renameat2 = 353; | |
| 356 | pub const SYS_seccomp = 354; | |
| 357 | pub const SYS_getrandom = 355; | |
| 358 | pub const SYS_memfd_create = 356; | |
| 359 | pub const SYS_bpf = 357; | |
| 360 | pub const SYS_execveat = 358; | |
| 361 | pub const SYS_socket = 359; | |
| 362 | pub const SYS_socketpair = 360; | |
| 363 | pub const SYS_bind = 361; | |
| 364 | pub const SYS_connect = 362; | |
| 365 | pub const SYS_listen = 363; | |
| 366 | pub const SYS_accept4 = 364; | |
| 367 | pub const SYS_getsockopt = 365; | |
| 368 | pub const SYS_setsockopt = 366; | |
| 369 | pub const SYS_getsockname = 367; | |
| 370 | pub const SYS_getpeername = 368; | |
| 371 | pub const SYS_sendto = 369; | |
| 372 | pub const SYS_sendmsg = 370; | |
| 373 | pub const SYS_recvfrom = 371; | |
| 374 | pub const SYS_recvmsg = 372; | |
| 375 | pub const SYS_shutdown = 373; | |
| 376 | pub const SYS_userfaultfd = 374; | |
| 377 | pub const SYS_membarrier = 375; | |
| 378 | pub const SYS_mlock2 = 376; | |
| 379 | ||
| 380 | ||
| 1 | 381 | pub const O_CREAT = 0o100; |
| 2 | 382 | pub const O_EXCL = 0o200; |
| 3 | 383 | pub const O_NOCTTY = 0o400; |
| ... | ... | @@ -79,7 +459,22 @@ pub fn syscall4(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isiz |
| 79 | 459 | [arg4] "{esi}" (arg4)) |
| 80 | 460 | } |
| 81 | 461 | |
| 82 | pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isize, arg5: isize, arg6: isize) -> isize { | |
| 462 | pub fn syscall5(number: isize, arg1: isize, arg2: isize, arg3: isize, | |
| 463 | arg4: isize, arg5: isize) -> isize | |
| 464 | { | |
| 465 | asm volatile ("int $0x80" | |
| 466 | : [ret] "={eax}" (-> isize) | |
| 467 | : [number] "{eax}" (number), | |
| 468 | [arg1] "{ebx}" (arg1), | |
| 469 | [arg2] "{ecx}" (arg2), | |
| 470 | [arg3] "{edx}" (arg3), | |
| 471 | [arg4] "{esi}" (arg4), | |
| 472 | [arg5] "{edi}" (arg5)) | |
| 473 | } | |
| 474 | ||
| 475 | pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, | |
| 476 | arg4: isize, arg5: isize, arg6: isize) -> isize | |
| 477 | { | |
| 83 | 478 | asm volatile ("int $0x80" |
| 84 | 479 | : [ret] "={eax}" (-> isize) |
| 85 | 480 | : [number] "{eax}" (number), |
| ... | ... | @@ -90,3 +485,13 @@ pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isiz |
| 90 | 485 | [arg5] "{edi}" (arg5), |
| 91 | 486 | [arg6] "{ebp}" (arg6)) |
| 92 | 487 | } |
| 488 | ||
| 489 | export struct msghdr { | |
| 490 | msg_name: &u8, | |
| 491 | msg_namelen: socklen_t, | |
| 492 | msg_iov: &iovec, | |
| 493 | msg_iovlen: i32, | |
| 494 | msg_control: &u8, | |
| 495 | msg_controllen: socklen_t, | |
| 496 | msg_flags: i32, | |
| 497 | } |
std/linux_x86_64.zig+341-2| ... | ... | @@ -1,20 +1,333 @@ |
| 1 | const linux = @import("linux.zig"); | |
| 2 | const socklen_t = linux.socklen_t; | |
| 3 | const iovec = linux.iovec; | |
| 4 | ||
| 1 | 5 | pub const SYS_read = 0; |
| 2 | 6 | pub const SYS_write = 1; |
| 3 | 7 | pub const SYS_open = 2; |
| 4 | 8 | pub const SYS_close = 3; |
| 5 | pub const SYS_creat = 85; | |
| 9 | pub const SYS_stat = 4; | |
| 10 | pub const SYS_fstat = 5; | |
| 11 | pub const SYS_lstat = 6; | |
| 12 | pub const SYS_poll = 7; | |
| 6 | 13 | pub const SYS_lseek = 8; |
| 7 | 14 | pub const SYS_mmap = 9; |
| 15 | pub const SYS_mprotect = 10; | |
| 8 | 16 | pub const SYS_munmap = 11; |
| 17 | pub const SYS_brk = 12; | |
| 18 | pub const SYS_rt_sigaction = 13; | |
| 9 | 19 | pub const SYS_rt_sigprocmask = 14; |
| 20 | pub const SYS_rt_sigreturn = 15; | |
| 21 | pub const SYS_ioctl = 16; | |
| 22 | pub const SYS_pread64 = 17; | |
| 23 | pub const SYS_pwrite64 = 18; | |
| 24 | pub const SYS_readv = 19; | |
| 25 | pub const SYS_writev = 20; | |
| 26 | pub const SYS_access = 21; | |
| 27 | pub const SYS_pipe = 22; | |
| 28 | pub const SYS_select = 23; | |
| 29 | pub const SYS_sched_yield = 24; | |
| 30 | pub const SYS_mremap = 25; | |
| 31 | pub const SYS_msync = 26; | |
| 32 | pub const SYS_mincore = 27; | |
| 33 | pub const SYS_madvise = 28; | |
| 34 | pub const SYS_shmget = 29; | |
| 35 | pub const SYS_shmat = 30; | |
| 36 | pub const SYS_shmctl = 31; | |
| 37 | pub const SYS_dup = 32; | |
| 38 | pub const SYS_dup2 = 33; | |
| 39 | pub const SYS_pause = 34; | |
| 40 | pub const SYS_nanosleep = 35; | |
| 41 | pub const SYS_getitimer = 36; | |
| 42 | pub const SYS_alarm = 37; | |
| 43 | pub const SYS_setitimer = 38; | |
| 44 | pub const SYS_getpid = 39; | |
| 45 | pub const SYS_sendfile = 40; | |
| 46 | pub const SYS_socket = 41; | |
| 47 | pub const SYS_connect = 42; | |
| 48 | pub const SYS_accept = 43; | |
| 49 | pub const SYS_sendto = 44; | |
| 50 | pub const SYS_recvfrom = 45; | |
| 51 | pub const SYS_sendmsg = 46; | |
| 52 | pub const SYS_recvmsg = 47; | |
| 53 | pub const SYS_shutdown = 48; | |
| 54 | pub const SYS_bind = 49; | |
| 55 | pub const SYS_listen = 50; | |
| 56 | pub const SYS_getsockname = 51; | |
| 57 | pub const SYS_getpeername = 52; | |
| 58 | pub const SYS_socketpair = 53; | |
| 59 | pub const SYS_setsockopt = 54; | |
| 60 | pub const SYS_getsockopt = 55; | |
| 61 | pub const SYS_clone = 56; | |
| 62 | pub const SYS_fork = 57; | |
| 63 | pub const SYS_vfork = 58; | |
| 64 | pub const SYS_execve = 59; | |
| 10 | 65 | pub const SYS_exit = 60; |
| 66 | pub const SYS_wait4 = 61; | |
| 11 | 67 | pub const SYS_kill = 62; |
| 68 | pub const SYS_uname = 63; | |
| 69 | pub const SYS_semget = 64; | |
| 70 | pub const SYS_semop = 65; | |
| 71 | pub const SYS_semctl = 66; | |
| 72 | pub const SYS_shmdt = 67; | |
| 73 | pub const SYS_msgget = 68; | |
| 74 | pub const SYS_msgsnd = 69; | |
| 75 | pub const SYS_msgrcv = 70; | |
| 76 | pub const SYS_msgctl = 71; | |
| 77 | pub const SYS_fcntl = 72; | |
| 78 | pub const SYS_flock = 73; | |
| 79 | pub const SYS_fsync = 74; | |
| 80 | pub const SYS_fdatasync = 75; | |
| 81 | pub const SYS_truncate = 76; | |
| 82 | pub const SYS_ftruncate = 77; | |
| 83 | pub const SYS_getdents = 78; | |
| 84 | pub const SYS_getcwd = 79; | |
| 85 | pub const SYS_chdir = 80; | |
| 86 | pub const SYS_fchdir = 81; | |
| 87 | pub const SYS_rename = 82; | |
| 88 | pub const SYS_mkdir = 83; | |
| 89 | pub const SYS_rmdir = 84; | |
| 90 | pub const SYS_creat = 85; | |
| 91 | pub const SYS_link = 86; | |
| 92 | pub const SYS_unlink = 87; | |
| 93 | pub const SYS_symlink = 88; | |
| 94 | pub const SYS_readlink = 89; | |
| 95 | pub const SYS_chmod = 90; | |
| 96 | pub const SYS_fchmod = 91; | |
| 97 | pub const SYS_chown = 92; | |
| 98 | pub const SYS_fchown = 93; | |
| 99 | pub const SYS_lchown = 94; | |
| 100 | pub const SYS_umask = 95; | |
| 101 | pub const SYS_gettimeofday = 96; | |
| 102 | pub const SYS_getrlimit = 97; | |
| 103 | pub const SYS_getrusage = 98; | |
| 104 | pub const SYS_sysinfo = 99; | |
| 105 | pub const SYS_times = 100; | |
| 106 | pub const SYS_ptrace = 101; | |
| 107 | pub const SYS_getuid = 102; | |
| 108 | pub const SYS_syslog = 103; | |
| 12 | 109 | pub const SYS_getgid = 104; |
| 110 | pub const SYS_setuid = 105; | |
| 111 | pub const SYS_setgid = 106; | |
| 112 | pub const SYS_geteuid = 107; | |
| 113 | pub const SYS_getegid = 108; | |
| 114 | pub const SYS_setpgid = 109; | |
| 115 | pub const SYS_getppid = 110; | |
| 116 | pub const SYS_getpgrp = 111; | |
| 117 | pub const SYS_setsid = 112; | |
| 118 | pub const SYS_setreuid = 113; | |
| 119 | pub const SYS_setregid = 114; | |
| 120 | pub const SYS_getgroups = 115; | |
| 121 | pub const SYS_setgroups = 116; | |
| 122 | pub const SYS_setresuid = 117; | |
| 123 | pub const SYS_getresuid = 118; | |
| 124 | pub const SYS_setresgid = 119; | |
| 125 | pub const SYS_getresgid = 120; | |
| 126 | pub const SYS_getpgid = 121; | |
| 127 | pub const SYS_setfsuid = 122; | |
| 128 | pub const SYS_setfsgid = 123; | |
| 129 | pub const SYS_getsid = 124; | |
| 130 | pub const SYS_capget = 125; | |
| 131 | pub const SYS_capset = 126; | |
| 132 | pub const SYS_rt_sigpending = 127; | |
| 133 | pub const SYS_rt_sigtimedwait = 128; | |
| 134 | pub const SYS_rt_sigqueueinfo = 129; | |
| 135 | pub const SYS_rt_sigsuspend = 130; | |
| 136 | pub const SYS_sigaltstack = 131; | |
| 137 | pub const SYS_utime = 132; | |
| 138 | pub const SYS_mknod = 133; | |
| 139 | pub const SYS_uselib = 134; | |
| 140 | pub const SYS_personality = 135; | |
| 141 | pub const SYS_ustat = 136; | |
| 142 | pub const SYS_statfs = 137; | |
| 143 | pub const SYS_fstatfs = 138; | |
| 144 | pub const SYS_sysfs = 139; | |
| 145 | pub const SYS_getpriority = 140; | |
| 146 | pub const SYS_setpriority = 141; | |
| 147 | pub const SYS_sched_setparam = 142; | |
| 148 | pub const SYS_sched_getparam = 143; | |
| 149 | pub const SYS_sched_setscheduler = 144; | |
| 150 | pub const SYS_sched_getscheduler = 145; | |
| 151 | pub const SYS_sched_get_priority_max = 146; | |
| 152 | pub const SYS_sched_get_priority_min = 147; | |
| 153 | pub const SYS_sched_rr_get_interval = 148; | |
| 154 | pub const SYS_mlock = 149; | |
| 155 | pub const SYS_munlock = 150; | |
| 156 | pub const SYS_mlockall = 151; | |
| 157 | pub const SYS_munlockall = 152; | |
| 158 | pub const SYS_vhangup = 153; | |
| 159 | pub const SYS_modify_ldt = 154; | |
| 160 | pub const SYS_pivot_root = 155; | |
| 161 | pub const SYS__sysctl = 156; | |
| 162 | pub const SYS_prctl = 157; | |
| 163 | pub const SYS_arch_prctl = 158; | |
| 164 | pub const SYS_adjtimex = 159; | |
| 165 | pub const SYS_setrlimit = 160; | |
| 166 | pub const SYS_chroot = 161; | |
| 167 | pub const SYS_sync = 162; | |
| 168 | pub const SYS_acct = 163; | |
| 169 | pub const SYS_settimeofday = 164; | |
| 170 | pub const SYS_mount = 165; | |
| 171 | pub const SYS_umount2 = 166; | |
| 172 | pub const SYS_swapon = 167; | |
| 173 | pub const SYS_swapoff = 168; | |
| 174 | pub const SYS_reboot = 169; | |
| 175 | pub const SYS_sethostname = 170; | |
| 176 | pub const SYS_setdomainname = 171; | |
| 177 | pub const SYS_iopl = 172; | |
| 178 | pub const SYS_ioperm = 173; | |
| 179 | pub const SYS_create_module = 174; | |
| 180 | pub const SYS_init_module = 175; | |
| 181 | pub const SYS_delete_module = 176; | |
| 182 | pub const SYS_get_kernel_syms = 177; | |
| 183 | pub const SYS_query_module = 178; | |
| 184 | pub const SYS_quotactl = 179; | |
| 185 | pub const SYS_nfsservctl = 180; | |
| 186 | pub const SYS_getpmsg = 181; | |
| 187 | pub const SYS_putpmsg = 182; | |
| 188 | pub const SYS_afs_syscall = 183; | |
| 189 | pub const SYS_tuxcall = 184; | |
| 190 | pub const SYS_security = 185; | |
| 13 | 191 | pub const SYS_gettid = 186; |
| 192 | pub const SYS_readahead = 187; | |
| 193 | pub const SYS_setxattr = 188; | |
| 194 | pub const SYS_lsetxattr = 189; | |
| 195 | pub const SYS_fsetxattr = 190; | |
| 196 | pub const SYS_getxattr = 191; | |
| 197 | pub const SYS_lgetxattr = 192; | |
| 198 | pub const SYS_fgetxattr = 193; | |
| 199 | pub const SYS_listxattr = 194; | |
| 200 | pub const SYS_llistxattr = 195; | |
| 201 | pub const SYS_flistxattr = 196; | |
| 202 | pub const SYS_removexattr = 197; | |
| 203 | pub const SYS_lremovexattr = 198; | |
| 204 | pub const SYS_fremovexattr = 199; | |
| 14 | 205 | pub const SYS_tkill = 200; |
| 206 | pub const SYS_time = 201; | |
| 207 | pub const SYS_futex = 202; | |
| 208 | pub const SYS_sched_setaffinity = 203; | |
| 209 | pub const SYS_sched_getaffinity = 204; | |
| 210 | pub const SYS_set_thread_area = 205; | |
| 211 | pub const SYS_io_setup = 206; | |
| 212 | pub const SYS_io_destroy = 207; | |
| 213 | pub const SYS_io_getevents = 208; | |
| 214 | pub const SYS_io_submit = 209; | |
| 215 | pub const SYS_io_cancel = 210; | |
| 216 | pub const SYS_get_thread_area = 211; | |
| 217 | pub const SYS_lookup_dcookie = 212; | |
| 218 | pub const SYS_epoll_create = 213; | |
| 219 | pub const SYS_epoll_ctl_old = 214; | |
| 220 | pub const SYS_epoll_wait_old = 215; | |
| 221 | pub const SYS_remap_file_pages = 216; | |
| 222 | pub const SYS_getdents64 = 217; | |
| 223 | pub const SYS_set_tid_address = 218; | |
| 224 | pub const SYS_restart_syscall = 219; | |
| 225 | pub const SYS_semtimedop = 220; | |
| 226 | pub const SYS_fadvise64 = 221; | |
| 227 | pub const SYS_timer_create = 222; | |
| 228 | pub const SYS_timer_settime = 223; | |
| 229 | pub const SYS_timer_gettime = 224; | |
| 230 | pub const SYS_timer_getoverrun = 225; | |
| 231 | pub const SYS_timer_delete = 226; | |
| 232 | pub const SYS_clock_settime = 227; | |
| 233 | pub const SYS_clock_gettime = 228; | |
| 234 | pub const SYS_clock_getres = 229; | |
| 235 | pub const SYS_clock_nanosleep = 230; | |
| 236 | pub const SYS_exit_group = 231; | |
| 237 | pub const SYS_epoll_wait = 232; | |
| 238 | pub const SYS_epoll_ctl = 233; | |
| 15 | 239 | pub const SYS_tgkill = 234; |
| 240 | pub const SYS_utimes = 235; | |
| 241 | pub const SYS_vserver = 236; | |
| 242 | pub const SYS_mbind = 237; | |
| 243 | pub const SYS_set_mempolicy = 238; | |
| 244 | pub const SYS_get_mempolicy = 239; | |
| 245 | pub const SYS_mq_open = 240; | |
| 246 | pub const SYS_mq_unlink = 241; | |
| 247 | pub const SYS_mq_timedsend = 242; | |
| 248 | pub const SYS_mq_timedreceive = 243; | |
| 249 | pub const SYS_mq_notify = 244; | |
| 250 | pub const SYS_mq_getsetattr = 245; | |
| 251 | pub const SYS_kexec_load = 246; | |
| 252 | pub const SYS_waitid = 247; | |
| 253 | pub const SYS_add_key = 248; | |
| 254 | pub const SYS_request_key = 249; | |
| 255 | pub const SYS_keyctl = 250; | |
| 256 | pub const SYS_ioprio_set = 251; | |
| 257 | pub const SYS_ioprio_get = 252; | |
| 258 | pub const SYS_inotify_init = 253; | |
| 259 | pub const SYS_inotify_add_watch = 254; | |
| 260 | pub const SYS_inotify_rm_watch = 255; | |
| 261 | pub const SYS_migrate_pages = 256; | |
| 16 | 262 | pub const SYS_openat = 257; |
| 263 | pub const SYS_mkdirat = 258; | |
| 264 | pub const SYS_mknodat = 259; | |
| 265 | pub const SYS_fchownat = 260; | |
| 266 | pub const SYS_futimesat = 261; | |
| 267 | pub const SYS_newfstatat = 262; | |
| 268 | pub const SYS_unlinkat = 263; | |
| 269 | pub const SYS_renameat = 264; | |
| 270 | pub const SYS_linkat = 265; | |
| 271 | pub const SYS_symlinkat = 266; | |
| 272 | pub const SYS_readlinkat = 267; | |
| 273 | pub const SYS_fchmodat = 268; | |
| 274 | pub const SYS_faccessat = 269; | |
| 275 | pub const SYS_pselect6 = 270; | |
| 276 | pub const SYS_ppoll = 271; | |
| 277 | pub const SYS_unshare = 272; | |
| 278 | pub const SYS_set_robust_list = 273; | |
| 279 | pub const SYS_get_robust_list = 274; | |
| 280 | pub const SYS_splice = 275; | |
| 281 | pub const SYS_tee = 276; | |
| 282 | pub const SYS_sync_file_range = 277; | |
| 283 | pub const SYS_vmsplice = 278; | |
| 284 | pub const SYS_move_pages = 279; | |
| 285 | pub const SYS_utimensat = 280; | |
| 286 | pub const SYS_epoll_pwait = 281; | |
| 287 | pub const SYS_signalfd = 282; | |
| 288 | pub const SYS_timerfd_create = 283; | |
| 289 | pub const SYS_eventfd = 284; | |
| 290 | pub const SYS_fallocate = 285; | |
| 291 | pub const SYS_timerfd_settime = 286; | |
| 292 | pub const SYS_timerfd_gettime = 287; | |
| 293 | pub const SYS_accept4 = 288; | |
| 294 | pub const SYS_signalfd4 = 289; | |
| 295 | pub const SYS_eventfd2 = 290; | |
| 296 | pub const SYS_epoll_create1 = 291; | |
| 297 | pub const SYS_dup3 = 292; | |
| 298 | pub const SYS_pipe2 = 293; | |
| 299 | pub const SYS_inotify_init1 = 294; | |
| 300 | pub const SYS_preadv = 295; | |
| 301 | pub const SYS_pwritev = 296; | |
| 302 | pub const SYS_rt_tgsigqueueinfo = 297; | |
| 303 | pub const SYS_perf_event_open = 298; | |
| 304 | pub const SYS_recvmmsg = 299; | |
| 305 | pub const SYS_fanotify_init = 300; | |
| 306 | pub const SYS_fanotify_mark = 301; | |
| 307 | pub const SYS_prlimit64 = 302; | |
| 308 | pub const SYS_name_to_handle_at = 303; | |
| 309 | pub const SYS_open_by_handle_at = 304; | |
| 310 | pub const SYS_clock_adjtime = 305; | |
| 311 | pub const SYS_syncfs = 306; | |
| 312 | pub const SYS_sendmmsg = 307; | |
| 313 | pub const SYS_setns = 308; | |
| 314 | pub const SYS_getcpu = 309; | |
| 315 | pub const SYS_process_vm_readv = 310; | |
| 316 | pub const SYS_process_vm_writev = 311; | |
| 317 | pub const SYS_kcmp = 312; | |
| 318 | pub const SYS_finit_module = 313; | |
| 319 | pub const SYS_sched_setattr = 314; | |
| 320 | pub const SYS_sched_getattr = 315; | |
| 321 | pub const SYS_renameat2 = 316; | |
| 322 | pub const SYS_seccomp = 317; | |
| 17 | 323 | pub const SYS_getrandom = 318; |
| 324 | pub const SYS_memfd_create = 319; | |
| 325 | pub const SYS_kexec_file_load = 320; | |
| 326 | pub const SYS_bpf = 321; | |
| 327 | pub const SYS_execveat = 322; | |
| 328 | pub const SYS_userfaultfd = 323; | |
| 329 | pub const SYS_membarrier = 324; | |
| 330 | pub const SYS_mlock2 = 325; | |
| 18 | 331 | |
| 19 | 332 | pub const O_CREAT = 0o100; |
| 20 | 333 | pub const O_EXCL = 0o200; |
| ... | ... | @@ -102,7 +415,21 @@ pub fn syscall4(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isiz |
| 102 | 415 | : "rcx", "r11") |
| 103 | 416 | } |
| 104 | 417 | |
| 105 | pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isize, arg5: isize, arg6: isize) -> isize { | |
| 418 | pub fn syscall5(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isize, arg5: isize) -> isize { | |
| 419 | asm volatile ("syscall" | |
| 420 | : [ret] "={rax}" (-> isize) | |
| 421 | : [number] "{rax}" (number), | |
| 422 | [arg1] "{rdi}" (arg1), | |
| 423 | [arg2] "{rsi}" (arg2), | |
| 424 | [arg3] "{rdx}" (arg3), | |
| 425 | [arg4] "{r10}" (arg4), | |
| 426 | [arg5] "{r8}" (arg5) | |
| 427 | : "rcx", "r11") | |
| 428 | } | |
| 429 | ||
| 430 | pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isize, | |
| 431 | arg5: isize, arg6: isize) -> isize | |
| 432 | { | |
| 106 | 433 | asm volatile ("syscall" |
| 107 | 434 | : [ret] "={rax}" (-> isize) |
| 108 | 435 | : [number] "{rax}" (number), |
| ... | ... | @@ -114,3 +441,15 @@ pub fn syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isiz |
| 114 | 441 | [arg6] "{r9}" (arg6) |
| 115 | 442 | : "rcx", "r11") |
| 116 | 443 | } |
| 444 | ||
| 445 | export struct msghdr { | |
| 446 | msg_name: &u8, | |
| 447 | msg_namelen: socklen_t, | |
| 448 | msg_iov: &iovec, | |
| 449 | msg_iovlen: i32, | |
| 450 | __pad1: i32, | |
| 451 | msg_control: &u8, | |
| 452 | msg_controllen: socklen_t, | |
| 453 | __pad2: socklen_t, | |
| 454 | msg_flags: i32, | |
| 455 | } |
std/net.zig created+4| ... | ... | @@ -0,0 +1,4 @@ |
| 1 | const linux = @import("linux.zig"); | |
| 2 | ||
| 3 | pub fn open(hostname: []const u8) -> %void { | |
| 4 | } |