[libc-commits] [libc] [libc] Implement getcontext and setcontext for x86_64 (PR #192343)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Thu Apr 16 01:16:01 PDT 2026


================
@@ -0,0 +1,78 @@
+//===-- Unittests for ucontext routines -----------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ucontext/getcontext.h"
+#include "src/ucontext/setcontext.h"
+
+#include "src/signal/sigaddset.h"
+#include "src/signal/sigemptyset.h"
+#include "src/signal/sigprocmask.h"
+
+#include "test/UnitTest/Test.h"
+
+#include "include/llvm-libc-macros/signal-macros.h"
+
+namespace LIBC_NAMESPACE {
+
+static bool is_signal_set(const sigset_t *set, int signum) {
+  // NSIG is 64, sigset_t is an array of unsigned long.
+  // Signum is 1-indexed.
----------------
labath wrote:

This is only true on linux (e.g. freebsd has a lot more signals). The rest of the test should be os-independent though.

I guess you did that because we don't have `sigismember` (yet)? Maybe leave a TODO to replace this once that is implemented?

https://github.com/llvm/llvm-project/pull/192343


More information about the libc-commits mailing list