From d4f8382ef3cad2fc553e7c5b4fa4f6ac236a61e4 Mon Sep 17 00:00:00 2001 From: Cel Andromeda Skeggs Date: Fri, 17 Jan 2025 02:37:14 +0000 Subject: [PATCH] Fix Os/Posix/Task.cpp compilation with musl --- Os/Posix/Task.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Os/Posix/Task.cpp b/Os/Posix/Task.cpp index 6a6eb060d0..4b1a67deef 100644 --- a/Os/Posix/Task.cpp +++ b/Os/Posix/Task.cpp @@ -111,8 +111,10 @@ namespace Task { PlatformIntType set_cpu_affinity(pthread_attr_t& attributes, const Os::Task::Arguments& arguments) { PlatformIntType status = 0; -// Feature set check for _GNU_SOURCE before using GNU only features -#ifdef _GNU_SOURCE +// pthread_attr_setaffinity_np is a non-POSIX function. Notably, it is not available on musl. +// Limit its use to builds that involve glibc, on Linux, with _GNU_SOURCE defined. +// That's the circumstance in which we expect this feature to work. +#if defined(TGT_OS_TYPE_LINUX) && defined(__GLIBC__) && defined(_GNU_SOURCE) const FwSizeType affinity = arguments.m_cpuAffinity; cpu_set_t cpu_set; CPU_ZERO(&cpu_set);