[gcc(refs/vendors/redhat/heads/gcc-8-branch)] libstdc++: Fix freestanding build (PR 92376)
Jakub Jelinek
jakub@gcc.gnu.org
Thu Sep 17 16:48:05 GMT 2020
https://gcc.gnu.org/g:1cf81be019eb7993c1a9946ecdb3f8285c8a95f4
commit 1cf81be019eb7993c1a9946ecdb3f8285c8a95f4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Feb 26 14:20:55 2020 +0000
libstdc++: Fix freestanding build (PR 92376)
Explicitly declare aligned alloc functions for freestanding, because
<cstdlib> doesn't declare them.
Backport from mainline
2020-01-17 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/92376
* libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation
functions if they were detected by configure.
Diff:
---
libstdc++-v3/ChangeLog | 9 +++++++++
libstdc++-v3/libsupc++/new_opa.cc | 15 +++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 8b4637246b9..175107b5b30 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-26 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2020-01-17 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/92376
+ * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare allocation
+ functions if they were detected by configure.
+
2020-02-26 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
index 64b9ccb3493..e48982f7a08 100644
--- a/libstdc++-v3/libsupc++/new_opa.cc
+++ b/libstdc++-v3/libsupc++/new_opa.cc
@@ -42,6 +42,21 @@ extern "C" void *memalign(std::size_t boundary, std::size_t size);
using std::new_handler;
using std::bad_alloc;
+#if ! _GLIBCXX_HOSTED
+extern "C"
+{
+# if _GLIBCXX_HAVE_ALIGNED_ALLOC
+ void *aligned_alloc(size_t alignment, size_t size);
+# elif _GLIBCXX_HAVE__ALIGNED_MALLOC
+ void *_aligned_malloc(size_t size, size_t alignment);
+# elif _GLIBCXX_HAVE_POSIX_MEMALIGN
+ void *posix_memalign(void **, size_t alignment, size_t size);
+# elif _GLIBCXX_HAVE_MEMALIGN
+ void *memalign(size_t alignment, size_t size);
+# endif
+}
+#endif
+
namespace __gnu_cxx {
#if _GLIBCXX_HAVE_ALIGNED_ALLOC
using ::aligned_alloc;
More information about the Gcc-cvs
mailing list