Skip to content

Commit 131553c

Browse files
fix
1 parent 2c0e9fb commit 131553c

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

libc/src/__support/time/windows/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_header_library(
2-
qpc
2+
performance_counter
33
HDRS
4-
qpc.h
4+
performance_counter.h
55
DEPENDS
66
libc.src.__support.CPP.atomic
77
libc.src.__support.common
@@ -14,7 +14,7 @@ add_object_library(
1414
SRCS
1515
clock_gettime.cpp
1616
DEPENDS
17-
.qpc
17+
.performance_counter
1818
libc.hdr.types.struct_timespec
1919
libc.hdr.types.clockid_t
2020
libc.hdr.errno_macros

libc/src/__support/time/windows/clock_gettime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "src/__support/macros/optimization.h"
1515
#include "src/__support/time/clock_gettime.h"
1616
#include "src/__support/time/units.h"
17-
#include "src/__support/time/windows/qpc.h"
17+
#include "src/__support/time/windows/performance_counter.h"
1818

1919
#define WIN32_LEAN_AND_MEAN
2020
#define NOMINMAX
@@ -37,12 +37,12 @@ ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
3737
// see
3838
// https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
3939
// Is the performance counter monotonic (non-decreasing)?
40-
// Yes. QPC does not go backward.
40+
// Yes. performance_counter does not go backward.
4141
[[clang::uninitialized]] LARGE_INTEGER buffer;
4242
// On systems that run Windows XP or later, the function will always
4343
// succeed and will thus never return zero.
4444
::QueryPerformanceCounter(&buffer);
45-
long long freq = qpc::get_ticks_per_second();
45+
long long freq = performance_counter::get_ticks_per_second();
4646
long long ticks = buffer.QuadPart;
4747
long long tv_sec = ticks / freq;
4848
long long tv_nsec = (ticks % freq) * 1_s_ns / freq;

libc/src/__support/time/windows/qpc.h renamed to libc/src/__support/time/windows/performance_counter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- Cached QPC Frequency ----------------------------------*- C++ -*-===//
1+
//===--- Cached Performance Counter Frequency ----------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +14,7 @@
1414
#include <Windows.h>
1515

1616
namespace LIBC_NAMESPACE_DECL {
17-
namespace qpc {
17+
namespace performance_counter {
1818
LIBC_INLINE long long get_ticks_per_second() {
1919
static cpp::Atomic<long long> frequency = 0;
2020
// Relaxed ordering is enough. It is okay to record the frequency multiple
@@ -31,5 +31,5 @@ LIBC_INLINE long long get_ticks_per_second() {
3131
}
3232
return freq;
3333
}
34-
} // namespace qpc
34+
} // namespace performance_counter
3535
} // namespace LIBC_NAMESPACE_DECL

libc/src/time/windows/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ add_entrypoint_object(
33
SRCS
44
clock_getres.cpp
55
DEPENDS
6-
libc.src.__support.time.windows.qpc
6+
libc.src.__support.time.windows.performance_counter
77
libc.src.__support.time.units
88
libc.src.__support.common
99
libc.src.__support.macros.optimization

libc/src/time/windows/clock_getres.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "src/__support/common.h"
1616
#include "src/__support/macros/optimization.h"
1717
#include "src/__support/time/units.h"
18-
#include "src/__support/time/windows/qpc.h"
18+
#include "src/__support/time/windows/performance_counter.h"
1919
#include "src/errno/libc_errno.h"
2020
#include "src/time/clock_getres.h"
2121

@@ -36,9 +36,9 @@ LLVM_LIBC_FUNCTION(int, clock_getres, (clockid_t id, struct timespec *res)) {
3636
constexpr unsigned long long HNS_PER_SEC = 1_s_ns / 100ULL;
3737
constexpr unsigned long long SEC_LIMIT =
3838
cpp::numeric_limits<decltype(res->tv_sec)>::max();
39-
// For CLOCK_MONOTONIC, we are using QPC
39+
// For CLOCK_MONOTONIC, we are using performance counter
4040
// https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
41-
// Hence, the resolution is given by the QPC frequency.
41+
// Hence, the resolution is given by the performance counter frequency.
4242
// For CLOCK_REALTIME, the precision is given by
4343
// GetSystemTimeAdjustmentPrecise
4444
// (https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeadjustmentprecise)
@@ -51,8 +51,8 @@ LLVM_LIBC_FUNCTION(int, clock_getres, (clockid_t id, struct timespec *res)) {
5151
return -1;
5252

5353
case CLOCK_MONOTONIC: {
54-
long long freq = qpc::get_ticks_per_second();
55-
[[clang::assume(freq != 0)]];
54+
long long freq = performance_counter::get_ticks_per_second();
55+
__builtin_assume(freq != 0);
5656
// division of 1 second by frequency, rounded up.
5757
long long tv_sec = static_cast<long long>(freq == 1);
5858
long long tv_nsec =

0 commit comments

Comments
 (0)