aboutsummaryrefslogtreecommitdiffstats
path: root/init/init.c
diff options
context:
space:
mode:
authorturret <turret@duck.com>2023-12-18 18:40:19 -0600
committerturret <turret@duck.com>2023-12-18 18:40:19 -0600
commit7648b5a7b22ae3b3e3a3fa39fd83bce06554385d (patch)
treed553afe5122333663c32645d660a54fdfa872716 /init/init.c
parent54b308af97b91ceabb0a482f325d3a8595b01aa3 (diff)
downloaddiscord-bot-skeleton-7648b5a7b22ae3b3e3a3fa39fd83bce06554385d.tar.gz
discord-bot-skeleton-7648b5a7b22ae3b3e3a3fa39fd83bce06554385d.tar.bz2
discord-bot-skeleton-7648b5a7b22ae3b3e3a3fa39fd83bce06554385d.zip
init: minor optimisations
move spin locks to dedicated function so we can minimise repetition of code. now uses more C and less assembly. init.c uses 8192 * 512 as a maximum even if the stack rlimit is larger
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/init/init.c b/init/init.c
index e2ece8a..806792f 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1,6 +1,7 @@
#include <signal.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/param.h>
#include <sys/resource.h>
#include <sys/wait.h>
@@ -71,7 +72,7 @@ int main(void)
struct rlimit *stack_rlimit = malloc(sizeof(struct rlimit));
getrlimit(RLIMIT_STACK, stack_rlimit);
if(stack_rlimit->rlim_cur != RLIM_INFINITY) {
- stack_size = stack_rlimit->rlim_cur;
+ stack_size = MIN(stack_rlimit->rlim_cur, stack_size);
}
free(stack_rlimit);