Mercurial > octave
changeset 33394:ee94862503e2
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 13 Apr 2024 14:23:04 +0200 |
parents | 35901ae8a563 (current diff) f3ffee7cf478 (diff) |
children | a258493e726a |
files | m4/acinclude.m4 |
diffstat | 1 files changed, 42 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/m4/acinclude.m4 Sat Apr 13 12:14:21 2024 +0200 +++ b/m4/acinclude.m4 Sat Apr 13 14:23:04 2024 +0200 @@ -200,6 +200,47 @@ AC_CACHE_CHECK([whether std::pmr::polymorphic_allocator is available], [octave_cv_std_pmr_polymorphic_allocator], [AC_LANG_PUSH(C++) + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include <cstdlib> + #include <memory_resource> + #include <vector> + class mx_memory_resource : public std::pmr::memory_resource + { + private: + void * do_allocate (std::size_t bytes, size_t /*alignment*/) + { + void *ptr = std::malloc (bytes); + if (! ptr) + throw std::bad_alloc (); + return ptr; + } + void do_deallocate (void* ptr, std::size_t /*bytes*/, + std::size_t /*alignment*/) + { + std::free (ptr); + } + bool do_is_equal (const std::pmr::memory_resource& other) const noexcept + { + return this == dynamic_cast<const mx_memory_resource *> (&other); + return true; + } + }; + mx_memory_resource the_mx_memory_resource; + ]], [[ + std::pmr::vector<int> my_int_vec { &the_mx_memory_resource }; + ]])], + octave_cv_std_pmr_polymorphic_allocator=yes, + octave_cv_std_pmr_polymorphic_allocator=no, + [## On macOS, we need to run an executable to check if polymorphic + ## allocators are working. + ## When cross-compiling to that target, the following test might succeed + ## even if polymorphic allocators are not actually implemented. In that + ## case, users would need to manually configure with + ## `--disable-std-pmr-polymorphic-allocator`. + ## When cross-compiling to any other target, the following test should be + ## giving accurate results. + + ## FIXME: Is there a way to not repeat the same code from above? AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <cstdlib> #include <memory_resource> @@ -230,7 +271,7 @@ std::pmr::vector<int> my_int_vec { &the_mx_memory_resource }; ]])], octave_cv_std_pmr_polymorphic_allocator=yes, - octave_cv_std_pmr_polymorphic_allocator=no) + octave_cv_std_pmr_polymorphic_allocator=no)]) AC_LANG_POP(C++) ]) if test $octave_cv_std_pmr_polymorphic_allocator = yes; then