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

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