diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-03-16 18:31:02 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-04-07 14:06:18 +0530 |
commit | d1a3dcabf2f89233a99a4a9be08f9f407da0b6b4 (patch) | |
tree | 923c89bfe24a3ab053337bcf3eb36675ee276c68 /elf/dl-tunables.h | |
parent | bf6b6243c9fe6e9727282ed63f774698e730cedd (diff) | |
download | glibc-d1a3dcabf2f89233a99a4a9be08f9f407da0b6b4.tar.gz glibc-d1a3dcabf2f89233a99a4a9be08f9f407da0b6b4.tar.xz glibc-d1a3dcabf2f89233a99a4a9be08f9f407da0b6b4.zip |
tunables: Fix comparison of tunable values
The simplification of tunable_set interfaces took care of signed/unsigned conversions while setting values, but comparison with bounds ended up being incorrect; comparing TUNABLE_SIZE_T values for example will fail because SIZE_MAX is seen as -1. Add comparison helpers that take tunable types into account and use them to do comparison instead.
Diffstat (limited to 'elf/dl-tunables.h')
-rw-r--r-- | elf/dl-tunables.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h index ba7ae6b52e..3880e4aab6 100644 --- a/elf/dl-tunables.h +++ b/elf/dl-tunables.h @@ -115,6 +115,24 @@ rtld_hidden_proto (__tunable_set_val) /* The default value for TUNABLES_FRONTEND. */ # define TUNABLES_FRONTEND_yes TUNABLES_FRONTEND_valstring +static __always_inline bool +tunable_val_lt (tunable_num_t lhs, tunable_num_t rhs, bool unsigned_cmp) +{ + if (unsigned_cmp) + return (uintmax_t) lhs < (uintmax_t) rhs; + else + return lhs < rhs; +} + +static __always_inline bool +tunable_val_gt (tunable_num_t lhs, tunable_num_t rhs, bool unsigned_cmp) +{ + if (unsigned_cmp) + return (uintmax_t) lhs > (uintmax_t) rhs; + else + return lhs > rhs; +} + /* Compare two name strings, bounded by the name hardcoded in glibc. */ static __always_inline bool tunable_is_name (const char *orig, const char *envname) |