[libc-commits] [libc] [libc] implement cached process/thread identity (PR #95965)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Tue Jun 18 15:35:23 PDT 2024
================
@@ -0,0 +1,32 @@
+//===------------ pid_t utilities -------------------------------*- 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_OSUTIL_PID_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_PID_H
+#include "hdr/types/pid_t.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/optimization.h"
+namespace LIBC_NAMESPACE {
+
+class ProcessIdentity {
+ static pid_t cache;
+ static pid_t get_uncached();
+
+public:
+ LIBC_INLINE static void invalidate_cache() { cache = -1; }
----------------
SchrodingerZhu wrote:
When multiple threads want to fork in the same time, is there a race condition happening here?
https://github.com/llvm/llvm-project/pull/95965
More information about the libc-commits
mailing list