bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nproc: use pstat_getdynamic when it is available.


From: Bruno Haible
Subject: Re: nproc: use pstat_getdynamic when it is available.
Date: Sun, 18 Oct 2009 10:58:26 +0200
User-agent: KMail/1.9.9

And this adds support for IRIX to the nproc module. Untested. Testing is
welcome.


2009-10-18  Bruno Haible  <address@hidden>

        Implement nproc for IRIX.
        * lib/nproc.c: Include <sys/sysmp.h>.
        (num_processors): On IRIX systems, try sysmp.
        * m4/nproc.m4 (gl_PREREQ_NPROC): Check for sys/sysmp.h and sysmp.

--- lib/nproc.c.orig    2009-10-18 10:54:20.000000000 +0200
+++ lib/nproc.c 2009-10-18 10:50:40.000000000 +0200
@@ -29,6 +29,10 @@
 # include <sys/pstat.h>
 #endif
 
+#if HAVE_SYS_SYSMP_H
+# include <sys/sysmp.h>
+#endif
+
 #if HAVE_SYS_PARAM_H
 # include <sys/param.h>
 #endif
@@ -62,6 +66,17 @@
   }
 #endif
 
+#if HAVE_SYSMP && defined MP_NAPROCS
+  { /* This works on IRIX.  */
+    /* MP_NPROCS yields the number of installed processors.
+       MP_NAPROCS yields the number of processors available to unprivileged
+       processes.  We need the latter.  */
+    int nprocs = sysmp (MP_NAPROCS);
+    if (0 < nprocs)
+      return nprocs;
+  }
+#endif
+
 #if HAVE_SYSCTL && defined HW_NCPU
   { /* This works on MacOS X, FreeBSD, NetBSD, OpenBSD.  */
     int nprocs;
--- m4/nproc.m4.orig    2009-10-18 10:54:20.000000000 +0200
+++ m4/nproc.m4 2009-10-18 10:51:38.000000000 +0200
@@ -1,4 +1,4 @@
-# nproc.m4 serial 2
+# nproc.m4 serial 3
 dnl Copyright (C) 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,8 @@
 # Prerequisites of lib/nproc.c.
 AC_DEFUN([gl_PREREQ_NPROC],
 [
-  AC_CHECK_HEADERS([sys/pstat.h sys/param.h],,, [AC_INCLUDES_DEFAULT])
+  AC_CHECK_HEADERS([sys/pstat.h sys/sysmp.h sys/param.h],,,
+    [AC_INCLUDES_DEFAULT])
   dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
   AC_CHECK_HEADERS([sys/sysctl.h],,,
     [AC_INCLUDES_DEFAULT
@@ -20,5 +21,5 @@
      # include <sys/param.h>
      #endif
     ])
-  AC_CHECK_FUNCS([pstat_getdynamic sysctl])
+  AC_CHECK_FUNCS([pstat_getdynamic sysmp sysctl])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]