Various FreeBSD fixes.
authorJostein Kjønigsen <jostein@kjonigsen.net>
Wed, 8 Apr 2015 18:40:20 +0000 (18:40 +0000)
committerJostein Kjønigsen <jostein@kjonigsen.net>
Thu, 9 Apr 2015 19:01:06 +0000 (19:01 +0000)
src/pal/src/loader/module.cpp
src/pal/src/misc/sysinfo.cpp

index 7cae708..dfc4b30 100644 (file)
@@ -56,7 +56,7 @@ Abstract:
 #include <sys/types.h>
 #include <sys/mman.h>
 
-#if !defined(__APPLE__)
+#if defined(__LINUX__)
 #include <gnu/lib-names.h>
 #endif
 
@@ -1382,6 +1382,8 @@ static HMODULE LOADLoadLibrary(LPCSTR ShortAsciiName, BOOL fDynamic)
     {
 #if defined(__APPLE__)
         ShortAsciiName = "libc.dylib";
+#elif defined(__FreeBSD__)
+        ShortAsciiName = "libc.so";
 #else
         ShortAsciiName = LIBC_SO;
 #endif
@@ -1939,4 +1941,4 @@ PAL_GetSymbolModuleBase(void *symbol)
     PERF_EXIT(PAL_GetPalModuleBase);
     return retval;
 
-}
\ No newline at end of file
+}
index 9bd442f..1f6f912 100644 (file)
@@ -76,6 +76,16 @@ SET_DEFAULT_DEBUG_CHANNEL(MISC);
 #include <sys/vmparam.h>
 #endif
 
+#ifndef __APPLE__
+#if HAVE_SYSCONF && HAVE__SC_AVPHYS_PAGES
+#define SYSCONF_PAGES _SC_AVPHYS_PAGES
+#elif HAVE_SYSCONF && HAVE__SC_PHYS_PAGES
+#define SYSCONF_PAGES _SC_PHYS_PAGES
+#else
+#error Dont know how to get page-size on this architecture!
+#endif
+#endif // __APPLE__
+
 
 /*++
 Function:
@@ -256,8 +266,8 @@ GlobalMemoryStatusEx(
     // We do this only when we have the total physical memory available.
     if (lpBuffer->ullTotalPhys > 0)
     {
-#if HAVE_SYSCONF && HAVE__SC_AVPHYS_PAGES
-        lpBuffer->ullAvailPhys = sysconf(_SC_AVPHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
+#ifndef __APPLE__
+        lpBuffer->ullAvailPhys = sysconf(SYSCONF_PAGES) * sysconf(_SC_PAGE_SIZE);
         INT64 used_memory = lpBuffer->ullTotalPhys - lpBuffer->ullAvailPhys;
         lpBuffer->dwMemoryLoad = (DWORD)((used_memory * 100) / lpBuffer->ullTotalPhys);
 #else
@@ -276,7 +286,7 @@ GlobalMemoryStatusEx(
                 lpBuffer->dwMemoryLoad = (DWORD)((used_memory * 100) / lpBuffer->ullTotalPhys);
             }
         }
-#endif // HAVE_SYSCONF
+#endif // __APPLE__
     }
 
     // TODO: figure out a way to get the real values for the total / available virtual