diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-03-12 22:52:16 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-03-12 22:52:16 +0000 |
commit | 97ca95ac6fb17297f40e160d86c29cbcb3488270 (patch) | |
tree | 257f20eaa3a9d1a61ebad1c00592842060b7f1d6 | |
parent | 50536fd5e8539f209983092c5278477fa0b4d570 (diff) | |
download | gcc-97ca95ac6fb17297f40e160d86c29cbcb3488270.zip gcc-97ca95ac6fb17297f40e160d86c29cbcb3488270.tar.gz gcc-97ca95ac6fb17297f40e160d86c29cbcb3488270.tar.bz2 |
PR libstdc++/84773 use aligned alloc functions for FreeBSD and MinGW cross-compilers
PR libstdc++/84773
PR libstdc++/83662
* crossconfig.m4: Check for aligned_alloc etc. on freebsd and mingw32.
* configure: Regenerate.
* include/c_global/cstdlib [_GLIBCXX_HAVE_ALIGNED_ALLOC]
(aligned_alloc): Add using-declaration.
* testsuite/18_support/aligned_alloc/aligned_alloc.cc: New test.
From-SVN: r258468
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rwxr-xr-x | libstdc++-v3/configure | 26 | ||||
-rw-r--r-- | libstdc++-v3/crossconfig.m4 | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/c_global/cstdlib | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/18_support/aligned_alloc/aligned_alloc.cc | 42 |
5 files changed, 86 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7db7e81..743479a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2018-03-12 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/84773 + PR libstdc++/83662 + * crossconfig.m4: Check for aligned_alloc etc. on freebsd and mingw32. + * configure: Regenerate. + * include/c_global/cstdlib [_GLIBCXX_HAVE_ALIGNED_ALLOC] + (aligned_alloc): Add using-declaration. + * testsuite/18_support/aligned_alloc/aligned_alloc.cc: New test. + 2018-03-09 François Dumont <fdumont@gcc.gnu.org> * python/libstdcxx/v6/printers.py (build_libstdcxx_dictionary): diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 54dd7ce..ad6c506 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -53350,6 +53350,19 @@ _ACEOF fi done + for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + ;; *-fuchsia*) @@ -66100,6 +66113,19 @@ done CXXFLAGS="$ac_save_CXXFLAGS" + for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + ;; *-netbsd*) SECTION_FLAGS='-ffunction-sections -fdata-sections' diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index a8b1da9..fa56795 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -133,6 +133,7 @@ case "${host}" in AC_DEFINE(HAVE_ISNANL) fi AC_CHECK_FUNCS(__cxa_thread_atexit) + AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) ;; *-fuchsia*) @@ -197,6 +198,7 @@ case "${host}" in GLIBCXX_CHECK_LINKER_FEATURES GLIBCXX_CHECK_MATH_SUPPORT GLIBCXX_CHECK_STDLIB_SUPPORT + AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) ;; *-netbsd*) SECTION_FLAGS='-ffunction-sections -fdata-sections' diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib index a3b19f3..1033501 100644 --- a/libstdc++-v3/include/c_global/cstdlib +++ b/libstdc++-v3/include/c_global/cstdlib @@ -78,6 +78,9 @@ namespace std // Get rid of those macros defined in <stdlib.h> in lieu of real functions. #undef abort +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) +# undef aligned_alloc +#endif #undef atexit #if __cplusplus >= 201103L # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT @@ -125,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using ::ldiv_t; using ::abort; +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) + using ::aligned_alloc; +#endif using ::atexit; #if __cplusplus >= 201103L # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT diff --git a/libstdc++-v3/testsuite/18_support/aligned_alloc/aligned_alloc.cc b/libstdc++-v3/testsuite/18_support/aligned_alloc/aligned_alloc.cc new file mode 100644 index 0000000..8af9c72 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/aligned_alloc/aligned_alloc.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } +// { dg-do run { target c++17 } } + +#include <cstdlib> +#include <cstdint> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_HAVE_ALIGNED_ALLOC + void* p = std::aligned_alloc(256, 1); + if (p) + { + VERIFY( (reinterpret_cast<std::uintptr_t>(p) % 256) == 0 ); + std::free(p); + } +#endif +} + +int +main() +{ + test01(); +} |