1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 12:21:48 +02:00

Fix more -Wundef, in darwin context

This commit is contained in:
Robert Hensing 2025-04-05 00:58:07 +02:00
parent 2b51250534
commit ba89da8fa2
17 changed files with 56 additions and 56 deletions

View file

@ -13,7 +13,7 @@
# include <mach-o/dyld.h>
#endif
#if __linux__
#ifdef __linux__
# include <mutex>
# include "nix/util/cgroup.hh"
# include "nix/util/namespaces.hh"
@ -23,7 +23,7 @@ namespace nix {
unsigned int getMaxCPU()
{
#if __linux__
#ifdef __linux__
try {
auto cgroupFS = getCgroupFS();
if (!cgroupFS) return 0;
@ -82,7 +82,7 @@ void restoreProcessContext(bool restoreMounts)
unix::restoreSignals();
#endif
if (restoreMounts) {
#if __linux__
#ifdef __linux__
restoreMountNamespace();
#endif
}
@ -106,7 +106,7 @@ std::optional<Path> getSelfExe()
{
static auto cached = []() -> std::optional<Path>
{
#if __linux__ || __GNU__
#if defined(__linux__) || defined(__GNU__)
return readLink("/proc/self/exe");
#elif __APPLE__
char buf[1024];

View file

@ -113,7 +113,7 @@ void AutoCloseFD::fsync() const
void AutoCloseFD::startFsync() const
{
#if __linux__
#ifdef __linux__
if (fd != -1) {
/* Ignore failure, since fsync must be run later anyway. This is just a performance optimization. */
::sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WRITE);

View file

@ -163,7 +163,7 @@ void Pipe::create()
//////////////////////////////////////////////////////////////////////
#if __linux__ || __FreeBSD__
#if defined(__linux__) || defined(__FreeBSD__)
static int unix_close_range(unsigned int first, unsigned int last, int flags)
{
#if !HAVE_CLOSE_RANGE
@ -179,7 +179,7 @@ void unix::closeExtraFDs()
constexpr int MAX_KEPT_FD = 2;
static_assert(std::max({STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO}) == MAX_KEPT_FD);
#if __linux__ || __FreeBSD__
#if defined(__linux__) || defined(__FreeBSD__)
// first try to close_range everything we don't care about. if this
// returns an error with these parameters we're running on a kernel
// that does not implement close_range (i.e. pre 5.9) and fall back
@ -189,7 +189,7 @@ void unix::closeExtraFDs()
}
#endif
#if __linux__
#ifdef __linux__
try {
for (auto & s : std::filesystem::directory_iterator{"/proc/self/fd"}) {
checkInterrupt();

View file

@ -190,7 +190,7 @@ static pid_t doFork(bool allowVfork, ChildWrapperFunction & fun)
}
#if __linux__
#ifdef __linux__
static int childEntry(void * arg)
{
auto & fun = *reinterpret_cast<ChildWrapperFunction*>(arg);
@ -213,7 +213,7 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
logger = makeSimpleLogger();
}
try {
#if __linux__
#ifdef __linux__
if (options.dieWithParent && prctl(PR_SET_PDEATHSIG, SIGKILL) == -1)
throw SysError("setting death signal");
#endif

View file

@ -105,7 +105,7 @@ void unix::setChildSignalMask(sigset_t * sigs)
{
assert(sigs); // C style function, but think of sigs as a reference
#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE) || (defined(_POSIX_SOURCE) && _POSIX_SOURCE)
sigemptyset(&savedSignalMask);
// There's no "assign" or "copy" function, so we rely on (math) idempotence
// of the or operator: a or a = a.