Skip to content

Commit

Permalink
Various FreeBSD fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
josteink committed Apr 9, 2015
1 parent aa46d62 commit 4690f45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/pal/src/loader/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Module Name:
#include <sys/types.h>
#include <sys/mman.h>

#if !defined(__APPLE__)
#if defined(__LINUX__)
#include <gnu/lib-names.h>
#endif

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1939,4 +1941,4 @@ PAL_GetSymbolModuleBase(void *symbol)
PERF_EXIT(PAL_GetPalModuleBase);
return retval;

}
}
16 changes: 13 additions & 3 deletions src/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4690f45

Please sign in to comment.