Some more funny sysconf()...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25627 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-05-23 01:38:05 +00:00
parent 4b9329efe1
commit 74be35c78b
2 changed files with 82 additions and 1 deletions

View File

@ -86,6 +86,21 @@
#define _SC_SEM_VALUE_MAX 29
#define _SC_SEMAPHORES 30
#define _SC_THREADS 31
/* TODO: check and reorder */
#define _SC_IOV_MAX 32
#define _SC_UIO_MAXIOV _CS_IOV_MAX
#define _SC_NPROCESSORS_MAX 33
#define _SC_NPROCESSORS_CONF 34
#define _SC_NPROCESSORS_ONLN 35
#define _SC_CPUID_MAX 36
#define _SC_ATEXIT_MAX 37
#define _SC_PASS_MAX 39
#define _SC_PHYS_PAGES 40
#define _SC_AVPHYS_PAGES 41
#define _SC_PIPE 42
#define _SC_SELECT 43
#define _SC_POLL 44
/* confstr() constants */
#define _CS_PATH 1

View File

@ -20,6 +20,7 @@
#include <posix/realtime_sem_defs.h>
#include <user_group.h>
bool _kern_cpu_enabled(int cpu);
int
getdtablesize(void)
@ -35,6 +36,7 @@ getdtablesize(void)
long
sysconf(int name)
{
int err;
// TODO: This is about what BeOS does, better POSIX conformance would be nice, though
switch (name) {
@ -72,6 +74,70 @@ sysconf(int name)
return _POSIX_SEMAPHORES;
case _SC_THREADS:
return _POSIX_THREADS;
case _SC_IOV_MAX:
return IOV_MAX;
case _SC_NPROCESSORS_MAX:
return B_MAX_CPU_COUNT;
case _SC_NPROCESSORS_CONF:
{
system_info info;
err = get_system_info(&info);
if (err < B_OK) {
errno = err;
return -1;
}
return info.cpu_count;
}
case _SC_NPROCESSORS_ONLN:
{
system_info info;
int i;
int count = 0;
err = get_system_info(&info);
if (err < B_OK) {
errno = err;
return -1;
}
for (i = 0; i < info.cpu_count; i++)
if (_kern_cpu_enabled(i))
count++;
return count;
}
case _SC_CPUID_MAX:
return B_MAX_CPU_COUNT - 1;
case _SC_ATEXIT_MAX:
return ATEXIT_MAX;
case _SC_PASS_MAX:
break;
//XXX:return PASS_MAX;
case _SC_PHYS_PAGES:
{
system_info info;
err = get_system_info(&info);
if (err < B_OK) {
errno = err;
return -1;
}
return info.max_pages;
}
case _SC_AVPHYS_PAGES:
{
system_info info;
err = get_system_info(&info);
if (err < B_OK) {
errno = err;
return -1;
}
return info.max_pages - info.used_pages;
}
/*
case _SC_PIPE:
return 1;
case _SC_SELECT:
return 1;
case _SC_POLL:
return 1;
*/
}
errno = EINVAL;
@ -158,7 +224,7 @@ __pathconf_common(struct statvfs *fs, struct stat *st,
return 32;
}
// XXX: add fs ? add to statvfs/fs_info ?
return 64;
return FILESIZEBITS;
}
case _PC_SYMLINK_MAX: