Skip to content

Commit

Permalink
- Fix for #74, #75: cpuset test for header contents and provide code.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcawijngaards committed Mar 19, 2020
1 parent 347a1b6 commit c426b15
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
21 changes: 4 additions & 17 deletions compat/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,65 @@
#include <unistd.h>

#ifndef HAVE_CPUSET_CREATE
#if __linux__ || __FreeBSD__
cpuset_t *cpuset_create(void)
{
cpuset_t *set = calloc(1, sizeof(*set));
return set;
}
#endif
#endif /* !HAVE_CPUSET_CREATE */

#ifndef HAVE_CPUSET_DESTROY
#if __linux__ || __FreeBSD__
void cpuset_destroy(cpuset_t *set)
{
free(set);
}
#endif
#endif /* !HAVE_CPUSET_DESTROY */

#ifndef HAVE_CPUSET_ZERO
#if __linux__ || __FreeBSD__
void cpuset_zero(cpuset_t *set)
{
CPU_ZERO(set);
}
#endif
#endif /* !HAVE_CPUSET_ZERO */

#ifndef HAVE_CPUSET_SET
#if __linux__ || __FreeBSD__
int cpuset_set(cpuid_t cpu, cpuset_t *set)
{
CPU_SET(cpu, set);
return 0;
}
#endif
#endif /* !HAVE_CPUSET_SET */

#ifndef HAVE_CPUSET_CLR
#if __linux__ || __FreeBSD__
int cpuset_clr(cpuid_t cpu, cpuset_t *set)
{
CPU_CLR(cpu, set);
return 0;
}
#endif
#endif /* !HAVE_CPUSET_CLR */

#ifndef HAVE_CPUSET_ISSET
#if __linux__ || __FreeBSD__
int cpuset_isset(cpuid_t cpu, const cpuset_t *set)
{
return CPU_ISSET(cpu, set);
}
#endif
#endif /* !HAVE_CPUSET_ISSET */

#ifndef HAVE_CPUSET_SIZE
#if __linux__ || __FreeBSD__
size_t cpuset_size(const cpuset_t *set)
{
return sizeof(*set);
}
#endif
#endif /* !HAVE_CPUSET_SIZE */

#if __linux__
#ifdef CPU_OR_THREE_ARGS
/* for Linux, use three arguments */
void cpuset_or(cpuset_t *destset, const cpuset_t *srcset)
{
CPU_OR(destset, destset, srcset);
}
#endif
#if __FreeBSD__
#else
/* for FreeBSD, use two arguments */
void cpuset_or(cpuset_t *destset, const cpuset_t *srcset)
{
CPU_OR(destset, srcset);
Expand Down
31 changes: 31 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,36 @@ AC_INCLUDES_DEFAULT
#endif
])

AC_DEFUN([AC_CHECK_CPU_OR],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether CPU_OR works with three arguments)
AC_TRY_COMPILE(
[#if HAVE_SCHED_H
# include <sched.h>
#endif
#if HAVE_SYS_CPUSET_H
# include <sys/cpuset.h>
#endif
#include <string.h>
#ifndef HAVE_CPUSET_T
#ifdef HAVE_CPU_SET_T
typedef cpu_set_t cpuset_t;
#endif
#endif
void testing (void) {
cpu_set_t a, b;
memset(&a, 0, sizeof(a));
memset(&b, 0, sizeof(b));
CPU_OR(&a, &a, &b);
}], [
testing();
], [
AC_MSG_RESULT(yes)
AC_DEFINE([CPU_OR_THREE_ARGS], 1, [number of arguments for CPU_OR is three])
], [
AC_MSG_RESULT(no)
])])

AS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],[
AC_CHECK_FUNC(cpuset_create)
AC_CHECK_FUNC(cpuset_destroy)
Expand All @@ -704,6 +734,7 @@ AS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],
AC_CHECK_FUNC(cpuset_size)
AC_LIBOBJ(cpuset)
AC_CHECK_FUNCS([sysconf sched_setaffinity])
AC_CHECK_CPU_OR
])

#
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fix #75: configure test for sched_setaffinity, and use
cpuset_setaffinity otherwise. Also test for presence of sysconf.
- Fix #74: GNU Hurd fix cast from pointer to integer of different size.
- Fix for #74, #75: cpuset test for header contents and provide code.

18 March 2020: Wouter
- Fix #70: error: 'fd_set' undeclared.
Expand Down
1 change: 1 addition & 0 deletions doc/RELNOTES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BUG FIXES:
- Fix #75: configure test for sched_setaffinity, and use
cpuset_setaffinity otherwise. Also test for presence of sysconf.
- Fix #74: GNU Hurd fix cast from pointer to integer of different size.
- Fix for #74, #75: cpuset test for header contents and provide code.


4.3.0
Expand Down

0 comments on commit c426b15

Please sign in to comment.