[scudo] Provide allocator declaration

Ensure that extern allocator declaration is visible before definition

Differential Revision: https://reviews.llvm.org/D121848

GitOrigin-RevId: 6ba8c8abe982722f5e4383553d03c1c77f9dfbb0
diff --git a/wrappers_c.cpp b/wrappers_c.cpp
index 81c7dd6..b4d51be 100644
--- a/wrappers_c.cpp
+++ b/wrappers_c.cpp
@@ -21,8 +21,6 @@
 #define SCUDO_PREFIX(name) name
 #define SCUDO_ALLOCATOR Allocator
 
-extern "C" void SCUDO_PREFIX(malloc_postinit)();
-
 // Export the static allocator so that the C++ wrappers can access it.
 // Technically we could have a completely separated heap for C & C++ but in
 // reality the amount of cross pollination between the two is staggering.
diff --git a/wrappers_c.h b/wrappers_c.h
index 5f7f51f..08dc679 100644
--- a/wrappers_c.h
+++ b/wrappers_c.h
@@ -54,4 +54,9 @@
 #define SCUDO_MALLINFO __scudo_mallinfo
 #endif
 
+#if !SCUDO_ANDROID || !_BIONIC
+extern "C" void malloc_postinit();
+extern HIDDEN scudo::Allocator<scudo::Config, malloc_postinit> Allocator;
+#endif
+
 #endif // SCUDO_WRAPPERS_C_H_
diff --git a/wrappers_cpp.cpp b/wrappers_cpp.cpp
index adb1041..16f495b 100644
--- a/wrappers_cpp.cpp
+++ b/wrappers_cpp.cpp
@@ -12,12 +12,10 @@
 #if !SCUDO_ANDROID || !_BIONIC
 
 #include "allocator_config.h"
+#include "wrappers_c.h"
 
 #include <stdint.h>
 
-extern "C" void malloc_postinit();
-extern HIDDEN scudo::Allocator<scudo::Config, malloc_postinit> Allocator;
-
 namespace std {
 struct nothrow_t {};
 enum class align_val_t : size_t {};