Merge branch 'fix-freebsd-build-errors' into 'master'

Fix FreeBSD build errors

See merge request KartKrew/Kart-Public!333
This commit is contained in:
Sal 2024-03-29 21:48:42 +00:00
commit fbe20b3805
4 changed files with 13 additions and 36 deletions

View file

@ -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))

View file

@ -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
#

View file

@ -90,7 +90,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <kvm.h>
#endif
#include <nlist.h>
#include <sys/vmmeter.h>
#include <sys/sysctl.h>
#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)

View file

@ -11,7 +11,7 @@
/* https://tools.ietf.org/html/rfc5389 */
#if defined (__linux__)
#if defined (__unix__)
#include <sys/random.h>
#elif defined (_WIN32)
#define _CRT_RAND_S