Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 7bbe1d1

Browse files
Merge pull request #1141 from lukaszstolarczuk/merge-stable-1.11-into-stable-1.12
Merge stable-1.11 into stable-1.12
2 parents 8dda53d + e98a1b6 commit 7bbe1d1

File tree

15 files changed

+115
-44
lines changed

15 files changed

+115
-44
lines changed

.github/workflows/gha.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181
steps:
8282
- name: Clone the git repo
8383
uses: actions/checkout@v2
84+
with:
85+
fetch-depth: 0
8486

8587
- name: Pull the image
8688
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh pull

ChangeLog

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
Tue Jul 06 2021 Łukasz Stolarczuk <[email protected]>
2+
3+
* Version 1.6.1
4+
5+
This release fixes minor bugs.
6+
7+
This is the last patch release for libpmemobj-cpp 1.6 version.
8+
Maintenance of this version is no longer supported.
9+
10+
Notable changes:
11+
- string: fix max_size() return value
12+
- allocation_flag: mark constructor as explicit
13+
- peristent_ptr: change ptr_offset_magic to be properly aligned
14+
- fix few headers' includes
15+
16+
Mon Jun 28 2021 Łukasz Stolarczuk <[email protected]>
17+
18+
* Version 1.5.2
19+
20+
This release fixes minor bugs.
21+
22+
This is the last patch release for libpmemobj-cpp 1.5 version.
23+
Maintenance of this version is no longer supported.
24+
25+
Notable changes:
26+
- operator[] for contiguous_iterator takes signed integral instead of
27+
unsigned
28+
- throw an exception when pmemobj_mutex_unlock fail
29+
- fix crash when a previous transaction failed to start because of
30+
already taken lock.
31+
132
Mon Feb 15 2021 Igor Chorążewicz <[email protected]>
233

334
* Version 1.12
@@ -201,7 +232,7 @@ Fri Mar 15 2019 Igor Chorążewicz <[email protected]>
201232
- decrease number of persistent_ptr dereferences in
202233
make_persistent_array
203234

204-
Tue Feb 19 2018 Marcin Ślusarz <[email protected]>
235+
Tue Feb 19 2019 Marcin Ślusarz <[email protected]>
205236

206237
* Version 1.5.1
207238

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# libpmemobj-cpp
22

