summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-01-16 21:08:04 -0500
committerAndrew Opalach <andrew@akon.city> 2024-01-16 21:08:04 -0500
commit639050bb884a10b892005d678c16d8167246be83 (patch)
tree4ffc62ef7ba65b5e2c087ce9a5e4479ed61156ae /src
parente2fb1d3a5f8b810eaefbff469cfcb3eddad7cbf3 (diff)
downloadlibnaunet-639050bb884a10b892005d678c16d8167246be83.tar.gz
libnaunet-639050bb884a10b892005d678c16d8167246be83.tar.bz2
libnaunet-639050bb884a10b892005d678c16d8167246be83.zip
More windows build fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
-rw-r--r--src/common.c7
-rw-r--r--src/ev_embed_compat.c1
-rw-r--r--src/evwrap.h2
-rw-r--r--src/util/error.h8
-rw-r--r--src/winwrap.c7
-rw-r--r--src/winwrap.h2
6 files changed, 14 insertions, 13 deletions
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 <al/lib.h>
#include <errno.h>
@@ -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 <al/lib.h>
-#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
@@ -13,7 +12,6 @@
#include <ntstatus.h>
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);