[libc-commits] [libc] [llvm] [libc] Move the fork gettid call into a syscall wrapper (PR #242606)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Sun Nov 15 20:08:40 PST 2026
================
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Syscall wrapper for gettid.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_WRAPPERS_GETTID_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_WRAPPERS_GETTID_H
+
+#include "hdr/types/pid_t.h"
+#include "src/__support/OSUtil/linux/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace linux_syscalls {
+
+LIBC_INLINE pid_t gettid() { return syscall_impl<pid_t>(SYS_gettid); }
----------------
SchrodingerZhu wrote:
```suggestion
// `gettid` shall never fail on a functional linux kernel
LIBC_INLINE pid_t gettid() { return syscall_impl<pid_t>(SYS_gettid); }
```
https://github.com/llvm/llvm-project/pull/242606
More information about the libc-commits
mailing list