diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -1416,11 +1416,32 @@ 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) { - // Consider RLIM_{INFINITY,SAVED_{CUR,MAX}} all equally infinite - bool a_inf = a == RLIM_INFINITY || a == RLIM_SAVED_CUR || a == RLIM_SAVED_MAX; - bool b_inf = b == RLIM_INFINITY || b == RLIM_SAVED_CUR || b == RLIM_SAVED_MAX; + bool a_inf = rlim_isinf(a); + bool b_inf = rlim_isinf(b); if (a_inf || b_inf) { return a_inf - b_inf; } |