17
17
py_rlimit* = tuple
18
18
rlim_cur: int
19
19
rlim_max: int
20
+ py_rlimit_abc = concept self
21
+ self.len is int
22
+ self[int ] is int
20
23
21
24
# XXX: NIM-BUG: rlim_cur and rlim_max are int over unsigned in std/posix
22
25
23
26
proc py2rlimit(limits: py_rlimit, rl_out: var RLimit) =
24
27
rl_out.rlim_cur = limits.rlim_cur
25
28
rl_out.rlim_max = limits.rlim_max
26
29
30
+ proc py2rlimit(limits: py_rlimit_abc, rl_out: var RLimit) =
31
+ assert limits.len == 2
32
+ rl_out.rlim_cur = limits[0 ]
33
+ rl_out.rlim_max = limits[1 ]
34
+
27
35
proc rlimit2py(rl_in: RLimit): py_rlimit = (rl_in.rlim_cur, rl_in.rlim_max)
28
36
29
37
let RLIM_NLIMITS{.importc, header: " <sys/resource.h>" .}: cint
@@ -41,7 +49,7 @@ proc getrlimit*(resource: int): py_rlimit =
41
49
42
50
proc raise_inval =
43
51
raise newException(ValueError, " current limit exceeds maximum limit" )
44
- proc setrlimit* (resource: int , limits: py_rlimit ) =
52
+ proc setrlimit* (resource: int , limits: py_rlimit_abc ) =
45
53
var rl: RLimit
46
54
py2rlimit(limits, rl)
47
55
if setrlimit(checked_resource(resource), rl) == - 1 :
@@ -64,7 +72,7 @@ when HAVE_PRLIMIT:
64
72
raiseErrno()
65
73
rlimit2py(old_limit)
66
74
67
- proc prlimit* (pid: int , resource: int , limits: py_rlimit ): py_rlimit{.discardable.} =
75
+ proc prlimit* (pid: int , resource: int , limits: py_rlimit_abc ): py_rlimit{.discardable.} =
68
76
let
69
77
pid = Pid pid
70
78
resource = checked_resource(resource)
0 commit comments