[libc-commits] [libc] [libc] Add Darwin mutex support via os_sync primitives (PR #167722)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Sun Nov 30 18:37:42 PST 2025


================
@@ -0,0 +1,131 @@
+//===--- Implementation of a Darwin mutex class -----------*- C++-*-===//
+//
+// 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 LLVM_LIBC_SRC___SUPPORT_THREADS_DARWIN_MUTEX_H
+#define LLVM_LIBC_SRC___SUPPORT_THREADS_DARWIN_MUTEX_H
+
+#include "src/__support/libc_assert.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/threads/mutex_common.h"
+#include "src/__support/threads/sleep.h" // For sleep_briefly
+#include "src/__support/time/abs_timeout.h"
+
+#include <mach/mach_init.h> // For mach_thread_self
+#include <mach/mach_port.h> // For mach_port_t and MACH_PORT_NULL
+#include <os/lock.h>        // For os_unfair_lock
+#include <time.h>           // For clock_gettime
+
+namespace LIBC_NAMESPACE_DECL {
+
+// This file is an implementation of `LIBC_NAMESPACE::mutex` for Darwin-based
----------------
SchrodingerZhu wrote:

Oh, I guess this implementation can be removed as futex-like lock is now ready to use?

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


More information about the libc-commits mailing list