forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
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
From d40a4786e9eab2bcab140506f84ecf11dd4646ae Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 13 Feb 2019 09:51:14 -0800
Subject: [PATCH] mallinfo implementation is glibc specific
 
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
@@ -35,7 +35,7 @@ bool MemoryUsage::IsSupported() {
 
 MemoryUsage GetMemoryUsage() {
   MemoryUsage result;
-#ifdef __linux__
+#if defined(__linux__) && defined(__GLIBC__)
   rusage res;
   if (getrusage(RUSAGE_SELF, &res) == 0) {
     result.max_rss_kb = res.ru_maxrss;
--- a/base/process/process_metrics_posix.cc
+++ b/base/process/process_metrics_posix.cc
@@ -105,7 +105,7 @@ void IncreaseFdLimitTo(unsigned int max_
 
 #endif  // !defined(OS_FUCHSIA)
 
-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
+#if (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
 namespace {
 
 size_t GetMallocUsageMallinfo() {
@@ -127,16 +127,16 @@ size_t GetMallocUsageMallinfo() {
 }
 
 }  // namespace
-#endif  // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
+#endif  // (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
 
 size_t ProcessMetrics::GetMallocUsage() {
 #if defined(OS_APPLE)
   malloc_statistics_t stats = {0};
   malloc_zone_statistics(nullptr, &stats);
   return stats.size_in_use;
-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
+#elif (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
   return GetMallocUsageMallinfo();
-#elif defined(OS_FUCHSIA)
+#else
   // TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
   return 0;
 #endif
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -219,7 +219,6 @@ bool MallocDumpProvider::OnMemoryDump(co
 #define MALLINFO2_FOUND_IN_LIBC
   struct mallinfo2 info = mallinfo2();
 #endif
-#endif  // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #if !defined(MALLINFO2_FOUND_IN_LIBC)
   struct mallinfo info = mallinfo();
 #endif
@@ -232,6 +231,7 @@ bool MallocDumpProvider::OnMemoryDump(co
 
   // Total allocated space is given by |uordblks|.
   allocated_objects_size = info.uordblks;
+#endif  // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #endif
 
   MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc");
--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
@@ -133,7 +133,7 @@
 /* #undef HAVE_MALLCTL */
 
 /* Define to 1 if you have the `mallinfo' function. */
-#define HAVE_MALLINFO 1
+/* #undef HAVE_MALLINFO */
 
 /* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
 /* so we need to check glibc version for the new API to be safe */
--- a/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
+++ b/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
@@ -128,7 +128,7 @@
 /* #undef HAVE_MALLCTL */
 
 /* Define to 1 if you have the `mallinfo' function. */
-#define HAVE_MALLINFO 1
+/* #undef HAVE_MALLINFO */
 
 /* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
 /* so we need to check glibc version for the new API to be safe */