@@ -21,88 +21,92 @@ use crate::Result;
21
21
22
22
pub use libc:: rlim_t;
23
23
24
+ #[ cfg( any( target_os = "linux" ) ) ]
25
+ libc_enum ! {
26
+ #[ repr( u32 ) ]
27
+ pub enum Resource {
28
+ /// See detail of each Resource https://man7.org/linux/man-pages/man2/getrlimit.2.html
29
+ RLIMIT_AS ,
30
+ RLIMIT_CORE ,
31
+ RLIMIT_CPU ,
32
+ RLIMIT_DATA ,
33
+ RLIMIT_FSIZE ,
34
+ RLIMIT_LOCKS ,
35
+ RLIMIT_MEMLOCK ,
36
+ RLIMIT_MSGQUEUE ,
37
+ RLIMIT_NICE ,
38
+ RLIMIT_NOFILE ,
39
+ RLIMIT_NPROC ,
40
+ RLIMIT_RSS ,
41
+ RLIMIT_RTPRIO ,
42
+ RLIMIT_RTTIME ,
43
+ RLIMIT_SIGPENDING ,
44
+ RLIMIT_STACK ,
45
+ }
46
+ }
47
+
48
+ #[ cfg( any(
49
+ target_os = "freebsd" ,
50
+ target_os = "openbsd" ,
51
+ target_os = "netbsd" ,
52
+ target_os = "macos" ,
53
+ target_os = "ios" ,
54
+ target_os = "android" ,
55
+ target_os = "dragonfly" ,
56
+ target_os = "bitrig" ,
57
+ ) ) ]
24
58
libc_enum ! {
25
- /// A resource that limits apply to
26
59
#[ repr( i32 ) ]
27
60
pub enum Resource {
28
- // POSIX
29
- /// This is the maximum size of the process's virtual memory (address space). The limit is
30
- /// specified in bytes, and is rounded down to the system page size.
61
+ /// See detail of each Resource https://man7.org/linux/man-pages/man2/getrlimit.2.html
62
+ /// BSD specific Resource https://www.freebsd.org/cgi/man.cgi?query=setrlimit
31
63
RLIMIT_AS ,
32
- /// This is the maximum size of a core file (see core(5)) in bytes that the process may
33
- /// dump.
34
64
RLIMIT_CORE ,
35
- /// This is a limit, in seconds, on the amount of CPU time that the process can consume.
36
65
RLIMIT_CPU ,
37
- /// This is the maximum size of the process's data segment (initialized data, uninitialized
38
- /// data, and heap). The limit is specified in bytes, and is rounded down to the system
39
- /// page size.
40
66
RLIMIT_DATA ,
41
- /// This is the maximum size in bytes of files that the process may create. Attempts to
42
- /// extend a file beyond this limit result in delivery of a SIGXFSZ signal.
43
67
RLIMIT_FSIZE ,
44
- /// This specifies a value one greater than the maximum file descriptor number that can be
45
- /// opened by this process.
46
68
RLIMIT_NOFILE ,
47
- /// This is the maximum size of the process stack, in bytes. Upon reaching this limit, a
48
- /// SIGSEGV signal is generated.
49
69
RLIMIT_STACK ,
50
70
51
- /// Linux
52
- /// This is a limit (in microseconds) on the amount of CPU time that a process scheduled
53
- /// under a real-time scheduling policy may consume without making a blocking system call.
54
- #[ cfg( any( target_os = "linux" ) ) ]
55
- RLIMIT_RTTIME ,
71
+ // platform specific
72
+ #[ cfg( target_os = "freebsd" ) ]
73
+ RLIMIT_KQUEUES ,
74
+
75
+ #[ cfg( any( target_os = "android" ) ) ]
76
+ RLIMIT_LOCKS ,
56
77
57
- // BSDs and Linux
58
- /// This is the maximum number of bytes of memory that may be locked into RAM. This limit
59
- /// is in effect rounded down to the nearest multiple of the system page size.
60
- #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" , target_os = "openbsd" ) ) ]
78
+ #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "openbsd" ) ) ]
61
79
RLIMIT_MEMLOCK ,
62
- /// This is a limit on the number of extant process (or, more precisely on Linux, threads)
63
- /// for the real user ID of the calling process.
64
- #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" , target_os = "openbsd" ) ) ]
65
- RLIMIT_NPROC ,
66
- /// This is a limit (in bytes) on the process's resident set (the number of virtual pages resident in RAM).
67
- #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" , target_os = "openbsd" ) ) ]
68
- RLIMIT_RSS ,
69
80
70
- // Android and Linux only
71
- /// This is a limit on the combined number of flock(2) locks and fcntl(2) leases that this process may establish.
72
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
73
- RLIMIT_LOCKS ,
74
- /// This is a limit on the number of bytes that can be allocated for POSIX message queues
75
- /// for the real user ID of the calling process.
76
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
81
+ #[ cfg( any( target_os = "android" ) ) ]
77
82
RLIMIT_MSGQUEUE ,
78
- /// This specifies a ceiling to which the process's nice value can be raised using
79
- /// setpriority(2) or nice(2). The actual ceiling for the nice value is calculated as 20 -
80
- /// rlim_cur.
81
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
83
+
84
+ #[ cfg( any( target_os = "android" ) ) ]
82
85
RLIMIT_NICE ,
83
- /// This specifies a ceiling on the real-time priority that may be set for this process
84
- /// using sched_setscheduler(2) and sched_setparam(2).
85
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
86
- RLIMIT_RTPRIO ,
87
- /// This is a limit on the number of signals that may be queued for the real user ID of the
88
- /// calling process. Both standard and real-time signals are counted for the purpose of
89
- /// checking this limit.
90
- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
91
- RLIMIT_SIGPENDING ,
92
86
93
- // Available on some BSD
94
- /// The maximum number of kqueues this user id is allowed to create.
95
- #[ cfg( target_os = "freebsd" ) ]
96
- RLIMIT_KQUEUES ,
97
- /// The maximum number of pseudo-terminals this user id is allowed to create.
87
+ #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "openbsd" ) ) ]
88
+ RLIMIT_NPROC ,
89
+
98
90
#[ cfg( target_os = "freebsd" ) ]
99
91
RLIMIT_NPTS ,
100
- /// The maximum size (in bytes) of socket buffer usage for this user.
92
+
93
+ #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "openbsd" ) ) ]
94
+ RLIMIT_RSS ,
95
+
96
+ #[ cfg( any( target_os = "android" ) ) ]
97
+ RLIMIT_RTPRIO ,
98
+
99
+ #[ cfg( any( target_os = "android" ) ) ]
100
+ RLIMIT_SIGPENDING ,
101
+
101
102
#[ cfg( any( target_os = "freebsd" , target_os = "dragonfly" ) ) ]
102
103
RLIMIT_SBSIZE ,
103
- /// The maximum size (in bytes) of the swap space that may be reserved or used by all of this user id's processes.
104
+
104
105
#[ cfg( target_os = "freebsd" ) ]
105
106
RLIMIT_SWAP ,
107
+
108
+ #[ cfg( target_os = "freebsd" ) ]
109
+ RLIMIT_VMEM ,
106
110
}
107
111
}
108
112
0 commit comments