Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:40:45

0001 // Copyright 2017 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // This file includes routines to find out characteristics
0016 // of the machine a program is running on.  It is undoubtedly
0017 // system-dependent.
0018 
0019 // Functions listed here that accept a pid_t as an argument act on the
0020 // current process if the pid_t argument is 0
0021 // All functions here are thread-hostile due to file caching unless
0022 // commented otherwise.
0023 
0024 #ifndef ABSL_BASE_INTERNAL_SYSINFO_H_
0025 #define ABSL_BASE_INTERNAL_SYSINFO_H_
0026 
0027 #ifndef _WIN32
0028 #include <sys/types.h>
0029 #endif
0030 
0031 #include <cstdint>
0032 
0033 #include "absl/base/config.h"
0034 #include "absl/base/port.h"
0035 
0036 namespace absl {
0037 ABSL_NAMESPACE_BEGIN
0038 namespace base_internal {
0039 
0040 // Nominal core processor cycles per second of each processor.   This is _not_
0041 // necessarily the frequency of the CycleClock counter (see cycleclock.h)
0042 // Thread-safe.
0043 double NominalCPUFrequency();
0044 
0045 // Number of logical processors (hyperthreads) in system. Thread-safe.
0046 int NumCPUs();
0047 
0048 // Return the thread id of the current thread, as told by the system.
0049 // No two currently-live threads implemented by the OS shall have the same ID.
0050 // Thread ids of exited threads may be reused.   Multiple user-level threads
0051 // may have the same thread ID if multiplexed on the same OS thread.
0052 //
0053 // On Linux, you may send a signal to the resulting ID with kill().  However,
0054 // it is recommended for portability that you use pthread_kill() instead.
0055 #ifdef _WIN32
0056 // On Windows, process id and thread id are of the same type according to the
0057 // return types of GetProcessId() and GetThreadId() are both DWORD, an unsigned
0058 // 32-bit type.
0059 using pid_t = uint32_t;
0060 #endif
0061 pid_t GetTID();
0062 
0063 // Like GetTID(), but caches the result in thread-local storage in order
0064 // to avoid unnecessary system calls. Note that there are some cases where
0065 // one must call through to GetTID directly, which is why this exists as a
0066 // separate function. For example, GetCachedTID() is not safe to call in
0067 // an asynchronous signal-handling context nor right after a call to fork().
0068 pid_t GetCachedTID();
0069 
0070 }  // namespace base_internal
0071 ABSL_NAMESPACE_END
0072 }  // namespace absl
0073 
0074 #endif  // ABSL_BASE_INTERNAL_SYSINFO_H_