aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-05-04 14:44:00 -0600
committerBen Burdette <bburdette@gmail.com>2020-05-04 14:44:00 -0600
commitafaa541013549c254f9c54e0865dc254973eea96 (patch)
treec69f959874063d0aa426b40d2411dad201c1cc9f /src/libutil
parent9c5ece44a7f32784dd5e2ea0faf110054f9233a8 (diff)
affinity operator<<
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/affinity.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libutil/affinity.cc b/src/libutil/affinity.cc
index e3cf33b58..ac2295e4a 100644
--- a/src/libutil/affinity.cc
+++ b/src/libutil/affinity.cc
@@ -12,6 +12,17 @@ namespace nix {
#if __linux__
static bool didSaveAffinity = false;
static cpu_set_t savedAffinity;
+
+std::ostream& operator<<(std::ostream &os, const cpu_set_t &cset)
+{
+ auto count = CPU_COUNT(&cset);
+ for (int i=0; i < count; ++i)
+ {
+ os << (CPU_ISSET(i,&cset) ? "1" : "0");
+ }
+
+ return os;
+}
#endif
@@ -47,7 +58,11 @@ void restoreAffinity()
#if __linux__
if (!didSaveAffinity) return;
if (sched_setaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1)
- _printError("failed to restore affinity");
+ {
+ std::ostringstream oss;
+ oss << savedAffinity;
+ printError("failed to restore CPU affinity %1%", oss.str());
+ }
#endif
}