| 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 |
|
| 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 |