authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2020-08-22 14:34:49+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2020-10-24 19:59:04+07:00
logde06b0a635bb865715e60ce1ac3ba336cfe7c385
tree733d475ddbd8126948cf9f512c6f2130aaff95e4
parente5a11020cc838019de12955437b371511b4745e5

Add sparc64 linux bits


2 files changed, 622 insertions(+), 0 deletions(-)

lib/std/os/bits/linux.zig+1
...@@ -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 {},
lib/std/os/bits/linux/sparc64.zig created+621
...@@ -0,0 +1,621 @@
1// sparc64-specific declarations that are intended to be imported into the POSIX namespace.
2const std = @import("../../../std.zig");
3const pid_t = linux.pid_t;
4const uid_t = linux.uid_t;
5const clock_t = linux.clock_t;
6const stack_t = linux.stack_t;
7const sigset_t = linux.sigset_t;
8
9const linux = std.os.linux;
10const sockaddr = linux.sockaddr;
11const socklen_t = linux.socklen_t;
12const iovec = linux.iovec;
13const iovec_const = linux.iovec_const;
14
15pub const mode_t = usize;
16
17pub const SYS = extern enum(usize) {
18 restart_syscall = 0,
19 exit = 1,
20 fork = 2,
21 read = 3,
22 write = 4,
23 open = 5,
24 close = 6,
25 wait4 = 7,
26 creat = 8,
27 link = 9,
28 unlink = 10,
29 execv = 11,
30 chdir = 12,
31 chown = 13,
32 mknod = 14,
33 chmod = 15,
34 lchown = 16,
35 brk = 17,
36 perfctr = 18,
37 lseek = 19,
38 getpid = 20,
39 capget = 21,
40 capset = 22,
41 setuid = 23,
42 getuid = 24,
43 vmsplice = 25,
44 ptrace = 26,
45 alarm = 27,
46 sigaltstack = 28,
47 pause = 29,
48 utime = 30,
49 access = 33,
50 nice = 34,
51 sync = 36,
52 kill = 37,
53 stat = 38,
54 sendfile = 39,
55 lstat = 40,
56 dup = 41,
57 pipe = 42,
58 times = 43,
59 umount2 = 45,
60 setgid = 46,
61 getgid = 47,
62 signal = 48,
63 geteuid = 49,
64 getegid = 50,
65 acct = 51,
66 memory_ordering = 52,
67 ioctl = 54,
68 reboot = 55,
69 symlink = 57,
70 readlink = 58,
71 execve = 59,
72 umask = 60,
73 chroot = 61,
74 fstat = 62,
75 fstat64 = 63,
76 getpagesize = 64,
77 msync = 65,
78 vfork = 66,
79 pread64 = 67,
80 pwrite64 = 68,
81 mmap = 71,
82 munmap = 73,
83 mprotect = 74,
84 madvise = 75,
85 vhangup = 76,
86 mincore = 78,
87 getgroups = 79,
88 setgroups = 80,
89 getpgrp = 81,
90 setitimer = 83,
91 swapon = 85,
92 getitimer = 86,
93 sethostname = 88,
94 dup2 = 90,
95 fcntl = 92,
96 select = 93,
97 fsync = 95,
98 setpriority = 96,
99 socket = 97,
100 connect = 98,
101 accept = 99,
102 getpriority = 100,
103 rt_sigreturn = 101,
104 rt_sigaction = 102,
105 rt_sigprocmask = 103,
106 rt_sigpending = 104,
107 rt_sigtimedwait = 105,
108 rt_sigqueueinfo = 106,
109 rt_sigsuspend = 107,
110 setresuid = 108,
111 getresuid = 109,
112 setresgid = 110,
113 getresgid = 111,
114 recvmsg = 113,
115 sendmsg = 114,
116 gettimeofday = 116,
117 getrusage = 117,
118 getsockopt = 118,
119 getcwd = 119,
120 readv = 120,
121 writev = 121,
122 settimeofday = 122,
123 fchown = 123,
124 fchmod = 124,
125 recvfrom = 125,
126 setreuid = 126,
127 setregid = 127,
128 rename = 128,
129 truncate = 129,
130 ftruncate = 130,
131 flock = 131,
132 lstat64 = 132,
133 sendto = 133,
134 shutdown = 134,
135 socketpair = 135,
136 mkdir = 136,
137 rmdir = 137,
138 utimes = 138,
139 stat64 = 139,
140 sendfile64 = 140,
141 getpeername = 141,
142 futex = 142,
143 gettid = 143,
144 getrlimit = 144,
145 setrlimit = 145,
146 pivot_root = 146,
147 prctl = 147,
148 pciconfig_read = 148,
149 pciconfig_write = 149,
150 getsockname = 150,
151 inotify_init = 151,
152 inotify_add_watch = 152,
153 poll = 153,
154 getdents64 = 154,
155 inotify_rm_watch = 156,
156 statfs = 157,
157 fstatfs = 158,
158 umount = 159,
159 sched_set_affinity = 160,
160 sched_get_affinity = 161,
161 getdomainname = 162,
162 setdomainname = 163,
163 utrap_install = 164,
164 quotactl = 165,
165 set_tid_address = 166,
166 mount = 167,
167 ustat = 168,
168 setxattr = 169,
169 lsetxattr = 170,
170 fsetxattr = 171,
171 getxattr = 172,
172 lgetxattr = 173,
173 getdents = 174,
174 setsid = 175,
175 fchdir = 176,
176 fgetxattr = 177,
177 listxattr = 178,
178 llistxattr = 179,
179 flistxattr = 180,
180 removexattr = 181,
181 lremovexattr = 182,
182 sigpending = 183,
183 query_module = 184,
184 setpgid = 185,
185 fremovexattr = 186,
186 tkill = 187,
187 exit_group = 188,
188 uname = 189,
189 init_module = 190,
190 personality = 191,
191 remap_file_pages = 192,
192 epoll_create = 193,
193 epoll_ctl = 194,
194 epoll_wait = 195,
195 ioprio_set = 196,
196 getppid = 197,
197 sigaction = 198,
198 sgetmask = 199,
199 ssetmask = 200,
200 sigsuspend = 201,
201 oldlstat = 202,
202 uselib = 203,
203 readdir = 204,
204 readahead = 205,
205 socketcall = 206,
206 syslog = 207,
207 lookup_dcookie = 208,
208 fadvise64 = 209,
209 fadvise64_64 = 210,
210 tgkill = 211,
211 waitpid = 212,
212 swapoff = 213,
213 sysinfo = 214,
214 ipc = 215,
215 sigreturn = 216,
216 clone = 217,
217 ioprio_get = 218,
218 adjtimex = 219,
219 sigprocmask = 220,
220 create_module = 221,
221 delete_module = 222,
222 get_kernel_syms = 223,
223 getpgid = 224,
224 bdflush = 225,
225 sysfs = 226,
226 afs_syscall = 227,
227 setfsuid = 228,
228 setfsgid = 229,
229 _newselect = 230,
230 splice = 232,
231 stime = 233,
232 statfs64 = 234,
233 fstatfs64 = 235,
234 _llseek = 236,
235 mlock = 237,
236 munlock = 238,
237 mlockall = 239,
238 munlockall = 240,
239 sched_setparam = 241,
240 sched_getparam = 242,
241 sched_setscheduler = 243,
242 sched_getscheduler = 244,
243 sched_yield = 245,
244 sched_get_priority_max = 246,
245 sched_get_priority_min = 247,
246 sched_rr_get_interval = 248,
247 nanosleep = 249,
248 mremap = 250,
249 _sysctl = 251,
250 getsid = 252,
251 fdatasync = 253,
252 nfsservctl = 254,
253 sync_file_range = 255,
254 clock_settime = 256,
255 clock_gettime = 257,
256 clock_getres = 258,
257 clock_nanosleep = 259,
258 sched_getaffinity = 260,
259 sched_setaffinity = 261,
260 timer_settime = 262,
261 timer_gettime = 263,
262 timer_getoverrun = 264,
263 timer_delete = 265,
264 timer_create = 266,
265 vserver = 267,
266 io_setup = 268,
267 io_destroy = 269,
268 io_submit = 270,
269 io_cancel = 271,
270 io_getevents = 272,
271 mq_open = 273,
272 mq_unlink = 274,
273 mq_timedsend = 275,
274 mq_timedreceive = 276,
275 mq_notify = 277,
276 mq_getsetattr = 278,
277 waitid = 279,
278 tee = 280,
279 add_key = 281,
280 request_key = 282,
281 keyctl = 283,
282 openat = 284,
283 mkdirat = 285,
284 mknodat = 286,
285 fchownat = 287,
286 futimesat = 288,
287 fstatat64 = 289,
288 unlinkat = 290,
289 renameat = 291,
290 linkat = 292,
291 symlinkat = 293,
292 readlinkat = 294,
293 fchmodat = 295,
294 faccessat = 296,
295 pselect6 = 297,
296 ppoll = 298,
297 unshare = 299,
298 set_robust_list = 300,
299 get_robust_list = 301,
300 migrate_pages = 302,
301 mbind = 303,
302 get_mempolicy = 304,
303 set_mempolicy = 305,
304 kexec_load = 306,
305 move_pages = 307,
306 getcpu = 308,
307 epoll_pwait = 309,
308 utimensat = 310,
309 signalfd = 311,
310 timerfd_create = 312,
311 eventfd = 313,
312 fallocate = 314,
313 timerfd_settime = 315,
314 timerfd_gettime = 316,
315 signalfd4 = 317,
316 eventfd2 = 318,
317 epoll_create1 = 319,
318 dup3 = 320,
319 pipe2 = 321,
320 inotify_init1 = 322,
321 accept4 = 323,
322 preadv = 324,
323 pwritev = 325,
324 rt_tgsigqueueinfo = 326,
325 perf_event_open = 327,
326 recvmmsg = 328,
327 fanotify_init = 329,
328 fanotify_mark = 330,
329 prlimit64 = 331,
330 name_to_handle_at = 332,
331 open_by_handle_at = 333,
332 clock_adjtime = 334,
333 syncfs = 335,
334 sendmmsg = 336,
335 setns = 337,
336 process_vm_readv = 338,
337 process_vm_writev = 339,
338 kern_features = 340,
339 kcmp = 341,
340 finit_module = 342,
341 sched_setattr = 343,
342 sched_getattr = 344,
343 renameat2 = 345,
344 seccomp = 346,
345 getrandom = 347,
346 memfd_create = 348,
347 bpf = 349,
348 execveat = 350,
349 membarrier = 351,
350 userfaultfd = 352,
351 bind = 353,
352 listen = 354,
353 setsockopt = 355,
354 mlock2 = 356,
355 copy_file_range = 357,
356 preadv2 = 358,
357 pwritev2 = 359,
358 statx = 360,
359 io_pgetevents = 361,
360 pkey_mprotect = 362,
361 pkey_alloc = 363,
362 pkey_free = 364,
363 rseq = 365,
364 semtimedop = 392,
365 semget = 393,
366 semctl = 394,
367 shmget = 395,
368 shmctl = 396,
369 shmat = 397,
370 shmdt = 398,
371 msgget = 399,
372 msgsnd = 400,
373 msgrcv = 401,
374 msgctl = 402,
375 pidfd_send_signal = 424,
376 io_uring_setup = 425,
377 io_uring_enter = 426,
378 io_uring_register = 427,
379 open_tree = 428,
380 move_mount = 429,
381 fsopen = 430,
382 fsconfig = 431,
383 fsmount = 432,
384 fspick = 433,
385 pidfd_open = 434,
386 openat2 = 437,
387 pidfd_getfd = 438,
388
389 _,
390};
391
392pub const O_CREAT = 0o100;
393pub const O_EXCL = 0o200;
394pub const O_NOCTTY = 0o400;
395pub const O_TRUNC = 0o1000;
396pub const O_APPEND = 0o2000;
397pub const O_NONBLOCK = 0o4000;
398pub const O_DSYNC = 0o10000;
399pub const O_SYNC = 0o4010000;
400pub const O_RSYNC = 0o4010000;
401pub const O_DIRECTORY = 0o200000;
402pub const O_NOFOLLOW = 0o400000;
403pub const O_CLOEXEC = 0o2000000;
404
405pub const O_ASYNC = 0o20000;
406pub const O_DIRECT = 0o40000;
407pub const O_LARGEFILE = 0o100000;
408pub const O_NOATIME = 0o1000000;
409pub const O_PATH = 0o10000000;
410pub const O_TMPFILE = 0o20200000;
411pub const O_NDELAY = O_NONBLOCK;
412
413pub const F_DUPFD = 0;
414pub const F_GETFD = 1;
415pub const F_SETFD = 2;
416pub const F_GETFL = 3;
417pub const F_SETFL = 4;
418
419pub const F_SETOWN = 8;
420pub const F_GETOWN = 9;
421pub const F_SETSIG = 10;
422pub const F_GETSIG = 11;
423
424pub const F_RDLCK = 0;
425pub const F_WRLCK = 1;
426pub const F_UNLCK = 2;
427
428pub const F_GETLK = 5;
429pub const F_SETLK = 6;
430pub const F_SETLKW = 7;
431
432pub const F_SETOWN_EX = 15;
433pub const F_GETOWN_EX = 16;
434
435pub const F_GETOWNER_UIDS = 17;
436
437pub const LOCK_SH = 1;
438pub const LOCK_EX = 2;
439pub const LOCK_UN = 8;
440pub const LOCK_NB = 4;
441
442/// stack-like segment
443pub const MAP_GROWSDOWN = 0x0200;
444
445/// ETXTBSY
446pub const MAP_DENYWRITE = 0x0800;
447
448/// mark it as an executable
449pub const MAP_EXECUTABLE = 0x1000;
450
451/// pages are locked
452pub const MAP_LOCKED = 0x0100;
453
454/// don't check for reservations
455pub const MAP_NORESERVE = 0x0040;
456
457pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
458pub const VDSO_CGT_VER = "LINUX_2.6";
459
460// TODO do this
461
462pub const Flock = extern struct {
463 l_type: i16,
464 l_whence: i16,
465 l_start: off_t,
466 l_len: off_t,
467 l_pid: pid_t,
468};
469
470pub const msghdr = extern struct {
471 msg_name: ?*sockaddr,
472 msg_namelen: socklen_t,
473 msg_iov: [*]iovec,
474 msg_iovlen: u64,
475 msg_control: ?*c_void,
476 msg_controllen: u64,
477 msg_flags: i32,
478};
479
480pub const msghdr_const = extern struct {
481 msg_name: ?*const sockaddr,
482 msg_namelen: socklen_t,
483 msg_iov: [*]iovec_const,
484 msg_iovlen: u64,
485 msg_control: ?*c_void,
486 msg_controllen: u64,
487 msg_flags: i32,
488};
489
490pub const off_t = i64;
491pub const ino_t = u64;
492
493/// Renamed to Stat to not conflict with the stat function.
494/// atime, mtime, and ctime have functions to return `timespec`,
495/// because although this is a POSIX API, the layout and names of
496/// the structs are inconsistent across operating systems, and
497/// in C, macros are used to hide the differences. Here we use
498/// methods to accomplish this.
499pub const Stat = extern struct {
500 dev: u64,
501 ino: ino_t,
502 mode: u32,
503 nlink: usize,
504
505 uid: u32,
506 gid: u32,
507 rdev: u64,
508 __pad0: u32,
509
510 size: off_t,
511 blksize: isize,
512 blocks: i64,
513
514 atim: timespec,
515 mtim: timespec,
516 ctim: timespec,
517 __unused: [2]isize,
518
519 pub fn atime(self: Stat) timespec {
520 return self.atim;
521 }
522
523 pub fn mtime(self: Stat) timespec {
524 return self.mtim;
525 }
526
527 pub fn ctime(self: Stat) timespec {
528 return self.ctim;
529 }
530};
531
532pub const timespec = extern struct {
533 tv_sec: isize,
534 tv_nsec: isize,
535};
536
537pub const timeval = extern struct {
538 tv_sec: isize,
539 tv_usec: isize,
540};
541
542pub const timezone = extern struct {
543 tz_minuteswest: i32,
544 tz_dsttime: i32,
545};
546
547pub const Elf_Symndx = u32;
548
549// TODO figure out how to do these on sparc64.
550
551pub const fpstate = extern struct {
552 regs: [32]u64,
553 fsr: u64,
554 gsr: u64,
555 fprs: u64,
556};
557pub const fpregset_t = *fpstate;
558
559pub const siginfo_fpu_t = extern struct {
560 float_regs: [64]u32,
561 fsr: u64,
562 gsr: u64,
563 fprs: u64,
564};
565
566pub const sigcontext = extern struct {
567 info: [128]i8,
568 regs: extern struct {
569 u_regs: [16]u64,
570 tstate: u64,
571 tpc: u64,
572 tnpc: u64,
573 y: u64,
574 fprs: u64,
575 },
576 fpu_save: *siginfo_fpu_t,
577 stack: extern struct {
578 sp: usize,
579 flags: i32,
580 size: u64,
581 },
582 mask: u64,
583};
584
585pub const greg_t = u64;
586pub const gregset_t = [19]greg_t;
587
588pub const fq = extern struct {
589 addr: *u64,
590 insn: u32,
591};
592
593pub const fpu_t = extern struct {
594 fregs: extern union {
595 sregs: [32]u32,
596 dregs: [32]u64,
597 qregs: [16]c_longdouble,
598 },
599 fsr: u64,
600 fprs: u64,
601 fq: *fq,
602 qcnt: u8,
603 qentsz: u8,
604 enab: u8,
605};
606
607pub const mcontext_t = extern struct {
608 gregs: gregset_t,
609 fp: greg_t,
610 i7: greg_t,
611 fpregs: fpu_t,
612};
613
614pub const ucontext_t = extern struct {
615 link: *ucontext_t,
616 flags: u64,
617 __sigmask: u64,
618 mcontext: mcontext_t,
619 stack: stack_t,
620 sigmask: sigset_t,
621};