diff options
| author | hryx <codroid@gmail.com> | 2019-05-27 17:24:21 -0700 |
|---|---|---|
| committer | hryx <codroid@gmail.com> | 2019-05-27 17:24:21 -0700 |
| commit | e1f3eec9cc05535b3f3b81f2fb7cd65dd4d1e841 (patch) | |
| tree | 5f408ed68a686491eaf759f9cbba02beac829b38 /std/os/linux | |
| parent | 2aa1c5da5dded6b1b346c3a1b57443f2c459ebe9 (diff) | |
| parent | 3fccc0747903f0726d6cc8ee73832cb62f1304bb (diff) | |
| download | zig-e1f3eec9cc05535b3f3b81f2fb7cd65dd4d1e841.tar.gz zig-e1f3eec9cc05535b3f3b81f2fb7cd65dd4d1e841.zip | |
Merge branch 'master' into translate-c-userland
Diffstat (limited to 'std/os/linux')
| -rw-r--r-- | std/os/linux/arm64.zig | 403 | ||||
| -rw-r--r-- | std/os/linux/errno.zig | 427 | ||||
| -rw-r--r-- | std/os/linux/test.zig | 2 | ||||
| -rw-r--r-- | std/os/linux/tls.zig | 17 | ||||
| -rw-r--r-- | std/os/linux/vdso.zig | 7 | ||||
| -rw-r--r-- | std/os/linux/x86_64.zig | 470 |
6 files changed, 16 insertions, 1310 deletions
diff --git a/std/os/linux/arm64.zig b/std/os/linux/arm64.zig index d752166280..94cf8818de 100644 --- a/std/os/linux/arm64.zig +++ b/std/os/linux/arm64.zig @@ -1,344 +1,3 @@ -const std = @import("../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; - -pub const SYS_io_setup = 0; -pub const SYS_io_destroy = 1; -pub const SYS_io_submit = 2; -pub const SYS_io_cancel = 3; -pub const SYS_io_getevents = 4; -pub const SYS_setxattr = 5; -pub const SYS_lsetxattr = 6; -pub const SYS_fsetxattr = 7; -pub const SYS_getxattr = 8; -pub const SYS_lgetxattr = 9; -pub const SYS_fgetxattr = 10; -pub const SYS_listxattr = 11; -pub const SYS_llistxattr = 12; -pub const SYS_flistxattr = 13; -pub const SYS_removexattr = 14; -pub const SYS_lremovexattr = 15; -pub const SYS_fremovexattr = 16; -pub const SYS_getcwd = 17; -pub const SYS_lookup_dcookie = 18; -pub const SYS_eventfd2 = 19; -pub const SYS_epoll_create1 = 20; -pub const SYS_epoll_ctl = 21; -pub const SYS_epoll_pwait = 22; -pub const SYS_dup = 23; -pub const SYS_dup3 = 24; -pub const SYS_fcntl = 25; -pub const SYS_inotify_init1 = 26; -pub const SYS_inotify_add_watch = 27; -pub const SYS_inotify_rm_watch = 28; -pub const SYS_ioctl = 29; -pub const SYS_ioprio_set = 30; -pub const SYS_ioprio_get = 31; -pub const SYS_flock = 32; -pub const SYS_mknodat = 33; -pub const SYS_mkdirat = 34; -pub const SYS_unlinkat = 35; -pub const SYS_symlinkat = 36; -pub const SYS_linkat = 37; -pub const SYS_renameat = 38; -pub const SYS_umount2 = 39; -pub const SYS_mount = 40; -pub const SYS_pivot_root = 41; -pub const SYS_nfsservctl = 42; -pub const SYS_statfs = 43; -pub const SYS_fstatfs = 44; -pub const SYS_truncate = 45; -pub const SYS_ftruncate = 46; -pub const SYS_fallocate = 47; -pub const SYS_faccessat = 48; -pub const SYS_chdir = 49; -pub const SYS_fchdir = 50; -pub const SYS_chroot = 51; -pub const SYS_fchmod = 52; -pub const SYS_fchmodat = 53; -pub const SYS_fchownat = 54; -pub const SYS_fchown = 55; -pub const SYS_openat = 56; -pub const SYS_close = 57; -pub const SYS_vhangup = 58; -pub const SYS_pipe2 = 59; -pub const SYS_quotactl = 60; -pub const SYS_getdents64 = 61; -pub const SYS_lseek = 62; -pub const SYS_read = 63; -pub const SYS_write = 64; -pub const SYS_readv = 65; -pub const SYS_writev = 66; -pub const SYS_pread64 = 67; -pub const SYS_pwrite64 = 68; -pub const SYS_preadv = 69; -pub const SYS_pwritev = 70; -pub const SYS_pselect6 = 72; -pub const SYS_ppoll = 73; -pub const SYS_signalfd4 = 74; -pub const SYS_vmsplice = 75; -pub const SYS_splice = 76; -pub const SYS_tee = 77; -pub const SYS_readlinkat = 78; -pub const SYS_fstatat = 79; -pub const SYS_fstat = 80; -pub const SYS_sync = 81; -pub const SYS_fsync = 82; -pub const SYS_fdatasync = 83; -pub const SYS_sync_file_range2 = 84; -pub const SYS_sync_file_range = 84; -pub const SYS_timerfd_create = 85; -pub const SYS_timerfd_settime = 86; -pub const SYS_timerfd_gettime = 87; -pub const SYS_utimensat = 88; -pub const SYS_acct = 89; -pub const SYS_capget = 90; -pub const SYS_capset = 91; -pub const SYS_personality = 92; -pub const SYS_exit = 93; -pub const SYS_exit_group = 94; -pub const SYS_waitid = 95; -pub const SYS_set_tid_address = 96; -pub const SYS_unshare = 97; -pub const SYS_futex = 98; -pub const SYS_set_robust_list = 99; -pub const SYS_get_robust_list = 100; -pub const SYS_nanosleep = 101; -pub const SYS_getitimer = 102; -pub const SYS_setitimer = 103; -pub const SYS_kexec_load = 104; -pub const SYS_init_module = 105; -pub const SYS_delete_module = 106; -pub const SYS_timer_create = 107; -pub const SYS_timer_gettime = 108; -pub const SYS_timer_getoverrun = 109; -pub const SYS_timer_settime = 110; -pub const SYS_timer_delete = 111; -pub const SYS_clock_settime = 112; -pub const SYS_clock_gettime = 113; -pub const SYS_clock_getres = 114; -pub const SYS_clock_nanosleep = 115; -pub const SYS_syslog = 116; -pub const SYS_ptrace = 117; -pub const SYS_sched_setparam = 118; -pub const SYS_sched_setscheduler = 119; -pub const SYS_sched_getscheduler = 120; -pub const SYS_sched_getparam = 121; -pub const SYS_sched_setaffinity = 122; -pub const SYS_sched_getaffinity = 123; -pub const SYS_sched_yield = 124; -pub const SYS_sched_get_priority_max = 125; -pub const SYS_sched_get_priority_min = 126; -pub const SYS_sched_rr_get_interval = 127; -pub const SYS_restart_syscall = 128; -pub const SYS_kill = 129; -pub const SYS_tkill = 130; -pub const SYS_tgkill = 131; -pub const SYS_sigaltstack = 132; -pub const SYS_rt_sigsuspend = 133; -pub const SYS_rt_sigaction = 134; -pub const SYS_rt_sigprocmask = 135; -pub const SYS_rt_sigpending = 136; -pub const SYS_rt_sigtimedwait = 137; -pub const SYS_rt_sigqueueinfo = 138; -pub const SYS_rt_sigreturn = 139; -pub const SYS_setpriority = 140; -pub const SYS_getpriority = 141; -pub const SYS_reboot = 142; -pub const SYS_setregid = 143; -pub const SYS_setgid = 144; -pub const SYS_setreuid = 145; -pub const SYS_setuid = 146; -pub const SYS_setresuid = 147; -pub const SYS_getresuid = 148; -pub const SYS_setresgid = 149; -pub const SYS_getresgid = 150; -pub const SYS_setfsuid = 151; -pub const SYS_setfsgid = 152; -pub const SYS_times = 153; -pub const SYS_setpgid = 154; -pub const SYS_getpgid = 155; -pub const SYS_getsid = 156; -pub const SYS_setsid = 157; -pub const SYS_getgroups = 158; -pub const SYS_setgroups = 159; -pub const SYS_uname = 160; -pub const SYS_sethostname = 161; -pub const SYS_setdomainname = 162; -pub const SYS_getrlimit = 163; -pub const SYS_setrlimit = 164; -pub const SYS_getrusage = 165; -pub const SYS_umask = 166; -pub const SYS_prctl = 167; -pub const SYS_getcpu = 168; -pub const SYS_gettimeofday = 169; -pub const SYS_settimeofday = 170; -pub const SYS_adjtimex = 171; -pub const SYS_getpid = 172; -pub const SYS_getppid = 173; -pub const SYS_getuid = 174; -pub const SYS_geteuid = 175; -pub const SYS_getgid = 176; -pub const SYS_getegid = 177; -pub const SYS_gettid = 178; -pub const SYS_sysinfo = 179; -pub const SYS_mq_open = 180; -pub const SYS_mq_unlink = 181; -pub const SYS_mq_timedsend = 182; -pub const SYS_mq_timedreceive = 183; -pub const SYS_mq_notify = 184; -pub const SYS_mq_getsetattr = 185; -pub const SYS_msgget = 186; -pub const SYS_msgctl = 187; -pub const SYS_msgrcv = 188; -pub const SYS_msgsnd = 189; -pub const SYS_semget = 190; -pub const SYS_semctl = 191; -pub const SYS_semtimedop = 192; -pub const SYS_semop = 193; -pub const SYS_shmget = 194; -pub const SYS_shmctl = 195; -pub const SYS_shmat = 196; -pub const SYS_shmdt = 197; -pub const SYS_socket = 198; -pub const SYS_socketpair = 199; -pub const SYS_bind = 200; -pub const SYS_listen = 201; -pub const SYS_accept = 202; -pub const SYS_connect = 203; -pub const SYS_getsockname = 204; -pub const SYS_getpeername = 205; -pub const SYS_sendto = 206; -pub const SYS_recvfrom = 207; -pub const SYS_setsockopt = 208; -pub const SYS_getsockopt = 209; -pub const SYS_shutdown = 210; -pub const SYS_sendmsg = 211; -pub const SYS_recvmsg = 212; -pub const SYS_readahead = 213; -pub const SYS_brk = 214; -pub const SYS_munmap = 215; -pub const SYS_mremap = 216; -pub const SYS_add_key = 217; -pub const SYS_request_key = 218; -pub const SYS_keyctl = 219; -pub const SYS_clone = 220; -pub const SYS_execve = 221; -pub const SYS_mmap = 222; -pub const SYS_fadvise64 = 223; -pub const SYS_swapon = 224; -pub const SYS_swapoff = 225; -pub const SYS_mprotect = 226; -pub const SYS_msync = 227; -pub const SYS_mlock = 228; -pub const SYS_munlock = 229; -pub const SYS_mlockall = 230; -pub const SYS_munlockall = 231; -pub const SYS_mincore = 232; -pub const SYS_madvise = 233; -pub const SYS_remap_file_pages = 234; -pub const SYS_mbind = 235; -pub const SYS_get_mempolicy = 236; -pub const SYS_set_mempolicy = 237; -pub const SYS_migrate_pages = 238; -pub const SYS_move_pages = 239; -pub const SYS_rt_tgsigqueueinfo = 240; -pub const SYS_perf_event_open = 241; -pub const SYS_accept4 = 242; -pub const SYS_recvmmsg = 243; -pub const SYS_arch_specific_syscall = 244; -pub const SYS_wait4 = 260; -pub const SYS_prlimit64 = 261; -pub const SYS_fanotify_init = 262; -pub const SYS_fanotify_mark = 263; -pub const SYS_clock_adjtime = 266; -pub const SYS_syncfs = 267; -pub const SYS_setns = 268; -pub const SYS_sendmmsg = 269; -pub const SYS_process_vm_readv = 270; -pub const SYS_process_vm_writev = 271; -pub const SYS_kcmp = 272; -pub const SYS_finit_module = 273; -pub const SYS_sched_setattr = 274; -pub const SYS_sched_getattr = 275; -pub const SYS_renameat2 = 276; -pub const SYS_seccomp = 277; -pub const SYS_getrandom = 278; -pub const SYS_memfd_create = 279; -pub const SYS_bpf = 280; -pub const SYS_execveat = 281; -pub const SYS_userfaultfd = 282; -pub const SYS_membarrier = 283; -pub const SYS_mlock2 = 284; -pub const SYS_copy_file_range = 285; -pub const SYS_preadv2 = 286; -pub const SYS_pwritev2 = 287; -pub const SYS_pkey_mprotect = 288; -pub const SYS_pkey_alloc = 289; -pub const SYS_pkey_free = 290; -pub const SYS_statx = 291; -pub const SYS_io_pgetevents = 292; -pub const SYS_rseq = 293; -pub const SYS_kexec_file_load = 294; -pub const SYS_pidfd_send_signal = 424; -pub const SYS_io_uring_setup = 425; -pub const SYS_io_uring_enter = 426; -pub const SYS_io_uring_register = 427; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const AT_FDCWD = -100; -pub const AT_SYMLINK_NOFOLLOW = 0x100; -pub const AT_REMOVEDIR = 0x200; -pub const AT_SYMLINK_FOLLOW = 0x400; -pub const AT_NO_AUTOMOUNT = 0x800; -pub const AT_EMPTY_PATH = 0x1000; - -pub const VDSO_USEFUL = true; -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.39"; - pub fn syscall0(number: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize) @@ -419,65 +78,3 @@ pub fn syscall6( /// This matches the libc clone function. pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - __pad1: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - __pad1: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t, - msg_flags: i32, -}; - -/// Renamed to Stat to not conflict with the stat function. -pub const Stat = extern struct { - dev: u64, - ino: u64, - nlink: usize, - - mode: u32, - uid: u32, - gid: u32, - __pad0: u32, - rdev: u64, - size: i64, - blksize: isize, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]isize, -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const Elf_Symndx = u32; diff --git a/std/os/linux/errno.zig b/std/os/linux/errno.zig deleted file mode 100644 index 5ad8777f92..0000000000 --- a/std/os/linux/errno.zig +++ /dev/null @@ -1,427 +0,0 @@ -/// Operation not permitted -pub const EPERM = 1; - -/// No such file or directory -pub const ENOENT = 2; - -/// No such process -pub const ESRCH = 3; - -/// Interrupted system call -pub const EINTR = 4; - -/// I/O error -pub const EIO = 5; - -/// No such device or address -pub const ENXIO = 6; - -/// Arg list too long -pub const E2BIG = 7; - -/// Exec format error -pub const ENOEXEC = 8; - -/// Bad file number -pub const EBADF = 9; - -/// No child processes -pub const ECHILD = 10; - -/// Try again -pub const EAGAIN = 11; - -/// Out of memory -pub const ENOMEM = 12; - -/// Permission denied -pub const EACCES = 13; - -/// Bad address -pub const EFAULT = 14; - -/// Block device required -pub const ENOTBLK = 15; - -/// Device or resource busy -pub const EBUSY = 16; - -/// File exists -pub const EEXIST = 17; - -/// Cross-device link -pub const EXDEV = 18; - -/// No such device -pub const ENODEV = 19; - -/// Not a directory -pub const ENOTDIR = 20; - -/// Is a directory -pub const EISDIR = 21; - -/// Invalid argument -pub const EINVAL = 22; - -/// File table overflow -pub const ENFILE = 23; - -/// Too many open files -pub const EMFILE = 24; - -/// Not a typewriter -pub const ENOTTY = 25; - -/// Text file busy -pub const ETXTBSY = 26; - -/// File too large -pub const EFBIG = 27; - -/// No space left on device -pub const ENOSPC = 28; - -/// Illegal seek -pub const ESPIPE = 29; - -/// Read-only file system -pub const EROFS = 30; - -/// Too many links -pub const EMLINK = 31; - -/// Broken pipe -pub const EPIPE = 32; - -/// Math argument out of domain of func -pub const EDOM = 33; - -/// Math result not representable -pub const ERANGE = 34; - -/// Resource deadlock would occur -pub const EDEADLK = 35; - -/// File name too long -pub const ENAMETOOLONG = 36; - -/// No record locks available -pub const ENOLCK = 37; - -/// Function not implemented -pub const ENOSYS = 38; - -/// Directory not empty -pub const ENOTEMPTY = 39; - -/// Too many symbolic links encountered -pub const ELOOP = 40; - -/// Operation would block -pub const EWOULDBLOCK = EAGAIN; - -/// No message of desired type -pub const ENOMSG = 42; - -/// Identifier removed -pub const EIDRM = 43; - -/// Channel number out of range -pub const ECHRNG = 44; - -/// Level 2 not synchronized -pub const EL2NSYNC = 45; - -/// Level 3 halted -pub const EL3HLT = 46; - -/// Level 3 reset -pub const EL3RST = 47; - -/// Link number out of range -pub const ELNRNG = 48; - -/// Protocol driver not attached -pub const EUNATCH = 49; - -/// No CSI structure available -pub const ENOCSI = 50; - -/// Level 2 halted -pub const EL2HLT = 51; - -/// Invalid exchange -pub const EBADE = 52; - -/// Invalid request descriptor -pub const EBADR = 53; - -/// Exchange full -pub const EXFULL = 54; - -/// No anode -pub const ENOANO = 55; - -/// Invalid request code -pub const EBADRQC = 56; - -/// Invalid slot -pub const EBADSLT = 57; - -/// Bad font file format -pub const EBFONT = 59; - -/// Device not a stream -pub const ENOSTR = 60; - -/// No data available -pub const ENODATA = 61; - -/// Timer expired -pub const ETIME = 62; - -/// Out of streams resources -pub const ENOSR = 63; - -/// Machine is not on the network -pub const ENONET = 64; - -/// Package not installed -pub const ENOPKG = 65; - -/// Object is remote -pub const EREMOTE = 66; - -/// Link has been severed -pub const ENOLINK = 67; - -/// Advertise error -pub const EADV = 68; - -/// Srmount error -pub const ESRMNT = 69; - -/// Communication error on send -pub const ECOMM = 70; - -/// Protocol error -pub const EPROTO = 71; - -/// Multihop attempted -pub const EMULTIHOP = 72; - -/// RFS specific error -pub const EDOTDOT = 73; - -/// Not a data message -pub const EBADMSG = 74; - -/// Value too large for defined data type -pub const EOVERFLOW = 75; - -/// Name not unique on network -pub const ENOTUNIQ = 76; - -/// File descriptor in bad state -pub const EBADFD = 77; - -/// Remote address changed -pub const EREMCHG = 78; - -/// Can not access a needed shared library -pub const ELIBACC = 79; - -/// Accessing a corrupted shared library -pub const ELIBBAD = 80; - -/// .lib section in a.out corrupted -pub const ELIBSCN = 81; - -/// Attempting to link in too many shared libraries -pub const ELIBMAX = 82; - -/// Cannot exec a shared library directly -pub const ELIBEXEC = 83; - -/// Illegal byte sequence -pub const EILSEQ = 84; - -/// Interrupted system call should be restarted -pub const ERESTART = 85; - -/// Streams pipe error -pub const ESTRPIPE = 86; - -/// Too many users -pub const EUSERS = 87; - -/// Socket operation on non-socket -pub const ENOTSOCK = 88; - -/// Destination address required -pub const EDESTADDRREQ = 89; - -/// Message too long -pub const EMSGSIZE = 90; - -/// Protocol wrong type for socket -pub const EPROTOTYPE = 91; - -/// Protocol not available -pub const ENOPROTOOPT = 92; - -/// Protocol not supported -pub const EPROTONOSUPPORT = 93; - -/// Socket type not supported -pub const ESOCKTNOSUPPORT = 94; - -/// Operation not supported on transport endpoint -pub const EOPNOTSUPP = 95; - -/// Protocol family not supported -pub const EPFNOSUPPORT = 96; - -/// Address family not supported by protocol -pub const EAFNOSUPPORT = 97; - -/// Address already in use -pub const EADDRINUSE = 98; - -/// Cannot assign requested address -pub const EADDRNOTAVAIL = 99; - -/// Network is down -pub const ENETDOWN = 100; - -/// Network is unreachable -pub const ENETUNREACH = 101; - -/// Network dropped connection because of reset -pub const ENETRESET = 102; - -/// Software caused connection abort -pub const ECONNABORTED = 103; - -/// Connection reset by peer -pub const ECONNRESET = 104; - -/// No buffer space available -pub const ENOBUFS = 105; - -/// Transport endpoint is already connected -pub const EISCONN = 106; - -/// Transport endpoint is not connected -pub const ENOTCONN = 107; - -/// Cannot send after transport endpoint shutdown -pub const ESHUTDOWN = 108; - -/// Too many references: cannot splice -pub const ETOOMANYREFS = 109; - -/// Connection timed out -pub const ETIMEDOUT = 110; - -/// Connection refused -pub const ECONNREFUSED = 111; - -/// Host is down -pub const EHOSTDOWN = 112; - -/// No route to host -pub const EHOSTUNREACH = 113; - -/// Operation already in progress -pub const EALREADY = 114; - -/// Operation now in progress -pub const EINPROGRESS = 115; - -/// Stale NFS file handle -pub const ESTALE = 116; - -/// Structure needs cleaning -pub const EUCLEAN = 117; - -/// Not a XENIX named type file -pub const ENOTNAM = 118; - -/// No XENIX semaphores available -pub const ENAVAIL = 119; - -/// Is a named type file -pub const EISNAM = 120; - -/// Remote I/O error -pub const EREMOTEIO = 121; - -/// Quota exceeded -pub const EDQUOT = 122; - -/// No medium found -pub const ENOMEDIUM = 123; - -/// Wrong medium type -pub const EMEDIUMTYPE = 124; - -// nameserver query return codes - -/// DNS server returned answer with no data -pub const ENSROK = 0; - -/// DNS server returned answer with no data -pub const ENSRNODATA = 160; - -/// DNS server claims query was misformatted -pub const ENSRFORMERR = 161; - -/// DNS server returned general failure -pub const ENSRSERVFAIL = 162; - -/// Domain name not found -pub const ENSRNOTFOUND = 163; - -/// DNS server does not implement requested operation -pub const ENSRNOTIMP = 164; - -/// DNS server refused query -pub const ENSRREFUSED = 165; - -/// Misformatted DNS query -pub const ENSRBADQUERY = 166; - -/// Misformatted domain name -pub const ENSRBADNAME = 167; - -/// Unsupported address family -pub const ENSRBADFAMILY = 168; - -/// Misformatted DNS reply -pub const ENSRBADRESP = 169; - -/// Could not contact DNS servers -pub const ENSRCONNREFUSED = 170; - -/// Timeout while contacting DNS servers -pub const ENSRTIMEOUT = 171; - -/// End of file -pub const ENSROF = 172; - -/// Error reading file -pub const ENSRFILE = 173; - -/// Out of memory -pub const ENSRNOMEM = 174; - -/// Application terminated lookup -pub const ENSRDESTRUCTION = 175; - -/// Domain name is too long -pub const ENSRQUERYDOMAINTOOLONG = 176; - -/// Domain name is too long -pub const ENSRCNAMELOOP = 177; diff --git a/std/os/linux/test.zig b/std/os/linux/test.zig index 1949d00298..c78b071c74 100644 --- a/std/os/linux/test.zig +++ b/std/os/linux/test.zig @@ -11,7 +11,7 @@ test "getpid" { test "timer" { const epoll_fd = linux.epoll_create(); - var err = linux.getErrno(epoll_fd); + var err: usize = linux.getErrno(epoll_fd); expect(err == 0); const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0); diff --git a/std/os/linux/tls.zig b/std/os/linux/tls.zig index 8640e71e62..a10d68663b 100644 --- a/std/os/linux/tls.zig +++ b/std/os/linux/tls.zig @@ -1,6 +1,6 @@ const std = @import("std"); +const os = std.os; const mem = std.mem; -const posix = std.os.posix; const elf = std.elf; const builtin = @import("builtin"); const assert = std.debug.assert; @@ -126,7 +126,7 @@ pub fn initTLS() void { var tls_phdr: ?*elf.Phdr = null; var img_base: usize = 0; - const auxv = std.os.linux_elf_aux_maybe.?; + const auxv = std.os.linux.elf_aux_maybe.?; var at_phent: usize = undefined; var at_phnum: usize = undefined; var at_phdr: usize = undefined; @@ -237,9 +237,14 @@ pub fn allocateTLS(size: usize) usize { return @ptrToInt(&main_thread_tls_buffer); } - const addr = posix.mmap(null, size, posix.PROT_READ | posix.PROT_WRITE, posix.MAP_PRIVATE | posix.MAP_ANONYMOUS, -1, 0); + const slice = os.mmap( + null, + size, + os.PROT_READ | os.PROT_WRITE, + os.MAP_PRIVATE | os.MAP_ANONYMOUS, + -1, + 0, + ) catch @panic("out of memory"); - if (posix.getErrno(addr) != 0) @panic("out of memory"); - - return addr; + return @ptrToInt(slice.ptr); } diff --git a/std/os/linux/vdso.zig b/std/os/linux/vdso.zig index efd69d8542..86d54bfbf8 100644 --- a/std/os/linux/vdso.zig +++ b/std/os/linux/vdso.zig @@ -1,12 +1,11 @@ const std = @import("../../std.zig"); const elf = std.elf; const linux = std.os.linux; -const cstr = std.cstr; const mem = std.mem; const maxInt = std.math.maxInt; pub fn lookup(vername: []const u8, name: []const u8) usize { - const vdso_addr = std.os.linuxGetAuxVal(std.elf.AT_SYSINFO_EHDR); + const vdso_addr = std.os.system.getauxval(std.elf.AT_SYSINFO_EHDR); if (vdso_addr == 0) return 0; const eh = @intToPtr(*elf.Ehdr, vdso_addr); @@ -66,7 +65,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { if (0 == (u32(1) << @intCast(u5, syms[i].st_info & 0xf) & OK_TYPES)) continue; if (0 == (u32(1) << @intCast(u5, syms[i].st_info >> 4) & OK_BINDS)) continue; if (0 == syms[i].st_shndx) continue; - if (!mem.eql(u8, name, cstr.toSliceConst(strings + syms[i].st_name))) continue; + if (!mem.eql(u8, name, mem.toSliceConst(u8, strings + syms[i].st_name))) continue; if (maybe_versym) |versym| { if (!checkver(maybe_verdef.?, versym[i], vername, strings)) continue; @@ -88,5 +87,5 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [ def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next); } const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux); - return mem.eql(u8, vername, cstr.toSliceConst(strings + aux.vda_name)); + return mem.eql(u8, vername, mem.toSliceConst(u8, strings + aux.vda_name)); } diff --git a/std/os/linux/x86_64.zig b/std/os/linux/x86_64.zig index f00a4680a4..fa866cff4c 100644 --- a/std/os/linux/x86_64.zig +++ b/std/os/linux/x86_64.zig @@ -1,410 +1,4 @@ -const std = @import("../../std.zig"); -const linux = std.os.linux; -const sockaddr = linux.sockaddr; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; - -pub const SYS_read = 0; -pub const SYS_write = 1; -pub const SYS_open = 2; -pub const SYS_close = 3; -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_mmap = 9; -pub const SYS_mprotect = 10; -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_sigreturn = 15; -pub const SYS_ioctl = 16; -pub const SYS_pread = 17; -pub const SYS_pwrite = 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_wait4 = 61; -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_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_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_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_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_mkdirat = 258; -pub const SYS_mknodat = 259; -pub const SYS_fchownat = 260; -pub const SYS_futimesat = 261; -pub const SYS_newfstatat = 262; -// https://github.com/ziglang/zig/issues/1439 -pub const SYS_fstatat = 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_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 SYS_copy_file_range = 326; -pub const SYS_preadv2 = 327; -pub const SYS_pwritev2 = 328; -pub const SYS_pkey_mprotect = 329; -pub const SYS_pkey_alloc = 330; -pub const SYS_pkey_free = 331; -pub const SYS_statx = 332; -pub const SYS_io_pgetevents = 333; -pub const SYS_rseq = 334; -pub const SYS_pidfd_send_signal = 424; -pub const SYS_io_uring_setup = 425; -pub const SYS_io_uring_enter = 426; -pub const SYS_io_uring_register = 427; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const AT_FDCWD = -100; -pub const AT_SYMLINK_NOFOLLOW = 0x100; -pub const AT_REMOVEDIR = 0x200; -pub const AT_SYMLINK_FOLLOW = 0x400; -pub const AT_NO_AUTOMOUNT = 0x800; -pub const AT_EMPTY_PATH = 0x1000; - -pub const VDSO_USEFUL = true; -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; -pub const VDSO_GETCPU_SYM = "__vdso_getcpu"; -pub const VDSO_GETCPU_VER = "LINUX_2.6"; - -pub const ARCH_SET_GS = 0x1001; -pub const ARCH_SET_FS = 0x1002; -pub const ARCH_GET_FS = 0x1003; -pub const ARCH_GET_GS = 0x1004; +use @import("../bits.zig"); pub fn syscall0(number: usize) usize { return asm volatile ("syscall" @@ -501,65 +95,3 @@ pub nakedcc fn restore_rt() void { : "rcx", "r11" ); } - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - __pad1: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - __pad1: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t, - msg_flags: i32, -}; - -/// Renamed to Stat to not conflict with the stat function. -pub const Stat = extern struct { - dev: u64, - ino: u64, - nlink: usize, - - mode: u32, - uid: u32, - gid: u32, - __pad0: u32, - rdev: u64, - size: i64, - blksize: isize, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]isize, -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const Elf_Symndx = u32; |
