diff --git config/system-headers config/system-headers index 432cba6..18a9627 100644 --- config/system-headers +++ config/system-headers @@ -1157,3 +1157,4 @@ unicode/uenum.h unicode/unum.h unicode/ustring.h #endif +libutil.h diff --git js/src/config/system-headers js/src/config/system-headers index 432cba6..18a9627 100644 --- js/src/config/system-headers +++ js/src/config/system-headers @@ -1157,3 +1157,4 @@ unicode/uenum.h unicode/unum.h unicode/ustring.h #endif +libutil.h diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in index 9975621..b4b037d 100644 --- toolkit/library/Makefile.in +++ toolkit/library/Makefile.in @@ -289,6 +289,10 @@ OS_LIBS += $(call EXPAND_LIBNAME,kvm) EXTRA_DSO_LDOPTS += -Wl,--warn-unresolved-symbols endif +ifeq ($(OS_ARCH),FreeBSD) +OS_LIBS += $(call EXPAND_LIBNAME,util) +endif + ifeq ($(OS_ARCH),WINNT) OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet wbemuuid) ifdef ACCESSIBILITY diff --git xpcom/base/nsMemoryReporterManager.cpp xpcom/base/nsMemoryReporterManager.cpp index b8147c8..0ffb34e 100644 --- xpcom/base/nsMemoryReporterManager.cpp +++ xpcom/base/nsMemoryReporterManager.cpp @@ -153,6 +153,43 @@ static nsresult GetResidentFast(int64_t return GetResident(n); } +#ifdef __FreeBSD__ +#include + +static nsresult +GetKinfoVmentrySelf(int64_t* prss) +{ + int cnt; + struct kinfo_vmentry *vmmap, *kve; + if ((vmmap = kinfo_getvmmap(getpid(), &cnt)) == NULL) + return NS_ERROR_FAILURE; + + if (prss) + *prss = 0; + + for (int i = 0; i < cnt; i++) { + kve = &vmmap[i]; + if (prss) + *prss += kve->kve_private_resident; + } + + free(vmmap); + return NS_OK; +} + +#define HAVE_PRIVATE_REPORTER +static nsresult +GetPrivate(int64_t* aN) +{ + int64_t priv; + nsresult rv = GetKinfoVmentrySelf(&priv); + if (NS_SUCCEEDED(rv)) + *aN = priv * getpagesize(); + + return NS_OK; +} +#endif // FreeBSD + #elif defined(SOLARIS) #include @@ -327,6 +364,24 @@ static nsresult GetResidentFast(int64_t } #define HAVE_PRIVATE_REPORTER +static nsresult +GetPrivate(int64_t* aN) +{ + PROCESS_MEMORY_COUNTERS_EX pmcex; + pmcex.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX); + + if (!GetProcessMemoryInfo( + GetCurrentProcess(), + (PPROCESS_MEMORY_COUNTERS) &pmcex, sizeof(pmcex))) { + return NS_ERROR_FAILURE; + } + + *aN = pmcex.PrivateUsage; + return NS_OK; +} +#endif // XP_ + +#ifdef HAVE_PRIVATE_REPORTER class PrivateReporter MOZ_FINAL : public MemoryReporterBase { public: @@ -339,21 +394,10 @@ public: NS_IMETHOD GetAmount(int64_t *aAmount) { - PROCESS_MEMORY_COUNTERS_EX pmcex; - pmcex.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX); - - if (!GetProcessMemoryInfo( - GetCurrentProcess(), - (PPROCESS_MEMORY_COUNTERS) &pmcex, sizeof(pmcex))) { - return NS_ERROR_FAILURE; - } - - *aAmount = pmcex.PrivateUsage; - return NS_OK; + return GetPrivate(aAmount); } }; - -#endif // XP_ +#endif #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS class VsizeReporter MOZ_FINAL : public MemoryReporterBase