aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac337
1 files changed, 337 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 65a700fb..b9160692 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3917,6 +3917,343 @@ AS_VAR_IF([enable_tools],["yes"],
3917 ) 3917 )
3918 ] 3918 ]
3919 ) 3919 )
3920 AC_CHECK_HEADERS([features.h sys/pstat.h vxCpuLib.h],[],[],[AC_INCLUDES_DEFAULT])
3921 AC_CHECK_DECLS(
3922 [_SC_NPROCESSORS_ONLN,_SC_NPROC_ONLN,_SC_CRAY_NCPU,_SC_NPROCESSORS_CONF,CTL_HW,HW_NCPUONLINE,HW_NCPU,HW_AVAILCPU],
3923 [],[],
3924 [[
3925#ifdef HAVE_SYS_TYPES_H
3926#include <sys/types.h>
3927#endif /* HAVE_SYS_TYPES_H */
3928#ifdef HAVE_SYS_PARAM_H
3929#include <sys/param.h>
3930#endif /* HAVE_SYS_PARAM_H */
3931#ifdef HAVE_SYS_SYSCTL_H
3932#include <sys/sysctl.h>
3933#endif /* HAVE_SYS_SYSCTL_H */
3934#ifdef HAVE_UNISTD_H
3935#include <unistd.h>
3936#endif /* HAVE_UNISTD_H */
3937 ]]
3938 )
3939 MHD_CHECK_FUNC([pstat_getdynamic],[[
3940#include <sys/param.h>
3941#include <sys/pstat.h>
3942 ]],
3943 [[
3944 struct pst_dynamic psd_data;
3945 i][f (1 != pstat_getdynamic(&psd_data, sizeof(psd_data), (size_t)1, 0))
3946 return 2;
3947 i][f (0 >= psd_data.psd_proc_cnt)
3948 return 3;
3949 ]]
3950 )
3951 MHD_CHECK_FUNC([vxCpuEnabledGet],[[#include <vxCpuLib.h>]],
3952 [[
3953 cpuset_t enb_set;
3954 enb_set = vxCpuEnabledGet();
3955 (void) enb_set;
3956 ]]
3957 )
3958 AC_CHECK_HEADERS([sched.h sys/_cpuset.h sys/cpuset.h],[],[],[AC_INCLUDES_DEFAULT])
3959 # glibc / Linux kernel
3960 MHD_CHECK_FUNC([getpid],[[
3961#ifdef HAVE_SYS_TYPES_H
3962#include <sys/types.h>
3963#endif /* HAVE_SYS_TYPES_H */
3964#include <unistd.h>
3965 ]],
3966 [[
3967 pid_t cur_pid;
3968 cur_pid = getpid();
3969 (void) &cur_pid; /* Mute possible warning */
3970 ]],
3971 [
3972 MHD_CHECK_FUNC([sched_getaffinity],[[
3973#ifdef HAVE_SYS_TYPES_H
3974#include <sys/types.h>
3975#endif /* HAVE_SYS_TYPES_H */
3976#include <unistd.h>
3977#include <sched.h>
3978 ]],
3979 [[
3980 cpu_set_t cur_set;
3981 i][f (0 != sched_getaffinity(getpid(), sizeof(cur_set), &cur_set))
3982 return 2;
3983 i][f (0 == CPU_SET (0, &cur_set))
3984 return 3; /* Actually this could be a valid result */
3985 ]],
3986 [
3987 MHD_CHECK_FUNC([CPU_COUNT],[[
3988#include <stddef.h>
3989#include <sched.h>
3990 ]],
3991 [[
3992 cpu_set_t cur_set;
3993 CPU_ZERO(&cur_set);
3994 i][f (0 != CPU_COUNT(&cur_set))
3995 return 2;
3996 ]],
3997 [
3998 MHD_CHECK_FUNC([CPU_COUNT_S],[[
3999#include <stddef.h>
4000#include <sched.h>
4001 ]],
4002 [[
4003 static const unsigned int set_size_cpus = 2048u;
4004 const size_t set_size_bytes = (size_t) CPU_ALLOC_SIZE(set_size_cpus);
4005 cpu_set_t *p_set;
4006 p_set = CPU_ALLOC(set_size_cpus);
4007 i][f (!p_set)
4008 return 2;
4009 CPU_ZERO_S(set_size_bytes, p_set);
4010 i][f (0 != CPU_COUNT_S(set_size_bytes, p_set))
4011 {
4012 CPU_FREE(p_set);
4013 return 3;
4014 }
4015 CPU_FREE(p_set);
4016 ]],
4017 [AC_CHECK_DECLS([CPU_SETSIZE],[],[],[#include <sched.h>])]
4018 )
4019 ]
4020 )
4021 ]
4022 )
4023 # NetBSD
4024 # Should work only with -lrt, but actually works without it.
4025 MHD_CHECK_FUNC([sched_getaffinity_np],[[
4026#ifdef HAVE_SYS_TYPES_H
4027#include <sys/types.h>
4028#endif /* HAVE_SYS_TYPES_H */
4029#include <unistd.h>
4030#include <sched.h>
4031 ]],
4032 [[
4033 cpuset_t *cpuset_ptr;
4034 cpuid_t cpu_num = 0;
4035 cpuset_ptr = cpuset_create();
4036 i][f (!cpuset_ptr)
4037 return 2;
4038 i][f (0 != sched_getaffinity_np(getpid(), cpuset_size(cpuset_ptr), cpuset_ptr))
4039 {
4040 cpuset_destroy(cpuset_ptr);
4041 return 3;
4042 }
4043 i][f (0 >= cpuset_isset(cpu_num, cpuset_ptr))
4044 {
4045 cpuset_destroy(cpuset_ptr);
4046 return 4; /* Actually this could be a valid result */
4047 }
4048 cpuset_destroy(cpuset_ptr);
4049 ]]
4050 )
4051 ]
4052 )
4053 # FreeBSD
4054 MHD_CHECK_FUNC([cpuset_getaffinity],[[
4055#ifdef HAVE_SYS_PARAM_H
4056#include <sys/param.h>
4057#endif /* HAVE_SYS_PARAM_H */
4058#include <sys/cpuset.h>
4059 ]],
4060 [[
4061 cpuset_t cur_mask;
4062 i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, sizeof(cur_mask), &cur_mask))
4063 return 2;
4064 ]],
4065 [
4066 MHD_CHECK_FUNC([CPU_COUNT],[[
4067#ifdef HAVE_SYS_PARAM_H
4068#include <sys/param.h>
4069#endif /* HAVE_SYS_PARAM_H */
4070#ifdef HAVE_SYS__CPUSET_H
4071#include <sys/_cpuset.h>
4072#endif /* HAVE_SYS_PARAM_H */
4073#include <sys/cpuset.h>
4074 ]],
4075 [[
4076 cpuset_t test_mask;
4077 CPU_ZERO(&test_mask);
4078 i][f (0 != CPU_COUNT(&test_mask))
4079 return 2;
4080 ]],
4081 [
4082 MHD_CHECK_FUNC([CPU_COUNT_S],[[
4083#ifdef HAVE_SYS_PARAM_H
4084#include <sys/param.h>
4085#endif /* HAVE_SYS_PARAM_H */
4086#ifdef HAVE_SYS__CPUSET_H
4087#include <sys/_cpuset.h>
4088#endif /* HAVE_SYS_PARAM_H */
4089#include <sys/cpuset.h>
4090 ]],
4091 [[
4092 static const unsigned int max_cpu_num = 2048u;
4093 cpuset_t *mask_ptr;
4094 mask_ptr = CPU_ALLOC(max_cpu_num);
4095 i][f (! mask_ptr)
4096 return 2;
4097 i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1,
4098 CPU_ALLOC_SIZE(max_cpu_num), mask_ptr))
4099 {
4100 CPU_FREE(mask_ptr);
4101 return 3;
4102 }
4103 i][f (0 == CPU_COUNT_S(CPU_ALLOC_SIZE(max_cpu_num), &test_mask))
4104 {
4105 CPU_FREE(mask_ptr);
4106 return 4;
4107 }
4108 CPU_FREE(mask_ptr);
4109 ]]
4110 )
4111 ]
4112 )
4113 ]
4114 )
4115 AS_VAR_IF([mhd_cv_func_CPU_COUNT_S],["yes"],
4116 [
4117 AC_CACHE_CHECK([whether CPU_COUNT_S() expects max CPU number as 'size' parameter],[mhd_cv_func_cpu_count_s_cpus],
4118 [
4119 AS_VAR_IF([cross-compiling],["yes"],[mhd_cv_func_cpu_count_s_cpus="assuming no"],
4120 [
4121 AC_LINK_IFELSE(
4122 [
4123 AC_LANG_PROGRAM([[
4124#ifdef HAVE_SYS_TYPES_H
4125#include <sys/types.h>
4126#endif /* HAVE_SYS_TYPES_H */
4127#ifdef HAVE_SYS_PARAM_H
4128#include <sys/param.h>
4129#endif /* HAVE_SYS_PARAM_H */
4130#ifdef HAVE_SYS__CPUSET_H
4131#include <sys/_cpuset.h>
4132#endif /* HAVE_SYS_PARAM_H */
4133#ifdef HAVE_SYS_CPUSET_H
4134#include <sys/cpuset.h>
4135#endif /* HAVE_SYS_CPUSET_H */
4136#ifdef HAVE_STDDEF_H
4137#include <stddef.h>
4138#endif /* HAVE_STDDEF_H */
4139#ifdef HAVE_UNISTD_H
4140#include <unistd.h>
4141#endif /* HAVE_UNISTD_H */
4142#ifdef HAVE_SCHED_H
4143#include <sched.h>
4144#endif /* HAVE_SCHED_H */
4145#include <stdio.h>
4146
4147#ifdef HAVE_SCHED_GETAFFINITY
4148#define TEST_CPUSET_TYPE cpu_set_t
4149#else /* ! HAVE_SCHED_GETAFFINITY */
4150#define TEST_CPUSET_TYPE cpuset_t
4151#endif /* ! HAVE_SCHED_GETAFFINITY */
4152 ]],
4153 [[
4154 TEST_CPUSET_TYPE *p_testset;
4155 /* The size of the cpuset that is larger then the test cpuset (in CPUs) */
4156 static const unsigned int testset_size_oversized_cpus = (8 * sizeof(long)) * 1024;
4157 const size_t testset_size_oversized_bytes = CPU_ALLOC_SIZE(testset_size_oversized_cpus);
4158 /* The size of the test cpuset in number of CPUs */
4159 const unsigned int testset_size_cpus = (unsigned int) testset_size_oversized_bytes;
4160 /* The size of the test cpuset in bytes */
4161 const size_t testset_size_bytes = CPU_ALLOC_SIZE(testset_size_cpus);
4162 /* The last one CPU in the test set */
4163 const unsigned int test_cpu_num1 = testset_size_cpus - 1;
4164 /* The penultimate CPU in the test set */
4165 const unsigned int test_cpu_num2 = testset_size_cpus - 2;
4166 /* The CPU numbers that should be cleared */
4167 const unsigned int test_cpu_clear1 = testset_size_cpus - 3;
4168 const unsigned int test_cpu_clear2 = testset_size_cpus - 4;
4169 unsigned int count_res;
4170 int ret = 0;
4171
4172 /* Allocate oversize area to ensure that memory outside the buffer is not used */
4173 p_testset = CPU_ALLOC(testset_size_oversized_cpus);
4174 if (! p_testset)
4175 {
4176 fprintf (stderr, "Error allocating memory.\n");
4177 return 99;
4178 }
4179 /* Set the some CPU numbers and then clear them */
4180 CPU_SET_S(test_cpu_clear1, testset_size_bytes, p_testset);
4181 CPU_SET_S(test_cpu_clear2, testset_size_bytes, p_testset);
4182 CPU_ZERO_S(testset_size_bytes, p_testset);
4183 /* Set two CPUs on */
4184 CPU_SET_S(test_cpu_num1, testset_size_bytes, p_testset);
4185 CPU_SET_S(test_cpu_num2, testset_size_bytes, p_testset);
4186 count_res = (unsigned int) CPU_COUNT_S(testset_size_bytes, p_testset);
4187 if (0 == count_res)
4188 {
4189 fprintf (stderr, "Full cpuset cannot be read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
4190 /* Set the some CPU numbers and then clear them */
4191 CPU_SET_S(test_cpu_clear1, testset_size_cpus, p_testset);
4192 CPU_SET_S(test_cpu_clear2, testset_size_cpus, p_testset);
4193 CPU_ZERO_S(testset_size_cpus, p_testset);
4194 /* Set two CPUs on */
4195 CPU_SET_S(test_cpu_num1, testset_size_cpus, p_testset);
4196 CPU_SET_S(test_cpu_num2, testset_size_cpus, p_testset);
4197 count_res = (unsigned int) CPU_COUNT_S(testset_size_cpus, p_testset);
4198 if (2 == count_res)
4199 {
4200 fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() only when using the maximum CPU number as the size parameter.\n");
4201 ret = 3;
4202 }
4203 else
4204 {
4205 fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the maximum CPU number as the size parameter.\n");
4206 fprintf (stderr, "Number of 'enabled' CPUs: 2\n");
4207 fprintf (stderr, "Number of counted CPUs: %u\n", count_res);
4208 fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n");
4209 ret = 70;
4210 }
4211 }
4212 else if (2 == count_res)
4213 {
4214 fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
4215 }
4216 else
4217 {
4218 fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
4219 fprintf (stderr, "Number of 'enabled' CPUs: 2\n");
4220 fprintf (stderr, "Number of counted CPUs: %u\n", count_res);
4221 fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n");
4222 ret = 71;
4223 }
4224 CPU_FREE(p_testset);
4225 if (0 != ret)
4226 return ret;
4227 ]]
4228 )
4229 ],
4230 [
4231 AM_RUN_LOG([./conftest$EXEEXT])
4232 count_test_res=$?
4233 AS_IF([test $count_test_res -eq 0],[mhd_cv_func_cpu_count_s_cpus="no"],
4234 [test $count_test_res -eq 3],[mhd_cv_func_cpu_count_s_cpus="yes"],
4235 [
4236 AC_MSG_WARN([Unexpected value returned by CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}])
4237 mhd_cv_func_cpu_count_s_cpus="assuming no"
4238 ]
4239 )
4240 ],
4241 [
4242 AC_MSG_WARN([Cannot build CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}])
4243 mhd_cv_func_cpu_count_s_cpus="assuming no"
4244 ]
4245 )
4246 ]
4247 )
4248 ]
4249 )
4250 AS_VAR_IF([mhd_cv_func_cpu_count_s_cpus],["yes"],
4251 [AC_DEFINE([MHD_FUNC_CPU_COUNT_S_GETS_CPUS],[1],
4252 [Define to '1' if CPU_COUNT_S() function expects max CPU number as 'size' parameter])
4253 ]
4254 )
4255 ]
4256 )
3920 ] 4257 ]
3921) 4258)
3922 4259