X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fnproc.m4;h=4664ffbbc0462de6dc5a244cab2cf4b4adb0246a;hb=effe7821374f8b7e22e9de3df9cc4e5f285712bd;hp=5e80fa6939720530d4e6a5f093cada924c10ef2a;hpb=c1c314994ba1f47f5af0be7600c400841c5d34da;p=gnulib.git diff --git a/m4/nproc.m4 b/m4/nproc.m4 index 5e80fa693..4664ffbbc 100644 --- a/m4/nproc.m4 +++ b/m4/nproc.m4 @@ -1,5 +1,5 @@ -# nproc.m4 serial 3 -dnl Copyright (C) 2009 Free Software Foundation, Inc. +# nproc.m4 serial 4 +dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -12,6 +12,9 @@ AC_DEFUN([gl_NPROC], # Prerequisites of lib/nproc.c. AC_DEFUN([gl_PREREQ_NPROC], [ + dnl Persuade glibc to declare CPU_SETSIZE, CPU_ISSET etc. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_HEADERS([sys/pstat.h sys/sysmp.h sys/param.h],,, [AC_INCLUDES_DEFAULT]) dnl requires on OpenBSD 4.0. @@ -21,5 +24,30 @@ AC_DEFUN([gl_PREREQ_NPROC], # include #endif ]) - AC_CHECK_FUNCS([pstat_getdynamic sysmp sysctl]) + + AC_CHECK_FUNCS([sched_getaffinity sched_getaffinity_np \ + pstat_getdynamic sysmp sysctl]) + + dnl Test whether sched_getaffinity has the expected declaration. + dnl glibc 2.3.[0-2]: + dnl int sched_getaffinity (pid_t, unsigned int, unsigned long int *); + dnl glibc 2.3.3: + dnl int sched_getaffinity (pid_t, cpu_set_t *); + dnl glibc >= 2.3.4: + dnl int sched_getaffinity (pid_t, size_t, cpu_set_t *); + if test $ac_cv_func_sched_getaffinity = yes; then + AC_CACHE_CHECK([for glibc compatible sched_getaffinity], + [gl_cv_func_sched_getaffinity3], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[sched_getaffinity (0, 0, (cpu_set_t *) 0);]])], + [gl_cv_func_sched_getaffinity3=yes], + [gl_cv_func_sched_getaffinity3=no]) + ]) + if test $gl_cv_func_sched_getaffinity3 = yes; then + AC_DEFINE([HAVE_SCHED_GETAFFINITY_LIKE_GLIBC], [1], + [Define to 1 if sched_getaffinity has a glibc compatible declaration.]) + fi + fi ])