diff options
author | Khem Raj <raj.khem@gmail.com> | 2010-07-09 11:23:36 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2010-07-09 11:23:36 -0700 |
commit | 87c1f3f912593910b978b51d62f549e4dc32e8fb (patch) | |
tree | 766a2d288c330d36794124610b19f2080c7f13e0 /libc/unistd/sysconf.c | |
parent | 42fb51e0d4e7ab9fe8ff2be3a7405acb8d44e9b2 (diff) |
include/param.h: Dont use ARG_MAX from kernel headers
* Use getrlimit for ARG_MAX in sysconf on nptl.
* Define NCARGS directly instead of ARG_MAX
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'libc/unistd/sysconf.c')
-rw-r--r-- | libc/unistd/sysconf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index b7cb4946f..d118f1b95 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -36,6 +36,8 @@ #endif #ifdef __UCLIBC_HAS_THREADS_NATIVE__ #include <sysdep.h> +#include <sys/resource.h> + #endif #ifndef num_present_cpus @@ -81,9 +83,16 @@ #define RETURN_FUNCTION(f) return f; #endif /* _UCLIBC_GENERATE_SYSCONF_ARCH */ +/* Legacy value of ARG_MAX. The macro is now not defined since the + actual value varies based on the stack size. */ +#define legacy_ARG_MAX 131072 + /* Get the value of the system variable NAME. */ long int sysconf(int name) { +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + struct rlimit rlimit; +#endif switch (name) { default: @@ -91,7 +100,11 @@ long int sysconf(int name) return -1; case _SC_ARG_MAX: -#ifdef ARG_MAX +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + /* Use getrlimit to get the stack limit. */ + if (getrlimit (RLIMIT_STACK, &rlimit) == 0) + return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4); +#elif defined ARG_MAX return ARG_MAX; #else RETURN_NEG_1; |