OSDN Git Service

handle _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 5 Aug 2009 20:56:03 +0000 (22:56 +0200)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 5 Aug 2009 20:56:03 +0000 (22:56 +0200)
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
libc/sysdeps/linux/common/bits/kernel-features.h
libc/unistd/sysconf.c

index 88a7182..5216d7b 100644 (file)
@@ -78,3 +78,8 @@
 # define __ASSUME_FCNTL64              1
 # define __ASSUME_VFORK_SYSCALL                1
 #endif
+
+/* This header was added somewhere around 2.6.13  */
+#if __LINUX_KERNEL_VERSION >= 132621
+# define HAVE_LINUX_CPUMASK_H  1
+#endif
index 37ccd4d..82bcf22 100644 (file)
 #include <regex.h>
 #endif
 
+#ifdef HAVE_LINUX_CPUMASK_H
+# include <linux/cpumask.h>
+#endif
+#ifndef num_present_cpus
+# define num_present_cpus() (1)
+#endif
+#ifndef num_online_cpus
+# define num_online_cpus() (1)
+#endif
+
 /* libc_hidden_proto(sysconf) */
 
 /* libc_hidden_proto(getpagesize) */
@@ -658,20 +668,10 @@ long int sysconf(int name)
 #endif
 
     case _SC_NPROCESSORS_CONF:
-#if 0
-      RETURN_FUNCTION(get_nprocs_conf());
-#else
-      /* this is a hack.  for now always claim we have exactly one cpu */
-      return 1;
-#endif
+      RETURN_FUNCTION(num_present_cpus());
 
     case _SC_NPROCESSORS_ONLN:
-#if 0
-      RETURN_FUNCTION(get_nprocs());
-#else
-      /* this is a hack.  for now always claim we have exactly one cpu */
-      return 1;
-#endif
+      RETURN_FUNCTION(num_online_cpus());
 
     case _SC_PHYS_PAGES:
 #if 0