#ifndef ZERIN_PLATFORM_H #define ZERIN_PLATFORM_H #include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include #include #include #include #include #pragma comment(lib, "winhttp.lib") #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "bcrypt.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "shlwapi.lib") #pragma comment(lib, "iphlpapi.lib") // NT status #ifndef STATUS_SUCCESS #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) #endif // Token integrity levels (guard against redefinition from winnt.h) #ifndef SECURITY_MANDATORY_UNTRUSTED_RID #define SECURITY_MANDATORY_UNTRUSTED_RID 0x0000 #endif #ifndef SECURITY_MANDATORY_LOW_RID #define SECURITY_MANDATORY_LOW_RID 0x1000 #endif #ifndef SECURITY_MANDATORY_MEDIUM_RID #define SECURITY_MANDATORY_MEDIUM_RID 0x2000 #endif #ifndef SECURITY_MANDATORY_HIGH_RID #define SECURITY_MANDATORY_HIGH_RID 0x3000 #endif #ifndef SECURITY_MANDATORY_SYSTEM_RID #define SECURITY_MANDATORY_SYSTEM_RID 0x4000 #endif #else // Non-Windows includes #include #include #endif // _WIN32 // Cross-platform sleep (milliseconds) static inline void platform_sleep_ms(uint32_t ms) { #ifdef _WIN32 Sleep(ms); #else usleep(ms * 1000); #endif } // Get current time as Unix timestamp static inline int64_t platform_time_unix(void) { #ifdef _WIN32 FILETIME ft; ULARGE_INTEGER uli; GetSystemTimeAsFileTime(&ft); uli.LowPart = ft.dwLowDateTime; uli.HighPart = ft.dwHighDateTime; // Convert from Windows epoch (1601) to Unix epoch (1970) return (int64_t)((uli.QuadPart - 116444736000000000ULL) / 10000000ULL); #else return (int64_t)time(NULL); #endif } #endif // ZERIN_PLATFORM_H