syscall
import syscall
"Syscall" is a low-level standard library that operates at the system level, designed for interacting with the operating system and delving into the realm of C language integration. It essentially mirrors Linux system calls, using the same system call parameters, so there's no need for an in-depth explanation of the purpose of each system call. Each system call can be affected by the operating system, leading to potential errors, which can be captured using a "try" mechanism.
Contents
https://github.com/nature-lang/nature/blob/master/std/syscall/main.linux.n
Examples
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230728_00_fork_exec.n
https://github.com/nature-lang/nature/tree/master/tests/blackbox/cases/20230725_00_syscall
https://github.com/nature-lang/nature/tree/master/tests/blackbox/cases/20230727_01_syscall
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230728_01_stat.n
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230728_02_syscall.n
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230729_00_syscall.n
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230729_01_syscall.n
https://github.com/nature-lang/nature/blob/master/tests/blackbox/cases/20230730_00_net.n
stat_t
type stat_t = struct {
u64 dev
u64 ino
u64 nlink
u32 mode
u32 uid
u32 gid
u32 __pad0
u64 rdev
i64 size
i64 blksize
i64 blocks
timespec_t atim
timespec_t mtim
timespec_t ctim
arr<i64,3> __unused
}
timespec_t
type timespec_t = struct {
i64 sec
i64 nsec
}
sockaddr_in
type sockaddr_in = struct {
u16 sin_family
u16 sin_port
u32 sin_addr
arr<u8,8> sin_zero
}
sockaddr_in6
type sockaddr_in6 = struct {
u8 sin6_len
u8 sin6_family
u16 sin6_port
u32 sin6_flowinfo
// ipv6 address(128-bit)
arr<u32,4> sin6_addr
u32 sin6_scope_id
}
sockaddr_un
type sockaddr_un = struct {
u8 sun_len
u8 sun_family
// char sun_path[108];
arr<u8,108> sun_path
}