1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_ 6 #define BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_ 7 8 #include "base/base_export.h" 9 #include "base/threading/platform_thread.h" 10 #include "build/build_config.h" 11 12 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD) 13 #include <pthread.h> 14 #endif 15 16 namespace base { 17 18 // SamplingProfilerThreadToken represents the thread identifier(s) required by 19 // sampling profiler to operate on a thread. PlatformThreadId is needed for all 20 // platforms, while non-Mac POSIX also requires a pthread_t to pass to pthread 21 // functions used to obtain the stack base address. 22 struct SamplingProfilerThreadToken { 23 PlatformThreadId id; 24 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD) 25 pthread_t pthread_id; 26 #endif 27 }; 28 29 BASE_EXPORT SamplingProfilerThreadToken GetSamplingProfilerCurrentThreadToken(); 30 31 } // namespace base 32 33 #endif // BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_ 34