fix <sys/cpuset.h> not detected on FreeBSD #520
+21
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On some FreeBSDs,
configurecould not detect<sys/cpuset.h>, because it tried to include it without<sys/param.h>, while (as seen in the man page forcpuset_setaffinity()), they should work in pair.Why?
This is likely due to an autoconf bug:
the historic list of headers included by
AC_INCLUDES_DEFAULTends with<sys/stat.h>and<unistd.h>, without<sys/param.h>,while in paradox
ac_header_cxx_listdefines theHAVE_…_Hmacros untilHAVE_SYS_TYPES_H,HAVE_UNISTD_H, plusHAVE_SYS_PARAM_H.What happens?
However, the detection for the function
cpuset_setaffinity()works well, in the sameconfigure.So we end up with:
HAVE_SYS_CPUSET_Hundefined(→ no
#include <sys/cpuset.h>),HAVE_CPUSET_SETAFFINITYis defined(→ in
set_this_thread_affinity_and_priority(), the#elif defined(__FreeBSD__) && defined(HAVE_CPUSET_SETAFFINITY)block gets compiled).→ The compilation fails with undefined types and macros.
Fixing
I put the test for
<sys/cpuset.h>apart from the other includes, appending<sys/param.h>to the preincluded files, similarly to what openldap did for a similar need (for<ucred.h>).