[libc-commits] [libc] [libc] Add sys/ucontext.h header (PR #194329)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Mon Apr 27 02:53:55 PDT 2026


https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/194329

POSIX historically provided <sys/ucontext.h> as an alias for <ucontext.h>. Some software still includes the sys/ path. Added the header as a simple wrapper that includes <ucontext.h>, gated to x86_64 alongside the existing ucontext support.

>From 846098d79dbe3c2866bb6837e18b3b35353855d9 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Mon, 20 Apr 2026 10:37:38 +0100
Subject: [PATCH] [libc] Add sys/ucontext.h header

POSIX historically provided <sys/ucontext.h> as an alias for
<ucontext.h>. Some software still includes the sys/ path. Added
the header as a simple wrapper that includes <ucontext.h>, gated
to x86_64 alongside the existing ucontext support.
---
 libc/config/linux/x86_64/headers.txt |  1 +
 libc/include/CMakeLists.txt          |  8 ++++++++
 libc/include/sys/ucontext.h          | 14 ++++++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 libc/include/sys/ucontext.h

diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index 2b93c84b13b5f..fb461444b43d8 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -53,6 +53,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.sys_syscall
     libc.include.sys_time
     libc.include.sys_types
+    libc.include.sys_ucontext
     libc.include.sys_un
     libc.include.sys_utsname
     libc.include.sys_wait
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 6c5ecac302dc8..5bcd69a01afce 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -476,6 +476,14 @@ if(LIBC_TARGET_ARCHITECTURE STREQUAL "x86_64")
       .llvm-libc-types.sigset_t
       .llvm-libc-types.stack_t
   )
+
+  add_header(
+    sys_ucontext
+    HDR
+      sys/ucontext.h
+    DEPENDS
+      .ucontext
+  )
 endif()
 
 add_header_macro(
diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h
new file mode 100644
index 0000000000000..9fd3557088336
--- /dev/null
+++ b/libc/include/sys/ucontext.h
@@ -0,0 +1,14 @@
+//===-- POSIX header sys/ucontext.h ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SYS_UCONTEXT_H
+#define SYS_UCONTEXT_H
+
+#include <ucontext.h>
+
+#endif // SYS_UCONTEXT_H



More information about the libc-commits mailing list