Procházet zdrojové kódy

sysconf: use getrlimit to determine ARG_MAX

getrlimit previously was only called for NPTL (why?), fix that to be
used everywhere.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer před 12 roky
rodič
revize
4b24c5ad36
1 změnil soubory, kde provedl 6 přidání a 8 odebrání
  1. 6 8
      libc/unistd/sysconf.c

+ 6 - 8
libc/unistd/sysconf.c

@@ -31,14 +31,14 @@
 #include <sys/syscall.h>
 #include <sys/sysinfo.h>
 #include <sys/types.h>
+#include <sys/param.h>
 #ifdef __UCLIBC_HAS_REGEX__
 #include <regex.h>
 #endif
 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
 #include <sysdep.h>
-#include <sys/resource.h>
-
 #endif
+#include <sys/resource.h>
 #include <string.h>
 #include <dirent.h>
 #include "internal/parse_config.h"
@@ -154,9 +154,8 @@ static int nprocessors_conf(void)
 /* Get the value of the system variable NAME.  */
 long int sysconf(int name)
 {
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-      struct rlimit rlimit;
-#endif
+  struct rlimit rlimit;
+
   switch (name)
     {
     default:
@@ -164,14 +163,13 @@ long int sysconf(int name)
       return -1;
 
     case _SC_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
+#if defined ARG_MAX
       return ARG_MAX;
 #else
-      RETURN_NEG_1;
+      return legacy_ARG_MAX;
 #endif
 
     case _SC_CHILD_MAX: