| author | |
| committer | |
| log | 090f2ffb820ab10773322636d3c940bbfd6028be |
| tree | 7a36bef3a48854cb08cb9bbc6a727212f0ff7858 |
| parent | e540e5b8ec1d90b86d6f41814507e6ae4ae5edd8 |
| parent | df06976e73e37a36009fb5f43c2310ad610a4a2e |
| signature |
Arm support improvement (part 1)10 files changed, 858 insertions(+), 31 deletions(-)
std/debug.zig+3-2| ... | ... | @@ -793,7 +793,7 @@ fn printLineInfo( |
| 793 | 793 | try out_stream.write(GREEN ++ "^" ++ RESET ++ "\n"); |
| 794 | 794 | } |
| 795 | 795 | } else |err| switch (err) { |
| 796 | error.EndOfFile => {}, | |
| 796 | error.EndOfFile, error.FileNotFound => {}, | |
| 797 | 797 | else => return err, |
| 798 | 798 | } |
| 799 | 799 | } else { |
| ... | ... | @@ -1053,7 +1053,8 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo { |
| 1053 | 1053 | S.self_exe_file = try fs.openSelfExe(); |
| 1054 | 1054 | errdefer S.self_exe_file.close(); |
| 1055 | 1055 | |
| 1056 | const self_exe_mmap_len = mem.alignForward(try S.self_exe_file.getEndPos(), mem.page_size); | |
| 1056 | const self_exe_len = math.cast(usize, try S.self_exe_file.getEndPos()) catch return error.DebugInfoTooLarge; | |
| 1057 | const self_exe_mmap_len = mem.alignForward(self_exe_len, mem.page_size); | |
| 1057 | 1058 | const self_exe_mmap = try os.mmap( |
| 1058 | 1059 | null, |
| 1059 | 1060 | self_exe_mmap_len, |
std/fs/file.zig+3-3| ... | ... | @@ -261,9 +261,9 @@ pub const File = struct { |
| 261 | 261 | return Stat{ |
| 262 | 262 | .size = @bitCast(u64, st.size), |
| 263 | 263 | .mode = st.mode, |
| 264 | .atime = atime.tv_sec * std.time.ns_per_s + atime.tv_nsec, | |
| 265 | .mtime = mtime.tv_sec * std.time.ns_per_s + mtime.tv_nsec, | |
| 266 | .ctime = ctime.tv_sec * std.time.ns_per_s + ctime.tv_nsec, | |
| 264 | .atime = i64(atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, | |
| 265 | .mtime = i64(mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec, | |
| 266 | .ctime = i64(ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec, | |
| 267 | 267 | }; |
| 268 | 268 | } |
| 269 | 269 |
std/os/bits/linux.zig+1| ... | ... | @@ -7,6 +7,7 @@ pub usingnamespace @import("linux/errno.zig"); |
| 7 | 7 | pub usingnamespace switch (builtin.arch) { |
| 8 | 8 | .x86_64 => @import("linux/x86_64.zig"), |
| 9 | 9 | .aarch64 => @import("linux/arm64.zig"), |
| 10 | .arm => @import("linux/arm-eabi.zig"), | |
| 10 | 11 | else => struct {}, |
| 11 | 12 | }; |
| 12 | 13 |
std/os/bits/linux/arm-eabi.zig created+571| ... | ... | @@ -0,0 +1,571 @@ |
| 1 | // arm-eabi-specific declarations that are intended to be imported into the POSIX namespace. | |
| 2 | ||
| 3 | const std = @import("../../std.zig"); | |
| 4 | const linux = std.os.linux; | |
| 5 | const socklen_t = linux.socklen_t; | |
| 6 | const iovec = linux.iovec; | |
| 7 | const iovec_const = linux.iovec_const; | |
| 8 | ||
| 9 | pub const SYS_restart_syscall = 0; | |
| 10 | pub const SYS_exit = 1; | |
| 11 | pub const SYS_fork = 2; | |
| 12 | pub const SYS_read = 3; | |
| 13 | pub const SYS_write = 4; | |
| 14 | pub const SYS_open = 5; | |
| 15 | pub const SYS_close = 6; | |
| 16 | pub const SYS_creat = 8; | |
| 17 | pub const SYS_link = 9; | |
| 18 | pub const SYS_unlink = 10; | |
| 19 | pub const SYS_execve = 11; | |
| 20 | pub const SYS_chdir = 12; | |
| 21 | pub const SYS_mknod = 14; | |
| 22 | pub const SYS_chmod = 15; | |
| 23 | pub const SYS_lchown = 16; | |
| 24 | pub const SYS_lseek = 19; | |
| 25 | pub const SYS_getpid = 20; | |
| 26 | pub const SYS_mount = 21; | |
| 27 | pub const SYS_setuid = 23; | |
| 28 | pub const SYS_getuid = 24; | |
| 29 | pub const SYS_ptrace = 26; | |
| 30 | pub const SYS_pause = 29; | |
| 31 | pub const SYS_access = 33; | |
| 32 | pub const SYS_nice = 34; | |
| 33 | pub const SYS_sync = 36; | |
| 34 | pub const SYS_kill = 37; | |
| 35 | pub const SYS_rename = 38; | |
| 36 | pub const SYS_mkdir = 39; | |
| 37 | pub const SYS_rmdir = 40; | |
| 38 | pub const SYS_dup = 41; | |
| 39 | pub const SYS_pipe = 42; | |
| 40 | pub const SYS_times = 43; | |
| 41 | pub const SYS_brk = 45; | |
| 42 | pub const SYS_setgid = 46; | |
| 43 | pub const SYS_getgid = 47; | |
| 44 | pub const SYS_geteuid = 49; | |
| 45 | pub const SYS_getegid = 50; | |
| 46 | pub const SYS_acct = 51; | |
| 47 | pub const SYS_umount2 = 52; | |
| 48 | pub const SYS_ioctl = 54; | |
| 49 | pub const SYS_fcntl = 55; | |
| 50 | pub const SYS_setpgid = 57; | |
| 51 | pub const SYS_umask = 60; | |
| 52 | pub const SYS_chroot = 61; | |
| 53 | pub const SYS_ustat = 62; | |
| 54 | pub const SYS_dup2 = 63; | |
| 55 | pub const SYS_getppid = 64; | |
| 56 | pub const SYS_getpgrp = 65; | |
| 57 | pub const SYS_setsid = 66; | |
| 58 | pub const SYS_sigaction = 67; | |
| 59 | pub const SYS_setreuid = 70; | |
| 60 | pub const SYS_setregid = 71; | |
| 61 | pub const SYS_sigsuspend = 72; | |
| 62 | pub const SYS_sigpending = 73; | |
| 63 | pub const SYS_sethostname = 74; | |
| 64 | pub const SYS_setrlimit = 75; | |
| 65 | pub const SYS_getrusage = 77; | |
| 66 | pub const SYS_gettimeofday = 78; | |
| 67 | pub const SYS_settimeofday = 79; | |
| 68 | pub const SYS_getgroups = 80; | |
| 69 | pub const SYS_setgroups = 81; | |
| 70 | pub const SYS_symlink = 83; | |
| 71 | pub const SYS_readlink = 85; | |
| 72 | pub const SYS_uselib = 86; | |
| 73 | pub const SYS_swapon = 87; | |
| 74 | pub const SYS_reboot = 88; | |
| 75 | pub const SYS_munmap = 91; | |
| 76 | pub const SYS_truncate = 92; | |
| 77 | pub const SYS_ftruncate = 93; | |
| 78 | pub const SYS_fchmod = 94; | |
| 79 | pub const SYS_fchown = 95; | |
| 80 | pub const SYS_getpriority = 96; | |
| 81 | pub const SYS_setpriority = 97; | |
| 82 | pub const SYS_statfs = 99; | |
| 83 | pub const SYS_fstatfs = 100; | |
| 84 | pub const SYS_syslog = 103; | |
| 85 | pub const SYS_setitimer = 104; | |
| 86 | pub const SYS_getitimer = 105; | |
| 87 | pub const SYS_stat = 106; | |
| 88 | pub const SYS_lstat = 107; | |
| 89 | pub const SYS_fstat = 108; | |
| 90 | pub const SYS_vhangup = 111; | |
| 91 | pub const SYS_wait4 = 114; | |
| 92 | pub const SYS_swapoff = 115; | |
| 93 | pub const SYS_sysinfo = 116; | |
| 94 | pub const SYS_fsync = 118; | |
| 95 | pub const SYS_sigreturn = 119; | |
| 96 | pub const SYS_clone = 120; | |
| 97 | pub const SYS_setdomainname = 121; | |
| 98 | pub const SYS_uname = 122; | |
| 99 | pub const SYS_adjtimex = 124; | |
| 100 | pub const SYS_mprotect = 125; | |
| 101 | pub const SYS_sigprocmask = 126; | |
| 102 | pub const SYS_init_module = 128; | |
| 103 | pub const SYS_delete_module = 129; | |
| 104 | pub const SYS_quotactl = 131; | |
| 105 | pub const SYS_getpgid = 132; | |
| 106 | pub const SYS_fchdir = 133; | |
| 107 | pub const SYS_bdflush = 134; | |
| 108 | pub const SYS_sysfs = 135; | |
| 109 | pub const SYS_personality = 136; | |
| 110 | pub const SYS_setfsuid = 138; | |
| 111 | pub const SYS_setfsgid = 139; | |
| 112 | pub const SYS__llseek = 140; | |
| 113 | pub const SYS_getdents = 141; | |
| 114 | pub const SYS__newselect = 142; | |
| 115 | pub const SYS_flock = 143; | |
| 116 | pub const SYS_msync = 144; | |
| 117 | pub const SYS_readv = 145; | |
| 118 | pub const SYS_writev = 146; | |
| 119 | pub const SYS_getsid = 147; | |
| 120 | pub const SYS_fdatasync = 148; | |
| 121 | pub const SYS__sysctl = 149; | |
| 122 | pub const SYS_mlock = 150; | |
| 123 | pub const SYS_munlock = 151; | |
| 124 | pub const SYS_mlockall = 152; | |
| 125 | pub const SYS_munlockall = 153; | |
| 126 | pub const SYS_sched_setparam = 154; | |
| 127 | pub const SYS_sched_getparam = 155; | |
| 128 | pub const SYS_sched_setscheduler = 156; | |
| 129 | pub const SYS_sched_getscheduler = 157; | |
| 130 | pub const SYS_sched_yield = 158; | |
| 131 | pub const SYS_sched_get_priority_max = 159; | |
| 132 | pub const SYS_sched_get_priority_min = 160; | |
| 133 | pub const SYS_sched_rr_get_interval = 161; | |
| 134 | pub const SYS_nanosleep = 162; | |
| 135 | pub const SYS_mremap = 163; | |
| 136 | pub const SYS_setresuid = 164; | |
| 137 | pub const SYS_getresuid = 165; | |
| 138 | pub const SYS_poll = 168; | |
| 139 | pub const SYS_nfsservctl = 169; | |
| 140 | pub const SYS_setresgid = 170; | |
| 141 | pub const SYS_getresgid = 171; | |
| 142 | pub const SYS_prctl = 172; | |
| 143 | pub const SYS_rt_sigreturn = 173; | |
| 144 | pub const SYS_rt_sigaction = 174; | |
| 145 | pub const SYS_rt_sigprocmask = 175; | |
| 146 | pub const SYS_rt_sigpending = 176; | |
| 147 | pub const SYS_rt_sigtimedwait = 177; | |
| 148 | pub const SYS_rt_sigqueueinfo = 178; | |
| 149 | pub const SYS_rt_sigsuspend = 179; | |
| 150 | pub const SYS_pread64 = 180; | |
| 151 | pub const SYS_pwrite64 = 181; | |
| 152 | pub const SYS_chown = 182; | |
| 153 | pub const SYS_getcwd = 183; | |
| 154 | pub const SYS_capget = 184; | |
| 155 | pub const SYS_capset = 185; | |
| 156 | pub const SYS_sigaltstack = 186; | |
| 157 | pub const SYS_sendfile = 187; | |
| 158 | pub const SYS_vfork = 190; | |
| 159 | pub const SYS_ugetrlimit = 191; | |
| 160 | pub const SYS_mmap2 = 192; | |
| 161 | pub const SYS_truncate64 = 193; | |
| 162 | pub const SYS_ftruncate64 = 194; | |
| 163 | pub const SYS_stat64 = 195; | |
| 164 | pub const SYS_lstat64 = 196; | |
| 165 | pub const SYS_fstat64 = 197; | |
| 166 | pub const SYS_lchown32 = 198; | |
| 167 | pub const SYS_getuid32 = 199; | |
| 168 | pub const SYS_getgid32 = 200; | |
| 169 | pub const SYS_geteuid32 = 201; | |
| 170 | pub const SYS_getegid32 = 202; | |
| 171 | pub const SYS_setreuid32 = 203; | |
| 172 | pub const SYS_setregid32 = 204; | |
| 173 | pub const SYS_getgroups32 = 205; | |
| 174 | pub const SYS_setgroups32 = 206; | |
| 175 | pub const SYS_fchown32 = 207; | |
| 176 | pub const SYS_setresuid32 = 208; | |
| 177 | pub const SYS_getresuid32 = 209; | |
| 178 | pub const SYS_setresgid32 = 210; | |
| 179 | pub const SYS_getresgid32 = 211; | |
| 180 | pub const SYS_chown32 = 212; | |
| 181 | pub const SYS_setuid32 = 213; | |
| 182 | pub const SYS_setgid32 = 214; | |
| 183 | pub const SYS_setfsuid32 = 215; | |
| 184 | pub const SYS_setfsgid32 = 216; | |
| 185 | pub const SYS_getdents64 = 217; | |
| 186 | pub const SYS_pivot_root = 218; | |
| 187 | pub const SYS_mincore = 219; | |
| 188 | pub const SYS_madvise = 220; | |
| 189 | pub const SYS_fcntl64 = 221; | |
| 190 | pub const SYS_gettid = 224; | |
| 191 | pub const SYS_readahead = 225; | |
| 192 | pub const SYS_setxattr = 226; | |
| 193 | pub const SYS_lsetxattr = 227; | |
| 194 | pub const SYS_fsetxattr = 228; | |
| 195 | pub const SYS_getxattr = 229; | |
| 196 | pub const SYS_lgetxattr = 230; | |
| 197 | pub const SYS_fgetxattr = 231; | |
| 198 | pub const SYS_listxattr = 232; | |
| 199 | pub const SYS_llistxattr = 233; | |
| 200 | pub const SYS_flistxattr = 234; | |
| 201 | pub const SYS_removexattr = 235; | |
| 202 | pub const SYS_lremovexattr = 236; | |
| 203 | pub const SYS_fremovexattr = 237; | |
| 204 | pub const SYS_tkill = 238; | |
| 205 | pub const SYS_sendfile64 = 239; | |
| 206 | pub const SYS_futex = 240; | |
| 207 | pub const SYS_sched_setaffinity = 241; | |
| 208 | pub const SYS_sched_getaffinity = 242; | |
| 209 | pub const SYS_io_setup = 243; | |
| 210 | pub const SYS_io_destroy = 244; | |
| 211 | pub const SYS_io_getevents = 245; | |
| 212 | pub const SYS_io_submit = 246; | |
| 213 | pub const SYS_io_cancel = 247; | |
| 214 | pub const SYS_exit_group = 248; | |
| 215 | pub const SYS_lookup_dcookie = 249; | |
| 216 | pub const SYS_epoll_create = 250; | |
| 217 | pub const SYS_epoll_ctl = 251; | |
| 218 | pub const SYS_epoll_wait = 252; | |
| 219 | pub const SYS_remap_file_pages = 253; | |
| 220 | pub const SYS_set_tid_address = 256; | |
| 221 | pub const SYS_timer_create = 257; | |
| 222 | pub const SYS_timer_settime = 258; | |
| 223 | pub const SYS_timer_gettime = 259; | |
| 224 | pub const SYS_timer_getoverrun = 260; | |
| 225 | pub const SYS_timer_delete = 261; | |
| 226 | pub const SYS_clock_settime = 262; | |
| 227 | pub const SYS_clock_gettime = 263; | |
| 228 | pub const SYS_clock_getres = 264; | |
| 229 | pub const SYS_clock_nanosleep = 265; | |
| 230 | pub const SYS_statfs64 = 266; | |
| 231 | pub const SYS_fstatfs64 = 267; | |
| 232 | pub const SYS_tgkill = 268; | |
| 233 | pub const SYS_utimes = 269; | |
| 234 | pub const SYS_fadvise64_64 = 270; | |
| 235 | pub const SYS_arm_fadvise64_64 = 270; | |
| 236 | pub const SYS_pciconfig_iobase = 271; | |
| 237 | pub const SYS_pciconfig_read = 272; | |
| 238 | pub const SYS_pciconfig_write = 273; | |
| 239 | pub const SYS_mq_open = 274; | |
| 240 | pub const SYS_mq_unlink = 275; | |
| 241 | pub const SYS_mq_timedsend = 276; | |
| 242 | pub const SYS_mq_timedreceive = 277; | |
| 243 | pub const SYS_mq_notify = 278; | |
| 244 | pub const SYS_mq_getsetattr = 279; | |
| 245 | pub const SYS_waitid = 280; | |
| 246 | pub const SYS_socket = 281; | |
| 247 | pub const SYS_bind = 282; | |
| 248 | pub const SYS_connect = 283; | |
| 249 | pub const SYS_listen = 284; | |
| 250 | pub const SYS_accept = 285; | |
| 251 | pub const SYS_getsockname = 286; | |
| 252 | pub const SYS_getpeername = 287; | |
| 253 | pub const SYS_socketpair = 288; | |
| 254 | pub const SYS_send = 289; | |
| 255 | pub const SYS_sendto = 290; | |
| 256 | pub const SYS_recv = 291; | |
| 257 | pub const SYS_recvfrom = 292; | |
| 258 | pub const SYS_shutdown = 293; | |
| 259 | pub const SYS_setsockopt = 294; | |
| 260 | pub const SYS_getsockopt = 295; | |
| 261 | pub const SYS_sendmsg = 296; | |
| 262 | pub const SYS_recvmsg = 297; | |
| 263 | pub const SYS_semop = 298; | |
| 264 | pub const SYS_semget = 299; | |
| 265 | pub const SYS_semctl = 300; | |
| 266 | pub const SYS_msgsnd = 301; | |
| 267 | pub const SYS_msgrcv = 302; | |
| 268 | pub const SYS_msgget = 303; | |
| 269 | pub const SYS_msgctl = 304; | |
| 270 | pub const SYS_shmat = 305; | |
| 271 | pub const SYS_shmdt = 306; | |
| 272 | pub const SYS_shmget = 307; | |
| 273 | pub const SYS_shmctl = 308; | |
| 274 | pub const SYS_add_key = 309; | |
| 275 | pub const SYS_request_key = 310; | |
| 276 | pub const SYS_keyctl = 311; | |
| 277 | pub const SYS_semtimedop = 312; | |
| 278 | pub const SYS_vserver = 313; | |
| 279 | pub const SYS_ioprio_set = 314; | |
| 280 | pub const SYS_ioprio_get = 315; | |
| 281 | pub const SYS_inotify_init = 316; | |
| 282 | pub const SYS_inotify_add_watch = 317; | |
| 283 | pub const SYS_inotify_rm_watch = 318; | |
| 284 | pub const SYS_mbind = 319; | |
| 285 | pub const SYS_get_mempolicy = 320; | |
| 286 | pub const SYS_set_mempolicy = 321; | |
| 287 | pub const SYS_openat = 322; | |
| 288 | pub const SYS_mkdirat = 323; | |
| 289 | pub const SYS_mknodat = 324; | |
| 290 | pub const SYS_fchownat = 325; | |
| 291 | pub const SYS_futimesat = 326; | |
| 292 | pub const SYS_fstatat64 = 327; | |
| 293 | pub const SYS_unlinkat = 328; | |
| 294 | pub const SYS_renameat = 329; | |
| 295 | pub const SYS_linkat = 330; | |
| 296 | pub const SYS_symlinkat = 331; | |
| 297 | pub const SYS_readlinkat = 332; | |
| 298 | pub const SYS_fchmodat = 333; | |
| 299 | pub const SYS_faccessat = 334; | |
| 300 | pub const SYS_pselect6 = 335; | |
| 301 | pub const SYS_ppoll = 336; | |
| 302 | pub const SYS_unshare = 337; | |
| 303 | pub const SYS_set_robust_list = 338; | |
| 304 | pub const SYS_get_robust_list = 339; | |
| 305 | pub const SYS_splice = 340; | |
| 306 | pub const SYS_sync_file_range2 = 341; | |
| 307 | pub const SYS_arm_sync_file_range = 341; | |
| 308 | pub const SYS_tee = 342; | |
| 309 | pub const SYS_vmsplice = 343; | |
| 310 | pub const SYS_move_pages = 344; | |
| 311 | pub const SYS_getcpu = 345; | |
| 312 | pub const SYS_epoll_pwait = 346; | |
| 313 | pub const SYS_kexec_load = 347; | |
| 314 | pub const SYS_utimensat = 348; | |
| 315 | pub const SYS_signalfd = 349; | |
| 316 | pub const SYS_timerfd_create = 350; | |
| 317 | pub const SYS_eventfd = 351; | |
| 318 | pub const SYS_fallocate = 352; | |
| 319 | pub const SYS_timerfd_settime = 353; | |
| 320 | pub const SYS_timerfd_gettime = 354; | |
| 321 | pub const SYS_signalfd4 = 355; | |
| 322 | pub const SYS_eventfd2 = 356; | |
| 323 | pub const SYS_epoll_create1 = 357; | |
| 324 | pub const SYS_dup3 = 358; | |
| 325 | pub const SYS_pipe2 = 359; | |
| 326 | pub const SYS_inotify_init1 = 360; | |
| 327 | pub const SYS_preadv = 361; | |
| 328 | pub const SYS_pwritev = 362; | |
| 329 | pub const SYS_rt_tgsigqueueinfo = 363; | |
| 330 | pub const SYS_perf_event_open = 364; | |
| 331 | pub const SYS_recvmmsg = 365; | |
| 332 | pub const SYS_accept4 = 366; | |
| 333 | pub const SYS_fanotify_init = 367; | |
| 334 | pub const SYS_fanotify_mark = 368; | |
| 335 | pub const SYS_prlimit64 = 369; | |
| 336 | pub const SYS_name_to_handle_at = 370; | |
| 337 | pub const SYS_open_by_handle_at = 371; | |
| 338 | pub const SYS_clock_adjtime = 372; | |
| 339 | pub const SYS_syncfs = 373; | |
| 340 | pub const SYS_sendmmsg = 374; | |
| 341 | pub const SYS_setns = 375; | |
| 342 | pub const SYS_process_vm_readv = 376; | |
| 343 | pub const SYS_process_vm_writev = 377; | |
| 344 | pub const SYS_kcmp = 378; | |
| 345 | pub const SYS_finit_module = 379; | |
| 346 | pub const SYS_sched_setattr = 380; | |
| 347 | pub const SYS_sched_getattr = 381; | |
| 348 | pub const SYS_renameat2 = 382; | |
| 349 | pub const SYS_seccomp = 383; | |
| 350 | pub const SYS_getrandom = 384; | |
| 351 | pub const SYS_memfd_create = 385; | |
| 352 | pub const SYS_bpf = 386; | |
| 353 | pub const SYS_execveat = 387; | |
| 354 | pub const SYS_userfaultfd = 388; | |
| 355 | pub const SYS_membarrier = 389; | |
| 356 | pub const SYS_mlock2 = 390; | |
| 357 | pub const SYS_copy_file_range = 391; | |
| 358 | pub const SYS_preadv2 = 392; | |
| 359 | pub const SYS_pwritev2 = 393; | |
| 360 | pub const SYS_pkey_mprotect = 394; | |
| 361 | pub const SYS_pkey_alloc = 395; | |
| 362 | pub const SYS_pkey_free = 396; | |
| 363 | pub const SYS_statx = 397; | |
| 364 | pub const SYS_rseq = 398; | |
| 365 | pub const SYS_io_pgetevents = 399; | |
| 366 | pub const SYS_migrate_pages = 400; | |
| 367 | pub const SYS_kexec_file_load = 401; | |
| 368 | pub const SYS_clock_gettime64 = 403; | |
| 369 | pub const SYS_clock_settime64 = 404; | |
| 370 | pub const SYS_clock_adjtime64 = 405; | |
| 371 | pub const SYS_clock_getres_time64 = 406; | |
| 372 | pub const SYS_clock_nanosleep_time64 = 407; | |
| 373 | pub const SYS_timer_gettime64 = 408; | |
| 374 | pub const SYS_timer_settime64 = 409; | |
| 375 | pub const SYS_timerfd_gettime64 = 410; | |
| 376 | pub const SYS_timerfd_settime64 = 411; | |
| 377 | pub const SYS_utimensat_time64 = 412; | |
| 378 | pub const SYS_pselect6_time64 = 413; | |
| 379 | pub const SYS_ppoll_time64 = 414; | |
| 380 | pub const SYS_io_pgetevents_time64 = 416; | |
| 381 | pub const SYS_recvmmsg_time64 = 417; | |
| 382 | pub const SYS_mq_timedsend_time64 = 418; | |
| 383 | pub const SYS_mq_timedreceive_time64 = 419; | |
| 384 | pub const SYS_semtimedop_time64 = 420; | |
| 385 | pub const SYS_rt_sigtimedwait_time64 = 421; | |
| 386 | pub const SYS_futex_time64 = 422; | |
| 387 | pub const SYS_sched_rr_get_interval_time64 = 423; | |
| 388 | pub const SYS_pidfd_send_signal = 424; | |
| 389 | pub const SYS_io_uring_setup = 425; | |
| 390 | pub const SYS_io_uring_enter = 426; | |
| 391 | pub const SYS_io_uring_register = 427; | |
| 392 | ||
| 393 | pub const SYS_breakpoint = 0x0f0001; | |
| 394 | pub const SYS_cacheflush = 0x0f0002; | |
| 395 | pub const SYS_usr26 = 0x0f0003; | |
| 396 | pub const SYS_usr32 = 0x0f0004; | |
| 397 | pub const SYS_set_tls = 0x0f0005; | |
| 398 | pub const SYS_get_tls = 0x0f0006; | |
| 399 | ||
| 400 | pub const MMAP2_UNIT = 4096; | |
| 401 | ||
| 402 | pub const O_CREAT = 0o100; | |
| 403 | pub const O_EXCL = 0o200; | |
| 404 | pub const O_NOCTTY = 0o400; | |
| 405 | pub const O_TRUNC = 0o1000; | |
| 406 | pub const O_APPEND = 0o2000; | |
| 407 | pub const O_NONBLOCK = 0o4000; | |
| 408 | pub const O_DSYNC = 0o10000; | |
| 409 | pub const O_SYNC = 0o4010000; | |
| 410 | pub const O_RSYNC = 0o4010000; | |
| 411 | pub const O_DIRECTORY = 0o40000; | |
| 412 | pub const O_NOFOLLOW = 0o100000; | |
| 413 | pub const O_CLOEXEC = 0o2000000; | |
| 414 | ||
| 415 | pub const O_ASYNC = 0o20000; | |
| 416 | pub const O_DIRECT = 0o200000; | |
| 417 | pub const O_LARGEFILE = 0o400000; | |
| 418 | pub const O_NOATIME = 0o1000000; | |
| 419 | pub const O_PATH = 0o10000000; | |
| 420 | pub const O_TMPFILE = 0o20040000; | |
| 421 | pub const O_NDELAY = O_NONBLOCK; | |
| 422 | ||
| 423 | pub const F_DUPFD = 0; | |
| 424 | pub const F_GETFD = 1; | |
| 425 | pub const F_SETFD = 2; | |
| 426 | pub const F_GETFL = 3; | |
| 427 | pub const F_SETFL = 4; | |
| 428 | ||
| 429 | pub const F_SETOWN = 8; | |
| 430 | pub const F_GETOWN = 9; | |
| 431 | pub const F_SETSIG = 10; | |
| 432 | pub const F_GETSIG = 11; | |
| 433 | ||
| 434 | pub const F_GETLK = 12; | |
| 435 | pub const F_SETLK = 13; | |
| 436 | pub const F_SETLKW = 14; | |
| 437 | ||
| 438 | pub const F_SETOWN_EX = 15; | |
| 439 | pub const F_GETOWN_EX = 16; | |
| 440 | ||
| 441 | pub const F_GETOWNER_UIDS = 17; | |
| 442 | ||
| 443 | /// stack-like segment | |
| 444 | pub const MAP_GROWSDOWN = 0x0100; | |
| 445 | ||
| 446 | /// ETXTBSY | |
| 447 | pub const MAP_DENYWRITE = 0x0800; | |
| 448 | ||
| 449 | /// mark it as an executable | |
| 450 | pub const MAP_EXECUTABLE = 0x1000; | |
| 451 | ||
| 452 | /// pages are locked | |
| 453 | pub const MAP_LOCKED = 0x2000; | |
| 454 | ||
| 455 | /// don't check for reservations | |
| 456 | pub const MAP_NORESERVE = 0x4000; | |
| 457 | ||
| 458 | /// populate (prefault) pagetables | |
| 459 | pub const MAP_POPULATE = 0x8000; | |
| 460 | ||
| 461 | /// do not block on IO | |
| 462 | pub const MAP_NONBLOCK = 0x10000; | |
| 463 | ||
| 464 | /// give out an address that is best suited for process/thread stacks | |
| 465 | pub const MAP_STACK = 0x20000; | |
| 466 | ||
| 467 | /// create a huge page mapping | |
| 468 | pub const MAP_HUGETLB = 0x40000; | |
| 469 | ||
| 470 | /// perform synchronous page faults for the mapping | |
| 471 | pub const MAP_SYNC = 0x80000; | |
| 472 | ||
| 473 | pub const VDSO_USEFUL = true; | |
| 474 | pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; | |
| 475 | pub const VDSO_CGT_VER = "LINUX_2.6"; | |
| 476 | ||
| 477 | pub const HWCAP_SWP = 1 << 0; | |
| 478 | pub const HWCAP_HALF = 1 << 1; | |
| 479 | pub const HWCAP_THUMB = 1 << 2; | |
| 480 | pub const HWCAP_26BIT = 1 << 3; | |
| 481 | pub const HWCAP_FAST_MULT = 1 << 4; | |
| 482 | pub const HWCAP_FPA = 1 << 5; | |
| 483 | pub const HWCAP_VFP = 1 << 6; | |
| 484 | pub const HWCAP_EDSP = 1 << 7; | |
| 485 | pub const HWCAP_JAVA = 1 << 8; | |
| 486 | pub const HWCAP_IWMMXT = 1 << 9; | |
| 487 | pub const HWCAP_CRUNCH = 1 << 10; | |
| 488 | pub const HWCAP_THUMBEE = 1 << 11; | |
| 489 | pub const HWCAP_NEON = 1 << 12; | |
| 490 | pub const HWCAP_VFPv3 = 1 << 13; | |
| 491 | pub const HWCAP_VFPv3D16 = 1 << 14; | |
| 492 | pub const HWCAP_TLS = 1 << 15; | |
| 493 | pub const HWCAP_VFPv4 = 1 << 16; | |
| 494 | pub const HWCAP_IDIVA = 1 << 17; | |
| 495 | pub const HWCAP_IDIVT = 1 << 18; | |
| 496 | pub const HWCAP_VFPD32 = 1 << 19; | |
| 497 | pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT; | |
| 498 | pub const HWCAP_LPAE = 1 << 20; | |
| 499 | pub const HWCAP_EVTSTRM = 1 << 21; | |
| 500 | ||
| 501 | pub const msghdr = extern struct { | |
| 502 | msg_name: ?*sockaddr, | |
| 503 | msg_namelen: socklen_t, | |
| 504 | msg_iov: [*]iovec, | |
| 505 | msg_iovlen: i32, | |
| 506 | msg_control: ?*c_void, | |
| 507 | msg_controllen: socklen_t, | |
| 508 | msg_flags: i32, | |
| 509 | }; | |
| 510 | ||
| 511 | pub const msghdr_const = extern struct { | |
| 512 | msg_name: ?*const sockaddr, | |
| 513 | msg_namelen: socklen_t, | |
| 514 | msg_iov: [*]iovec_const, | |
| 515 | msg_iovlen: i32, | |
| 516 | msg_control: ?*c_void, | |
| 517 | msg_controllen: socklen_t, | |
| 518 | msg_flags: i32, | |
| 519 | }; | |
| 520 | ||
| 521 | /// Renamed to Stat to not conflict with the stat function. | |
| 522 | /// atime, mtime, and ctime have functions to return `timespec`, | |
| 523 | /// because although this is a POSIX API, the layout and names of | |
| 524 | /// the structs are inconsistent across operating systems, and | |
| 525 | /// in C, macros are used to hide the differences. Here we use | |
| 526 | /// methods to accomplish this. | |
| 527 | pub const Stat = extern struct { | |
| 528 | dev: u64, | |
| 529 | __dev_padding: u32, | |
| 530 | __ino_truncated: u32, | |
| 531 | mode: u32, | |
| 532 | nlink: u32, | |
| 533 | uid: u32, | |
| 534 | gid: u32, | |
| 535 | rdev: u64, | |
| 536 | __rdev_padding: u32, | |
| 537 | size: i64, | |
| 538 | blksize: i32, | |
| 539 | blocks: u64, | |
| 540 | atim: timespec, | |
| 541 | mtim: timespec, | |
| 542 | ctim: timespec, | |
| 543 | ino: u64, | |
| 544 | ||
| 545 | pub fn atime(self: Stat) timespec { | |
| 546 | return self.atim; | |
| 547 | } | |
| 548 | ||
| 549 | pub fn mtime(self: Stat) timespec { | |
| 550 | return self.mtim; | |
| 551 | } | |
| 552 | ||
| 553 | pub fn ctime(self: Stat) timespec { | |
| 554 | return self.ctim; | |
| 555 | } | |
| 556 | }; | |
| 557 | ||
| 558 | pub const timespec = extern struct { | |
| 559 | tv_sec: i32, | |
| 560 | tv_nsec: i32, | |
| 561 | }; | |
| 562 | ||
| 563 | pub const timeval = extern struct { | |
| 564 | tv_sec: i32, | |
| 565 | tv_usec: i32, | |
| 566 | }; | |
| 567 | ||
| 568 | pub const timezone = extern struct { | |
| 569 | tz_minuteswest: i32, | |
| 570 | tz_dsttime: i32, | |
| 571 | }; |
std/os/linux.zig+132-25| ... | ... | @@ -17,6 +17,7 @@ pub const is_the_target = builtin.os == .linux; |
| 17 | 17 | pub usingnamespace switch (builtin.arch) { |
| 18 | 18 | .x86_64 => @import("linux/x86_64.zig"), |
| 19 | 19 | .aarch64 => @import("linux/arm64.zig"), |
| 20 | .arm => @import("linux/arm-eabi.zig"), | |
| 20 | 21 | else => struct {}, |
| 21 | 22 | }; |
| 22 | 23 | pub usingnamespace @import("bits.zig"); |
| ... | ... | @@ -189,7 +190,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize { |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | 192 | pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize { |
| 192 | return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset)); | |
| 193 | if (@hasDecl(@This(), "SYS_mmap2")) { | |
| 194 | return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, @divTrunc(offset, MMAP2_UNIT))); | |
| 195 | } else { | |
| 196 | return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset)); | |
| 197 | } | |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | 200 | pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize { |
| ... | ... | @@ -205,11 +210,26 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize { |
| 205 | 210 | } |
| 206 | 211 | |
| 207 | 212 | pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize { |
| 208 | return syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset); | |
| 213 | return syscall5( | |
| 214 | SYS_preadv, | |
| 215 | @bitCast(usize, isize(fd)), | |
| 216 | @ptrToInt(iov), | |
| 217 | count, | |
| 218 | @truncate(usize, offset), | |
| 219 | @truncate(usize, offset >> 32), | |
| 220 | ); | |
| 209 | 221 | } |
| 210 | 222 | |
| 211 | 223 | pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize { |
| 212 | return syscall5(SYS_preadv2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags); | |
| 224 | return syscall6( | |
| 225 | SYS_preadv2, | |
| 226 | @bitCast(usize, isize(fd)), | |
| 227 | @ptrToInt(iov), | |
| 228 | count, | |
| 229 | @truncate(usize, offset), | |
| 230 | @truncate(usize, offset >> 32), | |
| 231 | flags | |
| 232 | ); | |
| 213 | 233 | } |
| 214 | 234 | |
| 215 | 235 | pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize { |
| ... | ... | @@ -221,11 +241,26 @@ pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize { |
| 221 | 241 | } |
| 222 | 242 | |
| 223 | 243 | pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) usize { |
| 224 | return syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset); | |
| 244 | return syscall5( | |
| 245 | SYS_pwritev, | |
| 246 | @bitCast(usize, isize(fd)), | |
| 247 | @ptrToInt(iov), | |
| 248 | count, | |
| 249 | @truncate(usize, offset), | |
| 250 | @truncate(usize, offset >> 32), | |
| 251 | ); | |
| 225 | 252 | } |
| 226 | 253 | |
| 227 | 254 | pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize { |
| 228 | return syscall5(SYS_pwritev2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags); | |
| 255 | return syscall6( | |
| 256 | SYS_pwritev2, | |
| 257 | @bitCast(usize, isize(fd)), | |
| 258 | @ptrToInt(iov), | |
| 259 | count, | |
| 260 | @truncate(usize, offset), | |
| 261 | @truncate(usize, offset >> 32), | |
| 262 | flags | |
| 263 | ); | |
| 229 | 264 | } |
| 230 | 265 | |
| 231 | 266 | // TODO https://github.com/ziglang/zig/issues/265 |
| ... | ... | @@ -481,67 +516,123 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { |
| 481 | 516 | } |
| 482 | 517 | |
| 483 | 518 | pub fn setuid(uid: u32) usize { |
| 484 | return syscall1(SYS_setuid, uid); | |
| 519 | if (@hasDecl(@This(), "SYS_setuid32")) { | |
| 520 | return syscall1(SYS_setuid32, uid); | |
| 521 | } else { | |
| 522 | return syscall1(SYS_setuid, uid); | |
| 523 | } | |
| 485 | 524 | } |
| 486 | 525 | |
| 487 | 526 | pub fn setgid(gid: u32) usize { |
| 488 | return syscall1(SYS_setgid, gid); | |
| 527 | if (@hasDecl(@This(), "SYS_setgid32")) { | |
| 528 | return syscall1(SYS_setgid32, gid); | |
| 529 | } else { | |
| 530 | return syscall1(SYS_setgid, gid); | |
| 531 | } | |
| 489 | 532 | } |
| 490 | 533 | |
| 491 | 534 | pub fn setreuid(ruid: u32, euid: u32) usize { |
| 492 | return syscall2(SYS_setreuid, ruid, euid); | |
| 535 | if (@hasDecl(@This(), "SYS_setreuid32")) { | |
| 536 | return syscall2(SYS_setreuid32, ruid, euid); | |
| 537 | } else { | |
| 538 | return syscall2(SYS_setreuid, ruid, euid); | |
| 539 | } | |
| 493 | 540 | } |
| 494 | 541 | |
| 495 | 542 | pub fn setregid(rgid: u32, egid: u32) usize { |
| 496 | return syscall2(SYS_setregid, rgid, egid); | |
| 543 | if (@hasDecl(@This(), "SYS_setregid32")) { | |
| 544 | return syscall2(SYS_setregid32, rgid, egid); | |
| 545 | } else { | |
| 546 | return syscall2(SYS_setregid, rgid, egid); | |
| 547 | } | |
| 497 | 548 | } |
| 498 | 549 | |
| 499 | 550 | pub fn getuid() u32 { |
| 500 | return u32(syscall0(SYS_getuid)); | |
| 551 | if (@hasDecl(@This(), "SYS_getuid32")) { | |
| 552 | return u32(syscall0(SYS_getuid32)); | |
| 553 | } else { | |
| 554 | return u32(syscall0(SYS_getuid)); | |
| 555 | } | |
| 501 | 556 | } |
| 502 | 557 | |
| 503 | 558 | pub fn getgid() u32 { |
| 504 | return u32(syscall0(SYS_getgid)); | |
| 559 | if (@hasDecl(@This(), "SYS_getgid32")) { | |
| 560 | return u32(syscall0(SYS_getgid32)); | |
| 561 | } else { | |
| 562 | return u32(syscall0(SYS_getgid)); | |
| 563 | } | |
| 505 | 564 | } |
| 506 | 565 | |
| 507 | 566 | pub fn geteuid() u32 { |
| 508 | return u32(syscall0(SYS_geteuid)); | |
| 567 | if (@hasDecl(@This(), "SYS_geteuid32")) { | |
| 568 | return u32(syscall0(SYS_geteuid32)); | |
| 569 | } else { | |
| 570 | return u32(syscall0(SYS_geteuid)); | |
| 571 | } | |
| 509 | 572 | } |
| 510 | 573 | |
| 511 | 574 | pub fn getegid() u32 { |
| 512 | return u32(syscall0(SYS_getegid)); | |
| 575 | if (@hasDecl(@This(), "SYS_getegid32")) { | |
| 576 | return u32(syscall0(SYS_getegid32)); | |
| 577 | } else { | |
| 578 | return u32(syscall0(SYS_getegid)); | |
| 579 | } | |
| 513 | 580 | } |
| 514 | 581 | |
| 515 | 582 | pub fn seteuid(euid: u32) usize { |
| 516 | return syscall1(SYS_seteuid, euid); | |
| 583 | return setreuid(std.math.maxInt(u32), euid); | |
| 517 | 584 | } |
| 518 | 585 | |
| 519 | 586 | pub fn setegid(egid: u32) usize { |
| 520 | return syscall1(SYS_setegid, egid); | |
| 587 | return setregid(std.math.maxInt(u32), egid); | |
| 521 | 588 | } |
| 522 | 589 | |
| 523 | 590 | pub fn getresuid(ruid: *u32, euid: *u32, suid: *u32) usize { |
| 524 | return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid)); | |
| 591 | if (@hasDecl(@This(), "SYS_getresuid32")) { | |
| 592 | return syscall3(SYS_getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid)); | |
| 593 | } else { | |
| 594 | return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid)); | |
| 595 | } | |
| 525 | 596 | } |
| 526 | 597 | |
| 527 | 598 | pub fn getresgid(rgid: *u32, egid: *u32, sgid: *u32) usize { |
| 528 | return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid)); | |
| 599 | if (@hasDecl(@This(), "SYS_getresgid32")) { | |
| 600 | return syscall3(SYS_getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid)); | |
| 601 | } else { | |
| 602 | return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid)); | |
| 603 | } | |
| 529 | 604 | } |
| 530 | 605 | |
| 531 | 606 | pub fn setresuid(ruid: u32, euid: u32, suid: u32) usize { |
| 532 | return syscall3(SYS_setresuid, ruid, euid, suid); | |
| 607 | if (@hasDecl(@This(), "SYS_setresuid32")) { | |
| 608 | return syscall3(SYS_setresuid32, ruid, euid, suid); | |
| 609 | } else { | |
| 610 | return syscall3(SYS_setresuid, ruid, euid, suid); | |
| 611 | } | |
| 533 | 612 | } |
| 534 | 613 | |
| 535 | 614 | pub fn setresgid(rgid: u32, egid: u32, sgid: u32) usize { |
| 536 | return syscall3(SYS_setresgid, rgid, egid, sgid); | |
| 615 | if (@hasDecl(@This(), "SYS_setresgid32")) { | |
| 616 | return syscall3(SYS_setresgid32, rgid, egid, sgid); | |
| 617 | } else { | |
| 618 | return syscall3(SYS_setresgid, rgid, egid, sgid); | |
| 619 | } | |
| 537 | 620 | } |
| 538 | 621 | |
| 539 | 622 | pub fn getgroups(size: usize, list: *u32) usize { |
| 540 | return syscall2(SYS_getgroups, size, @ptrToInt(list)); | |
| 623 | if (@hasDecl(@This(), "SYS_getgroups32")) { | |
| 624 | return syscall2(SYS_getgroups32, size, @ptrToInt(list)); | |
| 625 | } else { | |
| 626 | return syscall2(SYS_getgroups, size, @ptrToInt(list)); | |
| 627 | } | |
| 541 | 628 | } |
| 542 | 629 | |
| 543 | 630 | pub fn setgroups(size: usize, list: *const u32) usize { |
| 544 | return syscall2(SYS_setgroups, size, @ptrToInt(list)); | |
| 631 | if (@hasDecl(@This(), "SYS_setgroups32")) { | |
| 632 | return syscall2(SYS_setgroups32, size, @ptrToInt(list)); | |
| 633 | } else { | |
| 634 | return syscall2(SYS_setgroups, size, @ptrToInt(list)); | |
| 635 | } | |
| 545 | 636 | } |
| 546 | 637 | |
| 547 | 638 | pub fn getpid() i32 { |
| ... | ... | @@ -708,22 +799,38 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags: |
| 708 | 799 | } |
| 709 | 800 | |
| 710 | 801 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { |
| 711 | return syscall2(SYS_fstat, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf)); | |
| 802 | if (@hasDecl(@This(), "SYS_fstat64")) { | |
| 803 | return syscall2(SYS_fstat64, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf)); | |
| 804 | } else { | |
| 805 | return syscall2(SYS_fstat, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf)); | |
| 806 | } | |
| 712 | 807 | } |
| 713 | 808 | |
| 714 | 809 | // TODO https://github.com/ziglang/zig/issues/265 |
| 715 | 810 | pub fn stat(pathname: [*]const u8, statbuf: *Stat) usize { |
| 716 | return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 811 | if (@hasDecl(@This(), "SYS_stat64")) { | |
| 812 | return syscall2(SYS_stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 813 | } else { | |
| 814 | return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 815 | } | |
| 717 | 816 | } |
| 718 | 817 | |
| 719 | 818 | // TODO https://github.com/ziglang/zig/issues/265 |
| 720 | 819 | pub fn lstat(pathname: [*]const u8, statbuf: *Stat) usize { |
| 721 | return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 820 | if (@hasDecl(@This(), "SYS_lstat64")) { | |
| 821 | return syscall2(SYS_lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 822 | } else { | |
| 823 | return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf)); | |
| 824 | } | |
| 722 | 825 | } |
| 723 | 826 | |
| 724 | 827 | // TODO https://github.com/ziglang/zig/issues/265 |
| 725 | 828 | pub fn fstatat(dirfd: i32, path: [*]const u8, stat_buf: *Stat, flags: u32) usize { |
| 726 | return syscall4(SYS_fstatat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); | |
| 829 | if (@hasDecl(@This(), "SYS_fstatat64")) { | |
| 830 | return syscall4(SYS_fstatat64, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); | |
| 831 | } else { | |
| 832 | return syscall4(SYS_fstatat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); | |
| 833 | } | |
| 727 | 834 | } |
| 728 | 835 | |
| 729 | 836 | // TODO https://github.com/ziglang/zig/issues/265 |
std/os/linux/arm-eabi.zig created+96| ... | ... | @@ -0,0 +1,96 @@ |
| 1 | pub fn syscall0(number: usize) usize { | |
| 2 | return asm volatile ("svc #0" | |
| 3 | : [ret] "={r0}" (-> usize) | |
| 4 | : [number] "{r7}" (number) | |
| 5 | : "memory" | |
| 6 | ); | |
| 7 | } | |
| 8 | ||
| 9 | pub fn syscall1(number: usize, arg1: usize) usize { | |
| 10 | return asm volatile ("svc #0" | |
| 11 | : [ret] "={r0}" (-> usize) | |
| 12 | : [number] "{r7}" (number), | |
| 13 | [arg1] "{r0}" (arg1) | |
| 14 | : "memory" | |
| 15 | ); | |
| 16 | } | |
| 17 | ||
| 18 | pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | |
| 19 | return asm volatile ("svc #0" | |
| 20 | : [ret] "={r0}" (-> usize) | |
| 21 | : [number] "{r7}" (number), | |
| 22 | [arg1] "{r0}" (arg1), | |
| 23 | [arg2] "{r1}" (arg2) | |
| 24 | : "memory" | |
| 25 | ); | |
| 26 | } | |
| 27 | ||
| 28 | pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | |
| 29 | return asm volatile ("svc #0" | |
| 30 | : [ret] "={r0}" (-> usize) | |
| 31 | : [number] "{r7}" (number), | |
| 32 | [arg1] "{r0}" (arg1), | |
| 33 | [arg2] "{r1}" (arg2), | |
| 34 | [arg3] "{r2}" (arg3) | |
| 35 | : "memory" | |
| 36 | ); | |
| 37 | } | |
| 38 | ||
| 39 | pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | |
| 40 | return asm volatile ("svc #0" | |
| 41 | : [ret] "={r0}" (-> usize) | |
| 42 | : [number] "{r7}" (number), | |
| 43 | [arg1] "{r0}" (arg1), | |
| 44 | [arg2] "{r1}" (arg2), | |
| 45 | [arg3] "{r2}" (arg3), | |
| 46 | [arg4] "{r3}" (arg4) | |
| 47 | : "memory" | |
| 48 | ); | |
| 49 | } | |
| 50 | ||
| 51 | pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | |
| 52 | return asm volatile ("svc #0" | |
| 53 | : [ret] "={r0}" (-> usize) | |
| 54 | : [number] "{r7}" (number), | |
| 55 | [arg1] "{r0}" (arg1), | |
| 56 | [arg2] "{r1}" (arg2), | |
| 57 | [arg3] "{r2}" (arg3), | |
| 58 | [arg4] "{r3}" (arg4), | |
| 59 | [arg5] "{r4}" (arg5) | |
| 60 | : "memory" | |
| 61 | ); | |
| 62 | } | |
| 63 | ||
| 64 | pub fn syscall6( | |
| 65 | number: usize, | |
| 66 | arg1: usize, | |
| 67 | arg2: usize, | |
| 68 | arg3: usize, | |
| 69 | arg4: usize, | |
| 70 | arg5: usize, | |
| 71 | arg6: usize, | |
| 72 | ) usize { | |
| 73 | return asm volatile ("svc #0" | |
| 74 | : [ret] "={r0}" (-> usize) | |
| 75 | : [number] "{r7}" (number), | |
| 76 | [arg1] "{r0}" (arg1), | |
| 77 | [arg2] "{r1}" (arg2), | |
| 78 | [arg3] "{r2}" (arg3), | |
| 79 | [arg4] "{r3}" (arg4), | |
| 80 | [arg5] "{r4}" (arg5), | |
| 81 | [arg6] "{r5}" (arg6) | |
| 82 | : "memory" | |
| 83 | ); | |
| 84 | } | |
| 85 | ||
| 86 | /// This matches the libc clone function. | |
| 87 | pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; | |
| 88 | ||
| 89 | // LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass | |
| 90 | // that to llvm via zig, see https://github.com/ziglang/zig/issues/2883. | |
| 91 | // LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig. | |
| 92 | pub extern fn getThreadPointer() usize { | |
| 93 | return asm volatile("mrc p15, 0, %[ret], c13, c0, 3" | |
| 94 | : [ret] "=r" (-> usize) | |
| 95 | ); | |
| 96 | } | |
| \ No newline at end of file |
std/os/linux/arm64.zig+7| ... | ... | @@ -2,6 +2,7 @@ pub fn syscall0(number: usize) usize { |
| 2 | 2 | return asm volatile ("svc #0" |
| 3 | 3 | : [ret] "={x0}" (-> usize) |
| 4 | 4 | : [number] "{x8}" (number) |
| 5 | : "memory", "cc" | |
| 5 | 6 | ); |
| 6 | 7 | } |
| 7 | 8 | |
| ... | ... | @@ -10,6 +11,7 @@ pub fn syscall1(number: usize, arg1: usize) usize { |
| 10 | 11 | : [ret] "={x0}" (-> usize) |
| 11 | 12 | : [number] "{x8}" (number), |
| 12 | 13 | [arg1] "{x0}" (arg1) |
| 14 | : "memory", "cc" | |
| 13 | 15 | ); |
| 14 | 16 | } |
| 15 | 17 | |
| ... | ... | @@ -19,6 +21,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { |
| 19 | 21 | : [number] "{x8}" (number), |
| 20 | 22 | [arg1] "{x0}" (arg1), |
| 21 | 23 | [arg2] "{x1}" (arg2) |
| 24 | : "memory", "cc" | |
| 22 | 25 | ); |
| 23 | 26 | } |
| 24 | 27 | |
| ... | ... | @@ -29,6 +32,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { |
| 29 | 32 | [arg1] "{x0}" (arg1), |
| 30 | 33 | [arg2] "{x1}" (arg2), |
| 31 | 34 | [arg3] "{x2}" (arg3) |
| 35 | : "memory", "cc" | |
| 32 | 36 | ); |
| 33 | 37 | } |
| 34 | 38 | |
| ... | ... | @@ -40,6 +44,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 40 | 44 | [arg2] "{x1}" (arg2), |
| 41 | 45 | [arg3] "{x2}" (arg3), |
| 42 | 46 | [arg4] "{x3}" (arg4) |
| 47 | : "memory", "cc" | |
| 43 | 48 | ); |
| 44 | 49 | } |
| 45 | 50 | |
| ... | ... | @@ -52,6 +57,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 52 | 57 | [arg3] "{x2}" (arg3), |
| 53 | 58 | [arg4] "{x3}" (arg4), |
| 54 | 59 | [arg5] "{x4}" (arg5) |
| 60 | : "memory", "cc" | |
| 55 | 61 | ); |
| 56 | 62 | } |
| 57 | 63 | |
| ... | ... | @@ -73,6 +79,7 @@ pub fn syscall6( |
| 73 | 79 | [arg4] "{x3}" (arg4), |
| 74 | 80 | [arg5] "{x4}" (arg5), |
| 75 | 81 | [arg6] "{x5}" (arg6) |
| 82 | : "memory", "cc" | |
| 76 | 83 | ); |
| 77 | 84 | } |
| 78 | 85 |
std/os/linux/tls.zig+13| ... | ... | @@ -118,6 +118,9 @@ pub fn setThreadPointer(addr: usize) void { |
| 118 | 118 | : [addr] "r" (addr) |
| 119 | 119 | ); |
| 120 | 120 | }, |
| 121 | .arm => |arm| { | |
| 122 | _ = std.os.linux.syscall1(std.os.linux.SYS_set_tls, addr); | |
| 123 | }, | |
| 121 | 124 | else => @compileError("Unsupported architecture"), |
| 122 | 125 | } |
| 123 | 126 | } |
| ... | ... | @@ -130,6 +133,7 @@ pub fn initTLS() void { |
| 130 | 133 | var at_phent: usize = undefined; |
| 131 | 134 | var at_phnum: usize = undefined; |
| 132 | 135 | var at_phdr: usize = undefined; |
| 136 | var at_hwcap: usize = undefined; | |
| 133 | 137 | |
| 134 | 138 | var i: usize = 0; |
| 135 | 139 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { |
| ... | ... | @@ -137,6 +141,7 @@ pub fn initTLS() void { |
| 137 | 141 | elf.AT_PHENT => at_phent = auxv[i].a_un.a_val, |
| 138 | 142 | elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val, |
| 139 | 143 | elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val, |
| 144 | elf.AT_HWCAP => at_phdr = auxv[i].a_un.a_val, | |
| 140 | 145 | else => continue, |
| 141 | 146 | } |
| 142 | 147 | } |
| ... | ... | @@ -156,6 +161,14 @@ pub fn initTLS() void { |
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | if (tls_phdr) |phdr| { |
| 164 | // If the cpu is arm-based, check if it supports the TLS register | |
| 165 | if (builtin.arch == builtin.Arch.arm and hwcap & std.os.linux.HWCAP_TLS == 0) { | |
| 166 | // If the CPU does not support TLS via a coprocessor register, | |
| 167 | // a kernel helper function can be used instead on certain linux kernels. | |
| 168 | // See linux/arch/arm/include/asm/tls.h and musl/src/thread/arm/__set_thread_area.c. | |
| 169 | @panic("TODO: Implement ARM fallback TLS functionality"); | |
| 170 | } | |
| 171 | ||
| 159 | 172 | // Offsets into the allocated TLS area |
| 160 | 173 | var tcb_offset: usize = undefined; |
| 161 | 174 | var dtv_offset: usize = undefined; |
std/special/c.zig+31| ... | ... | @@ -25,6 +25,8 @@ comptime { |
| 25 | 25 | @export("strncmp", strncmp, .Strong); |
| 26 | 26 | @export("strerror", strerror, .Strong); |
| 27 | 27 | @export("strlen", strlen, .Strong); |
| 28 | } else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) { | |
| 29 | @export("__aeabi_read_tp", std.os.linux.getThreadPointer, .Strong); | |
| 28 | 30 | } |
| 29 | 31 | } |
| 30 | 32 | |
| ... | ... | @@ -238,6 +240,35 @@ nakedcc fn clone() void { |
| 238 | 240 | \\ mov x8,#93 // SYS_exit |
| 239 | 241 | \\ svc #0 |
| 240 | 242 | ); |
| 243 | } else if (builtin.arch == builtin.Arch.arm) { | |
| 244 | asm volatile ( | |
| 245 | \\ stmfd sp!,{r4,r5,r6,r7} | |
| 246 | \\ mov r7,#120 | |
| 247 | \\ mov r6,r3 | |
| 248 | \\ mov r5,r0 | |
| 249 | \\ mov r0,r2 | |
| 250 | \\ and r1,r1,#-16 | |
| 251 | \\ ldr r2,[sp,#16] | |
| 252 | \\ ldr r3,[sp,#20] | |
| 253 | \\ ldr r4,[sp,#24] | |
| 254 | \\ svc 0 | |
| 255 | \\ tst r0,r0 | |
| 256 | \\ beq 1f | |
| 257 | \\ ldmfd sp!,{r4,r5,r6,r7} | |
| 258 | \\ bx lr | |
| 259 | \\ | |
| 260 | \\1: mov r0,r6 | |
| 261 | \\ tst r5,#1 | |
| 262 | \\ bne 1f | |
| 263 | \\ mov lr,pc | |
| 264 | \\ mov pc,r5 | |
| 265 | \\2: mov r7,#1 | |
| 266 | \\ svc 0 | |
| 267 | \\ | |
| 268 | \\1: mov lr,pc | |
| 269 | \\ bx r5 | |
| 270 | \\ b 2b | |
| 271 | ); | |
| 241 | 272 | } else { |
| 242 | 273 | @compileError("Implement clone() for this arch."); |
| 243 | 274 | } |
std/special/start.zig+1-1| ... | ... | @@ -44,7 +44,7 @@ nakedcc fn _start() noreturn { |
| 44 | 44 | : [argc] "={esp}" (-> [*]usize) |
| 45 | 45 | ); |
| 46 | 46 | }, |
| 47 | .aarch64, .aarch64_be => { | |
| 47 | .aarch64, .aarch64_be, .arm => { | |
| 48 | 48 | argc_ptr = asm ("mov %[argc], sp" |
| 49 | 49 | : [argc] "=r" (-> [*]usize) |
| 50 | 50 | ); |