| author | |
| committer | |
| log | 909aae8153e7ac71197bc9f864e4ceb2793317f2 |
| tree | 5da829286b85ef6e79ab9a9536b96b7ab6b33e97 |
| parent | af60931a488ac84030900d14c2ae7d17e0c84891 |
| parent | 891c6ddd5f4aa7a2de79bf5c155ffea71417bb15 |
| signature |
Initial sparc64-linux bringup13 files changed, 952 insertions(+), 29 deletions(-)
lib/std/os/bits/linux.zig+27-6| ... | @@ -19,6 +19,7 @@ pub usingnamespace switch (builtin.arch) { | ... | @@ -19,6 +19,7 @@ pub usingnamespace switch (builtin.arch) { |
| 19 | .aarch64 => @import("linux/arm64.zig"), | 19 | .aarch64 => @import("linux/arm64.zig"), |
| 20 | .arm => @import("linux/arm-eabi.zig"), | 20 | .arm => @import("linux/arm-eabi.zig"), |
| 21 | .riscv64 => @import("linux/riscv64.zig"), | 21 | .riscv64 => @import("linux/riscv64.zig"), |
| 22 | .sparcv9 => @import("linux/sparc64.zig"), | ||
| 22 | .mips, .mipsel => @import("linux/mips.zig"), | 23 | .mips, .mipsel => @import("linux/mips.zig"), |
| 23 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), | 24 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), |
| 24 | else => struct {}, | 25 | else => struct {}, |
| ... | @@ -30,6 +31,7 @@ pub usingnamespace @import("linux/securebits.zig"); | ... | @@ -30,6 +31,7 @@ pub usingnamespace @import("linux/securebits.zig"); |
| 30 | 31 | ||
| 31 | const is_mips = builtin.arch.isMIPS(); | 32 | const is_mips = builtin.arch.isMIPS(); |
| 32 | const is_ppc64 = builtin.arch.isPPC64(); | 33 | const is_ppc64 = builtin.arch.isPPC64(); |
| 34 | const is_sparc = builtin.arch.isSPARC(); | ||
| 33 | 35 | ||
| 34 | pub const pid_t = i32; | 36 | pub const pid_t = i32; |
| 35 | pub const fd_t = i32; | 37 | pub const fd_t = i32; |
| ... | @@ -182,28 +184,47 @@ pub usingnamespace if (is_mips) | ... | @@ -182,28 +184,47 @@ pub usingnamespace if (is_mips) |
| 182 | pub const SA_NOCLDSTOP = 1; | 184 | pub const SA_NOCLDSTOP = 1; |
| 183 | pub const SA_NOCLDWAIT = 0x10000; | 185 | pub const SA_NOCLDWAIT = 0x10000; |
| 184 | pub const SA_SIGINFO = 8; | 186 | pub const SA_SIGINFO = 8; |
| 187 | pub const SA_RESTART = 0x10000000; | ||
| 188 | pub const SA_RESETHAND = 0x80000000; | ||
| 189 | pub const SA_ONSTACK = 0x08000000; | ||
| 190 | pub const SA_NODEFER = 0x40000000; | ||
| 191 | pub const SA_RESTORER = 0x04000000; | ||
| 185 | 192 | ||
| 186 | pub const SIG_BLOCK = 1; | 193 | pub const SIG_BLOCK = 1; |
| 187 | pub const SIG_UNBLOCK = 2; | 194 | pub const SIG_UNBLOCK = 2; |
| 188 | pub const SIG_SETMASK = 3; | 195 | pub const SIG_SETMASK = 3; |
| 189 | } | 196 | } |
| 197 | else if (is_sparc) | ||
| 198 | struct { | ||
| 199 | pub const SA_NOCLDSTOP = 0x8; | ||
| 200 | pub const SA_NOCLDWAIT = 0x100; | ||
| 201 | pub const SA_SIGINFO = 0x200; | ||
| 202 | pub const SA_RESTART = 0x2; | ||
| 203 | pub const SA_RESETHAND = 0x4; | ||
| 204 | pub const SA_ONSTACK = 0x1; | ||
| 205 | pub const SA_NODEFER = 0x20; | ||
| 206 | pub const SA_RESTORER = 0x04000000; | ||
| 207 | |||
| 208 | pub const SIG_BLOCK = 1; | ||
| 209 | pub const SIG_UNBLOCK = 2; | ||
| 210 | pub const SIG_SETMASK = 4; | ||
| 211 | } | ||
| 190 | else | 212 | else |
| 191 | struct { | 213 | struct { |
| 192 | pub const SA_NOCLDSTOP = 1; | 214 | pub const SA_NOCLDSTOP = 1; |
| 193 | pub const SA_NOCLDWAIT = 2; | 215 | pub const SA_NOCLDWAIT = 2; |
| 194 | pub const SA_SIGINFO = 4; | 216 | pub const SA_SIGINFO = 4; |
| 217 | pub const SA_RESTART = 0x10000000; | ||
| 218 | pub const SA_RESETHAND = 0x80000000; | ||
| 219 | pub const SA_ONSTACK = 0x08000000; | ||
| 220 | pub const SA_NODEFER = 0x40000000; | ||
| 221 | pub const SA_RESTORER = 0x04000000; | ||
| 195 | 222 | ||
| 196 | pub const SIG_BLOCK = 0; | 223 | pub const SIG_BLOCK = 0; |
| 197 | pub const SIG_UNBLOCK = 1; | 224 | pub const SIG_UNBLOCK = 1; |
| 198 | pub const SIG_SETMASK = 2; | 225 | pub const SIG_SETMASK = 2; |
| 199 | }; | 226 | }; |
| 200 | 227 | ||
| 201 | pub const SA_ONSTACK = 0x08000000; | ||
| 202 | pub const SA_RESTART = 0x10000000; | ||
| 203 | pub const SA_NODEFER = 0x40000000; | ||
| 204 | pub const SA_RESETHAND = 0x80000000; | ||
| 205 | pub const SA_RESTORER = 0x04000000; | ||
| 206 | |||
| 207 | pub const SIGHUP = 1; | 228 | pub const SIGHUP = 1; |
| 208 | pub const SIGINT = 2; | 229 | pub const SIGINT = 2; |
| 209 | pub const SIGQUIT = 3; | 230 | pub const SIGQUIT = 3; |
lib/std/os/bits/linux/sparc64.zig created+679| ... | @@ -0,0 +1,679 @@ | ||
| 1 | // sparc64-specific declarations that are intended to be imported into the POSIX namespace. | ||
| 2 | const std = @import("../../../std.zig"); | ||
| 3 | const pid_t = linux.pid_t; | ||
| 4 | const uid_t = linux.uid_t; | ||
| 5 | const clock_t = linux.clock_t; | ||
| 6 | const stack_t = linux.stack_t; | ||
| 7 | const sigset_t = linux.sigset_t; | ||
| 8 | |||
| 9 | const linux = std.os.linux; | ||
| 10 | const sockaddr = linux.sockaddr; | ||
| 11 | const socklen_t = linux.socklen_t; | ||
| 12 | const iovec = linux.iovec; | ||
| 13 | const iovec_const = linux.iovec_const; | ||
| 14 | |||
| 15 | pub const SYS = extern enum(usize) { | ||
| 16 | restart_syscall = 0, | ||
| 17 | exit = 1, | ||
| 18 | fork = 2, | ||
| 19 | read = 3, | ||
| 20 | write = 4, | ||
| 21 | open = 5, | ||
| 22 | close = 6, | ||
| 23 | wait4 = 7, | ||
| 24 | creat = 8, | ||
| 25 | link = 9, | ||
| 26 | unlink = 10, | ||
| 27 | execv = 11, | ||
| 28 | chdir = 12, | ||
| 29 | chown = 13, | ||
| 30 | mknod = 14, | ||
| 31 | chmod = 15, | ||
| 32 | lchown = 16, | ||
| 33 | brk = 17, | ||
| 34 | perfctr = 18, | ||
| 35 | lseek = 19, | ||
| 36 | getpid = 20, | ||
| 37 | capget = 21, | ||
| 38 | capset = 22, | ||
| 39 | setuid = 23, | ||
| 40 | getuid = 24, | ||
| 41 | vmsplice = 25, | ||
| 42 | ptrace = 26, | ||
| 43 | alarm = 27, | ||
| 44 | sigaltstack = 28, | ||
| 45 | pause = 29, | ||
| 46 | utime = 30, | ||
| 47 | access = 33, | ||
| 48 | nice = 34, | ||
| 49 | sync = 36, | ||
| 50 | kill = 37, | ||
| 51 | stat = 38, | ||
| 52 | sendfile = 39, | ||
| 53 | lstat = 40, | ||
| 54 | dup = 41, | ||
| 55 | pipe = 42, | ||
| 56 | times = 43, | ||
| 57 | umount2 = 45, | ||
| 58 | setgid = 46, | ||
| 59 | getgid = 47, | ||
| 60 | signal = 48, | ||
| 61 | geteuid = 49, | ||
| 62 | getegid = 50, | ||
| 63 | acct = 51, | ||
| 64 | memory_ordering = 52, | ||
| 65 | ioctl = 54, | ||
| 66 | reboot = 55, | ||
| 67 | symlink = 57, | ||
| 68 | readlink = 58, | ||
| 69 | execve = 59, | ||
| 70 | umask = 60, | ||
| 71 | chroot = 61, | ||
| 72 | fstat = 62, | ||
| 73 | fstat64 = 63, | ||
| 74 | getpagesize = 64, | ||
| 75 | msync = 65, | ||
| 76 | vfork = 66, | ||
| 77 | pread64 = 67, | ||
| 78 | pwrite64 = 68, | ||
| 79 | mmap = 71, | ||
| 80 | munmap = 73, | ||
| 81 | mprotect = 74, | ||
| 82 | madvise = 75, | ||
| 83 | vhangup = 76, | ||
| 84 | mincore = 78, | ||
| 85 | getgroups = 79, | ||
| 86 | setgroups = 80, | ||
| 87 | getpgrp = 81, | ||
| 88 | setitimer = 83, | ||
| 89 | swapon = 85, | ||
| 90 | getitimer = 86, | ||
| 91 | sethostname = 88, | ||
| 92 | dup2 = 90, | ||
| 93 | fcntl = 92, | ||
| 94 | select = 93, | ||
| 95 | fsync = 95, | ||
| 96 | setpriority = 96, | ||
| 97 | socket = 97, | ||
| 98 | connect = 98, | ||
| 99 | accept = 99, | ||
| 100 | getpriority = 100, | ||
| 101 | rt_sigreturn = 101, | ||
| 102 | rt_sigaction = 102, | ||
| 103 | rt_sigprocmask = 103, | ||
| 104 | rt_sigpending = 104, | ||
| 105 | rt_sigtimedwait = 105, | ||
| 106 | rt_sigqueueinfo = 106, | ||
| 107 | rt_sigsuspend = 107, | ||
| 108 | setresuid = 108, | ||
| 109 | getresuid = 109, | ||
| 110 | setresgid = 110, | ||
| 111 | getresgid = 111, | ||
| 112 | recvmsg = 113, | ||
| 113 | sendmsg = 114, | ||
| 114 | gettimeofday = 116, | ||
| 115 | getrusage = 117, | ||
| 116 | getsockopt = 118, | ||
| 117 | getcwd = 119, | ||
| 118 | readv = 120, | ||
| 119 | writev = 121, | ||
| 120 | settimeofday = 122, | ||
| 121 | fchown = 123, | ||
| 122 | fchmod = 124, | ||
| 123 | recvfrom = 125, | ||
| 124 | setreuid = 126, | ||
| 125 | setregid = 127, | ||
| 126 | rename = 128, | ||
| 127 | truncate = 129, | ||
| 128 | ftruncate = 130, | ||
| 129 | flock = 131, | ||
| 130 | lstat64 = 132, | ||
| 131 | sendto = 133, | ||
| 132 | shutdown = 134, | ||
| 133 | socketpair = 135, | ||
| 134 | mkdir = 136, | ||
| 135 | rmdir = 137, | ||
| 136 | utimes = 138, | ||
| 137 | stat64 = 139, | ||
| 138 | sendfile64 = 140, | ||
| 139 | getpeername = 141, | ||
| 140 | futex = 142, | ||
| 141 | gettid = 143, | ||
| 142 | getrlimit = 144, | ||
| 143 | setrlimit = 145, | ||
| 144 | pivot_root = 146, | ||
| 145 | prctl = 147, | ||
| 146 | pciconfig_read = 148, | ||
| 147 | pciconfig_write = 149, | ||
| 148 | getsockname = 150, | ||
| 149 | inotify_init = 151, | ||
| 150 | inotify_add_watch = 152, | ||
| 151 | poll = 153, | ||
| 152 | getdents64 = 154, | ||
| 153 | inotify_rm_watch = 156, | ||
| 154 | statfs = 157, | ||
| 155 | fstatfs = 158, | ||
| 156 | umount = 159, | ||
| 157 | sched_set_affinity = 160, | ||
| 158 | sched_get_affinity = 161, | ||
| 159 | getdomainname = 162, | ||
| 160 | setdomainname = 163, | ||
| 161 | utrap_install = 164, | ||
| 162 | quotactl = 165, | ||
| 163 | set_tid_address = 166, | ||
| 164 | mount = 167, | ||
| 165 | ustat = 168, | ||
| 166 | setxattr = 169, | ||
| 167 | lsetxattr = 170, | ||
| 168 | fsetxattr = 171, | ||
| 169 | getxattr = 172, | ||
| 170 | lgetxattr = 173, | ||
| 171 | getdents = 174, | ||
| 172 | setsid = 175, | ||
| 173 | fchdir = 176, | ||
| 174 | fgetxattr = 177, | ||
| 175 | listxattr = 178, | ||
| 176 | llistxattr = 179, | ||
| 177 | flistxattr = 180, | ||
| 178 | removexattr = 181, | ||
| 179 | lremovexattr = 182, | ||
| 180 | sigpending = 183, | ||
| 181 | query_module = 184, | ||
| 182 | setpgid = 185, | ||
| 183 | fremovexattr = 186, | ||
| 184 | tkill = 187, | ||
| 185 | exit_group = 188, | ||
| 186 | uname = 189, | ||
| 187 | init_module = 190, | ||
| 188 | personality = 191, | ||
| 189 | remap_file_pages = 192, | ||
| 190 | epoll_create = 193, | ||
| 191 | epoll_ctl = 194, | ||
| 192 | epoll_wait = 195, | ||
| 193 | ioprio_set = 196, | ||
| 194 | getppid = 197, | ||
| 195 | sigaction = 198, | ||
| 196 | sgetmask = 199, | ||
| 197 | ssetmask = 200, | ||
| 198 | sigsuspend = 201, | ||
| 199 | oldlstat = 202, | ||
| 200 | uselib = 203, | ||
| 201 | readdir = 204, | ||
| 202 | readahead = 205, | ||
| 203 | socketcall = 206, | ||
| 204 | syslog = 207, | ||
| 205 | lookup_dcookie = 208, | ||
| 206 | fadvise64 = 209, | ||
| 207 | fadvise64_64 = 210, | ||
| 208 | tgkill = 211, | ||
| 209 | waitpid = 212, | ||
| 210 | swapoff = 213, | ||
| 211 | sysinfo = 214, | ||
| 212 | ipc = 215, | ||
| 213 | sigreturn = 216, | ||
| 214 | clone = 217, | ||
| 215 | ioprio_get = 218, | ||
| 216 | adjtimex = 219, | ||
| 217 | sigprocmask = 220, | ||
| 218 | create_module = 221, | ||
| 219 | delete_module = 222, | ||
| 220 | get_kernel_syms = 223, | ||
| 221 | getpgid = 224, | ||
| 222 | bdflush = 225, | ||
| 223 | sysfs = 226, | ||
| 224 | afs_syscall = 227, | ||
| 225 | setfsuid = 228, | ||
| 226 | setfsgid = 229, | ||
| 227 | _newselect = 230, | ||
| 228 | splice = 232, | ||
| 229 | stime = 233, | ||
| 230 | statfs64 = 234, | ||
| 231 | fstatfs64 = 235, | ||
| 232 | _llseek = 236, | ||
| 233 | mlock = 237, | ||
| 234 | munlock = 238, | ||
| 235 | mlockall = 239, | ||
| 236 | munlockall = 240, | ||
| 237 | sched_setparam = 241, | ||
| 238 | sched_getparam = 242, | ||
| 239 | sched_setscheduler = 243, | ||
| 240 | sched_getscheduler = 244, | ||
| 241 | sched_yield = 245, | ||
| 242 | sched_get_priority_max = 246, | ||
| 243 | sched_get_priority_min = 247, | ||
| 244 | sched_rr_get_interval = 248, | ||
| 245 | nanosleep = 249, | ||
| 246 | mremap = 250, | ||
| 247 | _sysctl = 251, | ||
| 248 | getsid = 252, | ||
| 249 | fdatasync = 253, | ||
| 250 | nfsservctl = 254, | ||
| 251 | sync_file_range = 255, | ||
| 252 | clock_settime = 256, | ||
| 253 | clock_gettime = 257, | ||
| 254 | clock_getres = 258, | ||
| 255 | clock_nanosleep = 259, | ||
| 256 | sched_getaffinity = 260, | ||
| 257 | sched_setaffinity = 261, | ||
| 258 | timer_settime = 262, | ||
| 259 | timer_gettime = 263, | ||
| 260 | timer_getoverrun = 264, | ||
| 261 | timer_delete = 265, | ||
| 262 | timer_create = 266, | ||
| 263 | vserver = 267, | ||
| 264 | io_setup = 268, | ||
| 265 | io_destroy = 269, | ||
| 266 | io_submit = 270, | ||
| 267 | io_cancel = 271, | ||
| 268 | io_getevents = 272, | ||
| 269 | mq_open = 273, | ||
| 270 | mq_unlink = 274, | ||
| 271 | mq_timedsend = 275, | ||
| 272 | mq_timedreceive = 276, | ||
| 273 | mq_notify = 277, | ||
| 274 | mq_getsetattr = 278, | ||
| 275 | waitid = 279, | ||
| 276 | tee = 280, | ||
| 277 | add_key = 281, | ||
| 278 | request_key = 282, | ||
| 279 | keyctl = 283, | ||
| 280 | openat = 284, | ||
| 281 | mkdirat = 285, | ||
| 282 | mknodat = 286, | ||
| 283 | fchownat = 287, | ||
| 284 | futimesat = 288, | ||
| 285 | fstatat64 = 289, | ||
| 286 | unlinkat = 290, | ||
| 287 | renameat = 291, | ||
| 288 | linkat = 292, | ||
| 289 | symlinkat = 293, | ||
| 290 | readlinkat = 294, | ||
| 291 | fchmodat = 295, | ||
| 292 | faccessat = 296, | ||
| 293 | pselect6 = 297, | ||
| 294 | ppoll = 298, | ||
| 295 | unshare = 299, | ||
| 296 | set_robust_list = 300, | ||
| 297 | get_robust_list = 301, | ||
| 298 | migrate_pages = 302, | ||
| 299 | mbind = 303, | ||
| 300 | get_mempolicy = 304, | ||
| 301 | set_mempolicy = 305, | ||
| 302 | kexec_load = 306, | ||
| 303 | move_pages = 307, | ||
| 304 | getcpu = 308, | ||
| 305 | epoll_pwait = 309, | ||
| 306 | utimensat = 310, | ||
| 307 | signalfd = 311, | ||
| 308 | timerfd_create = 312, | ||
| 309 | eventfd = 313, | ||
| 310 | fallocate = 314, | ||
| 311 | timerfd_settime = 315, | ||
| 312 | timerfd_gettime = 316, | ||
| 313 | signalfd4 = 317, | ||
| 314 | eventfd2 = 318, | ||
| 315 | epoll_create1 = 319, | ||
| 316 | dup3 = 320, | ||
| 317 | pipe2 = 321, | ||
| 318 | inotify_init1 = 322, | ||
| 319 | accept4 = 323, | ||
| 320 | preadv = 324, | ||
| 321 | pwritev = 325, | ||
| 322 | rt_tgsigqueueinfo = 326, | ||
| 323 | perf_event_open = 327, | ||
| 324 | recvmmsg = 328, | ||
| 325 | fanotify_init = 329, | ||
| 326 | fanotify_mark = 330, | ||
| 327 | prlimit64 = 331, | ||
| 328 | name_to_handle_at = 332, | ||
| 329 | open_by_handle_at = 333, | ||
| 330 | clock_adjtime = 334, | ||
| 331 | syncfs = 335, | ||
| 332 | sendmmsg = 336, | ||
| 333 | setns = 337, | ||
| 334 | process_vm_readv = 338, | ||
| 335 | process_vm_writev = 339, | ||
| 336 | kern_features = 340, | ||
| 337 | kcmp = 341, | ||
| 338 | finit_module = 342, | ||
| 339 | sched_setattr = 343, | ||
| 340 | sched_getattr = 344, | ||
| 341 | renameat2 = 345, | ||
| 342 | seccomp = 346, | ||
| 343 | getrandom = 347, | ||
| 344 | memfd_create = 348, | ||
| 345 | bpf = 349, | ||
| 346 | execveat = 350, | ||
| 347 | membarrier = 351, | ||
| 348 | userfaultfd = 352, | ||
| 349 | bind = 353, | ||
| 350 | listen = 354, | ||
| 351 | setsockopt = 355, | ||
| 352 | mlock2 = 356, | ||
| 353 | copy_file_range = 357, | ||
| 354 | preadv2 = 358, | ||
| 355 | pwritev2 = 359, | ||
| 356 | statx = 360, | ||
| 357 | io_pgetevents = 361, | ||
| 358 | pkey_mprotect = 362, | ||
| 359 | pkey_alloc = 363, | ||
| 360 | pkey_free = 364, | ||
| 361 | rseq = 365, | ||
| 362 | semtimedop = 392, | ||
| 363 | semget = 393, | ||
| 364 | semctl = 394, | ||
| 365 | shmget = 395, | ||
| 366 | shmctl = 396, | ||
| 367 | shmat = 397, | ||
| 368 | shmdt = 398, | ||
| 369 | msgget = 399, | ||
| 370 | msgsnd = 400, | ||
| 371 | msgrcv = 401, | ||
| 372 | msgctl = 402, | ||
| 373 | pidfd_send_signal = 424, | ||
| 374 | io_uring_setup = 425, | ||
| 375 | io_uring_enter = 426, | ||
| 376 | io_uring_register = 427, | ||
| 377 | open_tree = 428, | ||
| 378 | move_mount = 429, | ||
| 379 | fsopen = 430, | ||
| 380 | fsconfig = 431, | ||
| 381 | fsmount = 432, | ||
| 382 | fspick = 433, | ||
| 383 | pidfd_open = 434, | ||
| 384 | openat2 = 437, | ||
| 385 | pidfd_getfd = 438, | ||
| 386 | |||
| 387 | _, | ||
| 388 | }; | ||
| 389 | |||
| 390 | pub const O_CREAT = 0x200; | ||
| 391 | pub const O_EXCL = 0x800; | ||
| 392 | pub const O_NOCTTY = 0x8000; | ||
| 393 | pub const O_TRUNC = 0x400; | ||
| 394 | pub const O_APPEND = 0x8; | ||
| 395 | pub const O_NONBLOCK = 0x4000; | ||
| 396 | pub const O_SYNC = 0x802000; | ||
| 397 | pub const O_DSYNC = 0x2000; | ||
| 398 | pub const O_RSYNC = O_SYNC; | ||
| 399 | pub const O_DIRECTORY = 0x10000; | ||
| 400 | pub const O_NOFOLLOW = 0x20000; | ||
| 401 | pub const O_CLOEXEC = 0x400000; | ||
| 402 | |||
| 403 | pub const O_ASYNC = 0x40; | ||
| 404 | pub const O_DIRECT = 0x100000; | ||
| 405 | pub const O_LARGEFILE = 0; | ||
| 406 | pub const O_NOATIME = 0x200000; | ||
| 407 | pub const O_PATH = 0x1000000; | ||
| 408 | pub const O_TMPFILE = 0x2010000; | ||
| 409 | pub const O_NDELAY = O_NONBLOCK | 0x4; | ||
| 410 | |||
| 411 | pub const F_DUPFD = 0; | ||
| 412 | pub const F_GETFD = 1; | ||
| 413 | pub const F_SETFD = 2; | ||
| 414 | pub const F_GETFL = 3; | ||
| 415 | pub const F_SETFL = 4; | ||
| 416 | |||
| 417 | pub const F_SETOWN = 5; | ||
| 418 | pub const F_GETOWN = 6; | ||
| 419 | pub const F_GETLK = 7; | ||
| 420 | pub const F_SETLK = 8; | ||
| 421 | pub const F_SETLKW = 9; | ||
| 422 | |||
| 423 | pub const F_RDLCK = 1; | ||
| 424 | pub const F_WRLCK = 2; | ||
| 425 | pub const F_UNLCK = 3; | ||
| 426 | |||
| 427 | pub const F_SETOWN_EX = 15; | ||
| 428 | pub const F_GETOWN_EX = 16; | ||
| 429 | |||
| 430 | pub const F_GETOWNER_UIDS = 17; | ||
| 431 | |||
| 432 | pub const LOCK_SH = 1; | ||
| 433 | pub const LOCK_EX = 2; | ||
| 434 | pub const LOCK_NB = 4; | ||
| 435 | pub const LOCK_UN = 8; | ||
| 436 | |||
| 437 | /// stack-like segment | ||
| 438 | pub const MAP_GROWSDOWN = 0x0200; | ||
| 439 | |||
| 440 | /// ETXTBSY | ||
| 441 | pub const MAP_DENYWRITE = 0x0800; | ||
| 442 | |||
| 443 | /// mark it as an executable | ||
| 444 | pub const MAP_EXECUTABLE = 0x1000; | ||
| 445 | |||
| 446 | /// pages are locked | ||
| 447 | pub const MAP_LOCKED = 0x0100; | ||
| 448 | |||
| 449 | /// don't check for reservations | ||
| 450 | pub const MAP_NORESERVE = 0x0040; | ||
| 451 | |||
| 452 | pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; | ||
| 453 | pub const VDSO_CGT_VER = "LINUX_2.6"; | ||
| 454 | |||
| 455 | pub const Flock = extern struct { | ||
| 456 | l_type: i16, | ||
| 457 | l_whence: i16, | ||
| 458 | l_start: off_t, | ||
| 459 | l_len: off_t, | ||
| 460 | l_pid: pid_t, | ||
| 461 | }; | ||
| 462 | |||
| 463 | pub const msghdr = extern struct { | ||
| 464 | msg_name: ?*sockaddr, | ||
| 465 | msg_namelen: socklen_t, | ||
| 466 | msg_iov: [*]iovec, | ||
| 467 | msg_iovlen: u64, | ||
| 468 | msg_control: ?*c_void, | ||
| 469 | msg_controllen: u64, | ||
| 470 | msg_flags: i32, | ||
| 471 | }; | ||
| 472 | |||
| 473 | pub const msghdr_const = extern struct { | ||
| 474 | msg_name: ?*const sockaddr, | ||
| 475 | msg_namelen: socklen_t, | ||
| 476 | msg_iov: [*]iovec_const, | ||
| 477 | msg_iovlen: u64, | ||
| 478 | msg_control: ?*c_void, | ||
| 479 | msg_controllen: u64, | ||
| 480 | msg_flags: i32, | ||
| 481 | }; | ||
| 482 | |||
| 483 | pub const off_t = i64; | ||
| 484 | pub const ino_t = u64; | ||
| 485 | pub const mode_t = u32; | ||
| 486 | |||
| 487 | /// atime, mtime, and ctime have functions to return `timespec`, | ||
| 488 | /// because although this is a POSIX API, the layout and names of | ||
| 489 | /// the structs are inconsistent across operating systems, and | ||
| 490 | /// in C, macros are used to hide the differences. Here we use | ||
| 491 | /// methods to accomplish this. | ||
| 492 | pub const libc_stat = extern struct { | ||
| 493 | dev: u64, | ||
| 494 | ino: ino_t, | ||
| 495 | mode: u32, | ||
| 496 | nlink: usize, | ||
| 497 | |||
| 498 | uid: u32, | ||
| 499 | gid: u32, | ||
| 500 | rdev: u64, | ||
| 501 | __pad0: u32, | ||
| 502 | |||
| 503 | size: off_t, | ||
| 504 | blksize: isize, | ||
| 505 | blocks: i64, | ||
| 506 | |||
| 507 | atim: timespec, | ||
| 508 | mtim: timespec, | ||
| 509 | ctim: timespec, | ||
| 510 | __unused: [2]isize, | ||
| 511 | |||
| 512 | pub fn atime(self: libc_stat) timespec { | ||
| 513 | return self.atim; | ||
| 514 | } | ||
| 515 | |||
| 516 | pub fn mtime(self: libc_stat) timespec { | ||
| 517 | return self.mtim; | ||
| 518 | } | ||
| 519 | |||
| 520 | pub fn ctime(self: libc_stat) timespec { | ||
| 521 | return self.ctim; | ||
| 522 | } | ||
| 523 | }; | ||
| 524 | |||
| 525 | pub const kernel_stat = extern struct { | ||
| 526 | dev: u32, | ||
| 527 | ino: ino_t, | ||
| 528 | mode: mode_t, | ||
| 529 | nlink: i16, | ||
| 530 | |||
| 531 | uid: u32, | ||
| 532 | gid: u32, | ||
| 533 | rdev: u32, | ||
| 534 | |||
| 535 | size: off_t, | ||
| 536 | atim: isize, | ||
| 537 | mtim: isize, | ||
| 538 | ctim: isize, | ||
| 539 | |||
| 540 | blksize: off_t, | ||
| 541 | blocks: off_t, | ||
| 542 | |||
| 543 | __unused4: [2]isize, | ||
| 544 | |||
| 545 | // Hack to make the stdlib not complain about atime | ||
| 546 | // and friends not being a method. | ||
| 547 | // TODO what should tv_nsec be filled with? | ||
| 548 | pub fn atime(self: kernel_stat) timespec { | ||
| 549 | return timespec{.tv_sec=self.atim, .tv_nsec=0}; | ||
| 550 | } | ||
| 551 | |||
| 552 | pub fn mtime(self: kernel_stat) timespec { | ||
| 553 | return timespec{.tv_sec=self.mtim, .tv_nsec=0}; | ||
| 554 | } | ||
| 555 | |||
| 556 | pub fn ctime(self: kernel_stat) timespec { | ||
| 557 | return timespec{.tv_sec=self.ctim, .tv_nsec=0}; | ||
| 558 | } | ||
| 559 | }; | ||
| 560 | |||
| 561 | /// Renamed to Stat to not conflict with the stat function. | ||
| 562 | pub const Stat = if (std.builtin.link_libc) libc_stat else kernel_stat; | ||
| 563 | |||
| 564 | pub const timespec = extern struct { | ||
| 565 | tv_sec: isize, | ||
| 566 | tv_nsec: isize, | ||
| 567 | }; | ||
| 568 | |||
| 569 | pub const timeval = extern struct { | ||
| 570 | tv_sec: isize, | ||
| 571 | tv_usec: isize, | ||
| 572 | }; | ||
| 573 | |||
| 574 | pub const timezone = extern struct { | ||
| 575 | tz_minuteswest: i32, | ||
| 576 | tz_dsttime: i32, | ||
| 577 | }; | ||
| 578 | |||
| 579 | // TODO I'm not sure if the code below is correct, need someone with more | ||
| 580 | // knowledge about sparc64 linux internals to look into. | ||
| 581 | |||
| 582 | pub const Elf_Symndx = u32; | ||
| 583 | |||
| 584 | pub const fpstate = extern struct { | ||
| 585 | regs: [32]u64, | ||
| 586 | fsr: u64, | ||
| 587 | gsr: u64, | ||
| 588 | fprs: u64, | ||
| 589 | }; | ||
| 590 | |||
| 591 | pub const __fpq = extern struct { | ||
| 592 | fpq_addr: *u32, | ||
| 593 | fpq_instr: u32, | ||
| 594 | }; | ||
| 595 | |||
| 596 | pub const __fq = extern struct { | ||
| 597 | FQu: extern union { | ||
| 598 | whole: f64, | ||
| 599 | fpq: __fpq, | ||
| 600 | }, | ||
| 601 | }; | ||
| 602 | |||
| 603 | pub const fpregset_t = extern struct { | ||
| 604 | fpu_fr: extern union { | ||
| 605 | fpu_regs: [32]u32, | ||
| 606 | fpu_dregs: [32]f64, | ||
| 607 | fpu_qregs: [16]c_longdouble, | ||
| 608 | }, | ||
| 609 | fpu_q: *__fq, | ||
| 610 | fpu_fsr: u64, | ||
| 611 | fpu_qcnt: u8, | ||
| 612 | fpu_q_entrysize: u8, | ||
| 613 | fpu_en: u8, | ||
| 614 | }; | ||
| 615 | |||
| 616 | pub const siginfo_fpu_t = extern struct { | ||
| 617 | float_regs: [64]u32, | ||
| 618 | fsr: u64, | ||
| 619 | gsr: u64, | ||
| 620 | fprs: u64, | ||
| 621 | }; | ||
| 622 | |||
| 623 | pub const sigcontext = extern struct { | ||
| 624 | info: [128]i8, | ||
| 625 | regs: extern struct { | ||
| 626 | u_regs: [16]u64, | ||
| 627 | tstate: u64, | ||
| 628 | tpc: u64, | ||
| 629 | tnpc: u64, | ||
| 630 | y: u64, | ||
| 631 | fprs: u64, | ||
| 632 | }, | ||
| 633 | fpu_save: *siginfo_fpu_t, | ||
| 634 | stack: extern struct { | ||
| 635 | sp: usize, | ||
| 636 | flags: i32, | ||
| 637 | size: u64, | ||
| 638 | }, | ||
| 639 | mask: u64, | ||
| 640 | }; | ||
| 641 | |||
| 642 | pub const greg_t = u64; | ||
| 643 | pub const gregset_t = [19]greg_t; | ||
| 644 | |||
| 645 | pub const fq = extern struct { | ||
| 646 | addr: *u64, | ||
| 647 | insn: u32, | ||
| 648 | }; | ||
| 649 | |||
| 650 | pub const fpu_t = extern struct { | ||
| 651 | fregs: extern union { | ||
| 652 | sregs: [32]u32, | ||
| 653 | dregs: [32]u64, | ||
| 654 | qregs: [16]c_longdouble, | ||
| 655 | }, | ||
| 656 | fsr: u64, | ||
| 657 | fprs: u64, | ||
| 658 | gsr: u64, | ||
| 659 | fq: *fq, | ||
| 660 | qcnt: u8, | ||
| 661 | qentsz: u8, | ||
| 662 | enab: u8, | ||
| 663 | }; | ||
| 664 | |||
| 665 | pub const mcontext_t = extern struct { | ||
| 666 | gregs: gregset_t, | ||
| 667 | fp: greg_t, | ||
| 668 | @"i7": greg_t, | ||
| 669 | fpregs: fpu_t, | ||
| 670 | }; | ||
| 671 | |||
| 672 | pub const ucontext_t = extern struct { | ||
| 673 | link: *ucontext_t, | ||
| 674 | flags: u64, | ||
| 675 | sigmask: u64, | ||
| 676 | mcontext: mcontext_t, | ||
| 677 | stack: stack_t, | ||
| 678 | sigmask: sigset_t, | ||
| 679 | }; | ||
lib/std/os/linux.zig+7-2| ... | @@ -24,6 +24,7 @@ pub usingnamespace switch (builtin.arch) { | ... | @@ -24,6 +24,7 @@ pub usingnamespace switch (builtin.arch) { |
| 24 | .aarch64 => @import("linux/arm64.zig"), | 24 | .aarch64 => @import("linux/arm64.zig"), |
| 25 | .arm => @import("linux/arm-eabi.zig"), | 25 | .arm => @import("linux/arm-eabi.zig"), |
| 26 | .riscv64 => @import("linux/riscv64.zig"), | 26 | .riscv64 => @import("linux/riscv64.zig"), |
| 27 | .sparcv9 => @import("linux/sparc64.zig"), | ||
| 27 | .mips, .mipsel => @import("linux/mips.zig"), | 28 | .mips, .mipsel => @import("linux/mips.zig"), |
| 28 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), | 29 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), |
| 29 | else => struct {}, | 30 | else => struct {}, |
| ... | @@ -381,7 +382,7 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { | ... | @@ -381,7 +382,7 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { |
| 381 | } | 382 | } |
| 382 | 383 | ||
| 383 | pub fn pipe(fd: *[2]i32) usize { | 384 | pub fn pipe(fd: *[2]i32) usize { |
| 384 | if (comptime builtin.arch.isMIPS()) { | 385 | if (comptime (builtin.arch.isMIPS() or builtin.arch.isSPARC())) { |
| 385 | return syscall_pipe(fd); | 386 | return syscall_pipe(fd); |
| 386 | } else if (@hasField(SYS, "pipe")) { | 387 | } else if (@hasField(SYS, "pipe")) { |
| 387 | return syscall1(.pipe, @ptrToInt(fd)); | 388 | return syscall1(.pipe, @ptrToInt(fd)); |
| ... | @@ -818,7 +819,11 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti | ... | @@ -818,7 +819,11 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti |
| 818 | var ksa_old: k_sigaction = undefined; | 819 | var ksa_old: k_sigaction = undefined; |
| 819 | const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask)); | 820 | const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask)); |
| 820 | @memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), ksa_mask_size); | 821 | @memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), ksa_mask_size); |
| 821 | const result = syscall4(.rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size); | 822 | const result = switch (builtin.arch) { |
| 823 | // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. | ||
| 824 | .sparc, .sparcv9 => syscall5(.rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), @ptrToInt(ksa.restorer), ksa_mask_size), | ||
| 825 | else => syscall4(.rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size), | ||
| 826 | }; | ||
| 822 | const err = getErrno(result); | 827 | const err = getErrno(result); |
| 823 | if (err != 0) { | 828 | if (err != 0) { |
| 824 | return result; | 829 | return result; |
lib/std/os/linux/sparc64.zig created+153| ... | @@ -0,0 +1,153 @@ | ||
| 1 | usingnamespace @import("../bits.zig"); | ||
| 2 | |||
| 3 | pub fn syscall_pipe(fd: *[2]i32) usize { | ||
| 4 | return asm volatile ( | ||
| 5 | \\ mov %%o0, %%o2 | ||
| 6 | \\ t 0x6d | ||
| 7 | \\ bcc,pt %%xcc, 1f | ||
| 8 | \\ nop | ||
| 9 | \\ ba 2f | ||
| 10 | \\ neg %%o0 | ||
| 11 | \\ 1: | ||
| 12 | \\ st %%o0, [%%o2] | ||
| 13 | \\ st %%o1, [%%o2 + 4] | ||
| 14 | \\ clr %%o0 | ||
| 15 | \\ 2: | ||
| 16 | : [ret] "={o0}" (-> usize) | ||
| 17 | : [number] "{$2}" (@enumToInt(SYS.pipe)) | ||
| 18 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 19 | ); | ||
| 20 | } | ||
| 21 | |||
| 22 | pub fn syscall0(number: SYS) usize { | ||
| 23 | return asm volatile ( | ||
| 24 | \\ t 0x6d | ||
| 25 | \\ bcc,pt %%xcc, 1f | ||
| 26 | \\ nop | ||
| 27 | \\ neg %%o0 | ||
| 28 | \\ 1: | ||
| 29 | : [ret] "={o0}" (-> usize) | ||
| 30 | : [number] "{g1}" (@enumToInt(number)) | ||
| 31 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | |||
| 35 | pub fn syscall1(number: SYS, arg1: usize) usize { | ||
| 36 | return asm volatile ( | ||
| 37 | \\ t 0x6d | ||
| 38 | \\ bcc,pt %%xcc, 1f | ||
| 39 | \\ nop | ||
| 40 | \\ neg %%o0 | ||
| 41 | \\ 1: | ||
| 42 | : [ret] "={o0}" (-> usize) | ||
| 43 | : [number] "{g1}" (@enumToInt(number)), | ||
| 44 | [arg1] "{o0}" (arg1) | ||
| 45 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 46 | ); | ||
| 47 | } | ||
| 48 | |||
| 49 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { | ||
| 50 | return asm volatile ( | ||
| 51 | \\ t 0x6d | ||
| 52 | \\ bcc,pt %%xcc, 1f | ||
| 53 | \\ nop | ||
| 54 | \\ neg %%o0 | ||
| 55 | \\ 1: | ||
| 56 | : [ret] "={o0}" (-> usize) | ||
| 57 | : [number] "{g1}" (@enumToInt(number)), | ||
| 58 | [arg1] "{o0}" (arg1), | ||
| 59 | [arg2] "{o1}" (arg2) | ||
| 60 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 61 | ); | ||
| 62 | } | ||
| 63 | |||
| 64 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { | ||
| 65 | return asm volatile ( | ||
| 66 | \\ t 0x6d | ||
| 67 | \\ bcc,pt %%xcc, 1f | ||
| 68 | \\ nop | ||
| 69 | \\ neg %%o0 | ||
| 70 | \\ 1: | ||
| 71 | : [ret] "={o0}" (-> usize) | ||
| 72 | : [number] "{g1}" (@enumToInt(number)), | ||
| 73 | [arg1] "{o0}" (arg1), | ||
| 74 | [arg2] "{o1}" (arg2), | ||
| 75 | [arg3] "{o2}" (arg3) | ||
| 76 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 77 | ); | ||
| 78 | } | ||
| 79 | |||
| 80 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | ||
| 81 | return asm volatile ( | ||
| 82 | \\ t 0x6d | ||
| 83 | \\ bcc,pt %%xcc, 1f | ||
| 84 | \\ nop | ||
| 85 | \\ neg %%o0 | ||
| 86 | \\ 1: | ||
| 87 | : [ret] "={o0}" (-> usize) | ||
| 88 | : [number] "{g1}" (@enumToInt(number)), | ||
| 89 | [arg1] "{o0}" (arg1), | ||
| 90 | [arg2] "{o1}" (arg2), | ||
| 91 | [arg3] "{o2}" (arg3), | ||
| 92 | [arg4] "{o3}" (arg4) | ||
| 93 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 94 | ); | ||
| 95 | } | ||
| 96 | |||
| 97 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | ||
| 98 | return asm volatile ( | ||
| 99 | \\ t 0x6d | ||
| 100 | \\ bcc,pt %%xcc, 1f | ||
| 101 | \\ nop | ||
| 102 | \\ neg %%o0 | ||
| 103 | \\ 1: | ||
| 104 | : [ret] "={o0}" (-> usize) | ||
| 105 | : [number] "{g1}" (@enumToInt(number)), | ||
| 106 | [arg1] "{o0}" (arg1), | ||
| 107 | [arg2] "{o1}" (arg2), | ||
| 108 | [arg3] "{o2}" (arg3), | ||
| 109 | [arg4] "{o3}" (arg4), | ||
| 110 | [arg5] "{o4}" (arg5), | ||
| 111 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 112 | ); | ||
| 113 | } | ||
| 114 | |||
| 115 | pub fn syscall6( | ||
| 116 | number: SYS, | ||
| 117 | arg1: usize, | ||
| 118 | arg2: usize, | ||
| 119 | arg3: usize, | ||
| 120 | arg4: usize, | ||
| 121 | arg5: usize, | ||
| 122 | arg6: usize, | ||
| 123 | ) usize { | ||
| 124 | return asm volatile ( | ||
| 125 | \\ t 0x6d | ||
| 126 | \\ bcc,pt %%xcc, 1f | ||
| 127 | \\ nop | ||
| 128 | \\ neg %%o0 | ||
| 129 | \\ 1: | ||
| 130 | : [ret] "={o0}" (-> usize) | ||
| 131 | : [number] "{g1}" (@enumToInt(number)), | ||
| 132 | [arg1] "{o0}" (arg1), | ||
| 133 | [arg2] "{o1}" (arg2), | ||
| 134 | [arg3] "{o2}" (arg3), | ||
| 135 | [arg4] "{o3}" (arg4), | ||
| 136 | [arg5] "{o4}" (arg5), | ||
| 137 | [arg6] "{o5}" (arg6), | ||
| 138 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 139 | ); | ||
| 140 | } | ||
| 141 | |||
| 142 | /// This matches the libc clone function. | ||
| 143 | pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; | ||
| 144 | |||
| 145 | pub const restore = restore_rt; | ||
| 146 | |||
| 147 | pub fn restore_rt() callconv(.Naked) void { | ||
| 148 | return asm volatile ("t 0x6d" | ||
| 149 | : | ||
| 150 | : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)) | ||
| 151 | : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7" | ||
| 152 | ); | ||
| 153 | } | ||
lib/std/os/linux/tls.zig+8-1| ... | @@ -54,7 +54,7 @@ const TLSVariant = enum { | ... | @@ -54,7 +54,7 @@ const TLSVariant = enum { |
| 54 | 54 | ||
| 55 | const tls_variant = switch (builtin.arch) { | 55 | const tls_variant = switch (builtin.arch) { |
| 56 | .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => TLSVariant.VariantI, | 56 | .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => TLSVariant.VariantI, |
| 57 | .x86_64, .i386 => TLSVariant.VariantII, | 57 | .x86_64, .i386, .sparcv9 => TLSVariant.VariantII, |
| 58 | else => @compileError("undefined tls_variant for this architecture"), | 58 | else => @compileError("undefined tls_variant for this architecture"), |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| ... | @@ -172,6 +172,13 @@ pub fn setThreadPointer(addr: usize) void { | ... | @@ -172,6 +172,13 @@ pub fn setThreadPointer(addr: usize) void { |
| 172 | : [addr] "r" (addr) | 172 | : [addr] "r" (addr) |
| 173 | ); | 173 | ); |
| 174 | }, | 174 | }, |
| 175 | .sparcv9 => { | ||
| 176 | asm volatile ( | ||
| 177 | \\ mov %[addr], %%g7 | ||
| 178 | : | ||
| 179 | : [addr] "r" (addr) | ||
| 180 | ); | ||
| 181 | }, | ||
| 175 | else => @compileError("Unsupported architecture"), | 182 | else => @compileError("Unsupported architecture"), |
| 176 | } | 183 | } |
| 177 | } | 184 | } |
lib/std/special/c.zig+43-2| ... | @@ -479,7 +479,6 @@ fn clone() callconv(.Naked) void { | ... | @@ -479,7 +479,6 @@ fn clone() callconv(.Naked) void { |
| 479 | \\ syscall | 479 | \\ syscall |
| 480 | ); | 480 | ); |
| 481 | }, | 481 | }, |
| 482 | |||
| 483 | .powerpc64, .powerpc64le => { | 482 | .powerpc64, .powerpc64le => { |
| 484 | asm volatile ( | 483 | asm volatile ( |
| 485 | \\ # store non-volatile regs r30, r31 on stack in order to put our | 484 | \\ # store non-volatile regs r30, r31 on stack in order to put our |
| ... | @@ -528,7 +527,49 @@ fn clone() callconv(.Naked) void { | ... | @@ -528,7 +527,49 @@ fn clone() callconv(.Naked) void { |
| 528 | \\ blr | 527 | \\ blr |
| 529 | ); | 528 | ); |
| 530 | }, | 529 | }, |
| 531 | 530 | .sparcv9 => { | |
| 531 | // __clone(func, stack, flags, arg, ptid, tls, ctid) | ||
| 532 | // i0, i1, i2, i3, i4, i5, sp | ||
| 533 | // syscall(SYS_clone, flags, stack, ptid, tls, ctid) | ||
| 534 | // g1 o0, o1, o2, o3, o4 | ||
| 535 | asm volatile ( | ||
| 536 | \\ save %%sp, -192, %%sp | ||
| 537 | \\ # Save the func pointer and the arg pointer | ||
| 538 | \\ mov %%i0, %%g2 | ||
| 539 | \\ mov %%i3, %%g3 | ||
| 540 | \\ # Shuffle the arguments | ||
| 541 | \\ mov 217, %%g1 | ||
| 542 | \\ mov %%i2, %%o0 | ||
| 543 | \\ sub %%i1, 2047, %%o1 | ||
| 544 | \\ mov %%i4, %%o2 | ||
| 545 | \\ mov %%i5, %%o3 | ||
| 546 | \\ ldx [%%fp + 192 - 2*8 + 2047], %%o4 | ||
| 547 | \\ t 0x6d | ||
| 548 | \\ bcs,pn %%xcc, 2f | ||
| 549 | \\ nop | ||
| 550 | \\ # sparc64 returns the child pid in o0 and a flag telling | ||
| 551 | \\ # whether the process is the child in o1 | ||
| 552 | \\ brnz %%o1, 1f | ||
| 553 | \\ nop | ||
| 554 | \\ # This is the parent process, return the child pid | ||
| 555 | \\ mov %%o0, %%i0 | ||
| 556 | \\ ret | ||
| 557 | \\ restore | ||
| 558 | \\1: | ||
| 559 | \\ # This is the child process | ||
| 560 | \\ mov %%g0, %%fp | ||
| 561 | \\ call %%g2 | ||
| 562 | \\ mov %%g3, %%o0 | ||
| 563 | \\ # Exit | ||
| 564 | \\ mov 1, %%g1 | ||
| 565 | \\ t 0x6d | ||
| 566 | \\2: | ||
| 567 | \\ # The syscall failed | ||
| 568 | \\ sub %%g0, %%o0, %%i0 | ||
| 569 | \\ ret | ||
| 570 | \\ restore | ||
| 571 | ); | ||
| 572 | }, | ||
| 532 | else => @compileError("Implement clone() for this arch."), | 573 | else => @compileError("Implement clone() for this arch."), |
| 533 | } | 574 | } |
| 534 | } | 575 | } |
lib/std/start.zig+17-9| ... | @@ -11,7 +11,7 @@ const builtin = std.builtin; | ... | @@ -11,7 +11,7 @@ const builtin = std.builtin; |
| 11 | const assert = std.debug.assert; | 11 | const assert = std.debug.assert; |
| 12 | const uefi = std.os.uefi; | 12 | const uefi = std.os.uefi; |
| 13 | 13 | ||
| 14 | var starting_stack_ptr: [*]usize = undefined; | 14 | var argc_argv_ptr: [*]usize = undefined; |
| 15 | 15 | ||
| 16 | const start_sym_name = if (builtin.arch.isMIPS()) "__start" else "_start"; | 16 | const start_sym_name = if (builtin.arch.isMIPS()) "__start" else "_start"; |
| 17 | 17 | ||
| ... | @@ -102,26 +102,26 @@ fn _start() callconv(.Naked) noreturn { | ... | @@ -102,26 +102,26 @@ fn _start() callconv(.Naked) noreturn { |
| 102 | 102 | ||
| 103 | switch (builtin.arch) { | 103 | switch (builtin.arch) { |
| 104 | .x86_64 => { | 104 | .x86_64 => { |
| 105 | starting_stack_ptr = asm volatile ( | 105 | argc_argv_ptr = asm volatile ( |
| 106 | \\ xor %%rbp, %%rbp | 106 | \\ xor %%rbp, %%rbp |
| 107 | : [argc] "={rsp}" (-> [*]usize) | 107 | : [argc] "={rsp}" (-> [*]usize) |
| 108 | ); | 108 | ); |
| 109 | }, | 109 | }, |
| 110 | .i386 => { | 110 | .i386 => { |
| 111 | starting_stack_ptr = asm volatile ( | 111 | argc_argv_ptr = asm volatile ( |
| 112 | \\ xor %%ebp, %%ebp | 112 | \\ xor %%ebp, %%ebp |
| 113 | : [argc] "={esp}" (-> [*]usize) | 113 | : [argc] "={esp}" (-> [*]usize) |
| 114 | ); | 114 | ); |
| 115 | }, | 115 | }, |
| 116 | .aarch64, .aarch64_be, .arm, .armeb => { | 116 | .aarch64, .aarch64_be, .arm, .armeb => { |
| 117 | starting_stack_ptr = asm volatile ( | 117 | argc_argv_ptr = asm volatile ( |
| 118 | \\ mov fp, #0 | 118 | \\ mov fp, #0 |
| 119 | \\ mov lr, #0 | 119 | \\ mov lr, #0 |
| 120 | : [argc] "={sp}" (-> [*]usize) | 120 | : [argc] "={sp}" (-> [*]usize) |
| 121 | ); | 121 | ); |
| 122 | }, | 122 | }, |
| 123 | .riscv64 => { | 123 | .riscv64 => { |
| 124 | starting_stack_ptr = asm volatile ( | 124 | argc_argv_ptr = asm volatile ( |
| 125 | \\ li s0, 0 | 125 | \\ li s0, 0 |
| 126 | \\ li ra, 0 | 126 | \\ li ra, 0 |
| 127 | : [argc] "={sp}" (-> [*]usize) | 127 | : [argc] "={sp}" (-> [*]usize) |
| ... | @@ -129,7 +129,7 @@ fn _start() callconv(.Naked) noreturn { | ... | @@ -129,7 +129,7 @@ fn _start() callconv(.Naked) noreturn { |
| 129 | }, | 129 | }, |
| 130 | .mips, .mipsel => { | 130 | .mips, .mipsel => { |
| 131 | // The lr is already zeroed on entry, as specified by the ABI. | 131 | // The lr is already zeroed on entry, as specified by the ABI. |
| 132 | starting_stack_ptr = asm volatile ( | 132 | argc_argv_ptr = asm volatile ( |
| 133 | \\ move $fp, $0 | 133 | \\ move $fp, $0 |
| 134 | : [argc] "={sp}" (-> [*]usize) | 134 | : [argc] "={sp}" (-> [*]usize) |
| 135 | ); | 135 | ); |
| ... | @@ -137,7 +137,7 @@ fn _start() callconv(.Naked) noreturn { | ... | @@ -137,7 +137,7 @@ fn _start() callconv(.Naked) noreturn { |
| 137 | .powerpc64le => { | 137 | .powerpc64le => { |
| 138 | // Setup the initial stack frame and clear the back chain pointer. | 138 | // Setup the initial stack frame and clear the back chain pointer. |
| 139 | // TODO: Support powerpc64 (big endian) on ELFv2. | 139 | // TODO: Support powerpc64 (big endian) on ELFv2. |
| 140 | starting_stack_ptr = asm volatile ( | 140 | argc_argv_ptr = asm volatile ( |
| 141 | \\ mr 4, 1 | 141 | \\ mr 4, 1 |
| 142 | \\ li 0, 0 | 142 | \\ li 0, 0 |
| 143 | \\ stdu 0, -32(1) | 143 | \\ stdu 0, -32(1) |
| ... | @@ -147,6 +147,14 @@ fn _start() callconv(.Naked) noreturn { | ... | @@ -147,6 +147,14 @@ fn _start() callconv(.Naked) noreturn { |
| 147 | : "r0" | 147 | : "r0" |
| 148 | ); | 148 | ); |
| 149 | }, | 149 | }, |
| 150 | .sparcv9 => { | ||
| 151 | // argc is stored after a register window (16 registers) plus stack bias | ||
| 152 | argc_argv_ptr = asm ( | ||
| 153 | \\ mov %%g0, %%i6 | ||
| 154 | \\ add %%o6, 2175, %[argc] | ||
| 155 | : [argc] "=r" (-> [*]usize) | ||
| 156 | ); | ||
| 157 | }, | ||
| 150 | else => @compileError("unsupported arch"), | 158 | else => @compileError("unsupported arch"), |
| 151 | } | 159 | } |
| 152 | // If LLVM inlines stack variables into _start, they will overwrite | 160 | // If LLVM inlines stack variables into _start, they will overwrite |
| ... | @@ -182,8 +190,8 @@ fn posixCallMainAndExit() noreturn { | ... | @@ -182,8 +190,8 @@ fn posixCallMainAndExit() noreturn { |
| 182 | if (builtin.os.tag == .freebsd) { | 190 | if (builtin.os.tag == .freebsd) { |
| 183 | @setAlignStack(16); | 191 | @setAlignStack(16); |
| 184 | } | 192 | } |
| 185 | const argc = starting_stack_ptr[0]; | 193 | const argc = argc_argv_ptr[0]; |
| 186 | const argv = @ptrCast([*][*:0]u8, starting_stack_ptr + 1); | 194 | const argv = @ptrCast([*][*:0]u8, argc_argv_ptr + 1); |
| 187 | 195 | ||
| 188 | const envp_optional = @ptrCast([*:null]?[*:0]u8, @alignCast(@alignOf(usize), argv + argc + 1)); | 196 | const envp_optional = @ptrCast([*:null]?[*:0]u8, @alignCast(@alignOf(usize), argv + argc + 1)); |
| 189 | var envp_count: usize = 0; | 197 | var envp_count: usize = 0; |
lib/std/target.zig+9-1| ... | @@ -761,6 +761,13 @@ pub const Target = struct { | ... | @@ -761,6 +761,13 @@ pub const Target = struct { |
| 761 | }; | 761 | }; |
| 762 | } | 762 | } |
| 763 | 763 | ||
| 764 | pub fn isSPARC(arch: Arch) bool { | ||
| 765 | return switch (arch) { | ||
| 766 | .sparc, .sparcel, .sparcv9 => true, | ||
| 767 | else => false, | ||
| 768 | }; | ||
| 769 | } | ||
| 770 | |||
| 764 | pub fn parseCpuModel(arch: Arch, cpu_name: []const u8) !*const Cpu.Model { | 771 | pub fn parseCpuModel(arch: Arch, cpu_name: []const u8) !*const Cpu.Model { |
| 765 | for (arch.allCpuModels()) |cpu| { | 772 | for (arch.allCpuModels()) |cpu| { |
| 766 | if (mem.eql(u8, cpu_name, cpu.name)) { | 773 | if (mem.eql(u8, cpu_name, cpu.name)) { |
| ... | @@ -1120,7 +1127,8 @@ pub const Target = struct { | ... | @@ -1120,7 +1127,8 @@ pub const Target = struct { |
| 1120 | .amdgcn => &amdgpu.cpu.generic, | 1127 | .amdgcn => &amdgpu.cpu.generic, |
| 1121 | .riscv32 => &riscv.cpu.generic_rv32, | 1128 | .riscv32 => &riscv.cpu.generic_rv32, |
| 1122 | .riscv64 => &riscv.cpu.generic_rv64, | 1129 | .riscv64 => &riscv.cpu.generic_rv64, |
| 1123 | .sparc, .sparcv9, .sparcel => &sparc.cpu.generic, | 1130 | .sparc, .sparcel => &sparc.cpu.v8, |
| 1131 | .sparcv9 => &sparc.cpu.v9, | ||
| 1124 | .s390x => &systemz.cpu.generic, | 1132 | .s390x => &systemz.cpu.generic, |
| 1125 | .i386 => &x86.cpu._i386, | 1133 | .i386 => &x86.cpu._i386, |
| 1126 | .x86_64 => &x86.cpu.x86_64, | 1134 | .x86_64 => &x86.cpu.x86_64, |
lib/std/target/sparc.zig-5| ... | @@ -160,11 +160,6 @@ pub const cpu = struct { | ... | @@ -160,11 +160,6 @@ pub const cpu = struct { |
| 160 | .llvm_name = "f934", | 160 | .llvm_name = "f934", |
| 161 | .features = featureSet(&[_]Feature{}), | 161 | .features = featureSet(&[_]Feature{}), |
| 162 | }; | 162 | }; |
| 163 | pub const generic = CpuModel{ | ||
| 164 | .name = "generic", | ||
| 165 | .llvm_name = "generic", | ||
| 166 | .features = featureSet(&[_]Feature{}), | ||
| 167 | }; | ||
| 168 | pub const gr712rc = CpuModel{ | 163 | pub const gr712rc = CpuModel{ |
| 169 | .name = "gr712rc", | 164 | .name = "gr712rc", |
| 170 | .llvm_name = "gr712rc", | 165 | .llvm_name = "gr712rc", |
src/stage1/analyze.cpp+1| ... | @@ -1016,6 +1016,7 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) { | ... | @@ -1016,6 +1016,7 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) { |
| 1016 | target_is_arm(g->zig_target) || | 1016 | target_is_arm(g->zig_target) || |
| 1017 | target_is_riscv(g->zig_target) || | 1017 | target_is_riscv(g->zig_target) || |
| 1018 | target_is_wasm(g->zig_target) || | 1018 | target_is_wasm(g->zig_target) || |
| 1019 | target_is_sparc(g->zig_target) || | ||
| 1019 | target_is_ppc(g->zig_target)) | 1020 | target_is_ppc(g->zig_target)) |
| 1020 | { | 1021 | { |
| 1021 | X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type); | 1022 | X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type); |
src/stage1/target.cpp+4| ... | @@ -1223,6 +1223,10 @@ bool target_is_riscv(const ZigTarget *target) { | ... | @@ -1223,6 +1223,10 @@ bool target_is_riscv(const ZigTarget *target) { |
| 1223 | return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64; | 1223 | return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64; |
| 1224 | } | 1224 | } |
| 1225 | 1225 | ||
| 1226 | bool target_is_sparc(const ZigTarget *target) { | ||
| 1227 | return target->arch == ZigLLVM_sparc || target->arch == ZigLLVM_sparcv9; | ||
| 1228 | } | ||
| 1229 | |||
| 1226 | bool target_is_mips(const ZigTarget *target) { | 1230 | bool target_is_mips(const ZigTarget *target) { |
| 1227 | return target->arch == ZigLLVM_mips || target->arch == ZigLLVM_mipsel || | 1231 | return target->arch == ZigLLVM_mips || target->arch == ZigLLVM_mipsel || |
| 1228 | target->arch == ZigLLVM_mips64 || target->arch == ZigLLVM_mips64el; | 1232 | target->arch == ZigLLVM_mips64 || target->arch == ZigLLVM_mips64el; |
src/stage1/target.hpp+1| ... | @@ -86,6 +86,7 @@ bool target_is_glibc(const ZigTarget *target); | ... | @@ -86,6 +86,7 @@ bool target_is_glibc(const ZigTarget *target); |
| 86 | bool target_is_musl(const ZigTarget *target); | 86 | bool target_is_musl(const ZigTarget *target); |
| 87 | bool target_is_wasm(const ZigTarget *target); | 87 | bool target_is_wasm(const ZigTarget *target); |
| 88 | bool target_is_riscv(const ZigTarget *target); | 88 | bool target_is_riscv(const ZigTarget *target); |
| 89 | bool target_is_sparc(const ZigTarget *target); | ||
| 89 | bool target_is_android(const ZigTarget *target); | 90 | bool target_is_android(const ZigTarget *target); |
| 90 | bool target_has_debug_info(const ZigTarget *target); | 91 | bool target_has_debug_info(const ZigTarget *target); |
| 91 | const char *target_arch_musl_name(ZigLLVM_ArchType arch); | 92 | const char *target_arch_musl_name(ZigLLVM_ArchType arch); |
test/stack_traces.zig+3-3| ... | @@ -282,10 +282,10 @@ pub fn addCases(cases: *tests.StackTracesContext) void { | ... | @@ -282,10 +282,10 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 282 | \\source.zig:10:8: [address] in main (test) | 282 | \\source.zig:10:8: [address] in main (test) |
| 283 | \\ foo(); | 283 | \\ foo(); |
| 284 | \\ ^ | 284 | \\ ^ |
| 285 | \\start.zig:323:29: [address] in std.start.posixCallMainAndExit (test) | 285 | \\start.zig:331:29: [address] in std.start.posixCallMainAndExit (test) |
| 286 | \\ return root.main(); | 286 | \\ return root.main(); |
| 287 | \\ ^ | 287 | \\ ^ |
| 288 | \\start.zig:154:5: [address] in std.start._start (test) | 288 | \\start.zig:162:5: [address] in std.start._start (test) |
| 289 | \\ @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{}); | 289 | \\ @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{}); |
| 290 | \\ ^ | 290 | \\ ^ |
| 291 | \\ | 291 | \\ |
| ... | @@ -294,7 +294,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { | ... | @@ -294,7 +294,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 294 | switch (std.Target.current.cpu.arch) { | 294 | switch (std.Target.current.cpu.arch) { |
| 295 | .aarch64 => "", // TODO disabled; results in segfault | 295 | .aarch64 => "", // TODO disabled; results in segfault |
| 296 | else => | 296 | else => |
| 297 | \\start.zig:154:5: [address] in std.start._start (test) | 297 | \\start.zig:162:5: [address] in std.start._start (test) |
| 298 | \\ @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{}); | 298 | \\ @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{}); |
| 299 | \\ ^ | 299 | \\ ^ |
| 300 | \\ | 300 | \\ |