diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/sysconf.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/sysconf.c b/sysdeps/unix/sysv/linux/i386/sysconf.c index cb4706de73..8a9ab61912 100644 --- a/sysdeps/unix/sysv/linux/i386/sysconf.c +++ b/sysdeps/unix/sysv/linux/i386/sysconf.c @@ -319,16 +319,9 @@ handle_amd (int name) } -/* Get the value of the system variable NAME. */ -long int -__sysconf (int name) +static int +i386_i486_test (void) { - /* We only handle the cache information here (for now). */ - if (name < _SC_LEVEL1_ICACHE_SIZE || name > _SC_LEVEL4_CACHE_LINESIZE) - return linux_sysconf (name); - - /* Recognize i386 and compatible. These don't have any cache on - board. */ int eflags; int ac; asm volatile ("pushfl;\n\t" @@ -343,6 +336,35 @@ __sysconf (int name) "pushl %0;\n\t" "popfl" : "=r" (eflags), "=r" (ac)); + + return ac; +} + + +/* Get the value of the system variable NAME. */ +long int +__sysconf (int name) +{ + if (name == _SC_CPUTIME || name == _SC_THREAD_CPUTIME) + { + /* Check dynamically. */ + int ac = i386_i486_test (); + + /* Only i386 and i486 have no TSC. */ + // XXX We can add here test for machines which cannot support a + // XXX usabel TSC. + return ac == 0 || (ac & (1 << 21)) == 0 ? -1 : 200112L; + } + + /* All the remainder, except the cache information, is handled in + the generic code. */ + if (name < _SC_LEVEL1_ICACHE_SIZE || name > _SC_LEVEL4_CACHE_LINESIZE) + return linux_sysconf (name); + + /* Recognize i386 and compatible. These don't have any cache on + board. */ + int ac = i386_i486_test (); + if (ac == 0) /* This is an i386. */ // XXX Is this true for all brands? |