1const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
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;
14const timespec = linux.timespec;
15
16pub fn syscall_pipe(fd: *[2]i32) usize {
17    return asm volatile (
18        \\ mov %[arg], %%g3
19        \\ t 0x6d
20        \\ bcc,pt %%xcc, 1f
21        \\ nop
22        \\ # Return the error code
23        \\ ba 2f
24        \\ neg %%o0
25        \\1:
26        \\ st %%o0, [%%g3+0]
27        \\ st %%o1, [%%g3+4]
28        \\ clr %%o0
29        \\2:
30        : [ret] "={o0}" (-> usize),
31        : [number] "{g1}" (@enumToInt(SYS.pipe)),
32          [arg] "r" (fd),
33        : "memory", "g3"
34    );
35}
36
37pub fn syscall_fork() usize {
38    // Linux/sparc64 fork() returns two values in %o0 and %o1:
39    // - On the parent's side, %o0 is the child's PID and %o1 is 0.
40    // - On the child's side, %o0 is the parent's PID and %o1 is 1.
41    // We need to clear the child's %o0 so that the return values
42    // conform to the libc convention.
43    return asm volatile (
44        \\ t 0x6d
45        \\ bcc,pt %%xcc, 1f
46        \\ nop
47        \\ ba 2f
48        \\ neg %%o0
49        \\ 1:
50        \\ # Clear the child's %%o0
51        \\ dec %%o1
52        \\ and %%o1, %%o0, %%o0
53        \\ 2:
54        : [ret] "={o0}" (-> usize),
55        : [number] "{g1}" (@enumToInt(SYS.fork)),
56        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
57    );
58}
59
60pub fn syscall0(number: SYS) usize {
61    return asm volatile (
62        \\ t 0x6d
63        \\ bcc,pt %%xcc, 1f
64        \\ nop
65        \\ neg %%o0
66        \\ 1:
67        : [ret] "={o0}" (-> usize),
68        : [number] "{g1}" (@enumToInt(number)),
69        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
70    );
71}
72
73pub fn syscall1(number: SYS, arg1: usize) usize {
74    return asm volatile (
75        \\ t 0x6d
76        \\ bcc,pt %%xcc, 1f
77        \\ nop
78        \\ neg %%o0
79        \\ 1:
80        : [ret] "={o0}" (-> usize),
81        : [number] "{g1}" (@enumToInt(number)),
82          [arg1] "{o0}" (arg1),
83        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
84    );
85}
86
87pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
88    return asm volatile (
89        \\ t 0x6d
90        \\ bcc,pt %%xcc, 1f
91        \\ nop
92        \\ neg %%o0
93        \\ 1:
94        : [ret] "={o0}" (-> usize),
95        : [number] "{g1}" (@enumToInt(number)),
96          [arg1] "{o0}" (arg1),
97          [arg2] "{o1}" (arg2),
98        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
99    );
100}
101
102pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
103    return asm volatile (
104        \\ t 0x6d
105        \\ bcc,pt %%xcc, 1f
106        \\ nop
107        \\ neg %%o0
108        \\ 1:
109        : [ret] "={o0}" (-> usize),
110        : [number] "{g1}" (@enumToInt(number)),
111          [arg1] "{o0}" (arg1),
112          [arg2] "{o1}" (arg2),
113          [arg3] "{o2}" (arg3),
114        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
115    );
116}
117
118pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
119    return asm volatile (
120        \\ t 0x6d
121        \\ bcc,pt %%xcc, 1f
122        \\ nop
123        \\ neg %%o0
124        \\ 1:
125        : [ret] "={o0}" (-> usize),
126        : [number] "{g1}" (@enumToInt(number)),
127          [arg1] "{o0}" (arg1),
128          [arg2] "{o1}" (arg2),
129          [arg3] "{o2}" (arg3),
130          [arg4] "{o3}" (arg4),
131        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
132    );
133}
134
135pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
136    return asm volatile (
137        \\ t 0x6d
138        \\ bcc,pt %%xcc, 1f
139        \\ nop
140        \\ neg %%o0
141        \\ 1:
142        : [ret] "={o0}" (-> usize),
143        : [number] "{g1}" (@enumToInt(number)),
144          [arg1] "{o0}" (arg1),
145          [arg2] "{o1}" (arg2),
146          [arg3] "{o2}" (arg3),
147          [arg4] "{o3}" (arg4),
148          [arg5] "{o4}" (arg5),
149        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
150    );
151}
152
153pub fn syscall6(
154    number: SYS,
155    arg1: usize,
156    arg2: usize,
157    arg3: usize,
158    arg4: usize,
159    arg5: usize,
160    arg6: usize,
161) usize {
162    return asm volatile (
163        \\ t 0x6d
164        \\ bcc,pt %%xcc, 1f
165        \\ nop
166        \\ neg %%o0
167        \\ 1:
168        : [ret] "={o0}" (-> usize),
169        : [number] "{g1}" (@enumToInt(number)),
170          [arg1] "{o0}" (arg1),
171          [arg2] "{o1}" (arg2),
172          [arg3] "{o2}" (arg3),
173          [arg4] "{o3}" (arg4),
174          [arg5] "{o4}" (arg5),
175          [arg6] "{o5}" (arg6),
176        : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
177    );
178}
179
180/// This matches the libc clone function.
181pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
182
183pub const restore = restore_rt;
184
185// Need to use C ABI here instead of naked
186// to prevent an infinite loop when calling rt_sigreturn.
187pub fn restore_rt() callconv(.C) void {
188    return asm volatile ("t 0x6d"
189        :
190        : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)),
191        : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7"
192    );
193}
194
195pub const SYS = enum(usize) {
196    restart_syscall = 0,
197    exit = 1,
198    fork = 2,
199    read = 3,
200    write = 4,
201    open = 5,
202    close = 6,
203    wait4 = 7,
204    creat = 8,
205    link = 9,
206    unlink = 10,
207    execv = 11,
208    chdir = 12,
209    chown = 13,
210    mknod = 14,
211    chmod = 15,
212    lchown = 16,
213    brk = 17,
214    perfctr = 18,
215    lseek = 19,
216    getpid = 20,
217    capget = 21,
218    capset = 22,
219    setuid = 23,
220    getuid = 24,
221    vmsplice = 25,
222    ptrace = 26,
223    alarm = 27,
224    sigaltstack = 28,
225    pause = 29,
226    utime = 30,
227    access = 33,
228    nice = 34,
229    sync = 36,
230    kill = 37,
231    stat = 38,
232    sendfile = 39,
233    lstat = 40,
234    dup = 41,
235    pipe = 42,
236    times = 43,
237    umount2 = 45,
238    setgid = 46,
239    getgid = 47,
240    signal = 48,
241    geteuid = 49,
242    getegid = 50,
243    acct = 51,
244    memory_ordering = 52,
245    ioctl = 54,
246    reboot = 55,
247    symlink = 57,
248    readlink = 58,
249    execve = 59,
250    umask = 60,
251    chroot = 61,
252    fstat = 62,
253    fstat64 = 63,
254    getpagesize = 64,
255    msync = 65,
256    vfork = 66,
257    pread64 = 67,
258    pwrite64 = 68,
259    mmap = 71,
260    munmap = 73,
261    mprotect = 74,
262    madvise = 75,
263    vhangup = 76,
264    mincore = 78,
265    getgroups = 79,
266    setgroups = 80,
267    getpgrp = 81,
268    setitimer = 83,
269    swapon = 85,
270    getitimer = 86,
271    sethostname = 88,
272    dup2 = 90,
273    fcntl = 92,
274    select = 93,
275    fsync = 95,
276    setpriority = 96,
277    socket = 97,
278    connect = 98,
279    accept = 99,
280    getpriority = 100,
281    rt_sigreturn = 101,
282    rt_sigaction = 102,
283    rt_sigprocmask = 103,
284    rt_sigpending = 104,
285    rt_sigtimedwait = 105,
286    rt_sigqueueinfo = 106,
287    rt_sigsuspend = 107,
288    setresuid = 108,
289    getresuid = 109,
290    setresgid = 110,
291    getresgid = 111,
292    recvmsg = 113,
293    sendmsg = 114,
294    gettimeofday = 116,
295    getrusage = 117,
296    getsockopt = 118,
297    getcwd = 119,
298    readv = 120,
299    writev = 121,
300    settimeofday = 122,
301    fchown = 123,
302    fchmod = 124,
303    recvfrom = 125,
304    setreuid = 126,
305    setregid = 127,
306    rename = 128,
307    truncate = 129,
308    ftruncate = 130,
309    flock = 131,
310    lstat64 = 132,
311    sendto = 133,
312    shutdown = 134,
313    socketpair = 135,
314    mkdir = 136,
315    rmdir = 137,
316    utimes = 138,
317    stat64 = 139,
318    sendfile64 = 140,
319    getpeername = 141,
320    futex = 142,
321    gettid = 143,
322    getrlimit = 144,
323    setrlimit = 145,
324    pivot_root = 146,
325    prctl = 147,
326    pciconfig_read = 148,
327    pciconfig_write = 149,
328    getsockname = 150,
329    inotify_init = 151,
330    inotify_add_watch = 152,
331    poll = 153,
332    getdents64 = 154,
333    inotify_rm_watch = 156,
334    statfs = 157,
335    fstatfs = 158,
336    umount = 159,
337    sched_set_affinity = 160,
338    sched_get_affinity = 161,
339    getdomainname = 162,
340    setdomainname = 163,
341    utrap_install = 164,
342    quotactl = 165,
343    set_tid_address = 166,
344    mount = 167,
345    ustat = 168,
346    setxattr = 169,
347    lsetxattr = 170,
348    fsetxattr = 171,
349    getxattr = 172,
350    lgetxattr = 173,
351    getdents = 174,
352    setsid = 175,
353    fchdir = 176,
354    fgetxattr = 177,
355    listxattr = 178,
356    llistxattr = 179,
357    flistxattr = 180,
358    removexattr = 181,
359    lremovexattr = 182,
360    sigpending = 183,
361    query_module = 184,
362    setpgid = 185,
363    fremovexattr = 186,
364    tkill = 187,
365    exit_group = 188,
366    uname = 189,
367    init_module = 190,
368    personality = 191,
369    remap_file_pages = 192,
370    epoll_create = 193,
371    epoll_ctl = 194,
372    epoll_wait = 195,
373    ioprio_set = 196,
374    getppid = 197,
375    sigaction = 198,
376    sgetmask = 199,
377    ssetmask = 200,
378    sigsuspend = 201,
379    oldlstat = 202,
380    uselib = 203,
381    readdir = 204,
382    readahead = 205,
383    socketcall = 206,
384    syslog = 207,
385    lookup_dcookie = 208,
386    fadvise64 = 209,
387    fadvise64_64 = 210,
388    tgkill = 211,
389    waitpid = 212,
390    swapoff = 213,
391    sysinfo = 214,
392    ipc = 215,
393    sigreturn = 216,
394    clone = 217,
395    ioprio_get = 218,
396    adjtimex = 219,
397    sigprocmask = 220,
398    create_module = 221,
399    delete_module = 222,
400    get_kernel_syms = 223,
401    getpgid = 224,
402    bdflush = 225,
403    sysfs = 226,
404    afs_syscall = 227,
405    setfsuid = 228,
406    setfsgid = 229,
407    _newselect = 230,
408    splice = 232,
409    stime = 233,
410    statfs64 = 234,
411    fstatfs64 = 235,
412    _llseek = 236,
413    mlock = 237,
414    munlock = 238,
415    mlockall = 239,
416    munlockall = 240,
417    sched_setparam = 241,
418    sched_getparam = 242,
419    sched_setscheduler = 243,
420    sched_getscheduler = 244,
421    sched_yield = 245,
422    sched_get_priority_max = 246,
423    sched_get_priority_min = 247,
424    sched_rr_get_interval = 248,
425    nanosleep = 249,
426    mremap = 250,
427    _sysctl = 251,
428    getsid = 252,
429    fdatasync = 253,
430    nfsservctl = 254,
431    sync_file_range = 255,
432    clock_settime = 256,
433    clock_gettime = 257,
434    clock_getres = 258,
435    clock_nanosleep = 259,
436    sched_getaffinity = 260,
437    sched_setaffinity = 261,
438    timer_settime = 262,
439    timer_gettime = 263,
440    timer_getoverrun = 264,
441    timer_delete = 265,
442    timer_create = 266,
443    vserver = 267,
444    io_setup = 268,
445    io_destroy = 269,
446    io_submit = 270,
447    io_cancel = 271,
448    io_getevents = 272,
449    mq_open = 273,
450    mq_unlink = 274,
451    mq_timedsend = 275,
452    mq_timedreceive = 276,
453    mq_notify = 277,
454    mq_getsetattr = 278,
455    waitid = 279,
456    tee = 280,
457    add_key = 281,
458    request_key = 282,
459    keyctl = 283,
460    openat = 284,
461    mkdirat = 285,
462    mknodat = 286,
463    fchownat = 287,
464    futimesat = 288,
465    fstatat64 = 289,
466    unlinkat = 290,
467    renameat = 291,
468    linkat = 292,
469    symlinkat = 293,
470    readlinkat = 294,
471    fchmodat = 295,
472    faccessat = 296,
473    pselect6 = 297,
474    ppoll = 298,
475    unshare = 299,
476    set_robust_list = 300,
477    get_robust_list = 301,
478    migrate_pages = 302,
479    mbind = 303,
480    get_mempolicy = 304,
481    set_mempolicy = 305,
482    kexec_load = 306,
483    move_pages = 307,
484    getcpu = 308,
485    epoll_pwait = 309,
486    utimensat = 310,
487    signalfd = 311,
488    timerfd_create = 312,
489    eventfd = 313,
490    fallocate = 314,
491    timerfd_settime = 315,
492    timerfd_gettime = 316,
493    signalfd4 = 317,
494    eventfd2 = 318,
495    epoll_create1 = 319,
496    dup3 = 320,
497    pipe2 = 321,
498    inotify_init1 = 322,
499    accept4 = 323,
500    preadv = 324,
501    pwritev = 325,
502    rt_tgsigqueueinfo = 326,
503    perf_event_open = 327,
504    recvmmsg = 328,
505    fanotify_init = 329,
506    fanotify_mark = 330,
507    prlimit64 = 331,
508    name_to_handle_at = 332,
509    open_by_handle_at = 333,
510    clock_adjtime = 334,
511    syncfs = 335,
512    sendmmsg = 336,
513    setns = 337,
514    process_vm_readv = 338,
515    process_vm_writev = 339,
516    kern_features = 340,
517    kcmp = 341,
518    finit_module = 342,
519    sched_setattr = 343,
520    sched_getattr = 344,
521    renameat2 = 345,
522    seccomp = 346,
523    getrandom = 347,
524    memfd_create = 348,
525    bpf = 349,
526    execveat = 350,
527    membarrier = 351,
528    userfaultfd = 352,
529    bind = 353,
530    listen = 354,
531    setsockopt = 355,
532    mlock2 = 356,
533    copy_file_range = 357,
534    preadv2 = 358,
535    pwritev2 = 359,
536    statx = 360,
537    io_pgetevents = 361,
538    pkey_mprotect = 362,
539    pkey_alloc = 363,
540    pkey_free = 364,
541    rseq = 365,
542    semtimedop = 392,
543    semget = 393,
544    semctl = 394,
545    shmget = 395,
546    shmctl = 396,
547    shmat = 397,
548    shmdt = 398,
549    msgget = 399,
550    msgsnd = 400,
551    msgrcv = 401,
552    msgctl = 402,
553    pidfd_send_signal = 424,
554    io_uring_setup = 425,
555    io_uring_enter = 426,
556    io_uring_register = 427,
557    open_tree = 428,
558    move_mount = 429,
559    fsopen = 430,
560    fsconfig = 431,
561    fsmount = 432,
562    fspick = 433,
563    pidfd_open = 434,
564    clone3 = 435,
565    close_range = 436,
566    openat2 = 437,
567    pidfd_getfd = 438,
568    faccessat2 = 439,
569    process_madvise = 440,
570    epoll_pwait2 = 441,
571    mount_setattr = 442,
572    landlock_create_ruleset = 444,
573    landlock_add_rule = 445,
574    landlock_restrict_self = 446,
575
576    _,
577};
578
579pub const O = struct {
580    pub const CREAT = 0x200;
581    pub const EXCL = 0x800;
582    pub const NOCTTY = 0x8000;
583    pub const TRUNC = 0x400;
584    pub const APPEND = 0x8;
585    pub const NONBLOCK = 0x4000;
586    pub const SYNC = 0x802000;
587    pub const DSYNC = 0x2000;
588    pub const RSYNC = SYNC;
589    pub const DIRECTORY = 0x10000;
590    pub const NOFOLLOW = 0x20000;
591    pub const CLOEXEC = 0x400000;
592
593    pub const ASYNC = 0x40;
594    pub const DIRECT = 0x100000;
595    pub const LARGEFILE = 0;
596    pub const NOATIME = 0x200000;
597    pub const PATH = 0x1000000;
598    pub const TMPFILE = 0x2010000;
599    pub const NDELAY = NONBLOCK | 0x4;
600};
601
602pub const F = struct {
603    pub const DUPFD = 0;
604    pub const GETFD = 1;
605    pub const SETFD = 2;
606    pub const GETFL = 3;
607    pub const SETFL = 4;
608
609    pub const SETOWN = 5;
610    pub const GETOWN = 6;
611    pub const GETLK = 7;
612    pub const SETLK = 8;
613    pub const SETLKW = 9;
614
615    pub const RDLCK = 1;
616    pub const WRLCK = 2;
617    pub const UNLCK = 3;
618
619    pub const SETOWN_EX = 15;
620    pub const GETOWN_EX = 16;
621
622    pub const GETOWNER_UIDS = 17;
623};
624
625pub const LOCK = struct {
626    pub const SH = 1;
627    pub const EX = 2;
628    pub const NB = 4;
629    pub const UN = 8;
630};
631
632pub const MAP = struct {
633    /// stack-like segment
634    pub const GROWSDOWN = 0x0200;
635    /// ETXTBSY
636    pub const DENYWRITE = 0x0800;
637    /// mark it as an executable
638    pub const EXECUTABLE = 0x1000;
639    /// pages are locked
640    pub const LOCKED = 0x0100;
641    /// don't check for reservations
642    pub const NORESERVE = 0x0040;
643};
644
645pub const VDSO = struct {
646    pub const CGT_SYM = "__vdso_clock_gettime";
647    pub const CGT_VER = "LINUX_2.6";
648};
649
650pub const Flock = extern struct {
651    l_type: i16,
652    l_whence: i16,
653    l_start: off_t,
654    l_len: off_t,
655    l_pid: pid_t,
656};
657
658pub const msghdr = extern struct {
659    msg_name: ?*sockaddr,
660    msg_namelen: socklen_t,
661    msg_iov: [*]iovec,
662    msg_iovlen: u64,
663    msg_control: ?*anyopaque,
664    msg_controllen: u64,
665    msg_flags: i32,
666};
667
668pub const msghdr_const = extern struct {
669    msg_name: ?*const sockaddr,
670    msg_namelen: socklen_t,
671    msg_iov: [*]iovec_const,
672    msg_iovlen: u64,
673    msg_control: ?*anyopaque,
674    msg_controllen: u64,
675    msg_flags: i32,
676};
677
678pub const off_t = i64;
679pub const ino_t = u64;
680pub const mode_t = u32;
681pub const dev_t = usize;
682pub const nlink_t = u32;
683pub const blksize_t = isize;
684pub const blkcnt_t = isize;
685
686// The `stat64` definition used by the kernel.
687pub const Stat = extern struct {
688    dev: u64,
689    ino: u64,
690    nlink: u64,
691
692    mode: u32,
693    uid: u32,
694    gid: u32,
695    __pad0: u32,
696
697    rdev: u64,
698    size: i64,
699    blksize: i64,
700    blocks: i64,
701
702    atim: timespec,
703    mtim: timespec,
704    ctim: timespec,
705    __unused: [3]u64,
706
707    pub fn atime(self: @This()) timespec {
708        return self.atim;
709    }
710
711    pub fn mtime(self: @This()) timespec {
712        return self.mtim;
713    }
714
715    pub fn ctime(self: @This()) timespec {
716        return self.ctim;
717    }
718};
719
720pub const timeval = extern struct {
721    tv_sec: isize,
722    tv_usec: i32,
723};
724
725pub const timezone = extern struct {
726    tz_minuteswest: i32,
727    tz_dsttime: i32,
728};
729
730// TODO I'm not sure if the code below is correct, need someone with more
731// knowledge about sparc64 linux internals to look into.
732
733pub const Elf_Symndx = u32;
734
735pub const fpstate = extern struct {
736    regs: [32]u64,
737    fsr: u64,
738    gsr: u64,
739    fprs: u64,
740};
741
742pub const __fpq = extern struct {
743    fpq_addr: *u32,
744    fpq_instr: u32,
745};
746
747pub const __fq = extern struct {
748    FQu: extern union {
749        whole: f64,
750        fpq: __fpq,
751    },
752};
753
754pub const fpregset_t = extern struct {
755    fpu_fr: extern union {
756        fpu_regs: [32]u32,
757        fpu_dregs: [32]f64,
758        fpu_qregs: [16]c_longdouble,
759    },
760    fpu_q: *__fq,
761    fpu_fsr: u64,
762    fpu_qcnt: u8,
763    fpu_q_entrysize: u8,
764    fpu_en: u8,
765};
766
767pub const siginfo_fpu_t = extern struct {
768    float_regs: [64]u32,
769    fsr: u64,
770    gsr: u64,
771    fprs: u64,
772};
773
774pub const sigcontext = extern struct {
775    info: [128]i8,
776    regs: extern struct {
777        u_regs: [16]u64,
778        tstate: u64,
779        tpc: u64,
780        tnpc: u64,
781        y: u64,
782        fprs: u64,
783    },
784    fpu_save: *siginfo_fpu_t,
785    stack: extern struct {
786        sp: usize,
787        flags: i32,
788        size: u64,
789    },
790    mask: u64,
791};
792
793pub const greg_t = u64;
794pub const gregset_t = [19]greg_t;
795
796pub const fq = extern struct {
797    addr: *u64,
798    insn: u32,
799};
800
801pub const fpu_t = extern struct {
802    fregs: extern union {
803        sregs: [32]u32,
804        dregs: [32]u64,
805        qregs: [16]c_longdouble,
806    },
807    fsr: u64,
808    fprs: u64,
809    gsr: u64,
810    fq: *fq,
811    qcnt: u8,
812    qentsz: u8,
813    enab: u8,
814};
815
816pub const mcontext_t = extern struct {
817    gregs: gregset_t,
818    fp: greg_t,
819    @"i7": greg_t,
820    fpregs: fpu_t,
821};
822
823pub const ucontext_t = extern struct {
824    link: *ucontext_t,
825    flags: u64,
826    sigmask: u64,
827    mcontext: mcontext_t,
828    stack: stack_t,
829    sigmask: sigset_t,
830};
831
832pub const rlimit_resource = enum(c_int) {
833    /// Per-process CPU limit, in seconds.
834    CPU,
835
836    /// Largest file that can be created, in bytes.
837    FSIZE,
838
839    /// Maximum size of data segment, in bytes.
840    DATA,
841
842    /// Maximum size of stack segment, in bytes.
843    STACK,
844
845    /// Largest core file that can be created, in bytes.
846    CORE,
847
848    /// Largest resident set size, in bytes.
849    /// This affects swapping; processes that are exceeding their
850    /// resident set size will be more likely to have physical memory
851    /// taken from them.
852    RSS,
853
854    /// Number of open files.
855    NOFILE,
856
857    /// Number of processes.
858    NPROC,
859
860    /// Locked-in-memory address space.
861    MEMLOCK,
862
863    /// Address space limit.
864    AS,
865
866    /// Maximum number of file locks.
867    LOCKS,
868
869    /// Maximum number of pending signals.
870    SIGPENDING,
871
872    /// Maximum bytes in POSIX message queues.
873    MSGQUEUE,
874
875    /// Maximum nice priority allowed to raise to.
876    /// Nice levels 19 .. -20 correspond to 0 .. 39
877    /// values of this resource limit.
878    NICE,
879
880    /// Maximum realtime priority allowed for non-priviledged
881    /// processes.
882    RTPRIO,
883
884    /// Maximum CPU time in µs that a process scheduled under a real-time
885    /// scheduling policy may consume without making a blocking system
886    /// call before being forcibly descheduled.
887    RTTIME,
888
889    _,
890};
891