Fix FreeBSD build errors
This commit is contained in:
1 parent
383b395c78
commit
d3ea2eb287
3 files changed
+12
-35
No files matched your search
+1
-1
@@ -55,7 +55,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
|
||||
|
||||
#
|
||||
|
||||
+10
-33
@@ -91,7 +91,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
|
||||
|
||||
@@ -3990,40 +3990,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.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)
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user