[libc-commits] [libc] [llvm] [libc] Implement pthread_cleanup_push and pthread_cleanup_pop (PR #223427)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Sep 16 06:49:10 PDT 2026
================
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of __pthread_cleanup_push.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/pthread/__pthread_cleanup_push.h"
+#include "hdr/types/struct___pthread_cleanup_frame.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
+#include "src/__support/threads/thread.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, __pthread_cleanup_push,
+ (struct __pthread_cleanup_frame * frame,
+ void (*routine)(void *), void *arg)) {
+ LIBC_CRASH_ON_NULLPTR(frame);
+ LIBC_CRASH_ON_NULLPTR(routine);
+ auto *attrib = current_thread().attrib;
+ frame->__routine = routine;
----------------
SchrodingerZhu wrote:
Xoring global canary like stack guard sounds good. We can also do PAUTH later on.
https://github.com/llvm/llvm-project/pull/223427
More information about the libc-commits
mailing list