--- Public.cpp-linux	Tue May 11 11:36:26 2004
+++ Public.cpp	Tue May 11 11:40:55 2004
@@ -13,7 +13,13 @@
 #ifdef _WIN32
 	#include <windows.h>
 #else
-	#include <sys/sysinfo.h>
+	#include <sys/param.h>
+	#include <sys/sysctl.h>
+	#include <unistd.h>
+
+	static int      pageshift;
+	#define pagetok(size) ((size) << pageshift)
+
 #endif
 
 //////////////////////////////////////////////////////////////////////
@@ -157,9 +163,27 @@
 		GlobalMemoryStatus(&ms);
 		return ms.dwAvailPhys;
 #else
-	struct sysinfo info;
-	sysinfo(&info);			// This function is Linux-specific
-	return info.freeram;
+	// this is for (open)bsd
+
+	static int mib[] = {CTL_VM, VM_METER};
+	struct vmtotal vmtotal;
+	size_t size;
+	int pagesize;
+
+	size = sizeof(vmtotal);
+
+	pagesize = getpagesize();
+	pageshift = 0;
+	while (pagesize > 1) {
+		pageshift++;
+		pagesize >>= 1;
+	}
+
+	if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0) {
+		bzero(&vmtotal, sizeof(vmtotal));
+	}
+
+	return(pagetok(vmtotal.t_free));
 #endif
 }
 
