Skip to content

Commit

Permalink
- Fix #75: configure test for sched_setaffinity, and use
Browse files Browse the repository at this point in the history
  cpuset_setaffinity otherwise.  Also test for presence of sysconf.
  • Loading branch information
wcawijngaards committed Mar 19, 2020
1 parent 0a78f02 commit c49004b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ AS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],
AC_CHECK_FUNC(cpuset_isset)
AC_CHECK_FUNC(cpuset_size)
AC_LIBOBJ(cpuset)
AC_CHECK_FUNCS([sysconf sched_setaffinity])
])

#
Expand Down
2 changes: 2 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
19 March 2020: Wouter
- Fix #76: cpuid typedef for Hurd, DragonflyBSD compile.
- Fix #75: configure test for sched_setaffinity, and use
cpuset_setaffinity otherwise. Also test for presence of sysconf.

18 March 2020: Wouter
- Fix #70: error: 'fd_set' undeclared.
Expand Down
2 changes: 2 additions & 0 deletions doc/RELNOTES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ BUG FIXES:
mode.
- Fix to move declarations out of for loops in event test too.
- Fix #76: cpuid typedef for Hurd, DragonflyBSD compile.
- Fix #75: configure test for sched_setaffinity, and use
cpuset_setaffinity otherwise. Also test for presence of sysconf.


4.3.0
Expand Down
15 changes: 11 additions & 4 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,20 +1167,27 @@ error(const char *format, ...)
}

#ifdef HAVE_CPUSET_T
#if __linux__ || __FreeBSD__
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF)
/* exists on Linux and FreeBSD */
int number_of_cpus(void)
{
return (int)sysconf(_SC_NPROCESSORS_CONF);
}
#else
int number_of_cpus(void)
{
return -1;
}
#endif
#if __linux__
#ifdef HAVE_SCHED_SETAFFINITY
/* Linux */
int set_cpu_affinity(cpuset_t *set)
{
assert(set != NULL);
return sched_setaffinity(getpid(), sizeof(*set), set);
}
#endif
#if __FreeBSD__
#else
/* FreeBSD */
int set_cpu_affinity(cpuset_t *set)
{
assert(set != NULL);
Expand Down

0 comments on commit c49004b

Please sign in to comment.