|
|
|||
File indexing completed on 2026-01-09 09:40:44
0001 // Copyright 2022 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 #ifndef ABSL_BASE_INTERNAL_CYCLECLOCK_CONFIG_H_ 0016 #define ABSL_BASE_INTERNAL_CYCLECLOCK_CONFIG_H_ 0017 0018 #include <cstdint> 0019 0020 #include "absl/base/config.h" 0021 #include "absl/base/internal/inline_variable.h" 0022 #include "absl/base/internal/unscaledcycleclock_config.h" 0023 0024 namespace absl { 0025 ABSL_NAMESPACE_BEGIN 0026 namespace base_internal { 0027 0028 #if ABSL_USE_UNSCALED_CYCLECLOCK 0029 #ifdef NDEBUG 0030 #ifdef ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY 0031 // Not debug mode and the UnscaledCycleClock frequency is the CPU 0032 // frequency. Scale the CycleClock to prevent overflow if someone 0033 // tries to represent the time as cycles since the Unix epoch. 0034 ABSL_INTERNAL_INLINE_CONSTEXPR(int32_t, kCycleClockShift, 1); 0035 #else 0036 // Not debug mode and the UnscaledCycleClock isn't operating at the 0037 // raw CPU frequency. There is no need to do any scaling, so don't 0038 // needlessly sacrifice precision. 0039 ABSL_INTERNAL_INLINE_CONSTEXPR(int32_t, kCycleClockShift, 0); 0040 #endif 0041 #else // NDEBUG 0042 // In debug mode use a different shift to discourage depending on a 0043 // particular shift value. 0044 ABSL_INTERNAL_INLINE_CONSTEXPR(int32_t, kCycleClockShift, 2); 0045 #endif // NDEBUG 0046 0047 ABSL_INTERNAL_INLINE_CONSTEXPR(double, kCycleClockFrequencyScale, 0048 1.0 / (1 << kCycleClockShift)); 0049 #endif // ABSL_USE_UNSCALED_CYCLECLOC 0050 0051 } // namespace base_internal 0052 ABSL_NAMESPACE_END 0053 } // namespace absl 0054 0055 #endif // ABSL_BASE_INTERNAL_CYCLECLOCK_CONFIG_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|