xref: /freebsd/contrib/llvm-project/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1 //===-- common_posix.cpp ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "gwp_asan/common.h"
10 
11 #include <stdint.h>
12 #include <sys/syscall.h> // IWYU pragma: keep
13 // IWYU pragma: no_include <syscall.h>
14 #include <unistd.h>
15 
16 namespace gwp_asan {
17 
getThreadID()18 uint64_t getThreadID() {
19 #ifdef SYS_gettid
20   return syscall(SYS_gettid);
21 #else
22   return kInvalidThreadID;
23 #endif
24 }
25 
26 } // namespace gwp_asan
27