diff options
author | Rich Felker <dalias@aerifal.cx> | 2022-08-26 11:34:46 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2022-08-26 11:34:46 -0400 |
commit | 996b6154b20184c3b08cce28eb01edb7f47e9413 (patch) | |
tree | 3db80b6e5da61f809baf98899a4d69b8e3103cfc /src/conf | |
parent | 25340a93375fc6d3324ab65c154edbf8d1701801 (diff) | |
download | musl-996b6154b20184c3b08cce28eb01edb7f47e9413.tar.gz |
use kernel-provided AT_MINSIGSTKSZ for sysconf(_SC_[MIN]SIGSTKSZ)
use the legacy constant values if the kernel does not provide
AT_MINSIGSTKSZ (__getauxval will return 0 in this case) and as a
safety check if something is wrong and the provided value is less than
the legacy constant.
sysconf(_SC_SIGSTKSZ) returns SIGSTKSZ adjusted for the difference
between the legacy constant MINSIGSTKSZ and the runtime value, so that
the working space the application has on top of the minimum remains
invariant under changes to the minimum.
Diffstat (limited to 'src/conf')
-rw-r--r-- | src/conf/sysconf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c index 33220daf..60d3e745 100644 --- a/src/conf/sysconf.c +++ b/src/conf/sysconf.c @@ -4,6 +4,7 @@ #include <sys/resource.h> #include <signal.h> #include <sys/sysinfo.h> +#include <sys/auxv.h> #include "syscall.h" #include "libc.h" @@ -19,6 +20,8 @@ #define JT_AVPHYS_PAGES JT(9) #define JT_ZERO JT(10) #define JT_DELAYTIMER_MAX JT(11) +#define JT_MINSIGSTKSZ JT(12) +#define JT_SIGSTKSZ JT(13) #define RLIM(x) (-32768|(RLIMIT_ ## x)) @@ -166,8 +169,8 @@ long sysconf(int name) [_SC_THREAD_ROBUST_PRIO_INHERIT] = -1, [_SC_THREAD_ROBUST_PRIO_PROTECT] = -1, - [_SC_MINSIGSTKSZ] = MINSIGSTKSZ, - [_SC_SIGSTKSZ] = SIGSTKSZ, + [_SC_MINSIGSTKSZ] = JT_MINSIGSTKSZ, + [_SC_SIGSTKSZ] = JT_SIGSTKSZ, }; if (name >= sizeof(values)/sizeof(values[0]) || !values[name]) { @@ -215,6 +218,13 @@ long sysconf(int name) mem *= si.mem_unit; mem /= PAGE_SIZE; return (mem > LONG_MAX) ? LONG_MAX : mem; + case JT_MINSIGSTKSZ & 255: + case JT_SIGSTKSZ & 255: ; + long val = __getauxval(AT_MINSIGSTKSZ); + if (val < MINSIGSTKSZ) val = MINSIGSTKSZ; + if (values[name] == JT_SIGSTKSZ) + val += SIGSTKSZ - MINSIGSTKSZ; + return val; case JT_ZERO & 255: return 0; } |