3 dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
13 # Prerequisites of lib/nproc.c.
14 AC_DEFUN([gl_PREREQ_NPROC],
16 dnl Persuade glibc <sched.h> to declare CPU_SETSIZE, CPU_ISSET etc.
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
19 AC_CHECK_HEADERS([sys/pstat.h sys/sysmp.h sys/param.h],,,
20 [AC_INCLUDES_DEFAULT])
21 dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
22 AC_CHECK_HEADERS([sys/sysctl.h],,,
25 # include <sys/param.h>
29 AC_CHECK_FUNCS([sched_getaffinity_np pstat_getdynamic sysmp sysctl])
30 gl_CHECK_FUNCS_ANDROID([sched_getaffinity], [[#include <sched.h>]])
32 dnl Test whether sched_getaffinity has the expected declaration.
34 dnl int sched_getaffinity (pid_t, unsigned int, unsigned long int *);
36 dnl int sched_getaffinity (pid_t, cpu_set_t *);
38 dnl int sched_getaffinity (pid_t, size_t, cpu_set_t *);
39 if test $ac_cv_func_sched_getaffinity = yes; then
40 AC_CACHE_CHECK([for glibc compatible sched_getaffinity],
41 [gl_cv_func_sched_getaffinity3],
46 [[sched_getaffinity (0, 0, (cpu_set_t *) 0);]])],
47 [gl_cv_func_sched_getaffinity3=yes],
48 [gl_cv_func_sched_getaffinity3=no])
50 if test $gl_cv_func_sched_getaffinity3 = yes; then
51 AC_DEFINE([HAVE_SCHED_GETAFFINITY_LIKE_GLIBC], [1],
52 [Define to 1 if sched_getaffinity has a glibc compatible declaration.])