3-
[![Build Status](https://travis-ci.org/pmem/libpmemobj-cpp.svg?branch=master)](https://travis-ci.org/pmem/libpmemobj-cpp)
43
[![Build status](https://github.com/pmem/libpmemobj-cpp/workflows/CPP/badge.svg)](https://github.com/pmem/libpmemobj-cpp/actions)
54
[![libpmemobj-cpp version](https://img.shields.io/github/tag/pmem/libpmemobj-cpp.svg)](https://github.com/pmem/libpmemobj-cpp/releases/latest)
65
[![Coverity Scan Build Status](https://scan.coverity.com/projects/15911/badge.svg)](https://scan.coverity.com/projects/pmem-libpmemobj-cpp)
@@ -74,6 +73,7 @@ You will need the following packages for compilation:
7473
- **valgrind-devel** (at best with [pmemcheck support](https://github.com/pmem/valgrind))
7574
- **clang-format** 9.0
7675
- **perl**
76+
- **libatomic**
7777
- for Windows compilation:
7878
- [**vcpkg**](https://github.com/microsoft/vcpkg#quick-start-windows)
7979

@@ -164,4 +164,5 @@ or just use graphical CMake frontend like **cmake-qt-gui** or **cmake-curses-gui
164164
## Contact us
165165
For more information on this library, contact Igor Chorążewicz ([email protected]),
166166
Piotr Balcer ([email protected]) or post on our **#pmem** Slack channel using
167-
[this invite link](https://join.slack.com/t/pmem-io/shared_invite/enQtNzU4MzQ2Mzk3MDQwLWQ1YThmODVmMGFkZWI0YTdhODg4ODVhODdhYjg3NmE4N2ViZGI5NTRmZTBiNDYyOGJjYTIyNmZjYzQxODcwNDg) or [Google group](https://groups.google.com/group/pmem).
167+
[this invite link](https://join.slack.com/t/pmem-io/shared_invite/enQtNzU4MzQ2Mzk3MDQwLWQ1YThmODVmMGFkZWI0YTdhODg4ODVhODdhYjg3NmE4N2ViZGI5NTRmZTBiNDYyOGJjYTIyNmZjYzQxODcwNDg)
168+
or [Google group](https://groups.google.com/group/pmem).

include/libpmemobj++/container/detail/contiguous_iterator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2018-2020, Intel Corporation */
2+
/* Copyright 2018-2021, Intel Corporation */
33

44
/**
55
* @file
@@ -213,7 +213,7 @@ struct range_snapshotting_iterator
213213
{
214214
assert(data <= ptr);
215215

216-
if (snapshot_size > 0)
216+
if (snapshot_size && ptr)
217217
snapshot_range(ptr);
218218
}
219219

include/libpmemobj++/container/vector.hpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2018-2020, Intel Corporation */
2+
/* Copyright 2018-2021, Intel Corporation */
33

44
/**
55
* @file
@@ -644,7 +644,7 @@ vector<T>::assign(size_type count, const_reference value)
644644
add_data_to_tx(0, size_old);
645645

646646
std::fill_n(
647-
&_data[0],
647+
_data.get(),
648648
(std::min)(count,
649649
static_cast<size_type>(size_old)),
650650
value);
@@ -1578,7 +1578,7 @@ vector<T>::insert(const_iterator pos, size_type count, const value_type &value)
15781578
single_element_iterator<value_type>(&value, count));
15791579
});
15801580

1581-
return iterator(&_data[static_cast<difference_type>(idx)]);
1581+
return iterator(_data.get() + static_cast<difference_type>(idx));
15821582
}
15831583

15841584
/**
@@ -1821,7 +1821,7 @@ typename vector<T>::iterator
18211821
vector<T>::erase(const_iterator first, const_iterator last)
18221822
{
18231823
size_type idx = static_cast<size_type>(
1824-
std::distance(const_iterator(&_data[0]), first));
1824+
std::distance(const_iterator(_data.get()), first));
18251825
size_type count = static_cast<size_type>(std::distance(first, last));
18261826

18271827
if (count == 0)
@@ -2293,10 +2293,11 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
22932293
auto count = static_cast<size_type>(std::distance(first, last));
22942294

22952295
if (_capacity >= size() + count) {
2296-
pointer dest =
2297-
&_data[static_cast<difference_type>(size() + count)];
2298-
pointer begin = &_data[static_cast<difference_type>(idx)];
2299-
pointer end = &_data[static_cast<difference_type>(size())];
2296+
pointer dest = _data.get() +
2297+
static_cast<difference_type>(size() + count);
2298+
pointer begin = _data.get() + static_cast<difference_type>(idx);
2299+
pointer end =
2300+
_data.get() + static_cast<difference_type>(size());
23002301

23012302
add_data_to_tx(idx, size() - idx + count);
23022303

@@ -2314,9 +2315,11 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
23142315

23152316
auto old_data = _data;
23162317
auto old_size = _size;
2317-
pointer old_begin = &_data[0];
2318-
pointer old_mid = &_data[static_cast<difference_type>(idx)];
2319-
pointer old_end = &_data[static_cast<difference_type>(size())];
2318+
pointer old_begin = _data.get();
2319+
pointer old_mid =
2320+
_data.get() + static_cast<difference_type>(idx);
2321+
pointer old_end =
2322+
_data.get() + static_cast<difference_type>(size());
23202323

23212324
_data = nullptr;
23222325
_size = _capacity = 0;
@@ -2349,7 +2352,8 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
23492352
* Private helper function. Must be called during transaction. Allocates new
23502353
* memory for capacity_new number of elements and copies or moves old elements
23512354
* to new memory area. If the current size is greater than capacity_new, the
2352-
* container is reduced to its first capacity_new elements.
2355+
* container is reduced to its first capacity_new elements. If was never
2356+
* allocated behaves as an alloc call.
23532357
*
23542358
* param[in] capacity_new new capacity.
23552359
*
@@ -2368,6 +2372,13 @@ vector<T>::realloc(size_type capacity_new)
23682372
{
23692373
assert(pmemobj_tx_stage() == TX_STAGE_WORK);
23702374

2375+
/*
2376+
* If _data == nullptr this object has never allocated any memory
2377+
* so we need to behave as alloc instead.
2378+
*/
2379+
if (_data == nullptr)
2380+
return alloc(capacity_new);
2381+
23712382
/*
23722383
* XXX: future optimization: we don't have to snapshot data
23732384
* which we will not overwrite
@@ -2376,7 +2387,7 @@ vector<T>::realloc(size_type capacity_new)
23762387

23772388
auto old_data = _data;
23782389
auto old_size = _size;
2379-
pointer old_begin = &_data[0];
2390+
pointer old_begin = _data.get();
23802391
pointer old_end = capacity_new < _size
23812392
? &_data[static_cast<difference_type>(capacity_new)]
23822393
: &_data[static_cast<difference_type>(size())];

include/libpmemobj++/detail/self_relative_ptr_base_impl.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2020, Intel Corporation */
2+
/* Copyright 2020-2021, Intel Corporation */
33

44
/**
55
* @file
@@ -222,9 +222,8 @@ class self_relative_ptr_base_impl {
222222
*/
223223
uintptr_t mask = other_offset == nullptr_offset;
224224
--mask;
225-
uintptr_t ptr = reinterpret_cast<uintptr_t>(
226-
reinterpret_cast<const_byte_ptr_type>(this) +
227-
other_offset + 1);
225+
uintptr_t ptr = static_cast<uintptr_t>(
226+
reinterpret_cast<intptr_t>(this) + other_offset + 1);
228227
ptr &= mask;
229228
return reinterpret_cast<void *>(ptr);
230229
}

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ if(TEST_SELF_RELATIVE_POINTER)
283283
build_test(self_relative_ptr_arith ptr/self_relative_ptr_arith.cpp)
284284
add_test_generic(NAME self_relative_ptr_arith TRACERS none memcheck pmemcheck)
285285

286-
build_test_atomic(self_relative_ptr_atomic ptr/self_relative_ptr_atomic.cpp)
286+
build_test(self_relative_ptr_atomic ptr/self_relative_ptr_atomic.cpp)
287287
add_test_generic(NAME self_relative_ptr_atomic TRACERS none memcheck drd helgrind)
288288

289-
build_test_atomic(self_relative_ptr_atomic_pmem ptr/self_relative_ptr_atomic_pmem.cpp)
289+
build_test(self_relative_ptr_atomic_pmem ptr/self_relative_ptr_atomic_pmem.cpp)
290290
add_test_generic(NAME self_relative_ptr_atomic_pmem TRACERS none memcheck pmemcheck drd helgrind)
291291
endif()
292292

tests/ctest_helpers.cmake

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: BSD-3-Clause
2-
# Copyright 2018-2020, Intel Corporation
2+
# Copyright 2018-2021, Intel Corporation
33

44
#
55
# ctest_helpers.cmake - helper functions for tests/CMakeLists.txt
@@ -112,6 +112,8 @@ function(build_test name)
112112
endif()
113113
if(WIN32)
114114
target_link_libraries(${name} dbghelp)
115+
else()
116+
target_link_libraries(${name} atomic)
115117
endif()
116118

117119
add_dependencies(tests ${name})
@@ -132,14 +134,6 @@ function(build_test_tbb name)
132134
target_link_libraries(${name} ${TBB_LIBRARIES})
133135
endfunction()
134136

135-
# Function to build test with atomic
136-
function(build_test_atomic name)
137-
build_test(${name} ${ARGN})
138-
if(CLANG)
139-
target_link_libraries(${name} atomic)
140-
endif()
141-
endfunction()
142-
143137
# Function to build a TBB test with mocked pmemobj_defrag() function
144138
function(build_test_tbb_defrag name)
145139
build_test_tbb(${name} ${ARGN})

tests/ptr/ptr.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2015-2020, Intel Corporation */
2+
/* Copyright 2015-2021, Intel Corporation */
33

44
/*
55
* obj_cpp_ptr.c -- cpp bindings test
@@ -128,6 +128,38 @@ test_base_ptr_casting(nvobj::pool<root> &pop)
128128
UT_ASSERT(0);
129129
}
130130
}
131+
132+
/*
133+
* test_offset_with_alignment -- test offset calculation within a hierarchy of
134+
* objects with different alignments
135+
*/
136+
void
137+
test_offset_alignment(nvobj::pool<root> &pop)
138+
{
139+
struct A {
140+
char a;
141+
};
142+
143+
struct B {
144+
uint64_t b;
145+
};
146+
147+
struct C : public A, public B {
148+
uint64_t c;
149+
};
150+
151+
try {
152+
nvobj::transaction::run(pop, [] {
153+
auto cptr = nvobj::make_persistent<C>();
154+
nvobj::persistent_ptr<B> bptr = cptr;
155+
UT_ASSERT((bptr.raw().off - cptr.raw().off) ==
156+
alignof(B));
157+
nvobj::delete_persistent<C>(cptr);
158+
});
159+
} catch (...) {
160+
UT_ASSERT(0);
161+
}
162+
}
131163
}
132164

133165
static void
@@ -155,6 +187,7 @@ test(int argc, char *argv[])
155187
test_ptr_array(pop);
156188
test_offset(pop);
157189
test_base_ptr_casting(pop);
190+
test_offset_alignment(pop);
158191

159192
pop.close();
160193
}

utils/docker/images/Dockerfile.archlinux-base-latest

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88

99
# Pull base image
10-
FROM archlinux/base:latest
10+
FROM registry.hub.docker.com/library/archlinux:base
1111
1212

1313
# Set required environment variables
@@ -48,7 +48,8 @@ RUN pacman -S --noconfirm \
4848
wget \
4949
which \
5050
whois \
51-
xmlto
51+
xmlto \
52+
&& rm -rf /var/cache/pacman/pkg/*
5253

5354
# Install libndctl
5455
COPY install-libndctl.sh install-libndctl.sh
@@ -74,6 +75,3 @@ RUN rm -f $PFILE
7475
RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
7576
RUN gpasswd wheel -a $USER
7677
USER $USER
77-
78-
# Clean the cache of packages
79-
RUN rm -rf /var/cache/pacman/pkg/*

0 commit comments

Comments
 (0)