Apply clang-format across the whole tree

Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs,
Allman functions) over every source file so the tree is formatter-clean.
Whitespace only -- no behavior change; full x64 + x86 suites pass.

Also set SortIncludes: false in .clang-format. Windows include order is
load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h /
dinput.h; winsock2.h must precede windows.h), and the default
alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build
break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
2026-07-12 11:52:53 +02:00
parent c684a15fb9
commit 30eccf749d
155 changed files with 3333 additions and 6171 deletions

View File

@@ -13,14 +13,12 @@
using coop::hook::DetourGate;
namespace
{
namespace {
int g_failures = 0;
void check(bool ok, const char* what)
{
std::printf("%s %s\n", ok ? " ok:" : "FAIL:", what);
if (!ok)
{
if (!ok) {
++g_failures;
}
}
@@ -48,8 +46,7 @@ int main()
// Release the Guard; drain() must then return promptly.
delete guard;
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(500);
while (!drained.load(std::memory_order_acquire) && std::chrono::steady_clock::now() < deadline)
{
while (!drained.load(std::memory_order_acquire) && std::chrono::steady_clock::now() < deadline) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
check(drained.load(std::memory_order_acquire), "drain() returns once the in-flight detour finishes");
@@ -62,8 +59,8 @@ int main()
DetourGate gate;
const auto t0 = std::chrono::steady_clock::now();
gate.drain();
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0)
.count();
const auto ms =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0).count();
check(ms < 100, "drain() with no in-flight detours returns quickly");
}
@@ -79,15 +76,12 @@ int main()
std::atomic<long long> violations{0};
auto worker = [&] {
while (!stop.load(std::memory_order_relaxed))
{
if (disabled.load(std::memory_order_acquire))
{
while (!stop.load(std::memory_order_relaxed)) {
if (disabled.load(std::memory_order_acquire)) {
continue; // "hook removed" -> no new detour starts
}
DetourGate::Guard g(gate);
if (freed.load(std::memory_order_acquire))
{
if (freed.load(std::memory_order_acquire)) {
violations.fetch_add(1, std::memory_order_relaxed); // ran the body on freed state
}
guarded.fetch_add(1, std::memory_order_relaxed);
@@ -95,12 +89,10 @@ int main()
};
std::thread workers[6];
for (auto& w : workers)
{
for (auto& w : workers) {
w = std::thread(worker);
}
for (int c = 0; c < 3000; ++c)
{
for (int c = 0; c < 3000; ++c) {
disabled.store(true, std::memory_order_release); // disable: no new detours
gate.drain(); // wait for in-flight detours
freed.store(true, std::memory_order_release); // "free" the shared state
@@ -108,8 +100,7 @@ int main()
disabled.store(false, std::memory_order_release);
}
stop.store(true, std::memory_order_relaxed);
for (auto& w : workers)
{
for (auto& w : workers) {
w.join();
}
std::printf(" stress: guarded=%lld violations=%lld\n", guarded.load(), violations.load());