From 639050bb884a10b892005d678c16d8167246be83 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 16 Jan 2024 21:08:04 -0500 Subject: More windows build fixes Signed-off-by: Andrew Opalach --- src/common.c | 7 ++++--- src/ev_embed_compat.c | 1 + src/evwrap.h | 2 +- src/util/error.h | 8 +++++++- src/winwrap.c | 7 +------ src/winwrap.h | 2 -- 6 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/common.c b/src/common.c index 3c76cbd..803ce97 100644 --- a/src/common.c +++ b/src/common.c @@ -9,7 +9,6 @@ #endif #include "common.h" -#include "winwrap.h" bool aki_common_init(void) { @@ -17,8 +16,9 @@ bool aki_common_init(void) al_malloc_init(); al_rand_init(); - +#ifdef _WIN32 aki_windows_init(); +#endif #ifndef _WIN32 al_set_page_size(sysconf(_SC_PAGESIZE)); @@ -33,7 +33,8 @@ bool aki_common_init(void) void aki_common_close(void) { +#ifdef _WIN32 aki_windows_close(); - +#endif al_malloc_close(); } diff --git a/src/ev_embed_compat.c b/src/ev_embed_compat.c index 7fb39fb..8e36572 100644 --- a/src/ev_embed_compat.c +++ b/src/ev_embed_compat.c @@ -1,6 +1,7 @@ #define EV_STANDALONE 1 #define EV_USE_NANOSLEEP 1 #define EV_USE_REALTIME 1 +#define EV_USE_MONOTONIC 1 #ifdef _WIN32 #define FD_SETSIZE 2048 #define EV_SELECT_IS_WINSOCKET 1 diff --git a/src/evwrap.h b/src/evwrap.h index 331da06..02ad980 100644 --- a/src/evwrap.h +++ b/src/evwrap.h @@ -5,7 +5,7 @@ #define EV_MULTIPLICITY 1 #define EV_STAT_ENABLE 0 -//#define EV_PERIODIC_ENABLE 0 +#define EV_PERIODIC_ENABLE 0 #define EV_SIGNAL_ENABLE 0 #define EV_CHILD_ENABLE 0 #define EV_IDLE_ENABLE 0 diff --git a/src/util/error.h b/src/util/error.h index 0849ddb..c45f0f0 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -1,3 +1,5 @@ +#pragma once + #include #include @@ -9,7 +11,11 @@ extern __al_thread char errorbuf[AKI_ERROR_STR_MAXLEN]; static inline char *aki_strerror(s32 errnum) { #ifndef _WIN32 - (void)!strerror_r(errnum, errorbuf, AKI_ERROR_STR_MAXLEN); +#if (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE + if (strerror_r(errnum, errorbuf, AKI_ERROR_STR_MAXLEN) != 0) errorbuf[0] = '\0'; +#else + return strerror_r(errnum, errorbuf, AKI_ERROR_STR_MAXLEN); +#endif #else strerror_s(errorbuf, AKI_ERROR_STR_MAXLEN, errnum); #endif diff --git a/src/winwrap.c b/src/winwrap.c index b1ab115..dcfdef9 100644 --- a/src/winwrap.c +++ b/src/winwrap.c @@ -2,7 +2,7 @@ void aki_windows_init(void) { -#ifdef _WIN32 + // https://learn.microsoft.com/en-us/windows/win32/api/objbase/ne-objbase-coinit CoInitialize(NULL); WSADATA data; @@ -16,17 +16,12 @@ void aki_windows_init(void) NtDelayExecution = (NTSTATUS(__stdcall *)(BOOL, PLARGE_INTEGER))GetProcAddress(GetModuleHandleW(L"ntdll"), "NtDelayExecution"); QueryPerformanceFrequency(&performance_frequency); -#endif } void aki_windows_close(void) { -#ifdef _WIN32 WSACleanup(); CoUninitialize(); -#endif } -#ifdef _WIN32 LARGE_INTEGER performance_frequency; -#endif diff --git a/src/winwrap.h b/src/winwrap.h index 8a6b90d..2c71dc0 100644 --- a/src/winwrap.h +++ b/src/winwrap.h @@ -2,7 +2,6 @@ #include -#ifdef _WIN32 #include #include #include @@ -13,7 +12,6 @@ #include extern NTSTATUS(__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval); extern LARGE_INTEGER performance_frequency; -#endif void aki_windows_init(void); void aki_windows_close(void); -- cgit v1.2.3-101-g0448