From c1c314994ba1f47f5af0be7600c400841c5d34da Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 18 Oct 2009 10:56:30 +0200 Subject: [PATCH] Implement nproc for IRIX. --- ChangeLog | 7 +++++++ lib/nproc.c | 15 +++++++++++++++ m4/nproc.m4 | 7 ++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c715d0a41..5a820cd30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-10-18 Bruno Haible + Implement nproc for IRIX. + * lib/nproc.c: Include . + (num_processors): On IRIX systems, try sysmp. + * m4/nproc.m4 (gl_PREREQ_NPROC): Check for sys/sysmp.h and sysmp. + +2009-10-18 Bruno Haible + Implement nproc for HP-UX. * lib/nproc.c: Include (num_processors): On HP-UX systems, try pstat_getdynamic. diff --git a/lib/nproc.c b/lib/nproc.c index 48c0d8aff..04a047cfb 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -29,6 +29,10 @@ # include #endif +#if HAVE_SYS_SYSMP_H +# include +#endif + #if HAVE_SYS_PARAM_H # include #endif @@ -62,6 +66,17 @@ num_processors (void) } #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; diff --git a/m4/nproc.m4 b/m4/nproc.m4 index 5bcae8028..5e80fa693 100644 --- a/m4/nproc.m4 +++ b/m4/nproc.m4 @@ -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 @@ AC_DEFUN([gl_NPROC], # 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 requires on OpenBSD 4.0. AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT @@ -20,5 +21,5 @@ AC_DEFUN([gl_PREREQ_NPROC], # include #endif ]) - AC_CHECK_FUNCS([pstat_getdynamic sysctl]) + AC_CHECK_FUNCS([pstat_getdynamic sysmp sysctl]) ]) -- 2.11.0