]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fiber/src/numa/freebsd/pin_thread.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / fiber / src / numa / freebsd / pin_thread.cpp
CommitLineData
b32b8144
FG
1
2// Copyright Oliver Kowalke 2017.
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#include "boost/fiber/numa/pin_thread.hpp"
8
9extern "C" {
10#include <errno.h>
11#include <sys/param.h>
12#include <sys/cpuset.h>
11fdf7f2 13#include <sys/thread.h>
b32b8144
FG
14}
15
16#include <system_error>
17
18#ifdef BOOST_HAS_ABI_HEADERS
19# include BOOST_ABI_PREFIX
20#endif
21
22namespace boost {
23namespace fibers {
24namespace numa {
25
26BOOST_FIBERS_DECL
11fdf7f2
TL
27void pin_thread( std::uint32_t cpuid) {
28 pin_thread( cpuid, ::thr_self() );
29}
30
31BOOST_FIBERS_DECL
32void pin_thread( std::uint32_t cpuid, std::thread::native_handle_type h) {
b32b8144
FG
33 cpuset_t mask;
34 CPU_ZERO( & mask);
11fdf7f2
TL
35 CPU_SET( cpuid, & mask);
36 if ( BOOST_UNLIKELY( 0 != ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, h, sizeof( mask), & mask) ) ) {
b32b8144
FG
37 throw std::system_error(
38 std::error_code( errno, std::system_category() ),
39 "::cpuset_setaffinity() failed");
40 }
41}
42
43}}}
44
45#ifdef BOOST_HAS_ABI_HEADERS
46# include BOOST_ABI_SUFFIX
47#endif