summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bfstd.c33
-rw-r--r--src/bfstd.h7
-rw-r--r--src/eval.c33
3 files changed, 40 insertions, 33 deletions
diff --git a/src/bfstd.c b/src/bfstd.c
index 06226a2..985a268 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -368,6 +369,38 @@ void xstrmode(mode_t mode, char str[11]) {
}
}
+/** Check if an rlimit value is infinite. */
+static bool rlim_isinf(rlim_t r) {
+ // Consider RLIM_{INFINITY,SAVED_{CUR,MAX}} all equally infinite
+ if (r == RLIM_INFINITY) {
+ return true;
+ }
+
+#ifdef RLIM_SAVED_CUR
+ if (r == RLIM_SAVED_CUR) {
+ return true;
+ }
+#endif
+
+#ifdef RLIM_SAVED_MAX
+ if (r == RLIM_SAVED_MAX) {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
+int rlim_cmp(rlim_t a, rlim_t b) {
+ bool a_inf = rlim_isinf(a);
+ bool b_inf = rlim_isinf(b);
+ if (a_inf || b_inf) {
+ return a_inf - b_inf;
+ }
+
+ return (a > b) - (a < b);
+}
+
dev_t xmakedev(int ma, int mi) {
#ifdef makedev
return makedev(ma, mi);
diff --git a/src/bfstd.h b/src/bfstd.h
index 4e36aca..6cb2d7b 100644
--- a/src/bfstd.h
+++ b/src/bfstd.h
@@ -187,6 +187,13 @@ const char *xstrerror(int errnum);
*/
void xstrmode(mode_t mode, char str[11]);
+#include <sys/resource.h>
+
+/**
+ * Compare two rlim_t values, accounting for infinite limits.
+ */
+int rlim_cmp(rlim_t a, rlim_t b);
+
#include <sys/types.h>
/**
diff --git a/src/eval.c b/src/eval.c
index 56d7cd8..5ba3de8 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1427,39 +1427,6 @@ done:
return state.action;
}
-/** Check if an rlimit value is infinite. */
-static bool rlim_isinf(rlim_t r) {
- // Consider RLIM_{INFINITY,SAVED_{CUR,MAX}} all equally infinite
- if (r == RLIM_INFINITY) {
- return true;
- }
-
-#ifdef RLIM_SAVED_CUR
- if (r == RLIM_SAVED_CUR) {
- return true;
- }
-#endif
-
-#ifdef RLIM_SAVED_MAX
- if (r == RLIM_SAVED_MAX) {
- return true;
- }
-#endif
-
- return false;
-}
-
-/** Compare two rlimit values, accounting for RLIM_INFINITY etc. */
-static int rlim_cmp(rlim_t a, rlim_t b) {
- bool a_inf = rlim_isinf(a);
- bool b_inf = rlim_isinf(b);
- if (a_inf || b_inf) {
- return a_inf - b_inf;
- }
-
- return (a > b) - (a < b);
-}
-
/** Raise RLIMIT_NOFILE if possible, and return the new limit. */
static int raise_fdlimit(const struct bfs_ctx *ctx) {
rlim_t target = 64 << 10;