Glibc's support for processor dispatch

Newer versions of Glibc (e.g. version 2.12 or later) contain processor-tuned routines. In version 2.14, the following functions have processor-specific versions: memcmp, memcpy, memmove, mempcpy, memset, strcat, strchr, strcmp, strlen, strrchr, strspn, strstr .

The source code can be found here.

The processor identification code is __init_cpu_features. It will fill a global variable called __cpu_features, which is a struct as follows (defined in init-arch.h):

struct
{
  enum cpu_features_kind
    {
      arch_kind_unknown = 0,
      arch_kind_intel,
      arch_kind_amd,
      arch_kind_other
    } kind;

  int max_cpuid;

  struct cpuid_registers
  {
    unsigned int eax;
    unsigned int ebx;
    unsigned int ecx;
    unsigned int edx;
  } cpuid[COMMON_CPUID_INDEX_MAX];

  unsigned int family;
  unsigned int model;
  unsigned int feature[FEATURE_INDEX_MAX];
}