2 * D header file for POSIX.
4 * Copyright: Copyright (c) 2013 Lars Tandle Kyllingstad.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Lars Tandle Kyllingstad
7 * Standards: The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008
9 module core.sys.posix.sys.resource;
12 public import core.sys.posix.sys.time;
13 public import core.sys.posix.sys.types: id_t;
14 import core.sys.posix.config;
22 else version (WatchOS)
25 nothrow @nogc extern(C):
30 // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html
77 int getpriority(int, id_t);
78 int getrlimit(int, rlimit*);
79 int getrusage(int, rusage*);
80 int setpriority(int, id_t, int);
81 int setrlimit(int, const rlimit*);
85 version (CRuntime_Glibc)
87 // rusage and some other constants in the Bionic section below really
88 // come from the linux kernel headers, but they're all mixed right now.
96 static if (__USE_FILE_OFFSET64)
101 static if (__USE_FILE_OFFSET64)
102 enum RLIM_INFINITY = 0xffffffffffffffffUL;
104 enum RLIM_INFINITY = cast(c_ulong)(~0UL);
106 enum RLIM_SAVED_MAX = RLIM_INFINITY;
107 enum RLIM_SAVED_CUR = RLIM_INFINITY;
112 RUSAGE_CHILDREN = -1,
146 else version (Darwin)
159 RLIM_INFINITY = ((cast(ulong) 1 << 63) - 1),
160 RLIM_SAVED_MAX = RLIM_INFINITY,
161 RLIM_SAVED_CUR = RLIM_INFINITY,
167 RUSAGE_CHILDREN = -1,
174 c_long[14] ru_opaque;
188 else version (FreeBSD)
201 RLIM_INFINITY = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
202 // FreeBSD explicitly does not define the following:
210 RUSAGE_CHILDREN = -1,
218 alias ru_ixrss ru_first;
232 alias ru_nivcsw ru_last;
246 else version (NetBSD)
259 RLIM_INFINITY = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
260 // FreeBSD explicitly does not define the following:
268 RUSAGE_CHILDREN = -1,
276 alias ru_ixrss ru_first;
290 alias ru_nivcsw ru_last;
304 else version (OpenBSD)
317 RLIM_INFINITY = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
318 RLIM_SAVED_MAX = RLIM_INFINITY,
319 RLIM_SAVED_CUR = RLIM_INFINITY,
325 RUSAGE_CHILDREN = -1,
334 alias ru_ixrss ru_first;
348 alias ru_nivcsw ru_last;
359 // OpenBSD does not define the following:
363 else version (DragonFlyBSD)
376 RLIM_INFINITY = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
377 // DragonFlyBSD explicitly does not define the following:
385 RUSAGE_CHILDREN = -1,
393 alias ru_ixrss ru_first;
407 alias ru_nivcsw ru_last;
421 else version (Solaris)
430 alias c_ulong rlim_t;
442 RUSAGE_CHILDREN = -1,
476 else version (CRuntime_Bionic)
485 alias c_ulong rlim_t;
486 enum RLIM_INFINITY = cast(c_ulong)(~0UL);
491 RUSAGE_CHILDREN = -1,
525 else version (CRuntime_Musl)
529 int getrlimit(int, rlimit*);
530 int setrlimit(int, in rlimit*);
531 alias getrlimit getrlimit64;
532 alias setrlimit setrlimit64;
536 RUSAGE_CHILDREN = -1,
557 c_long[16] __reserved;
571 else version (CRuntime_UClibc)
580 static if (__USE_FILE_OFFSET64)
583 alias c_ulong rlim_t;
585 static if (__USE_FILE_OFFSET64)
586 enum RLIM_INFINITY = 0xffffffffffffffffUL;
588 enum RLIM_INFINITY = cast(c_ulong)(~0UL);
590 enum RLIM_SAVED_MAX = RLIM_INFINITY;
591 enum RLIM_SAVED_CUR = RLIM_INFINITY;
596 RUSAGE_CHILDREN = -1,
630 else static assert (false, "Unsupported platform");
638 version (CRuntime_Glibc)
640 int getpriority(int, id_t);
641 int setpriority(int, id_t, int);
643 else version (FreeBSD)
645 int getpriority(int, int);
646 int setpriority(int, int, int);
648 else version (DragonFlyBSD)
650 int getpriority(int, int);
651 int setpriority(int, int, int);
653 else version (CRuntime_Bionic)
655 int getpriority(int, int);
656 int setpriority(int, int, int);
658 else version (Solaris)
660 int getpriority(int, id_t);
661 int setpriority(int, id_t, int);
663 else version (Darwin)
665 int getpriority(int, id_t);
666 int setpriority(int, id_t, int);
668 else version (CRuntime_UClibc)
670 int getpriority(int, id_t);
671 int setpriority(int, id_t, int);
674 version (CRuntime_Glibc)
676 static if (__USE_FILE_OFFSET64)
678 int getrlimit64(int, rlimit*);
679 int setrlimit64(int, in rlimit*);
680 alias getrlimit = getrlimit64;
681 alias setrlimit = setrlimit64;
685 int getrlimit(int, rlimit*);
686 int setrlimit(int, in rlimit*);
688 int getrusage(int, rusage*);
690 else version (CRuntime_Bionic)
692 int getrlimit(int, rlimit*);
693 int getrusage(int, rusage*);
694 int setrlimit(int, in rlimit*);
696 else version (Darwin)
698 int getrlimit(int, rlimit*);
699 int getrusage(int, rusage*);
700 int setrlimit(int, in rlimit*);
702 else version (FreeBSD)
704 int getrlimit(int, rlimit*);
705 int getrusage(int, rusage*);
706 int setrlimit(int, in rlimit*);
708 else version (NetBSD)
710 int getrlimit(int, rlimit*);
711 int getrusage(int, rusage*);
712 int setrlimit(int, in rlimit*);
714 else version (OpenBSD)
716 int getrlimit(int, rlimit*);
717 int getrusage(int, rusage*);
718 int setrlimit(int, in rlimit*);
720 else version (DragonFlyBSD)
722 int getrlimit(int, rlimit*);
723 int getrusage(int, rusage*);
724 int setrlimit(int, in rlimit*);
726 else version (Solaris)
728 int getrlimit(int, rlimit*);
729 int getrusage(int, rusage*);
730 int setrlimit(int, in rlimit*);
732 else version (CRuntime_UClibc)
734 static if (__USE_FILE_OFFSET64)
736 int getrlimit64(int, rlimit*);
737 int setrlimit64(int, in rlimit*);
738 alias getrlimit = getrlimit64;
739 alias setrlimit = setrlimit64;
743 int getrlimit(int, rlimit*);
744 int setrlimit(int, in rlimit*);
746 int getrusage(int, rusage*);