Back to index

glibc  2.9
Functions
smp.h File Reference
#include <sys/sysctl.h>

Go to the source code of this file.

Functions

static int is_smp_system (void)

Function Documentation

static int is_smp_system ( void  ) [inline, static]

Definition at line 26 of file smp.h.

{
  static const int sysctl_args[] = { CTL_KERN, KERN_VERSION };
  char buf[512];
  size_t reslen = sizeof (buf);

  /* Try reading the number using `sysctl' first.  */
  if (__sysctl ((int *) sysctl_args,
              sizeof (sysctl_args) / sizeof (sysctl_args[0]),
              buf, &reslen, NULL, 0) < 0)
    {
      /* This was not successful.  Now try reading the /proc filesystem.  */
      int fd = __open ("/proc/sys/kernel/version", O_RDONLY);
      if (__builtin_expect (fd, 0) == -1
         || (reslen = __read (fd, buf, sizeof (buf))) <= 0)
       /* This also didn't work.  We give up and say it's a UP machine.  */
       buf[0] = '\0';

      __close (fd);
    }

  return strstr (buf, "SMP") != NULL;
}

Here is the call graph for this function: