mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
add const RLIMIT_STACK (#21772)
* add const RLIMIT_STACK * generate by detect.nim * add generated const for linux-amd64
This commit is contained in:
committed by
GitHub
parent
1d6fd30afb
commit
744a99d75c
@@ -453,6 +453,7 @@ const MAP_POPULATE* = cint(32768)
|
||||
|
||||
# <sys/resource.h>
|
||||
const RLIMIT_NOFILE* = cint(7)
|
||||
const RLIMIT_STACK* = cint(3)
|
||||
|
||||
# <sys/select.h>
|
||||
const FD_SETSIZE* = cint(1024)
|
||||
|
||||
@@ -467,6 +467,7 @@ var POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc: "POSIX_TYPED_MEM_MAP_ALLOCATABLE
|
||||
|
||||
# <sys/resource.h>
|
||||
var RLIMIT_NOFILE* {.importc: "RLIMIT_NOFILE", header: "<sys/resource.h>".}: cint
|
||||
var RLIMIT_STACK* {.importc: "RLIMIT_STACK", header: "<sys/resource.h>".}: cint
|
||||
|
||||
# <sys/select.h>
|
||||
var FD_SETSIZE* {.importc: "FD_SETSIZE", header: "<sys/select.h>".}: cint
|
||||
|
||||
@@ -62,3 +62,27 @@ when not defined(windows):
|
||||
)
|
||||
doAssert buffer == sent
|
||||
doAssert bytesRead == int(MQ_MESSAGE_SIZE)
|
||||
|
||||
block:
|
||||
var rl: RLimit
|
||||
var res = getrlimit(RLIMIT_STACK, rl)
|
||||
doAssert res == 0
|
||||
|
||||
# save old value
|
||||
let oldrlim = rl.rlim_cur
|
||||
|
||||
# set new value
|
||||
rl.rlim_cur = rl.rlim_max - 1
|
||||
res = setrlimit(RLIMIT_STACK, rl)
|
||||
doAssert res == 0
|
||||
|
||||
# get new value
|
||||
var rl1: RLimit
|
||||
res = getrlimit(RLIMIT_STACK, rl1)
|
||||
doAssert res == 0
|
||||
doAssert rl1.rlim_cur == rl.rlim_max - 1
|
||||
|
||||
# restore old value
|
||||
rl.rlim_cur = oldrlim
|
||||
res = setrlimit(RLIMIT_STACK, rl)
|
||||
doAssert res == 0
|
||||
|
||||
@@ -618,6 +618,7 @@ v("MAP_POPULATE", no_other = true)
|
||||
|
||||
header("<sys/resource.h>")
|
||||
v("RLIMIT_NOFILE")
|
||||
v("RLIMIT_STACK")
|
||||
|
||||
header("<sys/select.h>")
|
||||
v("FD_SETSIZE")
|
||||
|
||||
Reference in New Issue
Block a user