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; compareval4 = cv_usejoystick4.value;
compareval3 = cv_usejoystick3.value; compareval3 = cv_usejoystick3.value;
compareval2 = cv_usejoystick2.value; compareval2 = cv_usejoystick2.value;
compareval = cv_usejoystick.value compareval = cv_usejoystick.value;
#endif #endif
if ((setupcontrolplayer == 4 && (i == compareval4)) if ((setupcontrolplayer == 4 && (i == compareval4))

View file

@ -53,7 +53,7 @@ ifdef FREEBSD
OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include
SDL_CONFIG?=sdl11-config SDL_CONFIG?=sdl11-config
LDFLAGS+=-L/usr/X11R6/lib LDFLAGS+=-L/usr/X11R6/lib
LIBS+=-lipx -lkvm LIBS+=-lkvm -lexecinfo
endif endif
# #

View file

@ -90,7 +90,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <kvm.h> #include <kvm.h>
#endif #endif
#include <nlist.h> #include <nlist.h>
#include <sys/vmmeter.h> #include <sys/sysctl.h>
#endif #endif
#endif #endif
@ -3804,40 +3804,17 @@ static long get_entry(const char* name, const char* buf)
UINT32 I_GetFreeMem(UINT32 *total) UINT32 I_GetFreeMem(UINT32 *total)
{ {
#ifdef FREEBSD #ifdef FREEBSD
struct vmmeter sum; u_int v_free_count, v_page_size, v_page_count;
kvm_t *kd; size_t size = sizeof(v_free_count);
struct nlist namelist[] = sysctlbyname("vm.stats.vm.v_free_count", &v_free_count, &size, NULL, 0);
{ size = sizeof(v_page_size);
#define X_SUM 0 sysctlbyname("vm.stats.vm.v_page_size", &v_page_size, &size, NULL, 0);
{"_cnt"}, size = sizeof(v_page_count);
{NULL} sysctlbyname("vm.stats.vm.v_page_count", &v_page_count, &size, NULL, 0);
};
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);
if (total) if (total)
*total = sum.v_page_count * sum.v_page_size; *total = v_page_count * v_page_size;
return sum.v_free_count * sum.v_page_size; return v_free_count * v_page_size;
#elif defined (SOLARIS) #elif defined (SOLARIS)
/* Just guess */ /* Just guess */
if (total) if (total)

View file

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