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

Commit c9a06ae

Browse files
Merge pull request #1138 from lukaszstolarczuk/merge-stable-1.9-into-stable-1.10
Merge stable-1.9 into stable-1.10
2 parents 8d2006b + ef400f8 commit c9a06ae

20 files changed

+152
-101
lines changed

.github/workflows/gha.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#
2-
# The 'XXX_DISABLE_' suffix is used twice in this file to disable two actions:
3-
# 1) XXX_DISABLE_${CI_FILE_PUSH_IMAGE_TO_REPO} - disables pushing the rebuilt Docker image and
4-
# 2) XXX_DISABLE_AUTO_DOC_UPDATE - disables making pull requests with the update of documentation.
5-
# Those two actions are disabled, because they conflict with the same ones run on Travis.
6-
# Only one CI (Travis or GitHub Actions) can run them at the time, so they can be enabled here,
7-
# when we decide to switch from Travis to GitHub Actions. The 'XXX_DISABLE_' suffix should be removed then.
8-
#
91

102
name: CPP
113
on: [push, pull_request]
@@ -22,13 +14,14 @@ jobs:
2214
env:
2315
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
2416
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
17+
GITHUB_TOKEN: ${{ secrets.DOC_UPDATE_GITHUB_TOKEN }}
2518
HOST_WORKDIR: /home/runner/work/libpmemobj-cpp/libpmemobj-cpp
2619
WORKDIR: utils/docker
2720
strategy:
2821
matrix:
2922
CONFIG: ["TYPE=debug OS=fedora OS_VER=32 PUSH_IMAGE=1",
3023
"TYPE=debug OS=ubuntu OS_VER=20.04 PUSH_IMAGE=1 CHECK_CPP_STYLE=1",
31-
"TYPE=release OS=fedora OS_VER=32 XXX_DISABLE_AUTO_DOC_UPDATE=1",
24+
"TYPE=release OS=fedora OS_VER=32 AUTO_DOC_UPDATE=1",
3225
"TYPE=release OS=ubuntu OS_VER=20.04",
3326
"TYPE=valgrind OS=ubuntu OS_VER=20.04",
3427
"TYPE=memcheck_drd OS=ubuntu OS_VER=20.04",
@@ -40,16 +33,16 @@ jobs:
4033
- name: Clone the git repo
4134
uses: actions/checkout@v2
4235
with:
43-
fetch-depth: 50
36+
fetch-depth: 0
4437

4538
- name: Pull or rebuild the image
46-
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh
39+
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh rebuild
4740

4841
- name: Run the build
4942
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./build.sh
5043

5144
- name: Push the image
52-
run: cd $WORKDIR && source ./set-vars.sh && ${{ matrix.CONFIG }} /bin/bash -c "if [[ -f XXX_DISABLE_${CI_FILE_PUSH_IMAGE_TO_REPO} ]]; then images/push-image.sh $OS-$OS_VER; fi"
45+
run: cd $WORKDIR && source ./set-vars.sh && ${{ matrix.CONFIG }} /bin/bash -c "if [[ -f ${CI_FILE_PUSH_IMAGE_TO_REPO} ]]; then images/push-image.sh $OS-$OS_VER; fi"
5346

5447
windows:
5548
name: Windows
@@ -88,7 +81,7 @@ jobs:
8881
- name: Clone the git repo
8982
uses: actions/checkout@v2
9083
with:
91-
fetch-depth: 50
84+
fetch-depth: 0
9285

9386
- name: Install PMDK
9487
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
!.gitattributes
44
!.github/
55
!.clang-format
6-
!.travis.yml
76
!.mailmap
87
!.version
98
build/

.travis.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
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
cmake_minimum_required(VERSION 3.3)
55
project(libpmemobj-cpp C CXX)

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 <lukasz.stolarczuk@intel.com>
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 <lukasz.stolarczuk@intel.com>
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
Thu May 28 2020 Szymon Romik <szymon.romik@intel.com>
233

334
* Version 1.10
@@ -142,7 +173,7 @@ Fri Mar 15 2019 Igor Chorążewicz <igor.chorazewicz@intel.com>
142173
- decrease number of persistent_ptr dereferences in
143174
make_persistent_array
144175

145-
Tue Feb 19 2018 Marcin Ślusarz <marcin.slusarz@intel.com>
176+
Tue Feb 19 2019 Marcin Ślusarz <marcin.slusarz@intel.com>
146177

147178
* Version 1.5.1
148179

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
libpmemobj-cpp
22
===============
33

4-
[![Build Status](https://travis-ci.org/pmem/libpmemobj-cpp.svg?branch=master)](https://travis-ci.org/pmem/libpmemobj-cpp)
54
[![Build status](https://github.com/pmem/libpmemobj-cpp/workflows/CPP/badge.svg)](https://github.com/pmem/libpmemobj-cpp/actions)
65
[![libpmemobj-cpp version](https://img.shields.io/github/tag/pmem/libpmemobj-cpp.svg)](https://github.com/pmem/libpmemobj-cpp/releases/latest)
76
[![Coverity Scan Build Status](https://scan.coverity.com/projects/15911/badge.svg)](https://scan.coverity.com/projects/pmem-libpmemobj-cpp)

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
@@ -643,7 +643,7 @@ vector<T>::assign(size_type count, const_reference value)
643643
add_data_to_tx(0, size_old);
644644

645645
std::fill_n(
646-
&_data[0],
646+
_data.get(),
647647
(std::min)(count,
648648
static_cast<size_type>(size_old)),
649649
value);
@@ -1577,7 +1577,7 @@ vector<T>::insert(const_iterator pos, size_type count, const value_type &value)
15771577
single_element_iterator<value_type>(&value, count));
15781578
});
15791579

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

15831583
/**
@@ -1820,7 +1820,7 @@ typename vector<T>::iterator
18201820
vector<T>::erase(const_iterator first, const_iterator last)
18211821
{
18221822
size_type idx = static_cast<size_type>(
1823-
std::distance(const_iterator(&_data[0]), first));
1823+
std::distance(const_iterator(_data.get()), first));
18241824
size_type count = static_cast<size_type>(std::distance(first, last));
18251825

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

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

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

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

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

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

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

23782389
auto old_data = _data;
23792390
auto old_size = _size;
2380-
pointer old_begin = &_data[0];
2391+
pointer old_begin = _data.get();
23812392
pointer old_end = capacity_new < _size
23822393
? &_data[static_cast<difference_type>(capacity_new)]
23832394
: &_data[static_cast<difference_type>(size())];

tests/memcheck-libunwind.supp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@
2121
obj:*libunwind*
2222
...
2323
}
24+
{
25+
libunwind calls glibc's setcontext on some architectures, e.g. ppc
26+
Memcheck:Addr8
27+
fun:setcontext*
28+
...
29+
}
30+
{
31+
libunwind exception suppresion
32+
Memcheck:Param
33+
write(buf)
34+
...
35+
obj:*libunwind*
36+
...
37+
}

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
@@ -356,6 +356,38 @@ test_base_ptr_casting(nvobj::pool<root> &pop)
356356
UT_ASSERT(0);
357357
}
358358
}
359+
360+
/*
361+
* test_offset_with_alignment -- test offset calculation within a hierarchy of
362+
* objects with different alignments
363+
*/
364+
void
365+
test_offset_alignment(nvobj::pool<root> &pop)
366+
{
367+
struct A {
368+
char a;
369+
};
370+
371+
struct B {
372+
uint64_t b;
373+
};
374+
375+
struct C : public A, public B {
376+
uint64_t c;
377+
};
378+
379+
try {
380+
nvobj::transaction::run(pop, [] {
381+
auto cptr = nvobj::make_persistent<C>();
382+
nvobj::persistent_ptr<B> bptr = cptr;
383+
UT_ASSERT((bptr.raw().off - cptr.raw().off) ==
384+
alignof(B));
385+
nvobj::delete_persistent<C>(cptr);
386+
});
387+
} catch (...) {
388+
UT_ASSERT(0);
389+
}
390+
}
359391
}
360392

361393
static void
@@ -381,6 +413,7 @@ test(int argc, char *argv[])
381413
test_ptr_array(pop);
382414
test_offset(pop);
383415
test_base_ptr_casting(pop);
416+
test_offset_alignment(pop);
384417

385418
pop.close();
386419
}

0 commit comments

Comments
 (0)