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