Re: [PATCH] Add initial version of C++17 header
On 25/07/18 21:23 +0100, Jonathan Wakely wrote: On 25/07/18 12:01 +0100, Jonathan Wakely wrote: On 24/07/18 22:12 +0100, Jonathan Wakely wrote: This is missing the synchronized_pool_resource and unsynchronized_pool_resource classes but is otherwise complete. This is a new implementation, not based on the existing code in , but memory_resource and polymorphic_allocator ended up looking almost the same anyway. The constant_init kluge in src/c++17/memory_resource.cc is apparently due to Richard Smith and ensures that the objects are constructed during constant initialiation phase and not destroyed (because the constant_init destructor doesn't destroy the union member and the storage is not reused). * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include for C++17. * include/std/memory_resource: New header. (memory_resource, polymorphic_allocator, new_delete_resource) (null_memory_resource, set_default_resource, get_default_resource) (pool_options, monotonic_buffer_resource): Define. * src/Makefile.am: Add c++17 directory. * src/Makefile.in: Regenerate. * src/c++11/Makefile.am: Fix comment. * src/c++17/Makefile.am: Add makefile for new sub-directory. * src/c++17/Makefile.in: Generate. * src/c++17/memory_resource.cc: New. (newdel_res_t, null_res_t, constant_init, newdel_res, null_res) (default_res, new_delete_resource, null_memory_resource) (set_default_resource, get_default_resource): Define. * testsuite/20_util/memory_resource/1.cc: New test. * testsuite/20_util/memory_resource/2.cc: New test. * testsuite/20_util/monotonic_buffer_resource/1.cc: New test. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/release.cc: New test. * testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc: New test. * testsuite/20_util/polymorphic_allocator/1.cc: New test. * testsuite/20_util/polymorphic_allocator/resource.cc: New test. * testsuite/20_util/polymorphic_allocator/select.cc: New test. * testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource): Define concrete memory resource for testing. (__gnu_test::default_resource_mgr): Define RAII helper for changing default resource. Tested powerpc64le-linux, committed to trunk. I missed a change to acinclude.m4 that should have gone with this patch. Now also committed to trunk. One of the tests also needs this fix. And another correction to the same test. Tested powerpc-ibm-aix7.2.0.0, committed to trunk. commit 0dbdb55154fee2af4c02e45a373f5a2dc2985856 Author: Jonathan Wakely Date: Thu Jul 26 00:35:57 2018 +0100 PR libstdc++/86676 another alignment fix for test PR libstdc++/86676 * testsuite/20_util/monotonic_buffer_resource/release.cc: Request same alignment for post-release allocation. diff --git a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc index ac70385961d..8aab4692d52 100644 --- a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc +++ b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc @@ -127,7 +127,7 @@ test04() VERIFY( mbr.upstream_resource() == ); VERIFY( r.number_of_active_allocations() == 0 ); // initial buffer should be used again now: - p = mbr.allocate(1000); + p = mbr.allocate(1000, 16); VERIFY( p == p_in_buffer ); VERIFY( r.allocate_calls == 1 ); }
Re: [PATCH] Add initial version of C++17 header
On 25/07/18 12:01 +0100, Jonathan Wakely wrote: On 24/07/18 22:12 +0100, Jonathan Wakely wrote: This is missing the synchronized_pool_resource and unsynchronized_pool_resource classes but is otherwise complete. This is a new implementation, not based on the existing code in , but memory_resource and polymorphic_allocator ended up looking almost the same anyway. The constant_init kluge in src/c++17/memory_resource.cc is apparently due to Richard Smith and ensures that the objects are constructed during constant initialiation phase and not destroyed (because the constant_init destructor doesn't destroy the union member and the storage is not reused). * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include for C++17. * include/std/memory_resource: New header. (memory_resource, polymorphic_allocator, new_delete_resource) (null_memory_resource, set_default_resource, get_default_resource) (pool_options, monotonic_buffer_resource): Define. * src/Makefile.am: Add c++17 directory. * src/Makefile.in: Regenerate. * src/c++11/Makefile.am: Fix comment. * src/c++17/Makefile.am: Add makefile for new sub-directory. * src/c++17/Makefile.in: Generate. * src/c++17/memory_resource.cc: New. (newdel_res_t, null_res_t, constant_init, newdel_res, null_res) (default_res, new_delete_resource, null_memory_resource) (set_default_resource, get_default_resource): Define. * testsuite/20_util/memory_resource/1.cc: New test. * testsuite/20_util/memory_resource/2.cc: New test. * testsuite/20_util/monotonic_buffer_resource/1.cc: New test. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/release.cc: New test. * testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc: New test. * testsuite/20_util/polymorphic_allocator/1.cc: New test. * testsuite/20_util/polymorphic_allocator/resource.cc: New test. * testsuite/20_util/polymorphic_allocator/select.cc: New test. * testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource): Define concrete memory resource for testing. (__gnu_test::default_resource_mgr): Define RAII helper for changing default resource. Tested powerpc64le-linux, committed to trunk. I missed a change to acinclude.m4 that should have gone with this patch. Now also committed to trunk. One of the tests also needs this fix. Committed to trunk. commit 4875590bba5e5b77878264870671071016ab7ca2 Author: Jonathan Wakely Date: Wed Jul 25 21:22:19 2018 +0100 PR libstdc++/86676 Do not assume stack buffer is aligned PR libstdc++/86676 * testsuite/20_util/monotonic_buffer_resource/release.cc: Allow for buffer being misaligned and so returned pointer not being at start. diff --git a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc index 0c7f31789e6..ac70385961d 100644 --- a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc +++ b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/release.cc @@ -115,10 +115,12 @@ test04() unsigned char buffer[1024]; std::pmr::monotonic_buffer_resource mbr(buffer, sizeof(buffer), ); void* p = mbr.allocate(800, 16); - VERIFY( p == buffer ); + VERIFY( p >= buffer && p < (buffer + 16) ); + void* const p_in_buffer = p; VERIFY( r.allocate_calls == 0 ); p = mbr.allocate(300, 1); VERIFY( p != buffer ); + VERIFY( p != buffer ); VERIFY( r.allocate_calls == 1 ); mbr.release(); VERIFY( r.deallocate_calls == 1 ); @@ -126,7 +128,7 @@ test04() VERIFY( r.number_of_active_allocations() == 0 ); // initial buffer should be used again now: p = mbr.allocate(1000); - VERIFY( p == buffer ); + VERIFY( p == p_in_buffer ); VERIFY( r.allocate_calls == 1 ); }
Re: [PATCH] Add initial version of C++17 header
On 24/07/18 22:12 +0100, Jonathan Wakely wrote: This is missing the synchronized_pool_resource and unsynchronized_pool_resource classes but is otherwise complete. This is a new implementation, not based on the existing code in , but memory_resource and polymorphic_allocator ended up looking almost the same anyway. The constant_init kluge in src/c++17/memory_resource.cc is apparently due to Richard Smith and ensures that the objects are constructed during constant initialiation phase and not destroyed (because the constant_init destructor doesn't destroy the union member and the storage is not reused). * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include for C++17. * include/std/memory_resource: New header. (memory_resource, polymorphic_allocator, new_delete_resource) (null_memory_resource, set_default_resource, get_default_resource) (pool_options, monotonic_buffer_resource): Define. * src/Makefile.am: Add c++17 directory. * src/Makefile.in: Regenerate. * src/c++11/Makefile.am: Fix comment. * src/c++17/Makefile.am: Add makefile for new sub-directory. * src/c++17/Makefile.in: Generate. * src/c++17/memory_resource.cc: New. (newdel_res_t, null_res_t, constant_init, newdel_res, null_res) (default_res, new_delete_resource, null_memory_resource) (set_default_resource, get_default_resource): Define. * testsuite/20_util/memory_resource/1.cc: New test. * testsuite/20_util/memory_resource/2.cc: New test. * testsuite/20_util/monotonic_buffer_resource/1.cc: New test. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/release.cc: New test. * testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc: New test. * testsuite/20_util/polymorphic_allocator/1.cc: New test. * testsuite/20_util/polymorphic_allocator/resource.cc: New test. * testsuite/20_util/polymorphic_allocator/select.cc: New test. * testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource): Define concrete memory resource for testing. (__gnu_test::default_resource_mgr): Define RAII helper for changing default resource. Tested powerpc64le-linux, committed to trunk. I missed a change to acinclude.m4 that should have gone with this patch. Now also committed to trunk. commit cdaaa2b47d3fa093c741086e86d631d420a93663 Author: Jonathan Wakely Date: Wed Jul 25 11:52:19 2018 +0100 Add new src/c++17 directory to list in acinclude.m4 * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++17. * src/Makefile.am: Add comment. * src/c++17/Makefile.in: Regenerate. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index bbf3c8df3e1..6d68e907426 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [ # Keep these sync'd with the list in Makefile.am. The first provides an # expandable list at autoconf time; the second provides an expandable list # (i.e., shell variable) at configure time. - m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/filesystem doc po testsuite python]) + m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python]) SUBDIRS='glibcxx_SUBDIRS' # These need to be absolute paths, yet at the same time need to diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 09edcdbc471..9a2fe297ddb 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -28,6 +28,7 @@ else filesystem_dir = endif +## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. SUBDIRS = c++98 c++11 c++17 $(filesystem_dir) # Cross compiler support.
[PATCH] Add initial version of C++17 header
This is missing the synchronized_pool_resource and unsynchronized_pool_resource classes but is otherwise complete. This is a new implementation, not based on the existing code in , but memory_resource and polymorphic_allocator ended up looking almost the same anyway. The constant_init kluge in src/c++17/memory_resource.cc is apparently due to Richard Smith and ensures that the objects are constructed during constant initialiation phase and not destroyed (because the constant_init destructor doesn't destroy the union member and the storage is not reused). * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include for C++17. * include/std/memory_resource: New header. (memory_resource, polymorphic_allocator, new_delete_resource) (null_memory_resource, set_default_resource, get_default_resource) (pool_options, monotonic_buffer_resource): Define. * src/Makefile.am: Add c++17 directory. * src/Makefile.in: Regenerate. * src/c++11/Makefile.am: Fix comment. * src/c++17/Makefile.am: Add makefile for new sub-directory. * src/c++17/Makefile.in: Generate. * src/c++17/memory_resource.cc: New. (newdel_res_t, null_res_t, constant_init, newdel_res, null_res) (default_res, new_delete_resource, null_memory_resource) (set_default_resource, get_default_resource): Define. * testsuite/20_util/memory_resource/1.cc: New test. * testsuite/20_util/memory_resource/2.cc: New test. * testsuite/20_util/monotonic_buffer_resource/1.cc: New test. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/release.cc: New test. * testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc: New test. * testsuite/20_util/polymorphic_allocator/1.cc: New test. * testsuite/20_util/polymorphic_allocator/resource.cc: New test. * testsuite/20_util/polymorphic_allocator/select.cc: New test. * testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource): Define concrete memory resource for testing. (__gnu_test::default_resource_mgr): Define RAII helper for changing default resource. Tested powerpc64le-linux, committed to trunk. commit 05c7ae80dbd59fcef5d583eac15181afbc07a116 Author: Jonathan Wakely Date: Tue Jul 24 14:19:19 2018 +0100 Add initial version of C++17 header This is missing the synchronized_pool_resource and unsynchronized_pool_resource classes but is otherwise complete. This is a new implementation, not based on the existing code in , but memory_resource and polymorphic_allocator ended up looking almost the same anyway. The constant_init kluge in src/c++17/memory_resource.cc is apparently due to Richard Smith and ensures that the objects are constructed during constant initialiation phase and not destroyed (because the constant_init destructor doesn't destroy the union member and the storage is not reused). * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include for C++17. * include/std/memory_resource: New header. (memory_resource, polymorphic_allocator, new_delete_resource) (null_memory_resource, set_default_resource, get_default_resource) (pool_options, monotonic_buffer_resource): Define. * src/Makefile.am: Add c++17 directory. * src/Makefile.in: Regenerate. * src/c++11/Makefile.am: Fix comment. * src/c++17/Makefile.am: Add makefile for new sub-directory. * src/c++17/Makefile.in: Generate. * src/c++17/memory_resource.cc: New. (newdel_res_t, null_res_t, constant_init, newdel_res, null_res) (default_res, new_delete_resource, null_memory_resource) (set_default_resource, get_default_resource): Define. * testsuite/20_util/memory_resource/1.cc: New test. * testsuite/20_util/memory_resource/2.cc: New test. * testsuite/20_util/monotonic_buffer_resource/1.cc: New test. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test. * testsuite/20_util/monotonic_buffer_resource/release.cc: New test. * testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc: New test. * testsuite/20_util/polymorphic_allocator/1.cc: New