libstdc++: Declare malloc for freestanding
authorJonathan Wakely <jwakely@redhat.com>
Thu, 25 Mar 2021 18:24:37 +0000 (18:24 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 25 Mar 2021 18:25:40 +0000 (18:25 +0000)
For a target with none of aligned_alloc, memalign etc. we defined our
own aligned_alloc using malloc, so we need a declaration of malloc. As
in libsupc++/new_op.cc we need to declare it ourselves for freestanding
environments.

libstdc++-v3/ChangeLog:

* libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare malloc.

libstdc++-v3/libsupc++/new_opa.cc

index 5929622..6b78729 100644 (file)
@@ -54,6 +54,10 @@ extern "C"
   void *posix_memalign(void **, size_t alignment, size_t size);
 # elif _GLIBCXX_HAVE_MEMALIGN
   void *memalign(size_t alignment, size_t size);
+# else
+  // A freestanding C runtime may not provide "malloc" -- but there is no
+  // other reasonable way to implement "operator new".
+  void *malloc(size_t);
 # endif
 }
 #endif