1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
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 <libutil.h>
+
+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 <procfs.h>
@@ -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_<PLATFORM>
+
+#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_<PLATFORM>
+#endif
#ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS
class VsizeReporter MOZ_FINAL : public MemoryReporterBase
|