00001 // Copyright 2017 The Abseil Authors. 00002 // 00003 // Licensed under the Apache License, Version 2.0 (the "License"); 00004 // you may not use this file except in compliance with the License. 00005 // You may obtain a copy of the License at 00006 // 00007 // https://www.apache.org/licenses/LICENSE-2.0 00008 // 00009 // Unless required by applicable law or agreed to in writing, software 00010 // distributed under the License is distributed on an "AS IS" BASIS, 00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 // See the License for the specific language governing permissions and 00013 // limitations under the License. 00014 // 00015 // This file includes routines to find out characteristics 00016 // of the machine a program is running on. It is undoubtedly 00017 // system-dependent. 00018 00019 // Functions listed here that accept a pid_t as an argument act on the 00020 // current process if the pid_t argument is 0 00021 // All functions here are thread-hostile due to file caching unless 00022 // commented otherwise. 00023 00024 #ifndef ABSL_BASE_INTERNAL_SYSINFO_H_ 00025 #define ABSL_BASE_INTERNAL_SYSINFO_H_ 00026 00027 #ifndef _WIN32 00028 #include <sys/types.h> 00029 #else 00030 #include <intsafe.h> 00031 #endif 00032 00033 #include "absl/base/port.h" 00034 00035 namespace absl { 00036 namespace base_internal { 00037 00038 // Nominal core processor cycles per second of each processor. This is _not_ 00039 // necessarily the frequency of the CycleClock counter (see cycleclock.h) 00040 // Thread-safe. 00041 double NominalCPUFrequency(); 00042 00043 // Number of logical processors (hyperthreads) in system. Thread-safe. 00044 int NumCPUs(); 00045 00046 // Return the thread id of the current thread, as told by the system. 00047 // No two currently-live threads implemented by the OS shall have the same ID. 00048 // Thread ids of exited threads may be reused. Multiple user-level threads 00049 // may have the same thread ID if multiplexed on the same OS thread. 00050 // 00051 // On Linux, you may send a signal to the resulting ID with kill(). However, 00052 // it is recommended for portability that you use pthread_kill() instead. 00053 #ifdef _WIN32 00054 // On Windows, process id and thread id are of the same type according to 00055 // the return types of GetProcessId() and GetThreadId() are both DWORD. 00056 using pid_t = DWORD; 00057 #endif 00058 pid_t GetTID(); 00059 00060 } // namespace base_internal 00061 } // namespace absl 00062 00063 #endif // ABSL_BASE_INTERNAL_SYSINFO_H_