Make bionic_malloc.h a platform header.

Instead of having platform directories directly include the
private header, create a platform header directory and export it.

Bug: 130763340

Test: Builds.
Change-Id: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
Merged-In: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
(cherry picked from commit 8f582ef2f8a77d953d0e9f33387f592d20f852e2)
diff --git a/libc/Android.bp b/libc/Android.bp
index e505c67..e1c0072 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1726,6 +1726,25 @@
     sdk_version: "current",
 }
 
+// Headers that only other parts of the platform can include.
+cc_library_headers {
+    name: "bionic_libc_platform_headers",
+    visibility: [
+        "//bionic/libc/malloc_debug:__subpackages__",
+        "//bionic/libc/malloc_hooks:__subpackages__",
+        "//frameworks/av/media/libmedia:__subpackages__",
+        "//frameworks/av/media/utils:__subpackages__",
+        "//frameworks/base/core/jni:__subpackages__",
+        "//frameworks/base/services/core/jni:__subpackages__",
+        "//external/perfetto:__subpackages__",
+    ],
+    host_supported: true,
+    export_include_dirs: [
+        "platform",
+    ],
+    sdk_version: "current",
+}
+
 // libc_headers for libasync_safe and libpropertyinfoparser
 cc_library_headers {
     name: "libc_headers",
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index 9dc4d12..96e6140 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -39,7 +39,7 @@
 #include <stdio.h>
 
 #include <private/bionic_config.h>
-#include <private/bionic_malloc.h>
+#include <platform/bionic/malloc.h>
 
 #include "malloc_common.h"
 #include "malloc_limit.h"
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 8035746..9ad79a0 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -57,10 +57,10 @@
 
 #include <android/dlext.h>
 
+#include <platform/bionic/malloc.h>
 #include <private/bionic_config.h>
 #include <private/bionic_defs.h>
 #include <private/bionic_malloc_dispatch.h>
-#include <private/bionic_malloc.h>
 
 #include <sys/system_properties.h>
 
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index d0117f3..62249fb 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -37,8 +37,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <platform/bionic/malloc.h>
 #include <private/bionic_config.h>
-#include <private/bionic_malloc.h>
 #include <private/bionic_malloc_dispatch.h>
 #include <sys/system_properties.h>
 
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index 2bff260..41c4f9d 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -124,6 +124,10 @@
         "bionic/libc/async_safe/include",
     ],
 
+    header_libs: [
+        "bionic_libc_platform_headers",
+    ],
+
     static_libs: [
         "libc_malloc_debug",
         "libtinyxml2",
@@ -148,7 +152,13 @@
 cc_test {
     name: "malloc_debug_system_tests",
 
-    include_dirs: ["bionic/libc"],
+    include_dirs: [
+        "bionic/libc",
+    ],
+
+    header_libs: [
+        "bionic_libc_platform_headers",
+    ],
 
     srcs: [
         "tests/malloc_debug_system_tests.cpp",
diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
index f85c45b..0716758 100644
--- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
@@ -45,7 +45,7 @@
 #include <thread>
 #include <vector>
 
-#include "private/bionic_malloc.h"
+#include <bionic/malloc.h>
 
 static constexpr time_t kTimeoutSeconds = 10;
 
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index d119f89..a0f8102 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -49,7 +49,13 @@
     shared_libs: ["libbase"],
 
     local_include_dirs: ["tests"],
-    include_dirs: ["bionic/libc", "bionic"],
+    include_dirs: [
+        "bionic/libc",
+        "bionic"
+    ],
+    header_libs: [
+        "bionic_libc_platform_headers",
+    ],
 
     cflags: [
         "-Wall",
diff --git a/libc/malloc_hooks/tests/malloc_hooks_tests.cpp b/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
index 86e20ea..1858781 100644
--- a/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
+++ b/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
@@ -38,7 +38,7 @@
 
 #include <gtest/gtest.h>
 
-#include <private/bionic_malloc.h>
+#include <bionic/malloc.h>
 #include <private/bionic_malloc_dispatch.h>
 #include <tests/utils.h>
 
diff --git a/libc/private/bionic_malloc.h b/libc/platform/bionic/malloc.h
similarity index 100%
rename from libc/private/bionic_malloc.h
rename to libc/platform/bionic/malloc.h