From 656758fc40ecb84cc68baaab14049e5fc7078a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Tue, 24 Oct 2023 16:42:35 +0200 Subject: [PATCH] Fix FreeBSD build errors --- src/m_menu.c | 2 +- src/sdl/MakeNIX.cfg | 2 +- src/sdl/i_system.c | 43 ++++++++++--------------------------------- src/stun.c | 2 +- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9d44ff03..7a6bebf9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10178,7 +10178,7 @@ static void M_DrawJoystick(void) compareval4 = cv_usejoystick4.value; compareval3 = cv_usejoystick3.value; compareval2 = cv_usejoystick2.value; - compareval = cv_usejoystick.value + compareval = cv_usejoystick.value; #endif if ((setupcontrolplayer == 4 && (i == compareval4)) diff --git a/src/sdl/MakeNIX.cfg b/src/sdl/MakeNIX.cfg index 6998a03a..86c8521c 100644 --- a/src/sdl/MakeNIX.cfg +++ b/src/sdl/MakeNIX.cfg @@ -53,7 +53,7 @@ ifdef FREEBSD OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include SDL_CONFIG?=sdl11-config LDFLAGS+=-L/usr/X11R6/lib - LIBS+=-lipx -lkvm + LIBS+=-lkvm -lexecinfo endif # diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 50204f3f..e44f21b8 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -90,7 +90,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif #include -#include +#include #endif #endif @@ -3804,40 +3804,17 @@ static long get_entry(const char* name, const char* buf) UINT32 I_GetFreeMem(UINT32 *total) { #ifdef FREEBSD - struct vmmeter sum; - kvm_t *kd; - struct nlist namelist[] = - { -#define X_SUM 0 - {"_cnt"}, - {NULL} - }; - if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) - { - if (total) - *total = 0L; - return 0; - } - if (kvm_nlist(kd, namelist) != 0) - { - kvm_close (kd); - if (total) - *total = 0L; - return 0; - } - if (kvm_read(kd, namelist[X_SUM].n_value, &sum, - sizeof (sum)) != sizeof (sum)) - { - kvm_close(kd); - if (total) - *total = 0L; - return 0; - } - kvm_close(kd); + u_int v_free_count, v_page_size, v_page_count; + size_t size = sizeof(v_free_count); + sysctlbyname("vm.stats.vm.v_free_count", &v_free_count, &size, NULL, 0); + size = sizeof(v_page_size); + sysctlbyname("vm.stats.vm.v_page_size", &v_page_size, &size, NULL, 0); + size = sizeof(v_page_count); + sysctlbyname("vm.stats.vm.v_page_count", &v_page_count, &size, NULL, 0); if (total) - *total = sum.v_page_count * sum.v_page_size; - return sum.v_free_count * sum.v_page_size; + *total = v_page_count * v_page_size; + return v_free_count * v_page_size; #elif defined (SOLARIS) /* Just guess */ if (total) diff --git a/src/stun.c b/src/stun.c index dbcfe58e..1ff4dc96 100644 --- a/src/stun.c +++ b/src/stun.c @@ -11,7 +11,7 @@ /* https://tools.ietf.org/html/rfc5389 */ -#if defined (__linux__) +#if defined (__unix__) #include #elif defined (_WIN32) #define _CRT_RAND_S