diff --git a/nptl/sysdeps/unix/sysv/linux/i386/smp.h b/nptl/sysdeps/unix/sysv/linux/i386/smp.h index f68a0c0..859468f 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/smp.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/smp.h @@ -22,6 +22,7 @@ #include #include #include +#include /* Test whether the machine has more than one processor. This is not the best test but good enough. More complicated tests would require `malloc' @@ -29,28 +30,24 @@ static inline int is_smp_system (void) { - union - { - struct utsname uts; - char buf[512]; - } u; - char *cp; + 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 (uname (&u.uts) == 0) - cp = u.uts.version; - else + 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_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY); if (__builtin_expect (fd, 0) == -1 - || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0) - /* This also didn't work. We give up and say it's a UP machine. */ - u.buf[0] = '\0'; + || (reslen = read_not_cancel (fd, buf, sizeof (buf))) <= 0) + /* This also didn't work. We give up and say it's a UP machine. */ + buf[0] = '\0'; close_not_cancel_no_status (fd); - cp = u.buf; } - return strstr (cp, "SMP") != NULL; + return strstr (buf, "SMP") != NULL; }