Skip to content

Commit 5091283

Browse files
committed
[libc++] Update the status for lwg-3143
Current implementation use the larger one either requested bytes or growth factor multiply previous buffer size. This patch update the lwg 3143 issue latest status.
1 parent c727b48 commit 5091283

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

libcxx/docs/Status/Cxx23Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"Issue #","Issue Name","Meeting","Status","First released version","Notes"
22
"`LWG2839 <https://wg21.link/LWG2839>`__","Self-move-assignment of library types, again","2020-11 (Virtual)","|Nothing To Do|","",""
33
"`LWG3117 <https://wg21.link/LWG3117>`__","Missing ``packaged_task`` deduction guides","2020-11 (Virtual)","|Complete|","16",""
4-
"`LWG3143 <https://wg21.link/LWG3143>`__","``monotonic_buffer_resource`` growth policy is unclear","2020-11 (Virtual)","","",""
4+
"`LWG3143 <https://wg21.link/LWG3143>`__","``monotonic_buffer_resource`` growth policy is unclear","2020-11 (Virtual)","|Complete|","16",""
55
"`LWG3195 <https://wg21.link/LWG3195>`__","What is the stored pointer value of an empty ``weak_ptr``?","2020-11 (Virtual)","|Nothing To Do|","",""
66
"`LWG3211 <https://wg21.link/LWG3211>`__","``std::tuple<>`` should be trivially constructible","2020-11 (Virtual)","|Complete|","9",""
77
"`LWG3236 <https://wg21.link/LWG3236>`__","Random access iterator requirements lack limiting relational operators domain to comparing those from the same range","2020-11 (Virtual)","|Nothing To Do|","",""

libcxx/include/__memory_resource/monotonic_buffer_resource.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace pmr {
2727
// [mem.res.monotonic.buffer]
2828

2929
class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resource : public memory_resource {
30-
static const size_t __default_buffer_capacity = 1024;
31-
static const size_t __default_buffer_alignment = 16;
30+
static constexpr size_t __default_buffer_capacity = 1024;
31+
static constexpr size_t __default_growth_factor = 2;
3232

3333
struct __chunk_footer {
3434
__chunk_footer* __next_;

libcxx/src/memory_resource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
478478
size_t previous_capacity = previous_allocation_size();
479479

480480
if (aligned_capacity <= previous_capacity) {
481-
size_t newsize = 2 * (previous_capacity - footer_size);
481+
size_t newsize = __default_growth_factor * (previous_capacity - footer_size);
482482
aligned_capacity = roundup(newsize, footer_align) + footer_size;
483483
}
484484

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#include "count_new.h"
2121
#include "test_macros.h"
2222

23-
void test_geometric_progression() {
23+
// LWG 3143: https://cplusplus.github.io/LWG/issue3143
24+
void test_growth_capacity() {
2425
// mem.res.monotonic.buffer 1.3
25-
// Each additional buffer is larger than the previous one, following a
26-
// geometric progression.
26+
// Each additional buffer is larger than the previous one
2727

2828
globalMemCounter.reset();
2929
std::pmr::monotonic_buffer_resource mono1(100, std::pmr::new_delete_resource());
@@ -35,23 +35,23 @@ void test_geometric_progression() {
3535
assert(ret != nullptr);
3636
assert(globalMemCounter.checkNewCalledEq(1));
3737
assert(globalMemCounter.last_new_size >= next_buffer_size);
38-
next_buffer_size = globalMemCounter.last_new_size + 1;
38+
next_buffer_size = globalMemCounter.last_new_size;
3939

4040
int new_called = 1;
4141
while (new_called < 5) {
4242
ret = r1.allocate(10, 1);
4343
if (globalMemCounter.new_called > new_called) {
4444
assert(globalMemCounter.new_called == new_called + 1);
45-
assert(globalMemCounter.last_new_size >= next_buffer_size);
46-
next_buffer_size = globalMemCounter.last_new_size + 1;
45+
next_buffer_size = next_buffer_size * 2 - 4 * sizeof(void*);
46+
assert(globalMemCounter.last_new_size == next_buffer_size);
4747
new_called += 1;
4848
}
4949
}
5050
}
5151

5252
int main(int, char**) {
5353
#if TEST_SUPPORTS_LIBRARY_INTERNAL_ALLOCATIONS && !defined(DISABLE_NEW_COUNT)
54-
test_geometric_progression();
54+
test_growth_capacity();
5555
#endif
5656

5757
return 0;

0 commit comments

Comments
 (0)