27 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "gwp_asan/common.h"10 11#include <stdint.h>12#include <sys/syscall.h> // IWYU pragma: keep13// IWYU pragma: no_include <syscall.h>14#include <unistd.h>15 16namespace gwp_asan {17 18uint64_t getThreadID() {19#ifdef SYS_gettid20 return syscall(SYS_gettid);21#else22 return kInvalidThreadID;23#endif24}25 26} // namespace gwp_asan27