3#include "gaia/config/config.h"
5#if GAIA_PLATFORM_WINDOWS
14struct _SECURITY_ATTRIBUTES;
18__declspec(dllimport)
void* __stdcall CreateSemaphoreExW(
19 _SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
long lInitialCount,
long lMaximumCount,
const wchar_t* lpName,
20 unsigned long dwFlags,
unsigned long dwDesiredAccess);
21__declspec(dllimport)
int __stdcall ReleaseSemaphore(
void* hSemaphore,
long lReleaseCount,
long* lpPreviousCount);
22__declspec(dllimport)
unsigned long __stdcall WaitForSingleObject(
void* hHandle,
unsigned long dwMilliseconds);
23__declspec(dllimport)
int __stdcall CloseHandle(
void* hObject);
24__declspec(dllimport) HINSTANCE__* __stdcall GetModuleHandleA(
const char* lpModuleName);
25__declspec(dllimport) intptr_t(__stdcall* __stdcall GetProcAddress(HINSTANCE__* hModule,
const char* lpProcName))();
33 inline constexpr unsigned long SemaphoreAllAccess = 0x1F0003UL;
35 inline constexpr unsigned long Infinite = 0xFFFFFFFFUL;
37 inline constexpr unsigned long WaitObject0 = 0UL;
40 inline constexpr int RelationProcessorCore = 0;
43 inline constexpr uint32_t ProcessorInfoEfficiencyClassOffset = 9;
46 inline constexpr int ThreadPowerThrottling = 3;
48 inline constexpr unsigned long ThreadPowerThrottlingCurrentVersion = 1UL;
50 inline constexpr unsigned long ThreadPowerThrottlingExecutionSpeed = 0x1UL;
53 struct ThreadPowerThrottlingState {
54 unsigned long Version;
55 unsigned long ControlMask;
56 unsigned long StateMask;
60 using GetLogicalProcessorInformationExFunc = int(__stdcall*)(int,
void*,
unsigned long*);
62 using SetThreadInformationFunc = int(__stdcall*)(
void*, int,
void*,
unsigned long);
64 using SetThreadDescriptionFunc = long(__stdcall*)(
void*,
const wchar_t*);
72 template <
typename Func>
73 inline Func kernel32_func(
const char* name) {
74 HINSTANCE__*
module = ::GetModuleHandleA("kernel32.dll");
75 if (module ==
nullptr)
77 return reinterpret_cast<Func
>(
reinterpret_cast<void*
>(::GetProcAddress(module, name)));