diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-01-02 08:35:54 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-01-02 08:35:54 -0800 |
commit | 77340129486f06498bca2d536ec0406e02ca6d76 (patch) | |
tree | c0b0331ecaa3240143eea9769814187cbf8a8694 /sysif.c | |
parent | 338d76a0b8910d7d1082b16c688f53173316bc1a (diff) | |
download | txr-77340129486f06498bca2d536ec0406e02ca6d76.tar.gz txr-77340129486f06498bca2d536ec0406e02ca6d76.tar.bz2 txr-77340129486f06498bca2d536ec0406e02ca6d76.zip |
rlimit: var init problem due to large file offset.
Now that we fixed the regression in detecting whether to use
-D_FILE_OFFSET_BITS=64, this has unmasked an issue in newer
code. In sysif.c, the RLIM_INFINITY, and related constants,
are being passed to num_fast: but they are 64 bit unsigned
constants under the large file offset, which don't fit into a
cnum or unum on a 32 bit system.
* configure: When we detect large file offset, we deposit
the tell-tale configuration constant CONFIG_LARGE_FILE_OFFSET
into config.h.
* sysif.c (sysif_init): Under CONFIG_LARGE_FILE_OFFSET,
treat the RLIM_ constants using bignum_dbl_uipt.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -106,6 +106,9 @@ #include "itypes.h" #include "txr.h" #include "sysif.h" +#if CONFIG_LARGE_FILE_OFFSET +#include "arith.h" +#endif #ifndef DT_DIR #undef DT_UNKNOWN @@ -3158,9 +3161,22 @@ void sysif_init(void) #if HAVE_RLIMIT reg_fun(intern(lit("getrlimit"), user_package), func_n2o(getrlimit_wrap, 1)); reg_fun(intern(lit("setrlimit"), user_package), func_n2(setrlimit_wrap)); +#if CONFIG_LARGE_FILE_OFFSET + { + val rlim_inf = bignum_dbl_uipt(RLIM_INFINITY); + val rlim_smax = if3(RLIM_SAVED_MAX == RLIM_INFINITY, + rlim_inf, bignum_dbl_uipt(RLIM_SAVED_MAX)); + val rlim_scur = if3(RLIM_SAVED_CUR == RLIM_INFINITY, + rlim_inf, bignum_dbl_uipt(RLIM_SAVED_CUR)); + reg_varl(intern(lit("rlim-saved-max"), user_package), rlim_smax); + reg_varl(intern(lit("rlim-saved-cur"), user_package), rlim_scur); + reg_varl(intern(lit("rlim-infinity"), user_package), rlim_inf); + } +#else reg_varl(intern(lit("rlim-saved-max"), user_package), num_fast(RLIM_SAVED_MAX)); reg_varl(intern(lit("rlim-saved-cur"), user_package), num_fast(RLIM_SAVED_CUR)); reg_varl(intern(lit("rlim-infinity"), user_package), num_fast(RLIM_INFINITY)); +#endif reg_varl(intern(lit("rlimit-core"), user_package), num_fast(RLIMIT_CORE)); reg_varl(intern(lit("rlimit-cpu"), user_package), num_fast(RLIMIT_CPU)); reg_varl(intern(lit("rlimit-data"), user_package), num_fast(RLIMIT_DATA)); |