ports/math/ogdf/files/patch-src_ogdf_basic_System.cpp
Kurt Jaeger 141a25e582 math/ogdf: 2012.07 -> 2015.05
Changes:
  http://www.ogdf.net/doku.php/tech:versions#v_201505_baobab

- Remove dependencies on math/abacus and math/coinmp, as they are
  now bundled into the OGDF source tarballs and compiled from there
  (COIN remains optional)
- Point MASTER_SITES to the official OGDF website
- Utilise USES=compiler:features to detect C++11 support, and
  add compiler flags -std=c++11 if so (required for build to complete
  without errors)
- Remove custom do-install recipe, and instead use default
  make install target
- Take maintainership

PR:		207531
Submitted by:	Ben Woods <woodsb02@gmail.com>
2016-03-09 16:49:38 +00:00

77 lines
1.6 KiB
C++

--- src/ogdf/basic/System.cpp.orig 2015-05-29 15:36:49 UTC
+++ src/ogdf/basic/System.cpp
@@ -52,6 +52,13 @@
#include <mach/vm_statistics.h>
#include <mach/mach.h>
#include <mach/machine.h>
+#elif defined(OGDF_SYSTEM_FREEBSD)
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#elif defined(OGDF_SYSTEM_UNIX)
#include <malloc.h>
#endif
@@ -308,6 +315,40 @@ size_t System::memoryUsedByProcess()
return 0;
}
+#elif defined(OGDF_SYSTEM_FREEBSD)
+
+long long System::physicalMemory()
+{
+ unsigned long value;
+ size_t size = sizeof( value );
+ if (sysctlbyname("hw.physmem", (void *)&value, &size, NULL, 0) != -1)
+ return value;
+ else
+ return 0;
+}
+
+long long System::availablePhysicalMemory()
+{
+ int pageSize = getpagesize ();
+ unsigned long result;
+ size_t size = sizeof (result);
+
+ if (sysctlbyname("vm.stats.vm.v_free_count", (void *)&result, &size, NULL, 0) != -1)
+ return result * pageSize;
+ else
+ return 0;
+}
+
+
+size_t System::memoryUsedByProcess()
+{
+ struct rusage r;
+ if (getrusage(RUSAGE_SELF, &r) != -1)
+ return r.ru_maxrss;
+ else
+ return 0;
+}
+
#else
// LINUX, NOT MAC OS
long long System::physicalMemory()
@@ -389,6 +430,19 @@ size_t System::memoryInFreelistOfMalloc(
{
return mstats().chunks_free;
}
+
+#elif defined(OGDF_SYSTEM_FREEBSD)
+
+size_t System::memoryAllocatedByMalloc()
+{
+ return 0;
+}
+
+size_t System::memoryInFreelistOfMalloc()
+{
+ return 0;
+}
+
#else
size_t System::memoryAllocatedByMalloc()