Merge branch 'fix-freebsd-build' into 'next'

Fix FreeBSD build errors

See merge request STJr/SRB2!2071
This commit is contained in:
sphere 2023-08-20 17:19:39 +00:00
commit d4aac9a857
2 changed files with 11 additions and 34 deletions

View file

@ -25,7 +25,7 @@ endif
# Tested by Steel, as of release 2.2.8.
ifdef FREEBSD
opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD
libs+=-L/usr/X11R6/lib -lipx -lkvm
libs+=-L/usr/X11R6/lib -lkvm -lexecinfo
endif
# FIXME: UNTESTED

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
@ -3033,40 +3033,17 @@ static long get_entry(const char* name, const char* buf)
size_t I_GetFreeMem(size_t *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.stat.vm.v_free_count", &v_free_count, &size, NULL, 0);
size_t size = sizeof(v_page_size);
sysctlbyname("vm.stat.vm.v_page_size", &v_page_size, &size, NULL, 0);
size_t size = sizeof(v_page_count);
sysctlbyname("vm.stat.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)