Back to index

glibc  2.9
Classes | Defines | Functions | Variables
sysconf.c File Reference
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <hp-timing.h>
#include "../sysconf.c"

Go to the source code of this file.

Classes

struct  intel_02_cache_info

Defines

#define nintel_02_known   (sizeof (intel_02_known) / sizeof (intel_02_known[0]))
#define __sysconf   static linux_sysconf

Functions

static long int linux_sysconf (int name)
static long int __attribute__ ((noinline))
static int intel_02_known_compare (const void *p1, const void *p2)
static int i386_i486_test (void)
long int __sysconf (int name)

Variables

static struct intel_02_cache_info intel_02_known []

Class Documentation

struct intel_02_cache_info

Definition at line 68 of file sysconf.c.

Class Members
long int assoc
unsigned int idx
long int linesize
int name
long int size

Define Documentation

#define __sysconf   static linux_sysconf

Definition at line 440 of file sysconf.c.

#define nintel_02_known   (sizeof (intel_02_known) / sizeof (intel_02_known[0]))

Definition at line 126 of file sysconf.c.


Function Documentation

static long int __attribute__ ( (noinline)  ) [static]

Definition at line 29 of file sysconf.c.

{
  /* The processor only has a unified level 1 cache of 8k.  */
  switch (name)
    {
    case _SC_LEVEL1_ICACHE_SIZE:
    case _SC_LEVEL1_DCACHE_SIZE:
      return 8 * 1024;

    case _SC_LEVEL1_ICACHE_ASSOC:
    case _SC_LEVEL1_DCACHE_ASSOC:
      // XXX Anybody know this?
      return 0;

    case _SC_LEVEL1_ICACHE_LINESIZE:
    case _SC_LEVEL1_DCACHE_LINESIZE:
      // XXX Anybody know for sure?
      return 16;

    case _SC_LEVEL2_CACHE_SIZE:
    case _SC_LEVEL2_CACHE_ASSOC:
    case _SC_LEVEL2_CACHE_LINESIZE:
    case _SC_LEVEL3_CACHE_SIZE:
    case _SC_LEVEL3_CACHE_ASSOC:
    case _SC_LEVEL3_CACHE_LINESIZE:
    case _SC_LEVEL4_CACHE_SIZE:
    case _SC_LEVEL4_CACHE_ASSOC:
      /* Not available.  */
      break;

    default:
      assert (! "cannot happen");
    }

  return -1;
}
long int __sysconf ( int  name)

Definition at line 391 of file sysconf.c.

{
  /* 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?
    return -1;

  /* Detect i486, the last Intel processor without CPUID.  */
  if ((ac & (1 << 21)) == 0)
    {
      /* No CPUID.  */
      // XXX Fill in info about other brands.  For now only Intel.
      return handle_i486 (name);
    }

  /* Find out what brand of processor.  */
  unsigned int eax;
  unsigned int ebx;
  unsigned int ecx;
  unsigned int edx;
  asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
              : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx)
              : "0" (0));

  /* This spells out "GenuineIntel".  */
  if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69)
    return handle_intel (name, eax);

  /* This spells out "AuthenticAMD".  */
  if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
    return handle_amd (name);

  // XXX Fill in more vendors.

  /* CPU not known, we have no information.  */
  return 0;
}

Here is the call graph for this function:

static int i386_i486_test ( void  ) [static]

Definition at line 368 of file sysconf.c.

{
  int eflags;
  int ac;
  asm volatile ("pushfl;\n\t"
              "popl %0;\n\t"
              "movl $0x240000, %1;\n\t"
              "xorl %0, %1;\n\t"
              "pushl %1;\n\t"
              "popfl;\n\t"
              "pushfl;\n\t"
              "popl %1;\n\t"
              "xorl %0, %1;\n\t"
              "pushl %0;\n\t"
              "popfl"
              : "=r" (eflags), "=r" (ac));

  return ac;
}

Here is the caller graph for this function:

static int intel_02_known_compare ( const void *  p1,
const void *  p2 
) [static]

Definition at line 130 of file sysconf.c.

{
  const struct intel_02_cache_info *i1;
  const struct intel_02_cache_info *i2;

  i1 = (const struct intel_02_cache_info *) p1;
  i2 = (const struct intel_02_cache_info *) p2;

  if (i1->idx == i2->idx)
    return 0;

  return i1->idx < i2->idx ? -1 : 1;
}
static long int linux_sysconf ( int  name) [static]

Here is the caller graph for this function:


Variable Documentation