From 513634ab5bf97c32256733d12e7381c4e83e1adf Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 5 Apr 2024 12:25:43 -0400 Subject: [PATCH] Make `cgroup.{cc,hh}` linux-only files Forcing a conditional include, vs making the headers content conditional, I think is more maintainable. It is also how the other platform-specific headers (like `namespaces.hh`) have been adapted. --- src/libstore/build/local-derivation-goal.cc | 2 +- src/libutil/{ => linux}/cgroup.cc | 4 ---- src/libutil/{ => linux}/cgroup.hh | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) rename src/libutil/{ => linux}/cgroup.cc (99%) rename src/libutil/{ => linux}/cgroup.hh (96%) diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index f8794e783..ab66195b8 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -14,7 +14,6 @@ #include "topo-sort.hh" #include "callback.hh" #include "json-utils.hh" -#include "cgroup.hh" #include "personality.hh" #include "current-process.hh" #include "child.hh" @@ -52,6 +51,7 @@ # include # endif # define pivot_root(new_root, put_old) (syscall(SYS_pivot_root, new_root, put_old)) +# include "cgroup.hh" #endif #if __APPLE__ diff --git a/src/libutil/cgroup.cc b/src/libutil/linux/cgroup.cc similarity index 99% rename from src/libutil/cgroup.cc rename to src/libutil/linux/cgroup.cc index de83b5ad1..8b8942643 100644 --- a/src/libutil/cgroup.cc +++ b/src/libutil/linux/cgroup.cc @@ -1,5 +1,3 @@ -#if __linux__ - #include "cgroup.hh" #include "util.hh" #include "file-system.hh" @@ -145,5 +143,3 @@ CgroupStats destroyCgroup(const Path & cgroup) } } - -#endif diff --git a/src/libutil/cgroup.hh b/src/libutil/linux/cgroup.hh similarity index 96% rename from src/libutil/cgroup.hh rename to src/libutil/linux/cgroup.hh index 574ae8e5b..783a0ab87 100644 --- a/src/libutil/cgroup.hh +++ b/src/libutil/linux/cgroup.hh @@ -1,8 +1,6 @@ #pragma once ///@file -#if __linux__ - #include #include @@ -28,5 +26,3 @@ struct CgroupStats CgroupStats destroyCgroup(const Path & cgroup); } - -#endif