Skip to content

Commit d46dfb3

Browse files
maci0jmberg-intel
authored andcommitted
um: avoid struct sigcontext redefinition with musl
mcontext.c includes both <sys/ucontext.h> and <asm/sigcontext.h>. With musl libc, this causes a struct sigcontext redefinition error: <sys/ucontext.h> pulls in musl's <bits/signal.h>, which defines struct sigcontext directly. The kernel's <asm/sigcontext.h> then provides a second, conflicting definition of the same struct. With glibc this does not conflict because glibc's signal headers source their struct sigcontext from the kernel's own UAPI headers, so the include guard in <asm/sigcontext.h> makes the second inclusion a no-op. mcontext.c does not actually use struct sigcontext by name -- it only needs the FP-state types (_fpstate, _xstate, etc.) that are defined in <asm/sigcontext.h> independently of the sigcontext struct. Temporarily rename sigcontext to __kernel_sigcontext during the inclusion of <asm/sigcontext.h> so that the kernel's definition does not collide with musl's. The #undef restores normal name resolution immediately afterward. No functional change with glibc; fixes the build with musl. Signed-off-by: Marcel W. Wysocki <maci.stgn@gmail.com> Link: https://patch.msgid.link/20260215142803.1455757-2-maci.stgn@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 4076f73 commit d46dfb3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

arch/x86/um/os-Linux/mcontext.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
#include <linux/string.h>
55
#include <sys/ucontext.h>
66
#include <asm/ptrace.h>
7+
/*
8+
* musl defines struct sigcontext in <bits/signal.h>. Rename the kernel's
9+
* copy to avoid redefinition while keeping the FP-state types available.
10+
*/
11+
#define sigcontext __kernel_sigcontext
712
#include <asm/sigcontext.h>
13+
#undef sigcontext
814
#include <sysdep/ptrace.h>
915
#include <sysdep/mcontext.h>
1016
#include <arch.h>

0 commit comments

Comments
 (0)