X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fconf%2Fsysconf.c;h=4819ae6a5f76e48c8bbb1b2fa83ea24046da3415;hp=07072ccfdba7209dd1424fcd8bec4786bd808269;hb=4ca442157e381690202c3bcc102627d137fd0466;hpb=c61312596608bf819b693c04a395f1b4e3e0acf0 diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c index 07072ccf..4819ae6a 100644 --- a/src/conf/sysconf.c +++ b/src/conf/sysconf.c @@ -6,6 +6,7 @@ #define VER (-2) #define OFLOW (-3) +#define CPUCNT (-4) #define RLIM(x) (-32768|(RLIMIT_ ## x)) long sysconf(int name) @@ -88,14 +89,14 @@ long sysconf(int name) [_SC_THREAD_KEYS_MAX] = PTHREAD_KEYS_MAX, [_SC_THREAD_STACK_MIN] = PTHREAD_STACK_MIN, [_SC_THREAD_THREADS_MAX] = -1, - [_SC_THREAD_ATTR_STACKADDR] = -1, + [_SC_THREAD_ATTR_STACKADDR] = VER, [_SC_THREAD_ATTR_STACKSIZE] = VER, - [_SC_THREAD_PRIORITY_SCHEDULING] = -1, + [_SC_THREAD_PRIORITY_SCHEDULING] = VER, [_SC_THREAD_PRIO_INHERIT] = -1, [_SC_THREAD_PRIO_PROTECT] = -1, [_SC_THREAD_PROCESS_SHARED] = VER, - [_SC_NPROCESSORS_CONF] = -1, - [_SC_NPROCESSORS_ONLN] = -1, + [_SC_NPROCESSORS_CONF] = CPUCNT, + [_SC_NPROCESSORS_ONLN] = CPUCNT, [_SC_PHYS_PAGES] = -1, [_SC_AVPHYS_PAGES] = -1, [_SC_ATEXIT_MAX] = -1, @@ -150,7 +151,7 @@ long sysconf(int name) [_SC_C_LANG_SUPPORT_R] = -1, [_SC_CLOCK_SELECTION] = VER, [_SC_CPUTIME] = VER, - [_SC_THREAD_CPUTIME] = -1, + [_SC_THREAD_CPUTIME] = VER, [_SC_DEVICE_IO] = -1, [_SC_DEVICE_SPECIFIC] = -1, [_SC_DEVICE_SPECIFIC_R] = -1, @@ -220,6 +221,13 @@ long sysconf(int name) } else if (values[name] == OFLOW) { if (name == _SC_ARG_MAX) return ARG_MAX; if (name == _SC_SEM_VALUE_MAX) return SEM_VALUE_MAX; + } else if (values[name] == CPUCNT) { + unsigned char set[128] = {1}; + int i, cnt; + __syscall(SYS_sched_getaffinity, 0, sizeof set, set); + for (i=cnt=0; i