├── tests ├── concurrent_hash_map_rehash_break │ ├── .gitignore │ ├── break_in_rehash_0.gdb │ ├── break_in_rehash_1.gdb │ └── concurrent_hash_map_rehash_break.cmake.in ├── pool │ ├── pool_3_none.out.match │ ├── pool_win_3_none.out.match │ ├── pool_0_none.out.match │ ├── pool_win_0_none.out.match │ ├── pool_4_none.out.match │ ├── pool_5_none.out.match │ ├── pool_7_none.out.match │ ├── pool_6_none.out.match │ ├── pool_11_none.out.match │ ├── pool_1_none.out.match │ ├── pool_win_1_none.out.match │ ├── pool_9_none.out.match │ ├── pool_8_none.out.match │ ├── pool_2_none.out.match │ ├── pool_win_2_none.out.match │ ├── pool_10_none.out.match │ ├── pool_cleanup_0.cmake │ ├── pool_7.cmake │ ├── pool_3.cmake │ ├── pool_win_3.cmake │ ├── pool_5.cmake │ ├── pool_6.cmake │ ├── pool_0.cmake │ ├── pool_win_0.cmake │ ├── pool_2.cmake │ ├── pool_win_2.cmake │ ├── pool_4.cmake │ ├── pool_9.cmake │ ├── pool_11.cmake │ ├── pool_win_1.cmake │ ├── pool_8.cmake │ ├── pool_1.cmake │ └── pool_10.cmake ├── concurrent_map_pmreorder_break_insert │ ├── .gitignore │ ├── pmreorder.conf │ ├── break_before_set_next.gdb.in │ └── concurrent_map_pmreorder_break_insert.cmake.in ├── ctl │ ├── pool.set.in │ └── ctl_0.cmake ├── ex-queue │ ├── ex-queue_0_none.out.match │ └── ex-queue_0.cmake ├── array │ ├── pmreorder.conf │ ├── array_slice_0.cmake │ ├── array_slice_pmreorder_0.cmake │ ├── array_slice_pmreorder_1.cmake │ └── array_is_aggregate.cpp ├── concurrent_hash_map_pmreorder_break_insert │ ├── .gitignore │ ├── pmreorder.conf │ ├── break_before_persist.gdb.in │ └── concurrent_hash_map_pmreorder_break_insert.cmake.in ├── ctl_win │ └── pool.set.in ├── compatibility │ ├── version │ │ ├── README.txt │ │ ├── version_1.9.cpp │ │ ├── version_1.7.cpp │ │ ├── version_1.8.cpp │ │ ├── version_1.10.cpp │ │ ├── version_1.11.cpp │ │ └── version_1.12.cpp │ └── run.cmake ├── true.cmake ├── concurrent_hash_map_pmreorder_multiple_buckets │ └── pmreorder.conf ├── concurrent_map │ └── pmreorder.conf ├── concurrent_hash_map │ ├── pmreorder.conf │ ├── check_is_pmem.cmake │ ├── check_is_pmem_defrag.cmake │ ├── concurrent_hash_map_tbb_insert_erase.cpp │ ├── concurrent_hash_map_tbb_insert_lookup.cpp │ └── concurrent_hash_map_deadlock.cpp ├── concurrent_map_pmreorder_erase │ ├── pmreorder.conf │ └── concurrent_map_pmreorder_erase_0.cmake ├── concurrent_hash_map_pmreorder_erase │ ├── pmreorder.conf │ └── concurrent_hash_map_pmreorder_erase_0.cmake ├── cmake │ ├── run_default.cmake │ ├── common_0.cmake │ └── pmreorder.cmake ├── external │ ├── libcxx │ │ ├── README.md │ │ ├── basic_string │ │ │ ├── string.modifiers │ │ │ │ ├── nothing_to_do.pass.cpp │ │ │ │ ├── string_assign │ │ │ │ │ └── initializer_list.pass.cpp │ │ │ │ ├── string_append │ │ │ │ │ └── initializer_list.pass.cpp │ │ │ │ ├── string_op_plus_equal │ │ │ │ │ └── initializer_list.pass.cpp │ │ │ │ ├── string_replace │ │ │ │ │ └── iter_iter_initializer_list.pass.cpp │ │ │ │ └── string_insert │ │ │ │ │ └── iter_initializer_list.pass.cpp │ │ │ ├── test_traits.h │ │ │ ├── traits_mismatch.fail.cpp │ │ │ ├── string.cons │ │ │ │ ├── dtor_noexcept.pass.cpp │ │ │ │ ├── string_view.fail.cpp │ │ │ │ └── initializer_list_assignment.pass.cpp │ │ │ ├── string.ends_with │ │ │ │ └── ends_with.char.pass.cpp │ │ │ ├── string.starts_with │ │ │ │ └── starts_with.char.pass.cpp │ │ │ ├── string.nonmembers │ │ │ │ └── string.io │ │ │ │ │ ├── get_line_rv.pass.cpp │ │ │ │ │ └── get_line_delim_rv.pass.cpp │ │ │ ├── string.require │ │ │ │ └── contiguous.pass.cpp │ │ │ └── string.iterators │ │ │ │ ├── cend.pass.cpp │ │ │ │ └── crend.pass.cpp │ │ ├── array │ │ │ ├── array.fill │ │ │ │ └── fill.fail.cpp │ │ │ ├── array.tuple │ │ │ │ └── get.fail.cpp │ │ │ ├── compare.fail_0.cpp │ │ │ ├── compare.fail_1.cpp │ │ │ ├── compare.fail_2.cpp │ │ │ ├── array.swap │ │ │ │ └── swap.fail.cpp │ │ │ └── size_and_alignment.pass.cpp │ │ ├── vector │ │ │ ├── vector.cons │ │ │ │ ├── dtor_noexcept.pass.cpp │ │ │ │ └── op_equal_initializer_list.pass.cpp │ │ │ ├── vector.modifiers │ │ │ │ ├── clear.pass.cpp │ │ │ │ └── pop_back.pass.cpp │ │ │ └── vector.capacity │ │ │ │ ├── empty.pass.cpp │ │ │ │ └── max_size.pass.cpp │ │ ├── map │ │ │ └── default_only.hpp │ │ └── string.view │ │ │ ├── string.view.access │ │ │ ├── data.pass.cpp │ │ │ ├── at.pass.cpp │ │ │ └── index.pass.cpp │ │ │ └── string.view.modifiers │ │ │ ├── swap.pass.cpp │ │ │ ├── remove_suffix.pass.cpp │ │ │ └── remove_prefix.pass.cpp │ └── cmake │ │ └── run_default.cmake ├── helgrind.supp ├── ptr │ ├── self_relative_ptr_atomic.cpp │ ├── atomic_pmreorder_1.cmake │ ├── atomic_pmreorder_2.cmake │ ├── atomic_pmreorder_0.cmake │ └── self_relative_ptr_arith.cpp ├── mpsc_queue │ ├── basic.cmake │ ├── recovery_order.cmake │ ├── mpsc_queue_consume_interrupt.cmake │ └── pmreorder │ │ ├── recovery_0.cmake │ │ ├── recovery_1.cmake │ │ ├── recovery_2.cmake │ │ ├── recovery_3.cmake │ │ └── recovery_after_consume.cmake ├── memcheck-stdcpp.supp ├── concurrent_map_mt_gdb │ ├── concurrent_map_mt_gdb_0.cmake │ ├── concurrent_map_mt_gdb_1.cmake │ ├── concurrent_map_mt_gdb_2.cmake │ ├── concurrent_map_mt_gdb_0.gdb │ ├── concurrent_map_mt_gdb_1.gdb │ └── concurrent_map_mt_gdb_2.gdb ├── test_backtrace.h ├── ex-pman │ ├── prepare_input.sh │ └── ex-pman_0.cmake ├── drd.supp ├── common │ ├── pthread_common.hpp │ ├── transaction_helpers.hpp │ ├── helpers_test.cpp │ ├── helper_algorithm.hpp │ └── unittest_windows.hpp ├── memcheck-libunwind.supp ├── memcheck-ndctl.supp ├── transaction │ └── transaction.hpp ├── wrap_pmemobj_defrag.h ├── valgrind_internal.cpp ├── ld.supp ├── map │ ├── map_ctor_exception_notx.cpp │ ├── map_ctor_exception_nopmem.cpp │ ├── map_txabort.cpp │ └── map_ctor_and_assignment.cpp ├── enumerable_thread_specific │ └── enumerable_thread_specific_layout.cpp ├── check_is_pmem │ └── check_is_pmem.cpp ├── vector │ ├── vector_ctor_exceptions_nopmem.cpp │ ├── vector_ctor_exceptions_notx.cpp │ └── vector_std_arg.cpp ├── detail_common │ └── detail_common.cpp └── aggregate_initialization │ └── aggregate_initialization.cpp ├── .gitattributes ├── .mailmap ├── .gitignore ├── codecov.yml ├── appveyor.yml ├── utils ├── check_license │ └── file-exceptions.sh ├── docker │ ├── images │ │ ├── install-valgrind.sh │ │ ├── download-scripts.sh │ │ ├── README.md │ │ ├── install-pmdk.sh │ │ ├── build-image.sh │ │ ├── 0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch │ │ ├── install-libndctl.sh │ │ └── push-image.sh │ └── 0001-travis-fix-travisci_build_coverity_scan.sh.patch └── cppstyle ├── doc ├── shared │ └── self_relative_pointer_implementation.txt └── CMakeLists.txt ├── cmake ├── libpmemobj++.pc.in ├── libpmemobj++-config.cmake.in ├── version.hpp.in ├── FindLIBPMEM.cmake ├── FindLIBPMEMOBJ.cmake └── cmake_uninstall.cmake.in ├── examples ├── README ├── pmpong │ ├── View.hpp │ ├── MenuView.hpp │ ├── GameOverView.hpp │ ├── GameView.hpp │ ├── Pool.hpp │ ├── README │ ├── Ball.hpp │ ├── Paddle.hpp │ ├── GameController.hpp │ ├── MenuView.cpp │ ├── Pool.cpp │ ├── MainGame.cpp │ ├── GameOverView.cpp │ ├── PongGameStatus.hpp │ └── CMakeLists.txt ├── mpsc_queue │ └── CMakeLists.txt ├── simplekv │ └── CMakeLists.txt ├── v │ ├── CMakeLists.txt │ └── v.cpp ├── inline_string │ └── CMakeLists.txt ├── mutex │ └── CMakeLists.txt ├── slab │ └── CMakeLists.txt ├── defrag │ └── CMakeLists.txt ├── queue │ └── CMakeLists.txt ├── string │ └── CMakeLists.txt ├── array │ ├── CMakeLists.txt │ └── README.md ├── map_cli │ └── CMakeLists.txt ├── persistent │ └── CMakeLists.txt ├── transaction │ └── CMakeLists.txt ├── segment_vector │ └── CMakeLists.txt ├── make_persistent │ └── CMakeLists.txt ├── pman │ ├── README │ ├── CMakeLists.txt │ └── map ├── pool │ └── CMakeLists.txt ├── simplekv_rebuild │ └── CMakeLists.txt ├── panaconda │ ├── CMakeLists.txt │ ├── conf.cfg │ └── README ├── concurrent_hash_map │ └── CMakeLists.txt └── libpmemobj_cpp_examples_common.hpp ├── benchmarks └── measure.hpp ├── .github ├── ISSUE_TEMPLATE │ ├── feature.md │ └── question.md └── workflows │ └── coverity.yml ├── include └── libpmemobj++ │ ├── detail │ ├── variadic.hpp │ ├── pool_data.hpp │ ├── conversions.hpp │ ├── array_traits.hpp │ ├── template_helpers.hpp │ ├── check_persistent_ptr_array.hpp │ └── make_atomic_impl.hpp │ ├── container │ └── string.hpp │ ├── experimental │ └── self_relative_ptr_base.hpp │ └── utils.hpp └── .clang-format /tests/concurrent_hash_map_rehash_break/.gitignore: -------------------------------------------------------------------------------- 1 | *.cmake 2 | -------------------------------------------------------------------------------- /tests/pool/pool_3_none.out.match: -------------------------------------------------------------------------------- 1 | pool.get_root: Invalid pool handle 2 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_break_insert/.gitignore: -------------------------------------------------------------------------------- 1 | *.cmake 2 | *.gdb 3 | -------------------------------------------------------------------------------- /tests/ctl/pool.set.in: -------------------------------------------------------------------------------- 1 | PMEMPOOLSET 2 | OPTION SINGLEHDR 3 | 16M @TESTDIR@ 4 | -------------------------------------------------------------------------------- /tests/ex-queue/ex-queue_0_none.out.match: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 1 5 | 2 6 | 3 7 | -------------------------------------------------------------------------------- /tests/pool/pool_win_3_none.out.match: -------------------------------------------------------------------------------- 1 | pool.get_root: Invalid pool handle 2 | -------------------------------------------------------------------------------- /tests/array/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "libpmemobj_open" : "NoReorderNoCheck" 3 | } 4 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_break_insert/.gitignore: -------------------------------------------------------------------------------- 1 | *.cmake 2 | *.gdb 3 | -------------------------------------------------------------------------------- /tests/ctl_win/pool.set.in: -------------------------------------------------------------------------------- 1 | PMEMPOOLSET 2 | OPTION SINGLEHDR 3 | 16M @TESTDIR@ 4 | -------------------------------------------------------------------------------- /tests/pool/pool_0_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size 20971520 mode 0600 2 | -------------------------------------------------------------------------------- /tests/pool/pool_win_0_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size 20971520 mode 0600 2 | -------------------------------------------------------------------------------- /tests/pool/pool_4_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::create: Failed creating pool: $(*) 2 | -------------------------------------------------------------------------------- /tests/pool/pool_5_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::open: Failed opening pool: $(*) 2 | -------------------------------------------------------------------------------- /tests/pool/pool_7_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::create: Failed creating pool: $(*) 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.jpg binary 3 | *.png binary 4 | *.gif binary 5 | *.ico binary 6 | -------------------------------------------------------------------------------- /tests/pool/pool_6_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::create: (pool_error) Failed creating pool: $(*) 2 | -------------------------------------------------------------------------------- /tests/pool/pool_11_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::open: Success 3 | -------------------------------------------------------------------------------- /tests/pool/pool_1_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::open: Success 3 | -------------------------------------------------------------------------------- /tests/pool/pool_win_1_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::open: Success 3 | -------------------------------------------------------------------------------- /tests/pool/pool_9_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::create: Failed creating pool: $(*) 3 | -------------------------------------------------------------------------------- /tests/pool/pool_8_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::open: (pool_error) Failed opening pool: $(*) 3 | -------------------------------------------------------------------------------- /tests/compatibility/version/README.txt: -------------------------------------------------------------------------------- 1 | Those tests are implemented mainly to check whether compatibility test 2 | framework is working correctly. 3 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Igor Chorążewicz 2 | Michał Biesek 3 | Krzysztof Kajrewicz 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.clang-format 3 | !.gitattributes 4 | !.gitignore 5 | !.github/ 6 | !.mailmap 7 | !.version 8 | build/ 9 | *~ 10 | *.swp 11 | ~* 12 | -------------------------------------------------------------------------------- /tests/pool/pool_2_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::create: Success 2 | $(nW)testfile: pool.close: Success 3 | $(nW)testfile: pool.close: Pool already closed 4 | -------------------------------------------------------------------------------- /tests/pool/pool_win_2_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: pool::create: Success 2 | $(nW)testfile: pool.close: Success 3 | $(nW)testfile: pool.close: Pool already closed 4 | -------------------------------------------------------------------------------- /tests/true.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | # true.cmake - cmake script which always succeeds 5 | 6 | return() 7 | -------------------------------------------------------------------------------- /tests/pool/pool_10_none.out.match: -------------------------------------------------------------------------------- 1 | $(nW)testfile: file size $(N) mode $(N) 2 | $(nW)testfile: pool::open: Failed opening pool: wrong layout ("$(*)"), pool created with layout "$(*)" 3 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_multiple_buckets/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "no_reorder" : "NoReorderNoCheck" 5 | } 6 | -------------------------------------------------------------------------------- /tests/concurrent_map/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | threshold: 0.2 6 | 7 | ignore: 8 | - benchmarks/ 9 | - doc/ 10 | - examples/ 11 | - tests/ 12 | - utils/ 13 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_erase/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_erase/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_break_insert/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_break_insert/pmreorder.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pmemobj_open" : "NoReorderNoCheck", 3 | "pmemobj_close" : "NoReorderNoCheck", 4 | "pmemobj_alloc" : "NoReorderNoCheck", 5 | "pmemobj_xalloc" : "NoReorderNoCheck" 6 | } 7 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_rehash_break/break_in_rehash_0.gdb: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | 7 | b set_rehashed 8 | run 9 | 10 | info break 1 11 | 12 | quit 13 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_rehash_break/break_in_rehash_1.gdb: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | 7 | b pmemobj_tx_end 8 | run 9 | 10 | info break 1 11 | 12 | quit 13 | -------------------------------------------------------------------------------- /tests/cmake/run_default.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile) 9 | 10 | finish() 11 | -------------------------------------------------------------------------------- /tests/external/libcxx/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tests copied from https://github.com/llvm-mirror/libcxx 2 | and modified to test pmem::obj containers. 3 | 4 | For information on how these tests are licensed, see LICENSE.txt file in this 5 | directory. 6 | -------------------------------------------------------------------------------- /tests/external/cmake/run_default.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile) 9 | 10 | finish() 11 | -------------------------------------------------------------------------------- /tests/pool/pool_cleanup_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile1 ${DIR}/testfile2) 9 | 10 | finish() 11 | -------------------------------------------------------------------------------- /tests/helgrind.supp: -------------------------------------------------------------------------------- 1 | { 2 | Pthread mutex lock false positive 3 | Helgrind:Race 4 | ... 5 | fun:pthread_mutex_*lock* 6 | ... 7 | } 8 | { 9 | Pthread rwlock lock false positive 10 | Helgrind:Race 11 | ... 12 | fun:pthread_rwlock_*lock* 13 | ... 14 | } 15 | -------------------------------------------------------------------------------- /tests/cmake/common_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile) 9 | 10 | check_file_exists(${DIR}/testfile) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/ptr/self_relative_ptr_atomic.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "self_relative_ptr_atomic.hpp" 5 | 6 | int 7 | main(int argc, char *argv[]) 8 | { 9 | return run_test([&] { test(argc, argv); }); 10 | } 11 | -------------------------------------------------------------------------------- /tests/pool/pool_7.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test for creating too small pool 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 1 0600) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/mpsc_queue/basic.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 1) 9 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 0) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/pool/pool_3.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test for get_root on invalid pool handle 9 | execute(${TEST_EXECUTABLE} i ${DIR}/testfile "test" 20 0600) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/mpsc_queue/recovery_order.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 1) 9 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 0) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/pool/pool_win_3.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test for get_root on invalid pool handle 9 | execute(${TEST_EXECUTABLE} i ${DIR}/testfile "test" 20 0600) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.4.{build} 2 | os: Visual Studio 2017 3 | platform: x64 4 | 5 | environment: 6 | VCPKG_DEFAULT_TRIPLET: x64-windows 7 | GENERATOR: "Visual Studio 14 2015 Win64" 8 | 9 | configuration: 10 | - Debug 11 | - Release 12 | 13 | build_script: 14 | - exit 0 15 | 16 | test_script: 17 | - exit 0 18 | -------------------------------------------------------------------------------- /tests/mpsc_queue/mpsc_queue_consume_interrupt.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 1) 9 | execute(${TEST_EXECUTABLE} ${DIR}/testfile 0) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/pool/pool_5.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # failed to open non-existent dir (and file) 9 | execute(${TEST_EXECUTABLE} o ${DIR}/non-existent-dir/testfile "test") 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/pool/pool_6.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test for creating pool, without enough memory available 9 | execute(${TEST_EXECUTABLE} n ${DIR}/testfile "test" 20 0600) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /utils/check_license/file-exceptions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2016-2021, Intel Corporation 4 | # 5 | 6 | # file-exceptions.sh - filter out files not checked for copyright and license 7 | 8 | grep -v -E -e 'tests/external/libcxx/' 9 | grep -v -E -e 'include/libpmemobj++/detail/ebr.hpp/' 10 | -------------------------------------------------------------------------------- /doc/shared/self_relative_pointer_implementation.txt: -------------------------------------------------------------------------------- 1 | The current version uses an approach where we store offset=real_offset-1 2 | and zero offset (or real_offset equal one) is a null pointer. 3 | This is needed to support zero initialization. 4 | * real_offset = pointer - this; 5 | * pointer = real_offset + this; 6 | * or pointer = offset + this + 1; 7 | -------------------------------------------------------------------------------- /tests/pool/pool_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # non-existing file, poolsize > 0 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | 11 | check_file_exists(${DIR}/testfile) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/pool/pool_win_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test create proper pool 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | 11 | check_file_exists(${DIR}/testfile) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/pool/pool_2.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test properly create and double close 9 | execute(${TEST_EXECUTABLE} d ${DIR}/testfile "test" 20 0600) 10 | 11 | check_file_exists(${DIR}/testfile) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/pool/pool_win_2.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test properly create and double close 9 | execute(${TEST_EXECUTABLE} d ${DIR}/testfile "test" 20 0600) 10 | 11 | check_file_exists(${DIR}/testfile) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /cmake/libpmemobj++.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 3 | 4 | Name: libpmemobj++ 5 | Description: libpmemobj++ - c++ bindings for libpmemobj library 6 | Version: @SRCVERSION@ 7 | URL: https://github.com/pmem/libpmemobj-cpp 8 | Requires: libpmemobj >= @LIBPMEMOBJ_REQUIRED_VERSION@ 9 | Cflags: -I${includedir} 10 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.9.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 9, "Wrong minor version"); 11 | } 12 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.7.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020-2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 7, "Wrong minor version"); 11 | } 12 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.8.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020-2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 8, "Wrong minor version"); 11 | } 12 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_break_insert/break_before_set_next.gdb.in: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | 7 | # break before the set_next #@PERSIST@ 8 | b set_next 9 | ignore 1 @IGNORE@ 10 | run 11 | 12 | # it should print out: "breakpoint already hit @PERSIST@ times" 13 | info break 1 14 | 15 | quit 16 | -------------------------------------------------------------------------------- /tests/memcheck-stdcpp.supp: -------------------------------------------------------------------------------- 1 | { 2 | https://bugs.kde.org/show_bug.cgi?id=345307, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65434, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64535 3 | Memcheck:Leak 4 | match-leak-kinds: reachable 5 | fun:malloc 6 | obj:*/libstdc++.so.* 7 | fun:call_init.part.0 8 | ... 9 | fun:_dl_init 10 | obj:*/ld-*.so 11 | } 12 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | crash_with_gdb(${SRC_DIR}/concurrent_map_mt_gdb_0.gdb ${TEST_EXECUTABLE} i 0 ${DIR}/testfile) 9 | execute(${TEST_EXECUTABLE} c 0 ${DIR}/testfile) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | crash_with_gdb(${SRC_DIR}/concurrent_map_mt_gdb_1.gdb ${TEST_EXECUTABLE} i 1 ${DIR}/testfile) 9 | execute(${TEST_EXECUTABLE} c 1 ${DIR}/testfile) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_2.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | crash_with_gdb(${SRC_DIR}/concurrent_map_mt_gdb_2.gdb ${TEST_EXECUTABLE} i 2 ${DIR}/testfile) 9 | execute(${TEST_EXECUTABLE} c 2 ${DIR}/testfile) 10 | 11 | finish() 12 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | This directory contains examples for libpmemobj-cpp, the library providing 2 | a transactional object store for pmem. Some of these examples are explained 3 | in more detail here: https://pmem.io/libpmemobj-cpp/ 4 | 5 | If you're looking for documentation to get you started using PMDK, 6 | start here: https://pmem.io/pmdk and follow the links to examples and 7 | man pages. 8 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.10.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 10, 11 | "Wrong minor version"); 12 | } 13 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.11.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 11, 11 | "Wrong minor version"); 12 | } 13 | -------------------------------------------------------------------------------- /tests/compatibility/version/version_1.12.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | #include 5 | 6 | int 7 | main() 8 | { 9 | static_assert(LIBPMEMOBJ_CPP_VERSION_MAJOR == 1, "Wrong major version"); 10 | static_assert(LIBPMEMOBJ_CPP_VERSION_MINOR == 12, 11 | "Wrong minor version"); 12 | } 13 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_break_insert/break_before_persist.gdb.in: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | 7 | # break before the persist #@PERSIST@ 8 | b pmemobj_persist 9 | ignore 1 @IGNORE@ 10 | run 11 | 12 | # it should print out: "breakpoint already hit @PERSIST@ times" 13 | info break 1 14 | 15 | quit 16 | -------------------------------------------------------------------------------- /tests/array/array_slice_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | if(${TRACER} STREQUAL pmemcheck) 9 | set(IS_PMEMCHECK "1") 10 | else() 11 | set(IS_PMEMCHECK "0") 12 | endif() 13 | 14 | execute(${TEST_EXECUTABLE} ${DIR}/testfile "${IS_PMEMCHECK}") 15 | 16 | finish() 17 | -------------------------------------------------------------------------------- /tests/ctl/ctl_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | set(TESTDIR ${DIR}/testdir) 9 | configure_file(${SRC_DIR}/pool.set.in ${DIR}/pool.set @ONLY) 10 | 11 | file(MAKE_DIRECTORY ${DIR}/testdir) 12 | 13 | execute(${TEST_EXECUTABLE} ${DIR}/pool.set) 14 | 15 | finish() 16 | -------------------------------------------------------------------------------- /tests/pool/pool_4.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # failed to create, non-existent dir 9 | execute(${TEST_EXECUTABLE} c ${DIR}/non-existent-dir/testfile "test" 20 0600) 10 | 11 | check_file_doesnt_exist(${DIR}/non-existent-dir/testfile) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/compatibility/run.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020-2021, Intel Corporation 3 | 4 | # Simple script to 'create' with one executable and 'open' with another one 5 | 6 | include(${SRC_DIR}/../../helpers.cmake) 7 | 8 | setup() 9 | 10 | execute(${TEST_EXECUTABLE1} ${DIR}/testfile c) 11 | execute(${TEST_EXECUTABLE2} ${DIR}/testfile o) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/pool/pool_9.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # double create 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | check_file_exists(${DIR}/testfile) 11 | 12 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 13 | 14 | finish() 15 | -------------------------------------------------------------------------------- /tests/pool/pool_11.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # properly create using default size and mode 9 | execute(${TEST_EXECUTABLE} t ${DIR}/testfile "test") 10 | check_file_exists(${DIR}/testfile) 11 | 12 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile "test") 13 | 14 | finish() 15 | -------------------------------------------------------------------------------- /tests/pool/pool_win_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test proper create & open 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile "test" 20 0600) 11 | 12 | check_file_exists(${DIR}/testfile) 13 | 14 | finish() 15 | -------------------------------------------------------------------------------- /tests/pool/pool_8.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test for opening pool without access 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | execute_process(COMMAND chmod 000 ${DIR}/testfile) 11 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile "test") 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/test_backtrace.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2015-2017, Intel Corporation */ 3 | 4 | #ifndef TEST_BACKTRACE_H 5 | #define TEST_BACKTRACE_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void test_dump_backtrace(void); 12 | void test_sighandler(int sig); 13 | void test_register_sighandlers(void); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /tests/ex-pman/prepare_input.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2018-2021, Intel Corporation 4 | # 5 | set -e 6 | 7 | # prepares input for ex-pman test 8 | # usage: ./prepare_input.sh input_file 9 | 10 | dd if=/dev/zero bs=64 count=1 2>>/dev/null >> ${1} 11 | echo -n slkiiijjbjjii >> ${1} 12 | dd if=/dev/zero bs=128 count=1 2>>/dev/null >> ${1} 13 | echo -n q >> ${1} 14 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/check_is_pmem.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | set(DEFRAG 0) 9 | 10 | if ((${TRACER} STREQUAL "drd") OR (${TRACER} STREQUAL "helgrind")) 11 | check_is_pmem(${DIR}/testfile) 12 | endif() 13 | 14 | execute(${TEST_EXECUTABLE} ${DIR}/testfile ${DEFRAG}) 15 | 16 | finish() 17 | -------------------------------------------------------------------------------- /tests/pool/pool_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # test existing file, file size >= min required size 9 | # layout matches the value from pool header 10 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 11 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile "test") 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/cmake/pmreorder.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/check_is_pmem_defrag.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | set(DEFRAG 1) 9 | 10 | if ((${TRACER} STREQUAL "drd") OR (${TRACER} STREQUAL "helgrind")) 11 | check_is_pmem(${DIR}/testfile) 12 | endif() 13 | 14 | execute(${TEST_EXECUTABLE} ${DIR}/testfile ${DEFRAG}) 15 | 16 | finish() 17 | -------------------------------------------------------------------------------- /tests/array/array_slice_pmreorder_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x ${DIR}/testfile) 10 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/array/array_slice_pmreorder_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_execute(false ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/pool/pool_10.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | # properly create and try to open with different layout 9 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile "test" 20 0600) 10 | check_file_exists(${DIR}/testfile) 11 | 12 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile "test_layout" 20 0600) 13 | 14 | finish() 15 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_rehash_break/concurrent_hash_map_rehash_break.cmake.in: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | crash_with_gdb(${SRC_DIR}/break_in_rehash_@TESTCASE@.gdb ${TEST_EXECUTABLE} b ${DIR}/testfile) 10 | execute(${TEST_EXECUTABLE} o ${DIR}/testfile) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/ptr/atomic_pmreorder_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_execute(true NoReorderNoCheck PMREORDER_MARKER=ReorderAccumulative ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/concurrent_hash_map_tbb_insert_erase.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | /* 5 | * concurrent_hash_map_tbb_insert_erase.cpp -- pmem::obj::concurrent_hash_map 6 | * test with Intel TBB RW mutex 7 | * 8 | */ 9 | 10 | #define LIBPMEMOBJ_CPP_USE_TBB_RW_MUTEX 1 11 | #include "concurrent_hash_map_insert_erase.cpp" 12 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/concurrent_hash_map_tbb_insert_lookup.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | /* 5 | * concurrent_hash_map_tbb_insert_lookup.cpp -- pmem::obj::concurrent_hash_map 6 | * test with Intel TBB RW mutex 7 | * 8 | */ 9 | 10 | #define LIBPMEMOBJ_CPP_USE_TBB_RW_MUTEX 1 11 | #include "concurrent_hash_map_insert_lookup.cpp" 12 | -------------------------------------------------------------------------------- /tests/ptr/atomic_pmreorder_2.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_execute(true NoReorderNoCheck PMREORDER_MARKER=ReorderReverseAccumulative ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/mpsc_queue/pmreorder/recovery_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c 0 ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x 0 ${DIR}/testfile 1) 10 | pmreorder_execute(true NoReorderNoCheck "PMREORDER_MARKER=ReorderAccumulative" ${TEST_EXECUTABLE} o 0) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/mpsc_queue/pmreorder/recovery_1.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c 0 ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x 0 ${DIR}/testfile 0) 10 | pmreorder_execute(true NoReorderNoCheck "PMREORDER_MARKER=ReorderAccumulative" ${TEST_EXECUTABLE} o 0) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/mpsc_queue/pmreorder/recovery_2.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c 1 ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x 1 ${DIR}/testfile 0) 10 | pmreorder_execute(true NoReorderNoCheck "PMREORDER_MARKER=ReorderAccumulative" ${TEST_EXECUTABLE} o 1) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/mpsc_queue/pmreorder/recovery_3.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c 1 ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x 1 ${DIR}/testfile 1) 10 | pmreorder_execute(true NoReorderNoCheck "PMREORDER_MARKER=ReorderAccumulative" ${TEST_EXECUTABLE} o 1) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/mpsc_queue/pmreorder/recovery_after_consume.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} x ${DIR}/testfile) 10 | pmreorder_execute(true NoReorderNoCheck "PMREORDER_MARKER=ReorderAccumulative" ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /benchmarks/measure.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include 5 | 6 | template 7 | static typename TimeUnit::rep 8 | measure(F &&func) 9 | { 10 | auto start = std::chrono::steady_clock::now(); 11 | 12 | func(); 13 | 14 | auto duration = std::chrono::duration_cast( 15 | std::chrono::steady_clock::now() - start); 16 | return duration.count(); 17 | } 18 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_erase/concurrent_map_pmreorder_erase_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} e ${DIR}/testfile) 10 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature 3 | about: Request a feature 4 | labels: "Type: Feature" 5 | --- 6 | # FEAT: 7 | 8 | ## Rationale 9 | 10 | 11 | 12 | ## Description 13 | 14 | 15 | 16 | ## API Changes 17 | 18 | 19 | 20 | ## Implementation details 21 | 22 | 23 | 24 | ## Meta 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_erase/concurrent_hash_map_pmreorder_erase_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} e ${DIR}/testfile) 10 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 11 | 12 | finish() 13 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/nothing_to_do.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | int main() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Do you have question regarding libpmemobj-cpp? Don't hesitate to ask. 4 | labels: "Type: Question" 5 | --- 6 | # QUESTION: 7 | 8 | ## Details 9 | 10 | 11 | 12 | 16 | -------------------------------------------------------------------------------- /tests/ptr/atomic_pmreorder_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} m ${DIR}/testfile) 10 | # negative test, should fail, uses mock of atomic_self_relative_ptr 11 | pmreorder_execute(false NoReorderNoCheck PMREORDER_MARKER=ReorderReverseAccumulative ${TEST_EXECUTABLE} n) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /cmake/libpmemobj++-config.cmake.in: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018, Intel Corporation 3 | 4 | @PACKAGE_INIT@ 5 | 6 | find_path(LIBPMEMOBJ_INCLUDE_DIR libpmemobj.h) 7 | find_library(LIBPMEMOBJ_LIBRARY NAMES pmemobj libpmemobj) 8 | find_library(LIBPMEM_LIBRARY NAMES pmem libpmem) 9 | 10 | set_and_check(LIBPMEMOBJ++_INCLUDE "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") 11 | 12 | set(LIBPMEMOBJ++_LIBRARIES ${LIBPMEMOBJ_LIBRARY} ${LIBPMEM_LIBRARY}) 13 | set(LIBPMEMOBJ++_INCLUDE_DIRS ${LIBPMEMOBJ++_INCLUDE} ${LIBPMEMOBJ_INCLUDE_DIR}) 14 | -------------------------------------------------------------------------------- /tests/ex-pman/ex-pman_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute_process(COMMAND tty OUTPUT_FILE /dev/null RESULT_VARIABLE result) 9 | 10 | if (result EQUAL 0) 11 | execute(${SRC_DIR}/prepare_input.sh ${DIR}/input) 12 | execute(${TEST_EXECUTABLE} ${DIR}/testfile ${SRC_DIR}/../../examples/pman/map INPUT_FILE ${DIR}/input) 13 | else() 14 | message(WARNING "Skip: stdout is not a tty terminal") 15 | endif() 16 | 17 | finish() 18 | -------------------------------------------------------------------------------- /tests/drd.supp: -------------------------------------------------------------------------------- 1 | { 2 | Conditional variable destruction false-positive 3 | drd:CondErr 4 | ... 5 | fun:pthread_cond_destroy@* 6 | ... 7 | } 8 | { 9 | Pthread mutex lock false positive 10 | Drd:Race 11 | ... 12 | fun:pthread_mutex_*lock* 13 | ... 14 | } 15 | { 16 | Pthread rwlock lock false positive 17 | Drd:Race 18 | ... 19 | fun:pthread_rwlock_*lock* 20 | ... 21 | } 22 | { 23 | Dl lookup 24 | drd:ConflictingAccess 25 | fun:_dl_lookup_symbol_x 26 | fun:_dl_fixup 27 | fun:_dl_runtime_resolve_xsave 28 | } 29 | -------------------------------------------------------------------------------- /tests/ex-queue/ex-queue_0.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2021, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} ${DIR}/testfile push 1) 9 | execute(${TEST_EXECUTABLE} ${DIR}/testfile push 2) 10 | execute(${TEST_EXECUTABLE} ${DIR}/testfile push 3) 11 | execute(${TEST_EXECUTABLE} ${DIR}/testfile show) 12 | execute(${TEST_EXECUTABLE} ${DIR}/testfile pop) 13 | execute(${TEST_EXECUTABLE} ${DIR}/testfile show) 14 | 15 | check_file_exists(${DIR}/testfile) 16 | 17 | finish() 18 | -------------------------------------------------------------------------------- /examples/pmpong/View.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_VIEW_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_VIEW_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include "PongGameStatus.hpp" 9 | #include 10 | 11 | class View { 12 | public: 13 | virtual ~View(){}; 14 | virtual void prepareView(PongGameStatus &gameStatus) = 0; 15 | virtual void displayView(sf::RenderWindow *gameWindow) = 0; 16 | }; 17 | 18 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_VIEW_HPP */ 19 | -------------------------------------------------------------------------------- /tests/concurrent_map_pmreorder_break_insert/concurrent_map_pmreorder_break_insert.cmake.in: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | crash_with_gdb(${SRC_DIR}/break_before_set_next_@PERSIST@.gdb ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 11 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map_pmreorder_break_insert/concurrent_hash_map_pmreorder_break_insert.cmake.in: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | include(${SRC_DIR}/../helpers.cmake) 5 | 6 | setup() 7 | 8 | execute(${TEST_EXECUTABLE} c ${DIR}/testfile) 9 | crash_with_gdb(${SRC_DIR}/break_before_persist_@PERSIST@.gdb ${TEST_EXECUTABLE} i ${DIR}/testfile) 10 | pmreorder_create_store_log(${DIR}/testfile ${TEST_EXECUTABLE} i ${DIR}/testfile) 11 | pmreorder_execute(true ReorderAccumulative ${SRC_DIR}/pmreorder.conf ${TEST_EXECUTABLE} o) 12 | 13 | finish() 14 | -------------------------------------------------------------------------------- /cmake/version.hpp.in: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Auto-generated file containing source version 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_VERSION_HPP 10 | #define LIBPMEMOBJ_CPP_VERSION_HPP 11 | 12 | #define LIBPMEMOBJ_CPP_VERSION_MAJOR @VERSION_MAJOR@ 13 | #define LIBPMEMOBJ_CPP_VERSION_MINOR @VERSION_MINOR@ 14 | #define LIBPMEMOBJ_CPP_VERSION_PATCH @VERSION_PATCH@ 15 | 16 | #define LIBPMEMOBJ_CPP_VERSION "@VERSION@" 17 | #define LIBPMEMOBJ_CPP_SRCVERSION "@SRCVERSION@" 18 | 19 | #endif /* LIBPMEMOBJ_CPP_VERSION_HPP */ 20 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/test_traits.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef TEST_TRAITS_H 11 | #define TEST_TRAITS_H 12 | 13 | template 14 | struct test_traits 15 | { 16 | typedef charT char_type; 17 | }; 18 | 19 | #endif // TEST_TRAITS_H 20 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/traits_mismatch.fail.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | // 11 | // The strings's value type must be the same as the traits's char_type 12 | 13 | #include 14 | 15 | int main() 16 | { 17 | std::basic_string> s; 18 | } 19 | -------------------------------------------------------------------------------- /cmake/FindLIBPMEM.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | find_path(LIBPMEM_INCLUDE_DIR libpmem.h) 5 | find_library(LIBPMEM_LIBRARY NAMES pmem libpmem) 6 | 7 | set(LIBPMEM_LIBRARIES ${LIBPMEM_LIBRARY}) 8 | set(LIBPMEM_INCLUDE_DIRS ${LIBPMEM_INCLUDE_DIR}) 9 | 10 | set(MSG_NOT_FOUND "libpmem NOT found (set CMAKE_PREFIX_PATH to point the location)") 11 | if(NOT (LIBPMEM_INCLUDE_DIR AND LIBPMEM_LIBRARY)) 12 | if(LIBPMEM_FIND_REQUIRED) 13 | message(FATAL_ERROR ${MSG_NOT_FOUND}) 14 | else() 15 | message(WARNING ${MSG_NOT_FOUND}) 16 | endif() 17 | endif() 18 | 19 | mark_as_advanced(LIBPMEM_LIBRARY LIBPMEM_INCLUDE_DIR) 20 | -------------------------------------------------------------------------------- /tests/common/pthread_common.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018, Intel Corporation */ 3 | #ifndef PTHREAD_COMMON_HPP 4 | #define PTHREAD_COMMON_HPP 5 | 6 | #include "unittest.hpp" 7 | #include 8 | 9 | void 10 | ut_pthread_create(pthread_t *thread, const pthread_attr_t *attr, 11 | void *(*start_routine)(void *), void *arg) 12 | { 13 | if (pthread_create(thread, attr, start_routine, arg) != 0) 14 | UT_FATAL("pthread_create failed"); 15 | } 16 | 17 | void 18 | ut_pthread_join(pthread_t *thread, void **value) 19 | { 20 | if (pthread_join(*thread, value) != 0) 21 | UT_FATAL("pthread_join failed"); 22 | } 23 | 24 | #endif /* PTHREAD_COMMON_HPP */ 25 | -------------------------------------------------------------------------------- /examples/mpsc_queue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2021, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.3) 5 | project(mpsc_queue CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 13 | else() 14 | find_package(LIBPMEMOBJ++ REQUIRED) 15 | endif() 16 | 17 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 18 | 19 | add_executable(mpsc_queue.cpp) 20 | target_include_directories(mpsc_queue PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 21 | target_link_libraries(mpsc_queue ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 22 | -------------------------------------------------------------------------------- /examples/simplekv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.3) 5 | project(simplekv CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 13 | else() 14 | find_package(LIBPMEMOBJ++ REQUIRED) 15 | endif() 16 | 17 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 18 | 19 | add_executable(simplekv simplekv.cpp) 20 | target_include_directories(simplekv PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 21 | target_link_libraries(simplekv ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 22 | -------------------------------------------------------------------------------- /tests/memcheck-libunwind.supp: -------------------------------------------------------------------------------- 1 | { 2 | generic libunwind suppression 3 | Memcheck:Param 4 | msync(start) 5 | ... 6 | obj:*libunwind* 7 | ... 8 | } 9 | { 10 | generic libunwind suppression 11 | Memcheck:Param 12 | rt_sigprocmask(set) 13 | ... 14 | obj:*libunwind* 15 | ... 16 | } 17 | { 18 | generic libunwind suppression 19 | Memcheck:Addr8 20 | ... 21 | obj:*libunwind* 22 | ... 23 | } 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 | } 38 | -------------------------------------------------------------------------------- /cmake/FindLIBPMEMOBJ.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2019, Intel Corporation 3 | 4 | find_path(LIBPMEMOBJ_INCLUDE_DIR libpmemobj.h) 5 | find_library(LIBPMEMOBJ_LIBRARY NAMES pmemobj libpmemobj) 6 | 7 | set(LIBPMEMOBJ_LIBRARIES ${LIBPMEMOBJ_LIBRARY}) 8 | set(LIBPMEMOBJ_INCLUDE_DIRS ${LIBPMEMOBJ_INCLUDE_DIR}) 9 | 10 | set(MSG_NOT_FOUND "libpmemobj NOT found (set CMAKE_PREFIX_PATH to point the location)") 11 | if(NOT (LIBPMEMOBJ_INCLUDE_DIR AND LIBPMEMOBJ_LIBRARY)) 12 | if(LIBPMEMOBJ_FIND_REQUIRED) 13 | message(FATAL_ERROR ${MSG_NOT_FOUND}) 14 | else() 15 | message(WARNING ${MSG_NOT_FOUND}) 16 | endif() 17 | endif() 18 | 19 | mark_as_advanced(LIBPMEMOBJ_LIBRARY LIBPMEMOBJ_INCLUDE_DIR) 20 | -------------------------------------------------------------------------------- /examples/v/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(v CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(v v.cpp) 25 | target_include_directories(v PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(v ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/inline_string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.3) 5 | project(inline_string CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 13 | else() 14 | find_package(LIBPMEMOBJ++ REQUIRED) 15 | endif() 16 | 17 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 18 | 19 | add_executable(inline_string inline_string.cpp) 20 | target_include_directories(inline_string PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 21 | target_link_libraries(inline_string ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 22 | -------------------------------------------------------------------------------- /tests/array/array_is_aggregate.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | #include "unittest.hpp" 5 | 6 | #include 7 | 8 | /* Test which checks if array behave in the same way as any structure with 9 | * defaulted constructor - according to used c++ standard */ 10 | struct struct_with_defaulted_constructor { 11 | struct_with_defaulted_constructor() = default; 12 | }; 13 | 14 | int 15 | main() 16 | { 17 | bool array_is_aggregate = 18 | std::is_aggregate>::value; 19 | bool cpp_standard_support = 20 | std::is_aggregate::value; 21 | 22 | UT_ASSERTeq(array_is_aggregate, cpp_standard_support); 23 | } 24 | -------------------------------------------------------------------------------- /tests/memcheck-ndctl.supp: -------------------------------------------------------------------------------- 1 | { 2 | ndctl suppression 3 | Memcheck:Leak 4 | match-leak-kinds: definite 5 | fun:realloc 6 | ... 7 | fun:ndctl_pfn_get_first 8 | fun:ndctl_namespace_get_pfn 9 | ... 10 | } 11 | { 12 | ndctl suppression 13 | Memcheck:Leak 14 | match-leak-kinds: definite 15 | fun:realloc 16 | ... 17 | fun:ndctl_dax_get_first 18 | ... 19 | } 20 | { 21 | memory leak in ndctl 63 22 | Memcheck:Leak 23 | match-leak-kinds: reachable 24 | fun:malloc 25 | ... 26 | fun:ndctl_namespace_get_first_badblock 27 | ... 28 | } 29 | { 30 | cond jump in libkmod 31 | Memcheck:Cond 32 | ... 33 | fun:kmod_module_new_from_lookup 34 | ... 35 | fun:ndctl_region_get_first 36 | ... 37 | } 38 | -------------------------------------------------------------------------------- /utils/docker/images/install-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2016-2022, Intel Corporation 4 | 5 | # 6 | # install-valgrind.sh - installs valgrind with pmemcheck 7 | # 8 | 9 | set -e 10 | 11 | if [ "${SKIP_VALGRIND_BUILD}" ]; then 12 | echo "Variable 'SKIP_VALGRIND_BUILD' is set; skipping building valgrind (pmem's fork)" 13 | exit 14 | fi 15 | 16 | git clone https://github.com/pmem/valgrind.git 17 | cd valgrind 18 | # pmem-3.19: Merge pull request #88 from lukaszstolarczuk/pmem-3.19; 29.04.2022 19 | git checkout 541e1c3d22b34769ad29fa75ab29cce2a65bfa91 20 | 21 | ./autogen.sh 22 | ./configure --prefix=/usr 23 | make -j$(nproc) 24 | sudo make -j$(nproc) install 25 | cd .. 26 | rm -rf valgrind 27 | -------------------------------------------------------------------------------- /examples/mutex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(mutex CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(mutex mutex.cpp) 25 | target_include_directories(mutex PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(mutex ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/slab/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(slab CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(slab slab.cpp) 25 | 26 | target_include_directories(slab PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 27 | target_link_libraries(slab ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 28 | -------------------------------------------------------------------------------- /examples/defrag/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(defrag CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(defrag defrag.cpp) 25 | target_include_directories(defrag PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(defrag ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/queue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(queue CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(queue queue.cpp) 25 | target_include_directories(queue PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(queue ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(string CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(string string.cpp) 25 | target_include_directories(string PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(string ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/array/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(array CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(array array.cpp) 25 | target_include_directories(array PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(array ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | 28 | -------------------------------------------------------------------------------- /examples/map_cli/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(map_cli CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(map_cli map_cli.cpp) 25 | target_include_directories(map_cli PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(map_cli ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/pmpong/MenuView.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_MENUVIEW_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_MENUVIEW_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include "PongGameStatus.hpp" 9 | #include "View.hpp" 10 | #include 11 | 12 | enum menu_items { NEW_GAME, RESUME, SIMULATION, EXIT }; 13 | 14 | class MenuView : public View { 15 | public: 16 | MenuView(sf::Font &font); 17 | ~MenuView(); 18 | 19 | virtual void prepareView(PongGameStatus &gameStatus); 20 | virtual void displayView(sf::RenderWindow *gameWindow); 21 | 22 | private: 23 | sf::Text menuItems[MENU_ITEMS]; 24 | }; 25 | 26 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_MENUVIEW_HPP */ 27 | -------------------------------------------------------------------------------- /examples/persistent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(persistent CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(persistent persistent.cpp) 25 | target_include_directories(persistent PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(persistent ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/pmpong/GameOverView.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEOVERVIEW_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEOVERVIEW_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include "PongGameStatus.hpp" 9 | #include "View.hpp" 10 | #include 11 | 12 | class GameOverView : public View { 13 | public: 14 | GameOverView(sf::Font &font); 15 | ~GameOverView(); 16 | 17 | virtual void prepareView(PongGameStatus &gameStatus); 18 | virtual void displayView(sf::RenderWindow *gameWindow); 19 | 20 | private: 21 | sf::Text gameOver; 22 | sf::Text playerWinner; 23 | sf::Text entContinue; 24 | }; 25 | 26 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEOVERVIEW_HPP */ 27 | -------------------------------------------------------------------------------- /examples/transaction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(transaction CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(transaction transaction.cpp) 25 | target_include_directories(transaction PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(transaction ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.cons/dtor_noexcept.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | int 20 | main() 21 | { 22 | { 23 | typedef pmem::obj::string C; 24 | static_assert(std::is_nothrow_destructible::value, ""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/common/transaction_helpers.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #ifndef TRANSACTION_HELPERS_HPP 5 | #define TRANSACTION_HELPERS_HPP 6 | 7 | #include "unittest.hpp" 8 | 9 | #include 10 | #include 11 | 12 | void 13 | assert_tx_abort(pmem::obj::pool &pop, std::function f) 14 | { 15 | bool exception_thrown = false; 16 | try { 17 | pmem::obj::transaction::run(pop, [&] { 18 | f(); 19 | pmem::obj::transaction::abort(EINVAL); 20 | }); 21 | } catch (pmem::manual_tx_abort &) { 22 | exception_thrown = true; 23 | } catch (std::exception &e) { 24 | UT_FATALexc(e); 25 | } 26 | UT_ASSERT(exception_thrown); 27 | } 28 | 29 | #endif /* TRANSACTION_HELPERS_HPP */ 30 | -------------------------------------------------------------------------------- /examples/segment_vector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(segment_vector CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(segment_vector segment_vector.cpp) 25 | target_include_directories(segment_vector PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(segment_vector ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /examples/make_persistent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(make_persistent CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(make_persistent make_persistent.cpp) 25 | target_include_directories(make_persistent PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(make_persistent ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | -------------------------------------------------------------------------------- /tests/transaction/transaction.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_TESTS_TRANSACTION 5 | #define LIBPMEMOBJ_CPP_TESTS_TRANSACTION 6 | 7 | #include 8 | 9 | namespace 10 | { 11 | int counter = 0; 12 | } 13 | 14 | /* 15 | * XXX The Microsoft compiler does not follow the ISO SD-6: SG10 Feature 16 | * Test Recommendations. "_MSC_VER" is a workaround. 17 | */ 18 | #if _MSC_VER < 1900 19 | #ifndef __cpp_lib_uncaught_exceptions 20 | #define __cpp_lib_uncaught_exceptions 201411 21 | namespace std 22 | { 23 | 24 | int 25 | uncaught_exceptions() noexcept 26 | { 27 | return ::counter; 28 | } 29 | 30 | } /* namespace std */ 31 | #endif /* __cpp_lib_uncaught_exceptions */ 32 | #endif /* _MSC_VER */ 33 | #endif /* LIBPMEMOBJ_CPP_TESTS_TRANSACTION */ 34 | -------------------------------------------------------------------------------- /tests/wrap_pmemobj_defrag.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | /* 5 | * wrap_pmemobj_defrag.h -- mock function for pmemobj_defrag() 6 | * used in the concurrent_hash_map tests which are run under Valgrind 7 | * in order to test only the concurrent_hash_map part of implementation 8 | * of the defragment() method and not pmemobj_defrag() itself. 9 | * These tests would last too long without this mock function. 10 | */ 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /* 19 | * __wrap_pmemobj_defrag -- mock function for pmemobj_defrag() 20 | */ 21 | int 22 | __wrap_pmemobj_defrag(PMEMobjpool *pop, PMEMoid **oidv, size_t oidcnt, 23 | struct pobj_defrag_result *result) 24 | { 25 | return 0; 26 | } 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /tests/valgrind_internal.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019, Intel Corporation */ 3 | 4 | #include "valgrind_internal.hpp" 5 | #include 6 | 7 | unsigned On_valgrind = 0; 8 | unsigned On_pmemcheck = 0; 9 | unsigned On_memcheck = 0; 10 | unsigned On_helgrind = 0; 11 | unsigned On_drd = 0; 12 | 13 | void 14 | set_valgrind_internals(void) 15 | { 16 | #if LIBPMEMOBJ_CPP_ANY_VG_TOOL_ENABLED 17 | On_valgrind = RUNNING_ON_VALGRIND; 18 | 19 | if (On_valgrind) { 20 | if (getenv("LIBPMEMOBJ_CPP_TRACER_PMEMCHECK")) 21 | On_pmemcheck = 1; 22 | else if (getenv("LIBPMEMOBJ_CPP_TRACER_MEMCHECK")) 23 | On_memcheck = 1; 24 | else if (getenv("LIBPMEMOBJ_CPP_TRACER_HELGRIND")) 25 | On_helgrind = 1; 26 | else if (getenv("LIBPMEMOBJ_CPP_TRACER_DRD")) 27 | On_drd = 1; 28 | } 29 | #endif /* LIBPMEMOBJ_CPP_ANY_VG_TOOL_ENABLED */ 30 | } 31 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.cons/string_view.fail.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | // 11 | 12 | // explicit basic_string(basic_string_view sv, const Allocator& a 13 | // = Allocator()); 14 | 15 | #include 16 | #include 17 | 18 | void 19 | foo(const pmem::obj::string &s) 20 | { 21 | } 22 | 23 | int 24 | main() 25 | { 26 | pmem::obj::string_view sv = "ABCDE"; 27 | foo(sv); // requires implicit conversion from string_view to string 28 | } 29 | -------------------------------------------------------------------------------- /tests/ld.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | fun:index 5 | fun:expand_dynamic_string_token 6 | fun:_dl_map_object 7 | fun:map_doit 8 | fun:_dl_catch_error 9 | fun:do_preload 10 | fun:dl_main 11 | fun:_dl_sysdep_start 12 | fun:_dl_start 13 | obj:/lib/x86_64-linux-gnu/ld-2.*.so 14 | obj:* 15 | obj:* 16 | } 17 | { 18 | 19 | Memcheck:Cond 20 | fun:index 21 | fun:expand_dynamic_string_token 22 | fun:_dl_map_object 23 | fun:map_doit 24 | fun:_dl_catch_error 25 | fun:do_preload 26 | fun:handle_ld_preload 27 | fun:dl_main 28 | fun:_dl_sysdep_start 29 | fun:_dl_start 30 | obj:/lib/x86_64-linux-gnu/ld-2.*.so 31 | obj:* 32 | } 33 | { 34 | 35 | Memcheck:Leak 36 | ... 37 | fun:_dl_init 38 | fun:dl_open_worker 39 | fun:_dl_catch_error 40 | ... 41 | } 42 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | include(FindDoxygen) 5 | if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND) 6 | if(DEVELOPER_MODE) 7 | set(DOXYGEN_WARN_AS_ERROR "YES") 8 | else() 9 | set(DOXYGEN_WARN_AS_ERROR "NO") 10 | endif() 11 | 12 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpmemobj++.Doxyfile.in" 13 | "${CMAKE_CURRENT_BINARY_DIR}/libpmemobj++.Doxyfile" @ONLY) 14 | 15 | add_custom_target(doc ALL ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/libpmemobj++.Doxyfile" 16 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 17 | 18 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cpp_html/ DESTINATION ${CMAKE_INSTALL_DOCDIR}) 19 | elseif(NOT DOXYGEN_FOUND) 20 | message(WARNING "Doxygen not found - documentation will not be generated") 21 | else() 22 | message(WARNING "Dot tool not found - documentation will not be generated") 23 | endif() 24 | -------------------------------------------------------------------------------- /examples/pman/README: -------------------------------------------------------------------------------- 1 | This directory contains an example application implemented using libpmemobj, 2 | it's a game in which all the objects are stored on persistent memory. 3 | This means that the game process can be safely killed and then resumed. 4 | 5 | To launch the game: 6 | ./pman [map file] 7 | 8 | The file with the game session will either be created if it doesn't exist 9 | or opened if it contains a valid pool. 10 | 11 | Controls: 12 | move - arrow keys, jkli 13 | place bomb - spacebar, b 14 | quit - 'q' 15 | resume - 'r' 16 | 17 | This game demonstrates the usage of the very basics of the libpmemobj C++ 18 | bindings. It demonstrates pool management, persistent pointers and transactions. 19 | 20 | ** DEPENDENCIES: ** 21 | In order to build the game you need to install ncurses development package. 22 | 23 | rpm-based systems : ncurses-devel 24 | dpkg-based systems: libncursesX-dev (where X is the API/ABI version) 25 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/array.fill/fill.fail.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | int 20 | main() 21 | { 22 | { 23 | typedef double T; 24 | typedef pmem::obj::array C; 25 | C c = {{}}; 26 | // expected-error-re@array:* {{static_assert failed 27 | // {{.*}}"cannot fill zero-sized array of type 'const T'"}} 28 | c.fill(5.5); // expected-note {{requested here}} 29 | } 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /tests/ptr/self_relative_ptr_arith.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "ptr_arith.hpp" 5 | 6 | #include 7 | #include 8 | 9 | #define LAYOUT "cpp" 10 | 11 | static void 12 | test(int argc, char *argv[]) 13 | { 14 | if (argc != 2) 15 | UT_FATAL("usage: %s file-name", argv[0]); 16 | 17 | const char *path = argv[1]; 18 | 19 | nvobj::pool_base pop; 20 | 21 | try { 22 | pop = nvobj::pool_base::create(path, LAYOUT, PMEMOBJ_MIN_POOL, 23 | S_IWUSR | S_IRUSR); 24 | } catch (pmem::pool_error &pe) { 25 | UT_FATAL("!pool::create: %s %s", pe.what(), path); 26 | } 27 | 28 | test_arith(pop); 29 | test_relational(pop); 30 | 31 | pop.close(); 32 | } 33 | 34 | int 35 | main(int argc, char *argv[]) 36 | { 37 | return run_test([&] { test(argc, argv); }); 38 | } 39 | -------------------------------------------------------------------------------- /utils/docker/images/download-scripts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2020, Intel Corporation 4 | 5 | # 6 | # download-scripts.sh - downloads specific version of 7 | # codecov's bash script to generate and upload reports. 8 | # It's useful, since they may break our coverage. 9 | # 10 | 11 | set -e 12 | 13 | # master: Merge pull request #342 from codecov/revert-proj-name-..., 18.08.2020 14 | CODECOV_VERSION="e877c1280cc6e902101fb5df2981ed1c962da7f0" 15 | 16 | if [ "${SKIP_SCRIPTS_DOWNLOAD}" ]; then 17 | echo "Variable 'SKIP_SCRIPTS_DOWNLOAD' is set; skipping scripts' download" 18 | exit 19 | fi 20 | 21 | mkdir -p /opt/scripts 22 | 23 | # Download codecov's bash script 24 | git clone https://github.com/codecov/codecov-bash 25 | cd codecov-bash 26 | git checkout ${CODECOV_VERSION} 27 | 28 | git apply ../0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch 29 | mv -v codecov /opt/scripts/codecov 30 | 31 | cd .. 32 | rm -rf codecov-bash 33 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/array.tuple/get.fail.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | using pmem::obj::get; 20 | 21 | int 22 | main() 23 | { 24 | { 25 | typedef double T; 26 | typedef pmem::obj::array C; 27 | C c = {{1, 2, 3.5}}; 28 | get<3>(c) = 5.5; // expected-note {{requested here}} 29 | // expected-error@array:* {{static_assert failed "Index out of 30 | // bounds in std::get<> (std::array)"}} 31 | } 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.ends_with/ends_with.char.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 10 | 11 | // 12 | 13 | // bool ends_with(charT x) const noexcept; 14 | 15 | #include 16 | #include 17 | 18 | #include "test_macros.h" 19 | 20 | int main() 21 | { 22 | { 23 | typedef std::string S; 24 | S s1 {}; 25 | S s2 { "abcde", 5 }; 26 | 27 | ASSERT_NOEXCEPT(s1.ends_with('e')); 28 | 29 | assert (!s1.ends_with('e')); 30 | assert (!s1.ends_with('x')); 31 | assert ( s2.ends_with('e')); 32 | assert (!s2.ends_with('x')); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.cons/dtor_noexcept.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2019, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | 20 | int 21 | main() 22 | { 23 | /** 24 | * Test pmem::obj::vector destructor 25 | * 26 | * Expects that destructor is not deleted and noexcept 27 | */ 28 | { 29 | using vector_type = container_t; 30 | static_assert(std::is_nothrow_destructible::value, 31 | ""); 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/compare.fail_0.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | template 20 | struct NoCompare { 21 | }; 22 | 23 | int 24 | main() 25 | { 26 | int result = 0; 27 | { 28 | typedef NoCompare<0> T; 29 | typedef pmem::obj::array C; 30 | C c1 = {{}}; 31 | // expected-error@algorithm:* 2 {{invalid operands to binary 32 | // expression}} 33 | result = (c1 == c1); 34 | result = (c1 < c1); 35 | } 36 | 37 | return result; 38 | } 39 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/compare.fail_1.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | template 20 | struct NoCompare { 21 | }; 22 | 23 | int 24 | main() 25 | { 26 | int result = 0; 27 | { 28 | typedef NoCompare<1> T; 29 | typedef pmem::obj::array C; 30 | C c1 = {{}}; 31 | // expected-error@algorithm:* 2 {{invalid operands to binary 32 | // expression}} 33 | result = (c1 != c1); 34 | result = (c1 > c1); 35 | } 36 | 37 | return result; 38 | } 39 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/compare.fail_2.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | template 20 | struct NoCompare { 21 | }; 22 | 23 | int 24 | main() 25 | { 26 | int result = 0; 27 | { 28 | typedef NoCompare<2> T; 29 | typedef pmem::obj::array C; 30 | C c1 = {{}}; 31 | // expected-error@algorithm:* 2 {{invalid operands to binary 32 | // expression}} 33 | result = (c1 == c1); 34 | result = (c1 < c1); 35 | } 36 | 37 | return result; 38 | } 39 | -------------------------------------------------------------------------------- /examples/pool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020-2021, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(pool CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(pool_as_class_member pool_as_class_member.cpp) 25 | target_include_directories(pool_as_class_member PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(pool_as_class_member ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | 28 | add_executable(pool pool.cpp) 29 | target_include_directories(pool PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 30 | target_link_libraries(pool ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 31 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.starts_with/starts_with.char.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 10 | 11 | // 12 | 13 | // bool starts_with(charT x) const noexcept; 14 | 15 | #include 16 | #include 17 | 18 | #include "test_macros.h" 19 | 20 | int main() 21 | { 22 | { 23 | typedef std::string S; 24 | S s1 {}; 25 | S s2 { "abcde", 5 }; 26 | 27 | ASSERT_NOEXCEPT(s1.starts_with('e')); 28 | 29 | assert (!s1.starts_with('a')); 30 | assert (!s1.starts_with('x')); 31 | assert ( s2.starts_with('a')); 32 | assert (!s2.starts_with('x')); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/pman/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(pman CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | 19 | pkg_check_modules(CURSES REQUIRED ncurses) 20 | else() 21 | find_package(LIBPMEMOBJ++ REQUIRED) 22 | 23 | # Specifies that we want FindCurses to find ncurses and not just any 24 | # curses library 25 | set(CURSES_NEED_NCURSES TRUE) 26 | find_package(Curses REQUIRED) 27 | endif() 28 | 29 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 30 | 31 | add_executable(pman pman.cpp) 32 | target_include_directories(pman PUBLIC ${CURSES_INCLUDE_DIR} ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 33 | target_link_libraries(pman ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CURSES_LIBRARIES}) 34 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/array.swap/swap.fail.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | using pmem::obj::swap; 20 | 21 | int 22 | main() 23 | { 24 | { 25 | 26 | typedef double T; 27 | typedef pmem::obj::array C; 28 | C c = {{}}; 29 | C c2 = {{}}; 30 | // expected-error-re@array:* {{static_assert failed 31 | // {{.*}}"cannot swap zero-sized array of type 'const T'"}} 32 | c.swap(c2); // expected-note {{requested here}} 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /examples/simplekv_rebuild/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2019-2021, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.3) 5 | project(simplekv_rebuild CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 13 | else() 14 | find_package(LIBPMEMOBJ++ REQUIRED) 15 | endif() 16 | 17 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 18 | 19 | add_executable(simplekv_rebuild simplekv_rebuild.cpp) 20 | target_include_directories(simplekv_rebuild PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 21 | target_link_libraries(simplekv_rebuild ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 22 | 23 | add_executable(simplekv_rebuild_string simplekv_rebuild_string.cpp) 24 | target_include_directories(simplekv_rebuild_string PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 25 | target_link_libraries(simplekv_rebuild_string ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 26 | -------------------------------------------------------------------------------- /examples/pmpong/GameView.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEVIEW_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEVIEW_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include "PongGameStatus.hpp" 9 | #include "View.hpp" 10 | #include 11 | #include 12 | 13 | class GameView : public View { 14 | public: 15 | GameView(sf::Font &font); 16 | ~GameView(); 17 | 18 | virtual void prepareView(PongGameStatus &gameStatus); 19 | virtual void displayView(sf::RenderWindow *gameWindow); 20 | 21 | private: 22 | sf::Text scoreP1; 23 | sf::Text scoreP2; 24 | 25 | sf::RectangleShape upperLine; 26 | sf::RectangleShape downLine; 27 | sf::RectangleShape leftLine; 28 | sf::RectangleShape rightLine; 29 | sf::RectangleShape court; 30 | 31 | sf::CircleShape ballShape; 32 | sf::RectangleShape leftPaddleShape; 33 | sf::RectangleShape rightPaddleShape; 34 | }; 35 | 36 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMEVIEW_HPP */ 37 | -------------------------------------------------------------------------------- /examples/pmpong/Pool.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_POOL_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_POOL_HPP 6 | 7 | #include "GameController.hpp" 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct GameStruct { 14 | public: 15 | pmem::obj::persistent_ptr gam; 16 | }; 17 | 18 | class Pool { 19 | 20 | public: 21 | ~Pool(); 22 | static Pool *getGamePoolFromFile(const std::string &fileName); 23 | static Pool *getGamePool(); 24 | pmem::obj::persistent_ptr getGameController(); 25 | pmem::obj::pool &getPoolToTransaction(); 26 | 27 | private: 28 | Pool(const std::string &name); 29 | static Pool *pongPool; 30 | 31 | pmem::obj::pool pool; 32 | 33 | Pool(const Pool &); 34 | Pool &operator=(const Pool &); 35 | }; 36 | 37 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_POOL_HPP */ 38 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/variadic.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Helper functionality for handling variadic templates. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_VARIADIC_HPP 10 | #define LIBPMEMOBJ_CPP_VARIADIC_HPP 11 | 12 | namespace pmem 13 | { 14 | 15 | namespace detail 16 | { 17 | 18 | /* 19 | * Checks if T is the same type as first type in Args. 20 | * General case (for sizeof...(Args) == 0). 21 | */ 22 | template 23 | struct is_first_arg_same { 24 | static constexpr bool value = false; 25 | }; 26 | 27 | /* 28 | * Checks if T is the same type as first type in Args. 29 | * Specialization (for sizeof...(Args) > 0). 30 | */ 31 | template 32 | struct is_first_arg_same { 33 | static constexpr bool value = std::is_same::value; 34 | }; 35 | 36 | } /* namespace detail */ 37 | 38 | } /* namespace pmem */ 39 | 40 | #endif /* LIBPMEMOBJ_CPP_VARIADIC_HPP */ 41 | -------------------------------------------------------------------------------- /examples/panaconda/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(panaconda CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | 19 | pkg_check_modules(CURSES REQUIRED ncurses) 20 | else() 21 | find_package(LIBPMEMOBJ++ REQUIRED) 22 | 23 | # Specifies that we want FindCurses to find ncurses and not just any 24 | # curses library 25 | set(CURSES_NEED_NCURSES TRUE) 26 | find_package(Curses REQUIRED) 27 | endif() 28 | 29 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 30 | 31 | add_executable(panaconda panaconda.cpp) 32 | target_include_directories(panaconda PUBLIC ${CURSES_INCLUDE_DIR} ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 33 | target_link_libraries(panaconda ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CURSES_LIBRARIES}) 34 | -------------------------------------------------------------------------------- /tests/map/map_ctor_exception_notx.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "container_generic/ctor_exceptions_notx.hpp" 5 | #include "map_wrapper.hpp" 6 | #include "unittest.hpp" 7 | 8 | namespace nvobj = pmem::obj; 9 | 10 | using map_type = container_t; 11 | 12 | struct root { 13 | nvobj::persistent_ptr pptr; 14 | }; 15 | 16 | static void 17 | test(int argc, char *argv[]) 18 | { 19 | if (argc < 2) { 20 | UT_FATAL("usage: %s file-name", argv[0]); 21 | } 22 | auto path = argv[1]; 23 | auto pop = nvobj::pool::create(path, "map_ctor_exceptions_notx", 24 | PMEMOBJ_MIN_POOL * 2, 25 | S_IWUSR | S_IRUSR); 26 | 27 | test_copy_ctor(pop); 28 | test_default_ctor(pop); 29 | test_initializer_list_ctor(pop); 30 | test_iter_iter_ctor(pop); 31 | test_move_ctor(pop); 32 | 33 | pop.close(); 34 | } 35 | 36 | int 37 | main(int argc, char *argv[]) 38 | { 39 | return run_test([&] { test(argc, argv); }); 40 | } 41 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: -8 2 | AlignOperands: false 3 | AllowShortBlocksOnASingleLine: false 4 | AllowShortFunctionsOnASingleLine: false 5 | AllowShortIfStatementsOnASingleLine: false 6 | AlwaysBreakAfterDefinitionReturnType: true 7 | AlwaysBreakTemplateDeclarations: true 8 | BasedOnStyle: LLVM 9 | BraceWrapping: 10 | AfterClass: false 11 | AfterControlStatement: false 12 | AfterEnum: false 13 | AfterFunction: true 14 | AfterNamespace: true 15 | AfterObjCDeclaration: false 16 | AfterStruct: false 17 | AfterUnion: false 18 | BeforeCatch: false 19 | BeforeElse: false 20 | IndentBraces: false 21 | BreakBeforeBraces: Custom 22 | BreakStringLiterals: false 23 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 24 | ContinuationIndentWidth: 8 25 | FixNamespaceComments: false 26 | IndentCaseLabels: true 27 | IndentWidth: 8 28 | PointerAlignment: Right 29 | SpaceBeforeParens: ControlStatements 30 | SpacesBeforeTrailingComments: 1 31 | SpacesInContainerLiterals: false 32 | SpacesInCStyleCastParentheses: false 33 | UseTab: Always 34 | -------------------------------------------------------------------------------- /tests/common/helpers_test.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2021, Intel Corporation */ 3 | 4 | /* 5 | * helpers_test - test for all helper classes/functions used in testing 6 | * framework 7 | */ 8 | 9 | #include "thread_helpers.hpp" 10 | #include "unittest.hpp" 11 | 12 | #include 13 | 14 | static size_t const concurrency = 4; 15 | 16 | /* Verify if syncthreads is working correctly */ 17 | static void 18 | test() 19 | { 20 | std::atomic counter; 21 | counter = 0; 22 | 23 | parallel_xexec(concurrency, 24 | [&](size_t id, std::function syncthreads) { 25 | counter++; 26 | 27 | syncthreads(); 28 | UT_ASSERTeq(counter.load(), concurrency); 29 | syncthreads(); 30 | 31 | counter++; 32 | 33 | syncthreads(); 34 | UT_ASSERTeq(counter.load(), concurrency * 2); 35 | syncthreads(); 36 | UT_ASSERTeq(counter.load(), concurrency * 2); 37 | }); 38 | } 39 | 40 | int 41 | main() 42 | { 43 | return run_test(test); 44 | } 45 | -------------------------------------------------------------------------------- /utils/cppstyle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2017, Intel Corporation 4 | 5 | use strict; 6 | use Text::Diff; 7 | 8 | my $clangfmt = shift or die; 9 | my $mode = shift or die; 10 | 11 | sub check { 12 | my ($file) = @_; 13 | my $original; 14 | my $formatted; 15 | 16 | $formatted = `$clangfmt -style=file "$file"`; 17 | 18 | if ($mode eq 'check') { 19 | local $/=undef; 20 | open FILE, "$file" or die "Couldn't open file: $file"; 21 | binmode FILE; 22 | $original = ; 23 | close FILE; 24 | 25 | my $diff = diff \$original, \$formatted; 26 | 27 | if ($diff ne "") { 28 | print "Style check using $clangfmt for file $file failed\n"; 29 | print $diff; 30 | die "Style check using $clangfmt for file $file failed\n"; 31 | } 32 | } elsif ($mode eq 'format') { 33 | local $/=undef; 34 | open FILE, '>', "$file" or die "Couldn't open file: $file"; 35 | print FILE "$formatted"; 36 | close FILE; 37 | } else { 38 | die 'unknown mode'; 39 | } 40 | } 41 | 42 | foreach(@ARGV) { 43 | check($_) 44 | } 45 | -------------------------------------------------------------------------------- /examples/pmpong/README: -------------------------------------------------------------------------------- 1 | This directory contains an example application implemented using libpmemobj, 2 | it's a game in which all the objects are stored on persistent memory. 3 | This means that the game process can be safely killed and then resumed. 4 | 5 | To launch the game: 6 | ./pmpong [mode] 7 | 8 | Mode option might be skipped if you want to run game with GUI or use 9 | -s 10 | to run game simulation. 11 | 12 | The file with the game session will either be created if it doesn't exist 13 | or opened if it contains a valid pool. 14 | 15 | Controls: 16 | move left paddle - up and down arrow keys 17 | move right paddle - 'w' and 's' 18 | pause - esc 19 | start ball - space 20 | 21 | This game demonstrates the usage of the very basics of the libpmemobj C++ 22 | bindings. It demonstrates pool management, persistent pointers and transactions. 23 | 24 | ** DEPENDENCIES: ** 25 | In order to build the game you need to have SFML 2.4+ installed. 26 | rpm-based systems : sudo dnf install SFML-devel 27 | dpkg-based systems: sudo apt-get install libsfml-dev 28 | 29 | -------------------------------------------------------------------------------- /include/libpmemobj++/container/string.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019-2021, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * String typedefs for common character types. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_STRING_HPP 10 | #define LIBPMEMOBJ_CPP_STRING_HPP 11 | 12 | #include 13 | 14 | namespace pmem 15 | { 16 | 17 | namespace obj 18 | { 19 | 20 | /** 21 | * The most typical string usage - the char specialization. 22 | * @ingroup containers 23 | */ 24 | using string = basic_string; 25 | 26 | /** 27 | * The wide char specialization. 28 | * @ingroup containers 29 | */ 30 | using wstring = basic_string; 31 | 32 | /** 33 | * The char16 specialization. 34 | * @ingroup containers 35 | */ 36 | using u16string = basic_string; 37 | 38 | /** 39 | * The char32 specialization. 40 | * @ingroup containers 41 | */ 42 | using u32string = basic_string; 43 | 44 | } /* namespace obj */ 45 | 46 | } /* namespace pmem */ 47 | 48 | #endif /* LIBPMEMOBJ_CPP_STRING_HPP */ 49 | -------------------------------------------------------------------------------- /utils/docker/0001-travis-fix-travisci_build_coverity_scan.sh.patch: -------------------------------------------------------------------------------- 1 | From b5179dc4822eaab192361da05aa95d98f523960f Mon Sep 17 00:00:00 2001 2 | From: Lukasz Dorau 3 | Date: Mon, 7 May 2018 12:05:40 +0200 4 | Subject: [PATCH] travis: fix travisci_build_coverity_scan.sh 5 | 6 | --- 7 | travisci_build_coverity_scan.sh | 4 ++-- 8 | 1 file changed, 2 insertions(+), 2 deletions(-) 9 | 10 | diff --git a/travisci_build_coverity_scan.sh b/travisci_build_coverity_scan.sh 11 | index ad9d4afcf..562b08bcc 100644 12 | --- a/travisci_build_coverity_scan.sh 13 | +++ b/travisci_build_coverity_scan.sh 14 | @@ -92,8 +92,8 @@ response=$(curl \ 15 | --form description="Travis CI build" \ 16 | $UPLOAD_URL) 17 | status_code=$(echo "$response" | sed -n '$p') 18 | -if [ "$status_code" != "201" ]; then 19 | +if [ "$status_code" != "200" ]; then 20 | TEXT=$(echo "$response" | sed '$d') 21 | - echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" 22 | + echo -e "\033[33;1mCoverity Scan upload failed: $response.\033[0m" 23 | exit 1 24 | fi 25 | -- 26 | 2.13.6 27 | 28 | -------------------------------------------------------------------------------- /examples/pmpong/Ball.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_BALL_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_BALL_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class Ball { 14 | public: 15 | Ball(int x, int y); 16 | ~Ball(); 17 | 18 | void move(); 19 | void collisionWithWindow(); 20 | void increaseVelocity(); 21 | void setX(int xArg); 22 | void setY(int yArg); 23 | void setVelocityX(float xArg); 24 | void setVelocityY(float yArg); 25 | void setXY(int xArg, int yArg); 26 | void init(); 27 | int getX(); 28 | int getY(); 29 | pmem::obj::persistent_ptr getVelocity(); 30 | sf::CircleShape getBallShape(); 31 | 32 | private: 33 | pmem::obj::p x; 34 | pmem::obj::p y; 35 | pmem::obj::persistent_ptr velocity; 36 | }; 37 | 38 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_BALL_HPP */ 39 | -------------------------------------------------------------------------------- /tests/concurrent_hash_map/concurrent_hash_map_deadlock.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | /* 5 | * concurrent_hash_map_deadlock.cpp -- pmem::obj::concurrent_hash_map test 6 | * 7 | */ 8 | 9 | #include "../concurrent_hash_map/concurrent_hash_map_test.hpp" 10 | #include "unittest.hpp" 11 | 12 | static void 13 | test(int argc, char *argv[]) 14 | { 15 | if (argc < 2) { 16 | UT_FATAL("usage: %s file-name", argv[0]); 17 | } 18 | 19 | const char *path = argv[1]; 20 | 21 | nvobj::pool pop; 22 | 23 | try { 24 | pop = nvobj::pool::create( 25 | path, LAYOUT, PMEMOBJ_MIN_POOL * 20, S_IWUSR | S_IRUSR); 26 | pmem::obj::transaction::run(pop, [&] { 27 | pop.root()->cons = 28 | nvobj::make_persistent(); 29 | }); 30 | } catch (pmem::pool_error &pe) { 31 | UT_FATAL("!pool::create: %s %s", pe.what(), path); 32 | } 33 | 34 | lookup_insert_erase_deadlock_test(pop); 35 | 36 | pop.close(); 37 | } 38 | 39 | int 40 | main(int argc, char *argv[]) 41 | { 42 | return run_test([&] { test(argc, argv); }); 43 | } 44 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_0.gdb: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | set pagination off 7 | set print address off 8 | 9 | # This test does the following: 10 | # 1. Run all code until gdb_sync1 invocation and pause all threads 11 | # 2. Advance thread 10 (thread_id == 0) to internal_insert_ndode invocation 12 | # (threads 11 and 12 are waiting on spin loop) 13 | # 3. Advance thread 11 (thread_id == 1) to internal_insert_node invocation 14 | # 4. Advance thread 12 (thread_id == 2, reader thread) map->count invocation 15 | # New node should not be visible (neither thread 10 nor 11 completed) 16 | 17 | break gdb_sync1 18 | run 19 | rbreak concurrent_skip_list_impl.hpp:internal_insert_node 20 | thread 10 21 | c 22 | set scheduler-locking on 23 | thread 11 24 | break gdb_sync2 25 | c 26 | del 3 27 | finish 28 | set variable loop_sync_1 = 0 29 | c 30 | thread 12 31 | break gdb_sync3 32 | c 33 | del 4 34 | finish 35 | set variable loop_sync_2 = 0 36 | break gdb_sync_exit thread 12 37 | c 38 | finish 39 | info threads 40 | quit 41 | -------------------------------------------------------------------------------- /examples/panaconda/conf.cfg: -------------------------------------------------------------------------------- 1 | 11111111111111111111111111111111 2 | 10000000000000000000000000000001 3 | 10000000000000000000000000000001 4 | 10000000000000000000000000000001 5 | 10000000000000000000000000000001 6 | 10000000000000000000000000000001 7 | 10000000000000000000000000000001 8 | 10000000000000000000000000000001 9 | 10000000000000000000000000000001 10 | 10000000000000000000000000000001 11 | 10000000000000000000000000000001 12 | 10000000000000000000000000000001 13 | 10000000111000000000111000000001 14 | 10000000111000010000111000000001 15 | 10000000000000111000000000000001 16 | 10000000000001111100000000000001 17 | 10000000000000000000000000000001 18 | 10000011111111111111111111000001 19 | 10000000011111111111111000000001 20 | 10000000000000111100000000000001 21 | 10000000000000000000000000000001 22 | 10000000000000000000000000000001 23 | 10000000000000000000000000000001 24 | 10000000000000000000000000000001 25 | 10000000000000000000000000000001 26 | 10000000000000000000000000000001 27 | 10000000000000000000000000000001 28 | 10000000000000000000000000000001 29 | 10000000000000000000000000000001 30 | 11111111111111111111111111111111 -------------------------------------------------------------------------------- /tests/map/map_ctor_exception_nopmem.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "container_generic/ctor_exceptions_nopmem.hpp" 5 | #include "map_wrapper.hpp" 6 | #include "unittest.hpp" 7 | 8 | namespace nvobj = pmem::obj; 9 | 10 | using map_type = container_t; 11 | 12 | struct root { 13 | nvobj::persistent_ptr pptr; 14 | }; 15 | 16 | static void 17 | test(int argc, char *argv[]) 18 | { 19 | if (argc < 2) { 20 | UT_FATAL("usage: %s file-name", argv[0]); 21 | } 22 | 23 | auto path = argv[1]; 24 | auto pop = nvobj::pool::create(path, "map_ctor_exceptions_nopmem", 25 | PMEMOBJ_MIN_POOL * 2, 26 | S_IWUSR | S_IRUSR); 27 | 28 | auto r = pop.root(); 29 | 30 | (void)r; 31 | test_default_ctor(); 32 | test_iter_iter_ctor(); 33 | test_initializer_list_ctor(); 34 | test_move_ctor(pop, r->pptr); 35 | test_copy_ctor(pop, r->pptr); 36 | 37 | pop.close(); 38 | } 39 | 40 | int 41 | main(int argc, char *argv[]) 42 | { 43 | return run_test([&] { test(argc, argv); }); 44 | } 45 | -------------------------------------------------------------------------------- /examples/concurrent_hash_map/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2020-2021, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(concurrent_hash_map CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | else() 19 | find_package(LIBPMEMOBJ++ REQUIRED) 20 | endif() 21 | 22 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 23 | 24 | add_executable(concurrent_hash_map concurrent_hash_map.cpp) 25 | target_include_directories(concurrent_hash_map PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 26 | target_link_libraries(concurrent_hash_map ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 27 | 28 | add_executable(concurrent_hash_map_string concurrent_hash_map_string.cpp) 29 | target_include_directories(concurrent_hash_map_string PUBLIC ${LIBPMEMOBJ++_INCLUDE_DIRS} . ..) 30 | target_link_libraries(concurrent_hash_map_string ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 31 | -------------------------------------------------------------------------------- /examples/pmpong/Paddle.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PADDLE_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PADDLE_HPP 6 | 7 | #include "Ball.hpp" 8 | #include "GameConstants.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class Paddle { 15 | 16 | public: 17 | Paddle(); 18 | Paddle(int x, int y); 19 | ~Paddle(); 20 | 21 | void moveUp(int velocity); 22 | void moveDown(int velocity); 23 | void addPoint(); 24 | void init(); 25 | void adjustPaddleYtoBall(Ball &ball); 26 | void collisionWithBall(Ball &ball, bool increaseBallSpeed); 27 | 28 | int getX(); 29 | int getY(); 30 | int getPoints(); 31 | 32 | sf::RectangleShape getPaddleShape(); 33 | 34 | private: 35 | pmem::obj::p y; 36 | pmem::obj::p x; 37 | pmem::obj::p points; 38 | 39 | void setPoints(int pointsArg); 40 | void setY(int yArg); 41 | void setX(int xArg); 42 | }; 43 | 44 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PADDLE_HPP */ 45 | -------------------------------------------------------------------------------- /utils/docker/images/README.md: -------------------------------------------------------------------------------- 1 | # Content 2 | 3 | Dockerfiles and scripts placed in this directory are intended to be used as 4 | a development process vehicles and part of continuous integration process. 5 | 6 | Images built out of those recipes may by used with docker or podman as 7 | a development environment. 8 | Only those used on CI (Travis/Github Actions) are fully tested on a daily basis. 9 | In case of any problem, patches and Github issues are welcome. 10 | 11 | # How to build docker image 12 | 13 | ```sh 14 | docker build --build-arg https_proxy=http://proxy.com:port --build-arg http_proxy=http://proxy.com:port -t libpmemobj-cpp:debian-unstable -f ./Dockerfile.debian-unstable . 15 | ``` 16 | 17 | # How to use docker image 18 | 19 | To run build and tests on local machine on docker: 20 | 21 | ```sh 22 | docker run --network=bridge --shm-size=4G -v /your/workspace/path/:/opt/workspace:z -w /opt/workspace/ -e CC=clang -e CXX=clang++ -e PKG_CONFIG_PATH=/opt/pmdk/lib/pkgconfig -it libpmemobj-cpp:debian-unstable /bin/bash 23 | ``` 24 | 25 | To get strace working, add to docker commandline 26 | 27 | ```sh 28 | --cap-add SYS_PTRACE 29 | ``` 30 | -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # From: https://cmake.org/Wiki/CMake_FAQ 2 | 3 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 5 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | 7 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 13 | OUTPUT_VARIABLE rm_out 14 | RETURN_VALUE rm_retval 15 | ) 16 | if(NOT "${rm_retval}" STREQUAL 0) 17 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 18 | endif(NOT "${rm_retval}" STREQUAL 0) 19 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 20 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 21 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 22 | endforeach(file) 23 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_1.gdb: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | set pagination off 7 | 8 | # This test does the following: 9 | # 1. Run all code until gdb_sync1 invocation and pause all threads 10 | # 2. Advance thread 10 (thread_id == 0) to internal_insert_ndode invocation 11 | # (threads 11 and 12 are waiting on spin loop) 12 | # 3. Advance thread 11 (thread_id == 1) to try_insert_node_finish_marker invocation 13 | # 4. Advance thread 12 (thread_id == 2, reader thread) map->count invocation 14 | # New node should now be visible (thread 11 completed) 15 | 16 | break gdb_sync1 17 | run 18 | rbreak concurrent_skip_list_impl.hpp:internal_insert_node 19 | break concurrent_skip_list_impl.hpp:try_insert_node_finish_marker 20 | thread 10 21 | c 22 | set scheduler-locking on 23 | thread 11 24 | break gdb_sync2 25 | c 26 | del 4 27 | finish 28 | set variable loop_sync_1 = 0 29 | c 30 | c 31 | thread 12 32 | break gdb_sync3 33 | c 34 | del 5 35 | finish 36 | set variable loop_sync_2 = 0 37 | break gdb_sync_exit thread 12 38 | c 39 | finish 40 | info threads 41 | quit 42 | -------------------------------------------------------------------------------- /tests/enumerable_thread_specific/enumerable_thread_specific_layout.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019-2020, Intel Corporation */ 3 | 4 | #include "unittest.hpp" 5 | 6 | #include 7 | 8 | template 9 | using container_type = pmem::detail::enumerable_thread_specific; 10 | 11 | static void 12 | test(int argc, char *argv[]) 13 | { 14 | if (argc < 2) { 15 | UT_FATAL("usage: %s file-name", argv[0]); 16 | } 17 | 18 | static_assert( 19 | 2128 == 20 | sizeof(pmem::obj::shared_mutex) + 21 | sizeof(pmem::obj::segment_vector< 22 | char, 23 | pmem::obj:: 24 | exponential_size_array_policy<>>) + 25 | sizeof(std::atomic), 26 | ""); 27 | 28 | static_assert(sizeof(container_type) == 2128, ""); 29 | static_assert(sizeof(container_type) == 2128, ""); 30 | static_assert(sizeof(container_type>) == 2128, ""); 31 | 32 | static_assert(std::is_standard_layout>::value, ""); 33 | } 34 | 35 | int 36 | main(int argc, char *argv[]) 37 | { 38 | return run_test([&] { test(argc, argv); }); 39 | } 40 | -------------------------------------------------------------------------------- /tests/common/helper_algorithm.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | /* 5 | * Helper algorithms to test C++ containers 6 | */ 7 | 8 | #ifndef HELPER_ALGORITHM_HPP 9 | #define HELPER_ALGORITHM_HPP 10 | 11 | #include 12 | 13 | /** 14 | * Checks if the elements in range [first, last) are sorted in a strictly 15 | * ascending order. 16 | */ 17 | template 18 | bool 19 | is_strictly_increased(ForwardIt first, ForwardIt last, Compare comp) 20 | { 21 | if (first != last) { 22 | ForwardIt next = first; 23 | while (++next != last) { 24 | if (!comp(*first, *next)) 25 | return false; 26 | first = next; 27 | } 28 | } 29 | 30 | return true; 31 | } 32 | 33 | /** 34 | * Checks if the elements in range [first, last) are sorted in a strictly 35 | * ascending order. 36 | */ 37 | template 38 | bool 39 | is_strictly_increased(ForwardIt first, ForwardIt last) 40 | { 41 | return is_strictly_increased(first, last, 42 | std::less::value_type>()); 44 | } 45 | 46 | #endif /* HELPER_ALGORITHM_HPP */ 47 | -------------------------------------------------------------------------------- /tests/map/map_txabort.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "../common/map_wrapper.hpp" 5 | #include "../common/unittest.hpp" 6 | #include "../container_generic/container_txabort.hpp" 7 | 8 | #define LAYOUT "map_txabort" 9 | 10 | namespace nvobj = pmem::obj; 11 | 12 | using map_type = container_t>; 13 | 14 | struct root { 15 | nvobj::persistent_ptr pptr1; 16 | nvobj::persistent_ptr pptr2; 17 | }; 18 | 19 | static void 20 | test(int argc, char *argv[]) 21 | { 22 | if (argc < 2) { 23 | UT_FATAL("usage: %s file-name", argv[0]); 24 | } 25 | 26 | const char *path = argv[1]; 27 | 28 | nvobj::pool pop; 29 | 30 | try { 31 | pop = nvobj::pool::create( 32 | path, LAYOUT, PMEMOBJ_MIN_POOL * 20, S_IWUSR | S_IRUSR); 33 | } catch (pmem::pool_error &pe) { 34 | UT_FATAL("!pool::create: %s %s", pe.what(), path); 35 | } 36 | 37 | auto r = pop.root(); 38 | 39 | test_tx_singlethread(pop, r->pptr1, r->pptr2); 40 | 41 | pop.close(); 42 | } 43 | 44 | int 45 | main(int argc, char *argv[]) 46 | { 47 | return run_test([&] { test(argc, argv); }); 48 | } 49 | -------------------------------------------------------------------------------- /tests/concurrent_map_mt_gdb/concurrent_map_mt_gdb_2.gdb: -------------------------------------------------------------------------------- 1 | set width 0 2 | set height 0 3 | set verbose off 4 | set confirm off 5 | set breakpoint pending on 6 | set pagination off 7 | 8 | # This test does the following: 9 | # 1. Run all code until gdb_sync1 invocation and pause all threads 10 | # 2. Advance thread 10 (thread_id == 0) to internal_insert_ndode invocation 11 | # (threads 11 and 12 are waiting on spin loop) 12 | # 3. Advance thread 11 (thread_id == 1) to after first set_next invocation (in internal_insert_node) 13 | # 4. Advance thread 12 (thread_id == 2, reader thread) map->count invocation 14 | # New node should now be visible (thread 11 partially completed) 15 | 16 | break gdb_sync1 17 | run 18 | rbreak concurrent_skip_list_impl.hpp:internal_insert_node 19 | thread 10 20 | c 21 | set scheduler-locking on 22 | thread 11 23 | break gdb_sync2 24 | c 25 | del 3 26 | finish 27 | set variable loop_sync_1 = 0 28 | c 29 | break set_next 30 | c 31 | finish 32 | finish 33 | finish 34 | n 35 | n 36 | del 4 37 | thread 12 38 | break gdb_sync3 39 | c 40 | del 5 41 | finish 42 | set variable loop_sync_2 = 0 43 | break gdb_sync_exit thread 12 44 | c 45 | finish 46 | info threads 47 | quit 48 | -------------------------------------------------------------------------------- /examples/panaconda/README: -------------------------------------------------------------------------------- 1 | This directory contains an example application implemented using libpmemobj, 2 | it's a game in which all the objects are stored on persistent memory. 3 | This means that the game process can be safely killed and then resumed. 4 | 5 | To launch the game: 6 | ./panaconda /path/game/session/file 7 | or 8 | ./panaconda /path/game/session/file -m /path/config/file/conf/cfg 9 | 10 | The second option allow you to define your own maze. 11 | Meaning of symbols in config file is given below: 12 | '1' - wall 13 | '0' - space 14 | conf.cfg contains example of predefined maze. 15 | 16 | The file with the game session will either be created if it doesn't exist 17 | or opened if it contains a valid pool. 18 | 19 | Controls: 20 | move - arrow keys 21 | quit - 'q' 22 | new game - 'n' 23 | 24 | This game demonstrates the usage of the very basics of the libpmemobj C++ 25 | bindings. It demonstrates pool management, persistent pointers and transactions. 26 | 27 | ** DEPENDENCIES: ** 28 | In order to build the game you need to install ncurses development package. 29 | 30 | rpm-based systems : ncurses-devel 31 | dpkg-based systems: libncursesX-dev (where X is the API/ABI version) 32 | -------------------------------------------------------------------------------- /tests/check_is_pmem/check_is_pmem.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019-2020, Intel Corporation */ 3 | 4 | /* 5 | * check_is_pmem.cpp -- check if path points to a directory on pmem. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /* 13 | * return value is: 14 | * - 0 when path points to pmem 15 | * - 1 when path points to non-pmem 16 | * - 2 when error occurred 17 | */ 18 | int 19 | main(int argc, char *argv[]) 20 | { 21 | if (argc != 2) { 22 | std::cerr << "usage: " << argv[0] << " filepath\n"; 23 | return 2; 24 | } 25 | 26 | auto path = argv[1]; 27 | 28 | int is_pmem; 29 | size_t size; 30 | int flags = PMEM_FILE_CREATE; 31 | 32 | #ifdef _WIN32 33 | void *addr = pmem_map_fileU(path, 4096, flags, 0, &size, &is_pmem); 34 | #else 35 | void *addr = pmem_map_file(path, 4096, flags, 0, &size, &is_pmem); 36 | #endif 37 | if (addr == nullptr) { 38 | std::perror("pmem_map_file failed"); 39 | return 2; 40 | } 41 | 42 | pmem_unmap(addr, size); 43 | if (std::remove(path)) { 44 | std::perror("cannot remove file"); 45 | return 2; 46 | } 47 | 48 | if (is_pmem) 49 | return 0; 50 | else 51 | return 1; 52 | } 53 | -------------------------------------------------------------------------------- /examples/array/README.md: -------------------------------------------------------------------------------- 1 | ## Basic usage: 2 | 3 | After [building](https://github.com/pmem/libpmemobj-cpp#how-to-build) the source, navigate to the `/build/examples/` directory. Operations include: `alloc`, `realloc`, `free`, and `print`. 4 | 5 | `$ ./example-array [print|alloc|free|realloc] ` 6 | 7 | ## Options: 8 | 9 | ### Alloc: 10 | 11 | `$ ./example-array alloc ` 12 | 13 | Example: 14 | ``` 15 | $ ./example-array file alloc myArray 4 16 | $ ./example-array file print myArray 17 | myArray = [0, 1, 2, 3] 18 | ``` 19 | 20 | ### Realloc: 21 | 22 | `$ ./example-array realloc ` 23 | 24 | Example: 25 | ``` 26 | $ ./example-array file realloc myArray 7 27 | $ ./example-array file print myArray 28 | myArray = [0, 1, 2, 3, 0, 0, 0] 29 | ``` 30 | 31 | ### Free: 32 | 33 | `$ ./example-array free ` 34 | 35 | Example: 36 | ``` 37 | $ ./example-array file free myArray 38 | $ ./example-array file print myArray 39 | No array found with name: myArray 40 | ``` 41 | 42 | ### Print: 43 | 44 | `$ ./example-array print ` 45 | 46 | Example output can be seen in above example sections. 47 | -------------------------------------------------------------------------------- /tests/vector/vector_ctor_exceptions_nopmem.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | #include "container_generic/ctor_exceptions_nopmem.hpp" 5 | #include "list_wrapper.hpp" 6 | #include "unittest.hpp" 7 | 8 | namespace nvobj = pmem::obj; 9 | 10 | using vector_type = container_t; 11 | 12 | struct root { 13 | nvobj::persistent_ptr pptr; 14 | }; 15 | 16 | static void 17 | test(int argc, char *argv[]) 18 | { 19 | if (argc < 2) { 20 | UT_FATAL("usage: %s file-name", argv[0]); 21 | } 22 | 23 | auto path = argv[1]; 24 | auto pop = nvobj::pool::create(path, "VectorTest: ctor_nopmem", 25 | PMEMOBJ_MIN_POOL * 2, 26 | S_IWUSR | S_IRUSR); 27 | 28 | auto r = pop.root(); 29 | 30 | test_copy_ctor(pop, r->pptr); 31 | test_default_ctor(); 32 | test_initializer_list_ctor(); 33 | test_iter_iter_ctor(); 34 | test_move_ctor(pop, r->pptr); 35 | test_size_ctor(); 36 | test_size_value_ctor(); 37 | 38 | pop.close(); 39 | } 40 | 41 | int 42 | main(int argc, char *argv[]) 43 | { 44 | return run_test([&] { test(argc, argv); }); 45 | } 46 | -------------------------------------------------------------------------------- /tests/vector/vector_ctor_exceptions_notx.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | #include "../container_generic/ctor_exceptions_notx.hpp" 5 | #include "list_wrapper.hpp" 6 | #include "unittest.hpp" 7 | 8 | #include 9 | 10 | namespace nvobj = pmem::obj; 11 | 12 | using vector_type = container_t; 13 | 14 | struct root { 15 | nvobj::persistent_ptr pptr; 16 | }; 17 | 18 | static void 19 | test(int argc, char *argv[]) 20 | { 21 | if (argc < 2) { 22 | UT_FATAL("usage: %s file-name", argv[0]); 23 | } 24 | auto path = argv[1]; 25 | auto pop = nvobj::pool::create( 26 | path, "VectorTest: vector_ctor_exceptions_notx", 27 | PMEMOBJ_MIN_POOL * 2, S_IWUSR | S_IRUSR); 28 | 29 | test_copy_ctor(pop); 30 | test_default_ctor(pop); 31 | test_initializer_list_ctor(pop); 32 | test_iter_iter_ctor(pop); 33 | test_move_ctor(pop); 34 | test_size_ctor(pop); 35 | test_size_value_ctor(pop); 36 | 37 | pop.close(); 38 | } 39 | 40 | int 41 | main(int argc, char *argv[]) 42 | { 43 | return run_test([&] { test(argc, argv); }); 44 | } 45 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/pool_data.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * A volatile data stored along with pmemobjpool. Stores cleanup function which 7 | * is called on pool close. 8 | */ 9 | 10 | #ifndef LIBPMEMOBJ_CPP_POOL_DATA_HPP 11 | #define LIBPMEMOBJ_CPP_POOL_DATA_HPP 12 | 13 | #include 14 | #include 15 | 16 | namespace pmem 17 | { 18 | 19 | namespace detail 20 | { 21 | 22 | struct pool_data { 23 | pool_data() 24 | { 25 | initialized = false; 26 | } 27 | 28 | /* Set cleanup function if not already set */ 29 | void 30 | set_cleanup(std::function cleanup) 31 | { 32 | bool expected = false; 33 | 34 | /* this is only to protect from concurrent initializations, 35 | * there will be no concurrent reads */ 36 | if (initialized.compare_exchange_strong( 37 | expected, true, std::memory_order_release, 38 | std::memory_order_relaxed)) { 39 | this->cleanup = cleanup; 40 | } 41 | } 42 | 43 | std::atomic initialized; 44 | std::function cleanup; 45 | }; 46 | 47 | } /* namespace detail */ 48 | 49 | } /* namespace pmem */ 50 | 51 | #endif /* LIBPMEMOBJ_CPP_POOL_DATA_HPP */ 52 | -------------------------------------------------------------------------------- /utils/docker/images/install-pmdk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2018-2022, Intel Corporation 4 | 5 | # 6 | # install-pmdk.sh - installs libpmem & libpmemobj 7 | # and prepares DEB/RPM packages if possible (stored on docker image in /opt/). 8 | # 9 | 10 | set -e 11 | 12 | if [ "${SKIP_PMDK_BUILD}" ]; then 13 | echo "Variable 'SKIP_PMDK_BUILD' is set; skipping building PMDK" 14 | exit 15 | fi 16 | 17 | PACKAGE_MANAGER=${1} 18 | 19 | # common: 1.12.0 release, 24.05.2022 20 | PMDK_VERSION="73d8f958e855904dc0776a7d77d0f0d3698a65b1" 21 | 22 | git clone https://github.com/pmem/pmdk 23 | cd pmdk 24 | git checkout ${PMDK_VERSION} 25 | 26 | # Don't generate docs, they are reundant for us 27 | make DOC=n -j$(nproc) prefix=/opt/pmdk 28 | sudo make DOC=n install -j$(nproc) prefix=/opt/pmdk 29 | 30 | # Do not create nor test any packages if PACKAGE_MANAGER is not set 31 | [[ -z "${PACKAGE_MANAGER}" ]] && exit 0 32 | 33 | sudo mkdir /opt/pmdk-pkg 34 | make -j$(nproc) BUILD_PACKAGE_CHECK=n "${PACKAGE_MANAGER}" 35 | 36 | if [ "${PACKAGE_MANAGER}" = "dpkg" ]; then 37 | sudo mv dpkg/*.deb /opt/pmdk-pkg/ 38 | elif [ "${PACKAGE_MANAGER}" = "rpm" ]; then 39 | sudo mv rpm/x86_64/*.rpm /opt/pmdk-pkg/ 40 | fi 41 | 42 | cd .. 43 | rm -rf pmdk 44 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/conversions.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2016-2018, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Commonly used conversions. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_CONVERSIONS_HPP 10 | #define LIBPMEMOBJ_CPP_CONVERSIONS_HPP 11 | 12 | #include 13 | #include 14 | 15 | namespace pmem 16 | { 17 | 18 | namespace detail 19 | { 20 | 21 | /** 22 | * Convert std::chrono::time_point to posix timespec. 23 | * 24 | * @param[in] timepoint point in time to be converted. 25 | * 26 | * @return converted timespec structure. 27 | */ 28 | template 29 | timespec 30 | timepoint_to_timespec(const std::chrono::time_point &timepoint) 31 | { 32 | timespec ts; 33 | auto rel_duration = timepoint.time_since_epoch(); 34 | const auto sec = 35 | std::chrono::duration_cast(rel_duration); 36 | 37 | ts.tv_sec = sec.count(); 38 | ts.tv_nsec = static_cast( 39 | std::chrono::duration_cast( 40 | rel_duration - sec) 41 | .count()); 42 | 43 | return ts; 44 | } 45 | 46 | } /* namespace detail */ 47 | 48 | } /* namespace pmem */ 49 | 50 | #endif /* LIBPMEMOBJ_CPP_CONVERSIONS_HPP */ 51 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/array_traits.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2016-2018, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Common array traits. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_ARRAY_TRAITS_HPP 10 | #define LIBPMEMOBJ_CPP_ARRAY_TRAITS_HPP 11 | 12 | #include 13 | 14 | namespace pmem 15 | { 16 | 17 | namespace detail 18 | { 19 | 20 | /* 21 | * Returns the number of array elements. 22 | */ 23 | template 24 | struct pp_array_elems { 25 | enum { elems = 1 }; 26 | }; 27 | 28 | /* 29 | * Returns the number of array elements. 30 | */ 31 | template 32 | struct pp_array_elems { 33 | enum { elems = N }; 34 | }; 35 | 36 | /* 37 | * Returns the type of elements in an array. 38 | */ 39 | template 40 | struct pp_array_type; 41 | 42 | /* 43 | * Returns the type of elements in an array. 44 | */ 45 | template 46 | struct pp_array_type { 47 | typedef T type; 48 | }; 49 | 50 | /* 51 | * Returns the type of elements in an array. 52 | */ 53 | template 54 | struct pp_array_type { 55 | typedef T type; 56 | }; 57 | 58 | } /* namespace detail */ 59 | 60 | } /* namespace pmem */ 61 | 62 | #endif /* LIBPMEMOBJ_CPP_ARRAY_TRAITS_HPP */ 63 | -------------------------------------------------------------------------------- /tests/map/map_ctor_and_assignment.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | #include "../common/map_wrapper.hpp" 5 | #include "../common/unittest.hpp" 6 | #include "../container_generic/ctor_and_assignment.hpp" 7 | 8 | #include 9 | 10 | #define LAYOUT "map_ctor_and_assignment" 11 | 12 | namespace nvobj = pmem::obj; 13 | 14 | using map_type = container_t; 15 | 16 | struct root { 17 | nvobj::persistent_ptr pptr1; 18 | nvobj::persistent_ptr pptr2; 19 | }; 20 | 21 | static void 22 | test(int argc, char *argv[]) 23 | { 24 | if (argc < 2) { 25 | UT_FATAL("usage: %s file-name", argv[0]); 26 | } 27 | 28 | const char *path = argv[1]; 29 | 30 | nvobj::pool pop; 31 | 32 | try { 33 | pop = nvobj::pool::create( 34 | path, LAYOUT, PMEMOBJ_MIN_POOL * 20, S_IWUSR | S_IRUSR); 35 | } catch (pmem::pool_error &pe) { 36 | UT_FATAL("!pool::create: %s %s", pe.what(), path); 37 | } 38 | 39 | auto r = pop.root(); 40 | 41 | ctor_test(pop, r->pptr1, r->pptr2); 42 | assignment_test(pop, r->pptr1, r->pptr2); 43 | 44 | pop.close(); 45 | } 46 | 47 | int 48 | main(int argc, char *argv[]) 49 | { 50 | return run_test([&] { test(argc, argv); }); 51 | } 52 | -------------------------------------------------------------------------------- /examples/pmpong/GameController.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMECONTROLLER_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMECONTROLLER_HPP 6 | 7 | #include "GameConstants.hpp" 8 | #include "GameOverView.hpp" 9 | #include "GameView.hpp" 10 | #include "MenuView.hpp" 11 | #include "PongGameStatus.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class GameController { 19 | public: 20 | GameController(); 21 | ~GameController(); 22 | 23 | void gameLoop(bool isSimulation = false); 24 | 25 | private: 26 | pmem::obj::persistent_ptr gameStatus; 27 | 28 | void gameOver(sf::RenderWindow *gameWindow, View *view); 29 | void menu(sf::RenderWindow *gameWindow, View *view); 30 | void handleEventKeypress(sf::Event &event, 31 | sf::RenderWindow *gameWindow); 32 | void gameMatch(sf::RenderWindow *gameWindow, View *view); 33 | void gameMatchSimulation(sf::RenderWindow *gameWindow, View *view); 34 | 35 | void resetGameStatus(); 36 | }; 37 | 38 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_GAMECONTROLLER_HPP */ 39 | -------------------------------------------------------------------------------- /.github/workflows/coverity.yml: -------------------------------------------------------------------------------- 1 | 2 | name: CPP-coverity 3 | # It runs static analysis build - Coverity. It requires special token (set in CI's secret). 4 | 5 | # Run this job at 00:00 UTC once a month; but also allow manual trigger. 6 | on: 7 | workflow_dispatch: 8 | schedule: 9 | - cron: '0 0 1 * *' 10 | 11 | env: 12 | REPO: libpmemobj-cpp 13 | GITHUB_REPO: pmem/libpmemobj-cpp 14 | CONTAINER_REG: ghcr.io/pmem/libpmemobj-cpp 15 | HOST_WORKDIR: ${{ github.workspace }} 16 | WORKDIR: utils/docker 17 | IMG_VER: latest 18 | COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} 19 | COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 20 | 21 | jobs: 22 | linux: 23 | name: Linux-coverity 24 | runs-on: ubuntu-latest 25 | strategy: 26 | matrix: 27 | CONFIG: ["TYPE=coverity OS=ubuntu OS_VER=20.04"] 28 | steps: 29 | - name: Clone the git repo 30 | uses: actions/checkout@v2 31 | 32 | # coverity workflow should just reuse (pull) the most recent, available image 33 | - name: Pull the image 34 | run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh pull 35 | 36 | - name: Run the build 37 | run: cd $WORKDIR && ${{ matrix.CONFIG }} ./build.sh 38 | -------------------------------------------------------------------------------- /tests/external/libcxx/map/default_only.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | #ifndef LIBPMEMOBJ_CPP_TESTS_DEFAULT_ONLY_H 15 | #define LIBPMEMOBJ_CPP_TESTS_DEFAULT_ONLY_H 16 | 17 | #include 18 | 19 | #include 20 | 21 | class DefaultOnly { 22 | pmem::obj::p data_; 23 | 24 | DefaultOnly(const DefaultOnly &); 25 | DefaultOnly &operator=(const DefaultOnly &); 26 | 27 | public: 28 | static int count; 29 | 30 | DefaultOnly() : data_(-1) 31 | { 32 | ++count; 33 | } 34 | ~DefaultOnly() 35 | { 36 | data_ = 0; 37 | --count; 38 | } 39 | 40 | friend bool 41 | operator==(const DefaultOnly &x, const DefaultOnly &y) 42 | { 43 | return x.data_ == y.data_; 44 | } 45 | friend bool 46 | operator<(const DefaultOnly &x, const DefaultOnly &y) 47 | { 48 | return x.data_ < y.data_; 49 | } 50 | }; 51 | 52 | int DefaultOnly::count = 0; 53 | 54 | #endif // LIBPMEMOBJ_CPP_TESTS_DEFAULT_ONLY_H 55 | -------------------------------------------------------------------------------- /tests/common/unittest_windows.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018, Intel Corporation */ 3 | 4 | #ifndef UNITTEST_WINDOWS_HPP 5 | #define UNITTEST_WINDOWS_HPP 6 | 7 | #include 8 | 9 | #define S_IRUSR S_IREAD 10 | #define S_IWUSR S_IWRITE 11 | #define S_IRGRP S_IRUSR 12 | #define S_IWGRP S_IWUSR 13 | 14 | /* 15 | * ut_toUTF8 -- convert WCS to UTF-8 string 16 | */ 17 | char * 18 | ut_toUTF8(const wchar_t *wstr) 19 | { 20 | int size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr, -1, 21 | nullptr, 0, nullptr, nullptr); 22 | if (size == 0) { 23 | UT_FATAL("!ut_toUTF8"); 24 | } 25 | 26 | char *str = new char[size]; 27 | 28 | if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr, -1, str, 29 | size, nullptr, nullptr) == 0) { 30 | UT_FATAL("!ut_toUTF8"); 31 | } 32 | 33 | return str; 34 | } 35 | 36 | /* 37 | * ut_statw -- statw that never returns -1 38 | */ 39 | int 40 | ut_statw(const char *file, int line, const char *func, const wchar_t *path, 41 | os_stat_t *st) 42 | { 43 | int ret = _wstat64(path, st); 44 | 45 | if (ret < 0) 46 | UT_FATAL("%s:%d %s - !stat: %S", file, line, func, path); 47 | 48 | /* clear unused bits to avoid confusion */ 49 | st->st_mode &= 0600; 50 | 51 | return ret; 52 | } 53 | 54 | #define STATW(path, st) ut_statw(__FILE__, __LINE__, __func__, path, st) 55 | 56 | #endif /* UNITTEST_WINDOWS_HPP */ 57 | -------------------------------------------------------------------------------- /examples/pmpong/MenuView.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017, Intel Corporation */ 3 | 4 | #include "MenuView.hpp" 5 | 6 | MenuView::MenuView(sf::Font &font) 7 | { 8 | menuItems[NEW_GAME].setString("NEW GAME"); 9 | menuItems[RESUME].setString("RESUME"); 10 | menuItems[SIMULATION].setString("SIMULATION"); 11 | menuItems[EXIT].setString("EXIT"); 12 | for (int i = 0; i < MENU_ITEMS; i++) { 13 | menuItems[i].setFont(font); 14 | menuItems[i].setCharacterSize(MENUVIEW_ITEMS_FONTSIZE); 15 | menuItems[i].setPosition( 16 | WINDOW_WIDTH / 2 - 17 | (float)menuItems[i].getGlobalBounds().width / 2, 18 | (float)(i + 1) * MENUITEM_OFFSET - 19 | MENUVIEW_ITEMS_FONTSIZE); 20 | } 21 | } 22 | 23 | MenuView::~MenuView() 24 | { 25 | } 26 | 27 | void 28 | MenuView::prepareView(PongGameStatus &gameStatus) 29 | { 30 | for (int i = 0; i < MENU_ITEMS; i++) { 31 | if (i == gameStatus.getMenuItem()) { 32 | menuItems[i].setFillColor(sf::Color::Green); 33 | } else if (i == RESUME && !gameStatus.getIsGameToResume()) { 34 | menuItems[RESUME].setFillColor(sf::Color::White); 35 | } else { 36 | menuItems[i].setFillColor(sf::Color::Red); 37 | } 38 | } 39 | } 40 | 41 | void 42 | MenuView::displayView(sf::RenderWindow *gameWindow) 43 | { 44 | gameWindow->clear(); 45 | for (int i = 0; i < MENU_ITEMS; i++) { 46 | gameWindow->draw(menuItems[i]); 47 | } 48 | gameWindow->display(); 49 | } 50 | -------------------------------------------------------------------------------- /include/libpmemobj++/experimental/self_relative_ptr_base.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2020, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Base class for self_relative_ptr. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_BASE_HPP 10 | #define LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_BASE_HPP 11 | 12 | #include 13 | 14 | namespace pmem 15 | { 16 | 17 | namespace obj 18 | { 19 | 20 | namespace experimental 21 | { 22 | 23 | /** 24 | * self_relative_ptr base (non-template) class 25 | * 26 | * Implements some of the functionality of the self_relative_ptr class. It 27 | * defines all applicable conversions from and to a self_relative_ptr_base. 28 | * 29 | * It can be used e.g. as a parameter, where self_relative_ptr of any template 30 | * type is required. It is similar to self_relative_ptr (it can point 31 | * to whatever type), but it can be used when you want to have pointer to some 32 | * unspecified self_relative_ptr (with self_relative_ptr it can't be done, 33 | * because: self_relative_ptr* does not convert to self_relative_ptr*). 34 | */ 35 | using self_relative_ptr_base = 36 | pmem::detail::self_relative_ptr_base_impl; 37 | 38 | } /* namespace obj */ 39 | 40 | } /* namespace pmem */ 41 | 42 | } /* namespace experimental */ 43 | 44 | #endif /* LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_BASE_HPP */ 45 | -------------------------------------------------------------------------------- /examples/libpmemobj_cpp_examples_common.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_COMMON_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_COMMON_HPP 6 | 7 | #include 8 | 9 | #ifndef _WIN32 10 | 11 | #include 12 | 13 | #define CREATE_MODE_RW (S_IWUSR | S_IRUSR) 14 | 15 | /* 16 | * file_exists -- checks if file exists 17 | */ 18 | static inline int 19 | file_exists(char const *file) 20 | { 21 | return access(file, F_OK); 22 | } 23 | 24 | /* 25 | * find_last_set_64 -- returns last set bit position or -1 if set bit not found 26 | */ 27 | static inline int 28 | find_last_set_64(uint64_t val) 29 | { 30 | return 64 - __builtin_clzll(val) - 1; 31 | } 32 | 33 | #else 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #define CREATE_MODE_RW (S_IWRITE | S_IREAD) 40 | 41 | /* 42 | * file_exists -- checks if file exists 43 | */ 44 | static inline int 45 | file_exists(char const *file) 46 | { 47 | return _access(file, 0); 48 | } 49 | 50 | /* 51 | * find_last_set_64 -- returns last set bit position or -1 if set bit not found 52 | */ 53 | static inline int 54 | find_last_set_64(uint64_t val) 55 | { 56 | DWORD lz = 0; 57 | 58 | if (BitScanReverse64(&lz, val)) 59 | return (int)lz; 60 | else 61 | return -1; 62 | } 63 | 64 | #endif 65 | 66 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_COMMON_HPP */ 67 | -------------------------------------------------------------------------------- /utils/docker/images/build-image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2016-2021, Intel Corporation 4 | 5 | # 6 | # build-image.sh - prepares a Docker image with -based environment for 7 | # testing (and dev) purpose, tagged with ${CONTAINER_REG}:${OS}-${OS_VER}-${IMG_VER}, 8 | # according to the Dockerfile.${OS}-${OS_VER} file located in the same directory. 9 | # IMG_VER is a version of docker image (it usually relates to project's release tag) 10 | # and it defaults to "devel". 11 | # 12 | 13 | set -e 14 | IMG_VER=${IMG_VER:-devel} 15 | TAG="${OS}-${OS_VER}-${IMG_VER}" 16 | 17 | if [[ -z "${OS}" || -z "${OS_VER}" ]]; then 18 | echo "ERROR: The variables OS and OS_VER have to be set " \ 19 | "(e.g. OS=fedora, OS_VER=32)." 20 | exit 1 21 | fi 22 | 23 | if [[ -z "${CONTAINER_REG}" ]]; then 24 | echo "ERROR: CONTAINER_REG environment variable is not set " \ 25 | "(e.g. \"//\")." 26 | exit 1 27 | fi 28 | 29 | echo "Check if the file Dockerfile.${OS}-${OS_VER} exists" 30 | if [[ ! -f "Dockerfile.${OS}-${OS_VER}" ]]; then 31 | echo "Error: Dockerfile.${OS}-${OS_VER} does not exist." 32 | exit 1 33 | fi 34 | 35 | echo "Build a Docker image tagged with: ${CONTAINER_REG}:${TAG}" 36 | docker build -t ${CONTAINER_REG}:${TAG} \ 37 | --build-arg http_proxy=${http_proxy} \ 38 | --build-arg https_proxy=${https_proxy} \ 39 | -f Dockerfile.${OS}-${OS_VER} . 40 | -------------------------------------------------------------------------------- /tests/detail_common/detail_common.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | /* 5 | * detail_common.cpp -- detail/common.hpp functions tests 6 | */ 7 | #include "unittest.hpp" 8 | 9 | #include 10 | 11 | void 12 | test_next_pow_2() 13 | { 14 | UT_ASSERT(1 == pmem::detail::next_pow_2(0U)); 15 | UT_ASSERT(1 == pmem::detail::next_pow_2(1U)); 16 | UT_ASSERT(2 == pmem::detail::next_pow_2(2U)); 17 | UT_ASSERT(4 == pmem::detail::next_pow_2(3U)); 18 | UT_ASSERT(4096 == pmem::detail::next_pow_2(2507U)); 19 | UT_ASSERT(1 == pmem::detail::next_pow_2(static_cast(0))); 20 | UT_ASSERT(1 == pmem::detail::next_pow_2(static_cast(1))); 21 | UT_ASSERT(2 == pmem::detail::next_pow_2(static_cast(2))); 22 | UT_ASSERT(4 == pmem::detail::next_pow_2(static_cast(3))); 23 | UT_ASSERT(4096 == 24 | pmem::detail::next_pow_2(static_cast(2507))); 25 | UT_ASSERT(1ULL << 32 == 26 | pmem::detail::next_pow_2(static_cast(1ULL << 32))); 27 | UT_ASSERT(1ULL << 33 == 28 | pmem::detail::next_pow_2( 29 | static_cast((1ULL << 32) + 1))); 30 | UT_ASSERT(1ULL << 50 == 31 | pmem::detail::next_pow_2(static_cast( 32 | (1ULL << 49) + (1ULL << 38) + (1ULL << 17) + 2507))); 33 | } 34 | 35 | int 36 | main(int argc, char *argv[]) 37 | { 38 | return run_test([&] { test_next_pow_2(); }); 39 | } 40 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/template_helpers.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019-2020, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Commonly used SFINAE helpers. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP 10 | #define LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP 11 | 12 | #include 13 | 14 | namespace pmem 15 | { 16 | 17 | namespace detail 18 | { 19 | 20 | template 21 | struct make_void { 22 | typedef void type; 23 | }; 24 | template 25 | using void_t = typename make_void::type; 26 | 27 | /* Generic SFINAE helper for expression checks, based on the idea demonstrated 28 | * in ISO C++ paper n4502 */ 29 | template class... Checks> 30 | struct supports_impl { 31 | using type = std::false_type; 32 | }; 33 | template class... Checks> 34 | struct supports_impl...>, Checks...> { 35 | using type = std::true_type; 36 | }; 37 | 38 | template class... Checks> 39 | using supports = typename supports_impl::type; 40 | 41 | template 42 | using is_transparent = typename Compare::is_transparent; 43 | 44 | template 45 | using has_is_transparent = detail::supports; 46 | 47 | } /* namespace detail */ 48 | 49 | } /* namespace pmem */ 50 | 51 | #endif /* LIBPMEMOBJ_CPP_TEMPLATE_HELPERS_HPP */ 52 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.access/data.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // 15 | 16 | // constexpr const _CharT* data() const noexcept; 17 | 18 | #include "unittest.hpp" 19 | 20 | #include 21 | 22 | template 23 | void 24 | test(const CharT *s, size_t len) 25 | { 26 | pmem::obj::basic_string_view sv(s, len); 27 | UT_ASSERT(sv.length() == len); 28 | UT_ASSERT(sv.data() == s); 29 | } 30 | 31 | static void 32 | run() 33 | { 34 | test("ABCDE", 5); 35 | test("a", 1); 36 | 37 | test(L"ABCDE", 5); 38 | test(L"a", 1); 39 | 40 | test(u"ABCDE", 5); 41 | test(u"a", 1); 42 | 43 | test(U"ABCDE", 5); 44 | test(U"a", 1); 45 | 46 | { 47 | constexpr const char *s = "ABC"; 48 | constexpr pmem::obj::basic_string_view sv(s, 2); 49 | static_assert(sv.length() == 2, ""); 50 | static_assert(sv.data() == s, ""); 51 | } 52 | } 53 | 54 | int 55 | main(int argc, char *argv[]) 56 | { 57 | return run_test([&] { run(); }); 58 | } 59 | -------------------------------------------------------------------------------- /examples/pmpong/Pool.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2020, Intel Corporation */ 3 | 4 | #include "Pool.hpp" 5 | 6 | Pool *Pool::pongPool = nullptr; 7 | 8 | Pool::Pool(const std::string &fileName) 9 | { 10 | if (pmem::obj::pool::check(fileName, LAYOUT_NAME) == 1) { 11 | pool = pmem::obj::pool::open(fileName, LAYOUT_NAME); 12 | } else { 13 | pool = pmem::obj::pool::create( 14 | fileName, LAYOUT_NAME, PMEMOBJ_MIN_POOL * 6); 15 | } 16 | } 17 | 18 | Pool::~Pool() 19 | { 20 | try { 21 | pool.close(); 22 | } catch (const std::logic_error &e) { 23 | std::terminate(); 24 | } 25 | } 26 | 27 | Pool * 28 | Pool::getGamePoolFromFile(const std::string &fileName) 29 | { 30 | if (pongPool == nullptr) 31 | pongPool = new Pool(fileName); 32 | return pongPool; 33 | } 34 | 35 | Pool * 36 | Pool::getGamePool() 37 | { 38 | if (pongPool == nullptr) { 39 | return getGamePoolFromFile(DEFAULT_POOLFILE_NAME); 40 | } 41 | return pongPool; 42 | } 43 | 44 | pmem::obj::persistent_ptr 45 | Pool::getGameController() 46 | { 47 | pmem::obj::persistent_ptr root = pool.root(); 48 | if (root != nullptr) { 49 | if (root->gam == nullptr) 50 | pmem::obj::transaction::run(pool, [&] { 51 | root->gam = pmem::obj::make_persistent< 52 | GameController>(); 53 | }); 54 | } 55 | return root->gam; 56 | } 57 | 58 | pmem::obj::pool & 59 | Pool::getPoolToTransaction() 60 | { 61 | return pool; 62 | } 63 | -------------------------------------------------------------------------------- /examples/pmpong/MainGame.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #include "Pool.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int 12 | main(int argc, char *argv[]) 13 | { 14 | int exitCode = EXIT_FAILURE; 15 | std::string mode = ""; 16 | if (argc == 3) { 17 | mode = argv[2]; 18 | } 19 | if (argc < 2 || argc > 3 || (argc == 3 && mode != "-s")) { 20 | std::cout << "Usage: ./pmpong [options]" 21 | << std::endl 22 | << "Options: " << std::endl 23 | << "-s, simulates game between 2 AI players" 24 | << std::endl; 25 | return exitCode; 26 | } 27 | std::string fileName = argv[1]; 28 | try { 29 | Pool *pool = Pool::getGamePoolFromFile(fileName); 30 | pmem::obj::persistent_ptr gameController = 31 | pool->getGameController(); 32 | if (mode == "-s") 33 | gameController->gameLoop(true); 34 | else 35 | gameController->gameLoop(); 36 | delete pool; 37 | exitCode = EXIT_SUCCESS; 38 | } catch (pmem::transaction_error &err) { 39 | std::cerr << err.what() << std::endl; 40 | } catch (pmem::transaction_scope_error &tse) { 41 | std::cerr << tse.what() << std::endl; 42 | } catch (pmem::pool_error &pe) { 43 | std::cerr << pe.what() << std::endl; 44 | } catch (std::logic_error &le) { 45 | std::cerr << le.what() << std::endl; 46 | } catch (std::exception &exc) { 47 | std::cerr << exc.what() << std::endl; 48 | } 49 | 50 | return exitCode; 51 | } 52 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.modifiers/swap.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // 15 | 16 | // void swap(basic_string_view& _other) noexcept 17 | 18 | #include "unittest.hpp" 19 | 20 | #include 21 | 22 | template 23 | void 24 | test(const CharT *s, size_t len) 25 | { 26 | typedef pmem::obj::basic_string_view SV; 27 | { 28 | SV sv1(s); 29 | SV sv2; 30 | 31 | UT_ASSERT(sv1.size() == len); 32 | UT_ASSERT(sv1.data() == s); 33 | UT_ASSERT(sv2.size() == 0); 34 | 35 | sv1.swap(sv2); 36 | UT_ASSERT(sv1.size() == 0); 37 | UT_ASSERT(sv2.size() == len); 38 | UT_ASSERT(sv2.data() == s); 39 | } 40 | } 41 | 42 | static void 43 | run() 44 | { 45 | test("ABCDE", 5); 46 | test("a", 1); 47 | test("", 0); 48 | 49 | test(L"ABCDE", 5); 50 | test(L"a", 1); 51 | test(L"", 0); 52 | 53 | test(u"ABCDE", 5); 54 | test(u"a", 1); 55 | test(u"", 0); 56 | 57 | test(U"ABCDE", 5); 58 | test(U"a", 1); 59 | test(U"", 0); 60 | } 61 | 62 | int 63 | main(int argc, char *argv[]) 64 | { 65 | return run_test([&] { run(); }); 66 | } 67 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/string_assign/initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | #include 19 | 20 | namespace nvobj = pmem::obj; 21 | 22 | using S = pmem::obj::string; 23 | 24 | struct root { 25 | nvobj::persistent_ptr s; 26 | }; 27 | 28 | static void 29 | test(int argc, char *argv[]) 30 | { 31 | if (argc < 2) { 32 | UT_FATAL("usage: %s file-name", argv[0]); 33 | } 34 | 35 | auto path = argv[1]; 36 | auto pop = nvobj::pool::create( 37 | path, "string_test", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 38 | 39 | auto r = pop.root(); 40 | 41 | try { 42 | nvobj::transaction::run( 43 | pop, [&] { r->s = nvobj::make_persistent("123"); }); 44 | 45 | r->s->assign({'a', 'b', 'c'}); 46 | UT_ASSERT(*r->s == "abc"); 47 | 48 | nvobj::transaction::run( 49 | pop, [&] { nvobj::delete_persistent(r->s); }); 50 | } catch (std::exception &e) { 51 | UT_FATALexc(e); 52 | } 53 | 54 | pop.close(); 55 | } 56 | 57 | int 58 | main(int argc, char *argv[]) 59 | { 60 | return run_test([&] { test(argc, argv); }); 61 | } 62 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/string_append/initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using S = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s; 25 | }; 26 | 27 | static void 28 | test(int argc, char *argv[]) 29 | { 30 | if (argc < 2) { 31 | UT_FATAL("usage: %s file-name", argv[0]); 32 | } 33 | 34 | auto path = argv[1]; 35 | auto pop = nvobj::pool::create( 36 | path, "string_test", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 37 | 38 | auto r = pop.root(); 39 | { 40 | try { 41 | nvobj::transaction::run(pop, [&] { 42 | r->s = nvobj::make_persistent("123"); 43 | }); 44 | auto &s = *r->s; 45 | 46 | s.append({'a', 'b', 'c'}); 47 | UT_ASSERT(s == "123abc"); 48 | 49 | nvobj::transaction::run(pop, [&] { 50 | nvobj::delete_persistent(r->s); 51 | }); 52 | } catch (std::exception &e) { 53 | UT_FATALexc(e); 54 | } 55 | } 56 | 57 | pop.close(); 58 | } 59 | 60 | int 61 | main(int argc, char *argv[]) 62 | { 63 | return run_test([&] { test(argc, argv); }); 64 | } 65 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using S = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s; 25 | }; 26 | 27 | static void 28 | test(int argc, char *argv[]) 29 | { 30 | if (argc < 2) { 31 | UT_FATAL("usage: %s file-name", argv[0]); 32 | } 33 | 34 | auto path = argv[1]; 35 | auto pop = nvobj::pool::create( 36 | path, "string_test", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 37 | 38 | auto r = pop.root(); 39 | { 40 | try { 41 | nvobj::transaction::run(pop, [&] { 42 | r->s = nvobj::make_persistent("123"); 43 | }); 44 | auto &s = *r->s; 45 | 46 | s += {'a', 'b', 'c'}; 47 | UT_ASSERT(s == "123abc"); 48 | 49 | nvobj::transaction::run(pop, [&] { 50 | nvobj::delete_persistent(r->s); 51 | }); 52 | } catch (std::exception &e) { 53 | UT_FATALexc(e); 54 | } 55 | } 56 | 57 | pop.close(); 58 | } 59 | 60 | int 61 | main(int argc, char *argv[]) 62 | { 63 | return run_test([&] { test(argc, argv); }); 64 | } 65 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.access/at.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // NOTE: Older versions of clang have a bug where they fail to evaluate 15 | // string_view::at as a constant expression. 16 | // XFAIL: clang-3.4, clang-3.3 17 | 18 | // 19 | 20 | // constexpr const _CharT& at(size_type _pos) const; 21 | 22 | #include "unittest.hpp" 23 | 24 | #include 25 | 26 | template 27 | void 28 | test(const CharT *s, size_t len) 29 | { 30 | pmem::obj::basic_string_view sv(s, len); 31 | UT_ASSERT(sv.length() == len); 32 | for (size_t i = 0; i < len; ++i) { 33 | UT_ASSERT(sv.at(i) == s[i]); 34 | UT_ASSERT(&sv.at(i) == s + i); 35 | } 36 | 37 | try { 38 | (void)sv.at(len); 39 | } catch (const std::out_of_range &) { 40 | return; 41 | } 42 | UT_ASSERT(false); 43 | } 44 | 45 | static void 46 | run() 47 | { 48 | test("ABCDE", 5); 49 | test("a", 1); 50 | 51 | test(L"ABCDE", 5); 52 | test(L"a", 1); 53 | 54 | test(u"ABCDE", 5); 55 | test(u"a", 1); 56 | 57 | test(U"ABCDE", 5); 58 | test(U"a", 1); 59 | } 60 | 61 | int 62 | main(int argc, char *argv[]) 63 | { 64 | return run_test([&] { run(); }); 65 | } 66 | -------------------------------------------------------------------------------- /examples/pmpong/GameOverView.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017, Intel Corporation */ 3 | 4 | #include "GameOverView.hpp" 5 | 6 | GameOverView::GameOverView(sf::Font &font) 7 | { 8 | gameOver.setString("GAME OVER"); 9 | entContinue.setString("press ENTER to continue"); 10 | playerWinner.setString(""); 11 | gameOver.setFont(font); 12 | playerWinner.setFont(font); 13 | entContinue.setFont(font); 14 | gameOver.setCharacterSize(GAMEOVER_FONTSIZE); 15 | playerWinner.setCharacterSize(MENUVIEW_ITEMS_FONTSIZE); 16 | entContinue.setCharacterSize(MENUVIEW_ITEMS_FONTSIZE); 17 | gameOver.setPosition( 18 | WINDOW_WIDTH / 2 - gameOver.getGlobalBounds().width / 2, 0); 19 | playerWinner.setPosition( 20 | WINDOW_WIDTH / 2 - playerWinner.getGlobalBounds().width / 2, 21 | GAMOVERVIEW_OFFSET * 2); 22 | entContinue.setPosition(WINDOW_WIDTH / 2 - 23 | entContinue.getGlobalBounds().width / 2, 24 | WINDOW_HEIGHT - GAMOVERVIEW_OFFSET); 25 | gameOver.setFillColor(sf::Color::Red); 26 | playerWinner.setFillColor(sf::Color::Green); 27 | entContinue.setFillColor(sf::Color::White); 28 | } 29 | 30 | GameOverView::~GameOverView() 31 | { 32 | } 33 | 34 | void 35 | GameOverView::prepareView(PongGameStatus &gameStatus) 36 | { 37 | if (gameStatus.getPlayer1()->getPoints() == POINTS_TO_WIN) 38 | playerWinner.setString("LEFT PLAYER WON!"); 39 | else 40 | playerWinner.setString("RIGHT PLAYER WON!"); 41 | } 42 | 43 | void 44 | GameOverView::displayView(sf::RenderWindow *gameWindow) 45 | { 46 | gameWindow->clear(); 47 | gameWindow->draw(gameOver); 48 | gameWindow->draw(playerWinner); 49 | gameWindow->draw(entContinue); 50 | gameWindow->display(); 51 | } 52 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.modifiers/remove_suffix.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // 15 | 16 | // void remove_suffix(size_type _n) 17 | 18 | #include "unittest.hpp" 19 | 20 | #include 21 | 22 | template 23 | void 24 | test(const CharT *s, size_t len) 25 | { 26 | typedef pmem::obj::basic_string_view SV; 27 | { 28 | SV sv1(s); 29 | UT_ASSERT(sv1.size() == len); 30 | UT_ASSERT(sv1.data() == s); 31 | 32 | if (len > 0) { 33 | sv1.remove_suffix(1); 34 | UT_ASSERT(sv1.size() == (len - 1)); 35 | UT_ASSERT(sv1.data() == s); 36 | sv1.remove_suffix(len - 1); 37 | } 38 | 39 | UT_ASSERT(sv1.size() == 0); 40 | sv1.remove_suffix(0); 41 | UT_ASSERT(sv1.size() == 0); 42 | } 43 | } 44 | 45 | static void 46 | run() 47 | { 48 | test("ABCDE", 5); 49 | test("a", 1); 50 | test("", 0); 51 | 52 | test(L"ABCDE", 5); 53 | test(L"a", 1); 54 | test(L"", 0); 55 | 56 | test(u"ABCDE", 5); 57 | test(u"a", 1); 58 | test(u"", 0); 59 | 60 | test(U"ABCDE", 5); 61 | test(U"a", 1); 62 | test(U"", 0); 63 | } 64 | 65 | int 66 | main(int argc, char *argv[]) 67 | { 68 | return run_test([&] { run(); }); 69 | } 70 | -------------------------------------------------------------------------------- /examples/v/v.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | /* 5 | * v.cpp -- C++ documentation snippets. 6 | */ 7 | 8 | #include 9 | //! [v_property_example] 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace pmem::obj; 16 | using namespace pmem::obj::experimental; 17 | 18 | struct foo { 19 | foo() : counter(10){}; 20 | int counter; 21 | }; 22 | 23 | /* pool root structure */ 24 | struct root { 25 | v f; 26 | }; 27 | 28 | void 29 | v_property_example(pool &pop) 30 | { 31 | auto proot = pop.root(); 32 | 33 | assert(proot->f.get().counter == 10); 34 | 35 | proot->f.get().counter++; 36 | 37 | assert(proot->f.get().counter == 11); 38 | } 39 | //! [v_property_example] 40 | 41 | /* Before running this example, run: 42 | * pmempool create obj --layout="v_example" example_pool 43 | */ 44 | int 45 | main() 46 | { 47 | pool pop; 48 | 49 | /* open already existing pool */ 50 | try { 51 | pop = pool::open("example_pool", "v_example"); 52 | } catch (const pmem::pool_error &e) { 53 | std::cerr << e.what() << std::endl; 54 | std::cerr << "Pool not found" << std::endl; 55 | return 1; 56 | } 57 | 58 | try { 59 | v_property_example(pop); 60 | } catch (const std::exception &e) { 61 | std::cerr << "Exception " << e.what() << std::endl; 62 | return -1; 63 | } 64 | 65 | try { 66 | pop.close(); 67 | } catch (const std::logic_error &e) { 68 | std::cerr << "Exception: " << e.what() << std::endl; 69 | return 2; 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.modifiers/remove_prefix.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // 15 | 16 | // void remove_prefix(size_type _n) 17 | 18 | #include "unittest.hpp" 19 | 20 | #include 21 | 22 | template 23 | void 24 | test(const CharT *s, size_t len) 25 | { 26 | typedef pmem::obj::basic_string_view SV; 27 | { 28 | SV sv1(s); 29 | UT_ASSERT(sv1.size() == len); 30 | UT_ASSERT(sv1.data() == s); 31 | 32 | if (len > 0) { 33 | sv1.remove_prefix(1); 34 | UT_ASSERT(sv1.size() == (len - 1)); 35 | UT_ASSERT(sv1.data() == (s + 1)); 36 | sv1.remove_prefix(len - 1); 37 | } 38 | 39 | UT_ASSERT(sv1.size() == 0); 40 | sv1.remove_prefix(0); 41 | UT_ASSERT(sv1.size() == 0); 42 | } 43 | } 44 | 45 | static void 46 | run() 47 | { 48 | test("ABCDE", 5); 49 | test("a", 1); 50 | test("", 0); 51 | 52 | test(L"ABCDE", 5); 53 | test(L"a", 1); 54 | test(L"", 0); 55 | 56 | test(u"ABCDE", 5); 57 | test(u"a", 1); 58 | test(u"", 0); 59 | 60 | test(U"ABCDE", 5); 61 | test(U"a", 1); 62 | test(U"", 0); 63 | } 64 | 65 | int 66 | main(int argc, char *argv[]) 67 | { 68 | return run_test([&] { run(); }); 69 | } 70 | -------------------------------------------------------------------------------- /include/libpmemobj++/utils.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2016-2019, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Libpmemobj C++ utils. 7 | */ 8 | #ifndef LIBPMEMOBJ_CPP_UTILS_HPP 9 | #define LIBPMEMOBJ_CPP_UTILS_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace pmem 16 | { 17 | 18 | namespace obj 19 | { 20 | 21 | /** 22 | * Retrieve pool handle for the given pointer. 23 | * 24 | * @param[in] that pointer to an object from a persistent memory pool. 25 | * 26 | * @return handle to the pool containing the object. 27 | * 28 | * @throw pool_error if the given pointer does not belong to an open pool. 29 | */ 30 | template 31 | inline pool_base 32 | pool_by_vptr(const T *that) 33 | { 34 | auto pop = pmemobj_pool_by_ptr(that); 35 | if (!pop) 36 | throw pmem::pool_error("Object not in an open pool."); 37 | 38 | return pool_base(pop); 39 | } 40 | 41 | /** 42 | * Retrieve pool handle for the given persistent_ptr. 43 | * 44 | * @param[in] ptr pointer to an object from a persistent memory pool. 45 | * 46 | * @return handle to the pool containing the object. 47 | * 48 | * @throw pool_error if the given pointer does not belong to an open pool. 49 | */ 50 | template 51 | inline pool_base 52 | pool_by_pptr(const persistent_ptr ptr) 53 | { 54 | auto pop = pmemobj_pool_by_oid(ptr.raw()); 55 | if (!pop) 56 | throw pmem::pool_error("Object not in an open pool."); 57 | 58 | return pool_base(pop); 59 | } 60 | 61 | } /* namespace obj */ 62 | 63 | } /* namespace pmem */ 64 | 65 | #endif /* LIBPMEMOBJ_CPP_UTILS_HPP */ 66 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using S = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s; 25 | }; 26 | 27 | static void 28 | test(int argc, char *argv[]) 29 | { 30 | if (argc < 2) { 31 | UT_FATAL("usage: %s file-name", argv[0]); 32 | } 33 | 34 | auto path = argv[1]; 35 | auto pop = nvobj::pool::create( 36 | path, "string_test", 2 * PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 37 | 38 | auto r = pop.root(); 39 | 40 | try { 41 | nvobj::transaction::run(pop, [&] { 42 | r->s = nvobj::make_persistent("123def456"); 43 | }); 44 | 45 | auto &s = *r->s; 46 | 47 | s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'}); 48 | UT_ASSERT(s == "123abc456"); 49 | 50 | nvobj::transaction::run( 51 | pop, [&] { nvobj::delete_persistent(r->s); }); 52 | } catch (std::exception &e) { 53 | UT_FATALexc(e); 54 | } 55 | 56 | pop.close(); 57 | } 58 | 59 | int 60 | main(int argc, char *argv[]) 61 | { 62 | return run_test([&] { test(argc, argv); }); 63 | } 64 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.modifiers/string_insert/iter_initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using S = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s; 25 | }; 26 | 27 | static void 28 | test(int argc, char *argv[]) 29 | { 30 | if (argc < 2) { 31 | UT_FATAL("usage: %s file-name", argv[0]); 32 | } 33 | 34 | auto path = argv[1]; 35 | auto pop = nvobj::pool::create( 36 | path, "string_test", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 37 | 38 | auto r = pop.root(); 39 | 40 | try { 41 | nvobj::transaction::run(pop, [&] { 42 | r->s = nvobj::make_persistent("123456"); 43 | }); 44 | 45 | auto &s = *r->s; 46 | 47 | S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'}); 48 | UT_ASSERT(i - s.begin() == 3); 49 | UT_ASSERT(s == "123abc456"); 50 | 51 | nvobj::transaction::run( 52 | pop, [&] { nvobj::delete_persistent(r->s); }); 53 | } catch (std::exception &e) { 54 | UT_FATALexc(e); 55 | } 56 | 57 | pop.close(); 58 | } 59 | 60 | int 61 | main(int argc, char *argv[]) 62 | { 63 | return run_test([&] { test(argc, argv); }); 64 | } 65 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.nonmembers/string.io/get_line_rv.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | // UNSUPPORTED: c++98, c++03 11 | 12 | // 13 | 14 | // template 15 | // basic_istream& 16 | // getline(basic_istream&& is, 17 | // basic_string& str); 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "min_allocator.h" 24 | 25 | int main() 26 | { 27 | { 28 | std::string s("initial text"); 29 | getline(std::istringstream(" abc\n def\n ghij"), s); 30 | assert(s == " abc"); 31 | } 32 | { 33 | std::wstring s(L"initial text"); 34 | getline(std::wistringstream(L" abc\n def\n ghij"), s); 35 | assert(s == L" abc"); 36 | } 37 | { 38 | typedef std::basic_string, min_allocator> S; 39 | S s("initial text"); 40 | getline(std::istringstream(" abc\n def\n ghij"), s); 41 | assert(s == " abc"); 42 | } 43 | { 44 | typedef std::basic_string, min_allocator> S; 45 | S s(L"initial text"); 46 | getline(std::wistringstream(L" abc\n def\n ghij"), s); 47 | assert(s == L" abc"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.modifiers/clear.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | #include 20 | 21 | namespace nvobj = pmem::obj; 22 | 23 | using C = container_t; 24 | 25 | struct root { 26 | nvobj::persistent_ptr v; 27 | }; 28 | 29 | static void 30 | test(int argc, char *argv[]) 31 | { 32 | if (argc < 2) { 33 | UT_FATAL("usage: %s file-name", argv[0]); 34 | } 35 | 36 | auto path = argv[1]; 37 | auto pop = nvobj::pool::create(path, "VectorTest: clear", 38 | PMEMOBJ_MIN_POOL * 2, 39 | S_IWUSR | S_IRUSR); 40 | 41 | auto r = pop.root(); 42 | 43 | int a[] = {1, 2, 3}; 44 | 45 | try { 46 | nvobj::transaction::run(pop, [&] { 47 | r->v = nvobj::make_persistent(a, a + 3); 48 | }); 49 | 50 | r->v->clear(); 51 | UT_ASSERT(r->v->empty()); 52 | 53 | nvobj::transaction::run( 54 | pop, [&] { nvobj::delete_persistent(r->v); }); 55 | 56 | } catch (std::exception &e) { 57 | UT_FATALexc(e); 58 | } 59 | 60 | pop.close(); 61 | } 62 | 63 | int 64 | main(int argc, char *argv[]) 65 | { 66 | return run_test([&] { test(argc, argv); }); 67 | } 68 | -------------------------------------------------------------------------------- /tests/external/libcxx/array/size_and_alignment.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2018-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | #include 17 | 18 | #include 19 | 20 | template 21 | struct MyArray { 22 | T elems[Size]; 23 | }; 24 | 25 | template 26 | void 27 | test() 28 | { 29 | typedef T CArrayT[Size]; 30 | typedef pmem::obj::array ArrayT; 31 | typedef MyArray MyArrayT; 32 | static_assert(sizeof(ArrayT) == sizeof(CArrayT), ""); 33 | static_assert(sizeof(ArrayT) == sizeof(MyArrayT), ""); 34 | static_assert(alignof(ArrayT) == alignof(MyArrayT), ""); 35 | } 36 | 37 | template 38 | void 39 | test_zero_sized() 40 | { 41 | typedef pmem::obj::array ArrayT; 42 | static_assert(sizeof(ArrayT) == sizeof(T), ""); 43 | } 44 | 45 | template 46 | void 47 | test_type() 48 | { 49 | test(); 50 | test(); 51 | test_zero_sized(); 52 | } 53 | 54 | // static_assert(sizeof(void*) == 4, ""); 55 | 56 | int 57 | main(int argc, char *argv[]) 58 | { 59 | return run_test([&] { 60 | test_type(); 61 | test_type(); 62 | test_type(); 63 | test_type(); 64 | test_type(); 65 | }); 66 | } 67 | -------------------------------------------------------------------------------- /examples/pmpong/PongGameStatus.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2017-2018, Intel Corporation */ 3 | 4 | #ifndef LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PONGGAMESTATUS_HPP 5 | #define LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PONGGAMESTATUS_HPP 6 | 7 | #include "Ball.hpp" 8 | #include "GameConstants.hpp" 9 | #include "Paddle.hpp" 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | enum game_state { MATCH, MENU, GAME_OVER, SIMULATE }; 16 | 17 | class PongGameStatus { 18 | public: 19 | PongGameStatus(); 20 | ~PongGameStatus(); 21 | 22 | void startBall(float ballSpeed); 23 | void reset(); 24 | void movePaddles(); 25 | void lookForCollisions(bool increaseBallVelocity); 26 | void actualizeStatus(); 27 | void simulate(); 28 | void setMenuItem(int numb); 29 | void setIsGameToResume(bool isGameToRes); 30 | void setGameState(game_state state); 31 | 32 | int getMenuItem(); 33 | 34 | float randomizeFloatValue(float min, float max); 35 | 36 | bool score(); 37 | bool checkIfAnyPlayerWon(); 38 | bool randomizeDirection(); 39 | bool getIsGameToResume(); 40 | 41 | pmem::obj::persistent_ptr getPlayer1(); 42 | pmem::obj::persistent_ptr getPlayer2(); 43 | pmem::obj::persistent_ptr getBall(); 44 | 45 | game_state getGameState(); 46 | 47 | private: 48 | pmem::obj::persistent_ptr player1; 49 | pmem::obj::persistent_ptr player2; 50 | pmem::obj::persistent_ptr ball; 51 | 52 | pmem::obj::p menuItem; 53 | pmem::obj::p isGameToResume; 54 | pmem::obj::p actualGameState; 55 | }; 56 | #endif /* LIBPMEMOBJ_CPP_EXAMPLES_PMPONG_PONGGAMESTATUS_HPP */ 57 | -------------------------------------------------------------------------------- /utils/docker/images/0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch: -------------------------------------------------------------------------------- 1 | From d633d3b0a5f03be280efb80a69b9d5ed4e9c4d56 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= 3 | Date: Tue, 14 Jul 2020 13:58:34 +0200 4 | Subject: [PATCH] fix generating gcov files and turn-off verbose log 5 | 6 | --- 7 | codecov | 6 +++--- 8 | 1 file changed, 3 insertions(+), 3 deletions(-) 9 | 10 | diff --git a/codecov b/codecov 11 | index e702ecd..0a2f4d8 100755 12 | --- a/codecov 13 | +++ b/codecov 14 | @@ -1108,9 +1108,9 @@ then 15 | if [ "$ft_gcovout" = "0" ]; 16 | then 17 | # suppress gcov output 18 | - bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true 19 | + bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -execdir $gcov_exe -pb $gcov_arg {} \;" >/dev/null 2>&1 || true 20 | else 21 | - bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true 22 | + bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -execdir $gcov_exe -pb $gcov_arg {} \;" || true 23 | fi 24 | else 25 | say "${e}==>${x} gcov disabled" 26 | @@ -1425,7 +1425,7 @@ do 27 | report_len=$(wc -c < "$file") 28 | if [ "$report_len" -ne 0 ]; 29 | then 30 | - say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" 31 | + #say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" 32 | # append to to upload 33 | _filename=$(basename "$file") 34 | if [ "${_filename##*.}" = 'gcov' ]; 35 | -- 36 | 2.25.1 37 | 38 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/check_persistent_ptr_array.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2016-2018, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Compile time type check for make_persistent. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_CHECK_PERSISTENT_PTR_ARRAY_HPP 10 | #define LIBPMEMOBJ_CPP_CHECK_PERSISTENT_PTR_ARRAY_HPP 11 | 12 | #include 13 | 14 | #include 15 | 16 | namespace pmem 17 | { 18 | 19 | namespace detail 20 | { 21 | 22 | /* 23 | * Typedef checking if given type is not an array. 24 | */ 25 | template 26 | struct pp_if_not_array { 27 | typedef obj::persistent_ptr type; 28 | }; 29 | 30 | /* 31 | * Typedef checking if given type is not an array. 32 | */ 33 | template 34 | struct pp_if_not_array { 35 | }; 36 | 37 | /* 38 | * Typedef checking if given type is not an array. 39 | */ 40 | template 41 | struct pp_if_not_array { 42 | }; 43 | 44 | /* 45 | * Typedef checking if given type is an array. 46 | */ 47 | template 48 | struct pp_if_array; 49 | 50 | /* 51 | * Typedef checking if given type is an array. 52 | */ 53 | template 54 | struct pp_if_array { 55 | typedef obj::persistent_ptr type; 56 | }; 57 | 58 | /* 59 | * Typedef checking if given type is an array. 60 | */ 61 | template 62 | struct pp_if_size_array; 63 | 64 | /* 65 | * Typedef checking if given type is an array. 66 | */ 67 | template 68 | struct pp_if_size_array { 69 | typedef obj::persistent_ptr type; 70 | }; 71 | 72 | } /* namespace detail */ 73 | 74 | } /* namespace pmem */ 75 | 76 | #endif /* LIBPMEMOBJ_CPP_CHECK_PERSISTENT_PTR_ARRAY_HPP */ 77 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | // UNSUPPORTED: c++98, c++03 11 | 12 | // 13 | 14 | // template 15 | // basic_istream& 16 | // getline(basic_istream&& is, 17 | // basic_string& str, charT delim); 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "min_allocator.h" 24 | 25 | int main() 26 | { 27 | { 28 | std::string s("initial text"); 29 | getline(std::istringstream(" abc* def* ghij"), s, '*'); 30 | assert(s == " abc"); 31 | } 32 | { 33 | std::wstring s(L"initial text"); 34 | getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); 35 | assert(s == L" abc"); 36 | } 37 | { 38 | typedef std::basic_string, min_allocator> S; 39 | S s("initial text"); 40 | getline(std::istringstream(" abc* def* ghij"), s, '*'); 41 | assert(s == " abc"); 42 | } 43 | { 44 | typedef std::basic_string, min_allocator> S; 45 | S s(L"initial text"); 46 | getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); 47 | assert(s == L" abc"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /utils/docker/images/install-libndctl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2018-2021, Intel Corporation 4 | 5 | # 6 | # install-libndctl.sh - installs libndctl 7 | # 8 | 9 | set -e 10 | 11 | if [[ -z "${OS}" ]]; then 12 | echo "ERROR: The variable OS has to be set (e.g. OS=fedora)." 13 | exit 1 14 | fi 15 | 16 | echo "==== clone ndctl repo ====" 17 | git clone https://github.com/pmem/ndctl.git 18 | cd ndctl 19 | git checkout v69 20 | 21 | if [ "${OS}" = "fedora" ]; then 22 | 23 | echo "==== setup rpmbuild tree ====" 24 | rpmdev-setuptree 25 | 26 | RPMDIR=${HOME}/rpmbuild/ 27 | VERSION=$(./git-version) 28 | SPEC=./rhel/ndctl.spec 29 | 30 | echo "==== create source tarball =====" 31 | git archive --format=tar --prefix="ndctl-${VERSION}/" HEAD | gzip > "${RPMDIR}/SOURCES/ndctl-${VERSION}.tar.gz" 32 | 33 | echo "==== build ndctl ====" 34 | ./autogen.sh 35 | ./configure --disable-docs 36 | make -j$(nproc) 37 | 38 | echo "==== build ndctl packages ====" 39 | rpmbuild -ba ${SPEC} 40 | 41 | echo "==== install ndctl packages ====" 42 | rpm -i ${RPMDIR}/RPMS/x86_64/*.rpm 43 | 44 | echo "==== cleanup ====" 45 | rm -rf ${RPMDIR} 46 | 47 | else 48 | 49 | echo "==== set OS-specific options ====" 50 | OS_SPECIFIC="" 51 | LIBDIR=/usr/lib 52 | case $(echo ${OS} | cut -d'-' -f1) in 53 | centos|opensuse) 54 | LIBDIR=/usr/lib64 55 | ;; 56 | archlinux) 57 | OS_SPECIFIC="--disable-dependency-tracking" 58 | ;; 59 | esac 60 | 61 | echo "==== build ndctl ====" 62 | ./autogen.sh 63 | ./configure --libdir=${LIBDIR} --disable-docs ${OS_SPECIFIC} 64 | make -j$(nproc) 65 | 66 | echo "==== install ndctl ====" 67 | make -j$(nproc) install 68 | 69 | echo "==== cleanup ====" 70 | 71 | fi 72 | 73 | cd .. 74 | rm -rf ndctl 75 | -------------------------------------------------------------------------------- /examples/pmpong/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-3-Clause 2 | # Copyright 2018-2020, Intel Corporation 3 | 4 | cmake_minimum_required(VERSION 3.4) 5 | project(pmpong CXX) 6 | 7 | set(CXX_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | 10 | include(FindThreads) 11 | 12 | if(NOT WIN32) 13 | find_package(PkgConfig QUIET) 14 | endif() 15 | 16 | if(PKG_CONFIG_FOUND) 17 | pkg_check_modules(LIBPMEMOBJ++ REQUIRED libpmemobj++) 18 | 19 | pkg_check_modules(SFML REQUIRED sfml-all>=2.4) 20 | else() 21 | find_package(LIBPMEMOBJ++ REQUIRED) 22 | 23 | # SFML 2.5 has different cmake interface than <= 2.4 so previous versions are not supported 24 | find_package(SFML 2.5 REQUIRED COMPONENTS graphics window system) 25 | set(SFML_LIBRARIES sfml-graphics sfml-window sfml-system) 26 | endif() 27 | 28 | link_directories(${LIBPMEMOBJ++_LIBRARY_DIRS}) 29 | 30 | add_executable(pmpong Ball.cpp GameController.cpp GameOverView.cpp 31 | GameView.cpp MainGame.cpp MenuView.cpp Paddle.cpp 32 | PongGameStatus.cpp Pool.cpp) 33 | target_include_directories(pmpong PUBLIC ${SFML_INCLUDE_DIR} ${LIBPMEMOBJ++_INCLUDE_DIRS} .) 34 | target_link_libraries(pmpong ${LIBPMEMOBJ++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${SFML_LIBRARIES}) 35 | 36 | if(NOT WIN32) 37 | find_program(FCLIST NAMES fc-list) 38 | if(NOT FCLIST) 39 | message(WARNING "fc-list not found. Install fontconfig to allow examples-pmpong to automatically find fonts.") 40 | endif() 41 | 42 | execute_process(COMMAND bash -c "fc-list --format='%{file}\n' | head -n1 | tr -d '\n'" OUTPUT_VARIABLE FONT_PATH ERROR_QUIET) 43 | set(font ${FONT_PATH}) 44 | else() 45 | set(font "C:/Windows/Fonts/Arial.ttf") 46 | endif() 47 | 48 | target_compile_options(pmpong PUBLIC -DLIBPMEMOBJ_CPP_PMPONG_FONT_PATH="${font}") 49 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.cons/initializer_list_assignment.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace nvobj = pmem::obj; 24 | 25 | using C = pmem::obj::string; 26 | 27 | struct root { 28 | nvobj::persistent_ptr s; 29 | }; 30 | 31 | static void 32 | test(int argc, char *argv[]) 33 | { 34 | if (argc < 2) { 35 | UT_FATAL("usage: %s file-name", argv[0]); 36 | } 37 | 38 | auto path = argv[1]; 39 | auto pop = nvobj::pool::create( 40 | path, "string_test", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 41 | 42 | auto r = pop.root(); 43 | 44 | try { 45 | nvobj::transaction::run( 46 | pop, [&] { r->s = nvobj::make_persistent(); }); 47 | 48 | *r->s = {'a', 'b', 'c'}; 49 | UT_ASSERT(*r->s == "abc"); 50 | 51 | nvobj::transaction::run( 52 | pop, [&] { nvobj::delete_persistent(r->s); }); 53 | } catch (std::exception &e) { 54 | UT_FATALexc(e); 55 | } 56 | 57 | pop.close(); 58 | } 59 | 60 | int 61 | main(int argc, char *argv[]) 62 | { 63 | return run_test([&] { test(argc, argv); }); 64 | } 65 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.capacity/empty.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | #include 20 | 21 | namespace nvobj = pmem::obj; 22 | 23 | using C = container_t; 24 | 25 | struct root { 26 | nvobj::persistent_ptr v; 27 | }; 28 | 29 | static void 30 | test(int argc, char *argv[]) 31 | { 32 | if (argc < 2) { 33 | UT_FATAL("usage: %s file-name", argv[0]); 34 | } 35 | 36 | auto path = argv[1]; 37 | auto pop = nvobj::pool::create(path, "VectorTest: empty", 38 | PMEMOBJ_MIN_POOL * 2, 39 | S_IWUSR | S_IRUSR); 40 | 41 | auto r = pop.root(); 42 | 43 | try { 44 | nvobj::transaction::run( 45 | pop, [&] { r->v = nvobj::make_persistent(); }); 46 | 47 | UT_ASSERT(r->v->empty()); 48 | r->v->push_back(C::value_type(1)); 49 | UT_ASSERT(!r->v->empty()); 50 | r->v->clear(); 51 | UT_ASSERT(r->v->empty()); 52 | 53 | nvobj::transaction::run( 54 | pop, [&] { nvobj::delete_persistent(r->v); }); 55 | 56 | } catch (std::exception &e) { 57 | UT_FATALexc(e); 58 | } 59 | 60 | pop.close(); 61 | } 62 | 63 | int 64 | main(int argc, char *argv[]) 65 | { 66 | return run_test([&] { test(argc, argv); }); 67 | } 68 | -------------------------------------------------------------------------------- /include/libpmemobj++/detail/make_atomic_impl.hpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2016-2019, Intel Corporation */ 3 | 4 | /** 5 | * @file 6 | * Implementation details of atomic allocation and construction. 7 | */ 8 | 9 | #ifndef LIBPMEMOBJ_CPP_MAKE_ATOMIC_IMPL_HPP 10 | #define LIBPMEMOBJ_CPP_MAKE_ATOMIC_IMPL_HPP 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace pmem 20 | { 21 | 22 | namespace detail 23 | { 24 | 25 | /* 26 | * C-style function called by the allocator. 27 | * 28 | * The arg is a tuple containing constructor parameters. 29 | */ 30 | template 31 | int 32 | obj_constructor(PMEMobjpool *pop, void *ptr, void *arg) 33 | { 34 | auto ret = c_style_construct(ptr, arg); 35 | 36 | if (ret != 0) 37 | return -1; 38 | 39 | pmemobj_persist(pop, ptr, sizeof(T)); 40 | 41 | return 0; 42 | } 43 | 44 | /* 45 | * Constructor used for atomic array allocations. 46 | * 47 | * Returns -1 if an exception was thrown during T's construction, 48 | * 0 otherwise. 49 | */ 50 | template 51 | int 52 | array_constructor(PMEMobjpool *pop, void *ptr, void *arg) 53 | { 54 | std::size_t N = *static_cast(arg); 55 | 56 | T *tptr = static_cast(ptr); 57 | try { 58 | for (std::size_t i = 0; i < N; ++i) 59 | detail::create(tptr + i); 60 | } catch (...) { 61 | return -1; 62 | } 63 | 64 | pmemobj_persist(pop, ptr, sizeof(T) * N); 65 | 66 | return 0; 67 | } 68 | 69 | } /* namespace detail */ 70 | 71 | } /* namespace pmem */ 72 | 73 | #endif /* LIBPMEMOBJ_CPP_MAKE_ATOMIC_IMPL_HPP */ 74 | -------------------------------------------------------------------------------- /tests/aggregate_initialization/aggregate_initialization.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2018-2020, Intel Corporation */ 3 | 4 | #include "unittest.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #define LAYOUT "cpp" 15 | 16 | namespace nvobj = pmem::obj; 17 | 18 | struct foo { 19 | nvobj::p a; 20 | nvobj::p b; 21 | }; 22 | 23 | struct root { 24 | nvobj::persistent_ptr pfoo; 25 | }; 26 | 27 | void 28 | test_aggregate(nvobj::pool &pop) 29 | { 30 | nvobj::persistent_ptr r = pop.root(); 31 | 32 | #if !__cpp_lib_is_aggregate 33 | /* make sure aggregate initialization is available */ 34 | UT_ASSERT(0); 35 | #endif 36 | 37 | try { 38 | nvobj::transaction::run(pop, [&] { 39 | r->pfoo = nvobj::make_persistent(2, 3); 40 | 41 | UT_ASSERTeq(r->pfoo->a, 2); 42 | UT_ASSERTeq(r->pfoo->b, 3); 43 | 44 | nvobj::delete_persistent(r->pfoo); 45 | }); 46 | } catch (...) { 47 | UT_ASSERT(0); 48 | } 49 | } 50 | 51 | static void 52 | test(int argc, char *argv[]) 53 | { 54 | if (argc != 2) 55 | UT_FATAL("usage: %s file-name", argv[0]); 56 | 57 | const char *path = argv[1]; 58 | 59 | nvobj::pool pop; 60 | 61 | try { 62 | pop = nvobj::pool::create(path, LAYOUT, PMEMOBJ_MIN_POOL, 63 | S_IWUSR | S_IRUSR); 64 | } catch (pmem::pool_error &pe) { 65 | UT_FATAL("!pool::create: %s %s", pe.what(), path); 66 | } 67 | 68 | test_aggregate(pop); 69 | 70 | pop.close(); 71 | } 72 | 73 | int 74 | main(int argc, char *argv[]) 75 | { 76 | return run_test([&] { test(argc, argv); }); 77 | } 78 | -------------------------------------------------------------------------------- /tests/vector/vector_std_arg.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: BSD-3-Clause 2 | /* Copyright 2019-2020, Intel Corporation */ 3 | 4 | #include "list_wrapper.hpp" 5 | #include "unittest.hpp" 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace nvobj = pmem::obj; 12 | 13 | using pmem_vec = container_t; 14 | using std_vec = std::vector; 15 | 16 | struct root { 17 | nvobj::persistent_ptr pptr; 18 | }; 19 | 20 | void 21 | check_vector(const pmem_vec &v1, const std_vec &v2) 22 | { 23 | UT_ASSERTeq(v1.size(), v2.size()); 24 | 25 | for (unsigned i = 0; i < v1.size(); ++i) 26 | UT_ASSERTeq(v1[i], v2[i]); 27 | } 28 | 29 | static void 30 | test(int argc, char *argv[]) 31 | { 32 | if (argc < 2) { 33 | UT_FATAL("usage: %s file-name", argv[0]); 34 | } 35 | auto path = argv[1]; 36 | auto pop = nvobj::pool::create( 37 | path, "VectorTest", PMEMOBJ_MIN_POOL * 2, S_IWUSR | S_IRUSR); 38 | 39 | auto r = pop.root(); 40 | 41 | try { 42 | std_vec stdvector(10U, 1); 43 | 44 | nvobj::transaction::run(pop, [&] { 45 | r->pptr = nvobj::make_persistent(stdvector); 46 | }); 47 | 48 | pmem_vec &pvector = *(r->pptr); 49 | 50 | check_vector(pvector, stdvector); 51 | 52 | stdvector.assign(20U, 2); 53 | pvector.assign(stdvector); 54 | 55 | check_vector(pvector, stdvector); 56 | 57 | stdvector = std_vec(30U, 3); 58 | pvector = stdvector; 59 | 60 | check_vector(pvector, stdvector); 61 | 62 | nvobj::transaction::run(pop, [&] { 63 | nvobj::delete_persistent(r->pptr); 64 | }); 65 | } catch (std::exception &e) { 66 | UT_FATALexc(e); 67 | } 68 | 69 | pop.close(); 70 | } 71 | 72 | int 73 | main(int argc, char *argv[]) 74 | { 75 | return run_test([&] { test(argc, argv); }); 76 | } 77 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.modifiers/pop_back.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | #include 20 | 21 | namespace nvobj = pmem::obj; 22 | 23 | using C = container_t; 24 | 25 | struct root { 26 | nvobj::persistent_ptr c; 27 | }; 28 | 29 | static void 30 | test(int argc, char *argv[]) 31 | { 32 | if (argc < 2) { 33 | UT_FATAL("usage: %s file-name", argv[0]); 34 | } 35 | 36 | auto path = argv[1]; 37 | auto pop = nvobj::pool::create(path, "VectorTest: pop_back", 38 | PMEMOBJ_MIN_POOL * 2, 39 | S_IWUSR | S_IRUSR); 40 | 41 | auto r = pop.root(); 42 | 43 | try { 44 | nvobj::transaction::run( 45 | pop, [&] { r->c = nvobj::make_persistent(); }); 46 | r->c->push_back(1); 47 | UT_ASSERT(r->c->size() == 1); 48 | r->c->pop_back(); 49 | UT_ASSERT(r->c->size() == 0); 50 | r->c->pop_back(); 51 | UT_ASSERT(r->c->size() == 0); 52 | nvobj::transaction::run( 53 | pop, [&] { nvobj::delete_persistent(r->c); }); 54 | } catch (std::exception &e) { 55 | UT_FATALexc(e); 56 | } 57 | 58 | pop.close(); 59 | } 60 | 61 | int 62 | main(int argc, char *argv[]) 63 | { 64 | return run_test([&] { test(argc, argv); }); 65 | } 66 | -------------------------------------------------------------------------------- /examples/pman/map: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # # ## # # 3 | # # ############ # ## # ############ # # 4 | # # # # ## # # # # 5 | # # ###### # # ###### # # 6 | # # # # # # ## # # # # # 7 | # ##### #### ## #### ##### # 8 | # # # # ## # # # # 9 | # # # ############ ############ # # # 10 | # # # # # # # # 11 | # # # # ######## ###### ######## # # # # 12 | # # 13 | # ####### ### ########### ### ######## # 14 | # # ## # # 15 | # ####### ######## ## ####### ######## # 16 | # # ## # # 17 | # # ############ # ## # ############ # # 18 | # # # # # 19 | # # ########## ##### #### ########## # # 20 | # # # # . # # # # 21 | # # # # # # # 22 | # # ########## ########## ########## # # 23 | # # # # # 24 | # # ############ # ## # ############ # # 25 | # # ## # # 26 | # ####### ######## ## ####### ######## # 27 | # # ## # # 28 | # ####### ### ########### ### ######## # 29 | # # 30 | # # # # ######## ###### ######## # # # # 31 | # # # # # # # # 32 | # # # ############ ############ # # # 33 | # # # # ## # # # # 34 | # ##### #### ## #### ##### # 35 | # # # # # # ## # # # # # 36 | # # ###### # # ###### # # 37 | # # # # ## # # # # 38 | # # ############ # ## # ############ # # 39 | # # ## # # 40 | ######################################## 41 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.require/contiguous.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | // 11 | 12 | // An string is a contiguous container 13 | 14 | #include 15 | #include 16 | 17 | #include "test_allocator.h" 18 | #include "min_allocator.h" 19 | 20 | 21 | template 22 | void test_contiguous ( const C &c ) 23 | { 24 | for ( size_t i = 0; i < c.size(); ++i ) 25 | assert ( *(c.begin() + static_cast(i)) == *(std::addressof(*c.begin()) + i)); 26 | } 27 | 28 | int main() 29 | { 30 | { 31 | typedef std::string S; 32 | test_contiguous(S()); 33 | test_contiguous(S("1")); 34 | test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890")); 35 | } 36 | 37 | { 38 | typedef test_allocator A; 39 | typedef std::basic_string, A> S; 40 | test_contiguous(S(A(3))); 41 | test_contiguous(S("1", A(5))); 42 | test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); 43 | } 44 | #if TEST_STD_VER >= 11 45 | { 46 | typedef min_allocator A; 47 | typedef std::basic_string, A> S; 48 | test_contiguous(S(A{})); 49 | test_contiguous(S("1", A())); 50 | test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A())); 51 | } 52 | #endif 53 | } 54 | -------------------------------------------------------------------------------- /utils/docker/images/push-image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Copyright 2016-2021, Intel Corporation 4 | 5 | # 6 | # push-image.sh - pushes the Docker image tagged as described in 7 | # ./build-image.sh, to the ${CONTAINER_REG}. 8 | # 9 | # The script utilizes ${CONTAINER_REG_USER} and ${CONTAINER_REG_PASS} variables to 10 | # log in to the ${CONTAINER_REG}. 11 | # 12 | 13 | set -e 14 | IMG_VER=${IMG_VER:-devel} 15 | TAG="${OS}-${OS_VER}-${IMG_VER}" 16 | 17 | if [[ -z "${OS}" || -z "${OS_VER}" ]]; then 18 | echo "ERROR: The variables OS and OS_VER have to be set " \ 19 | "(e.g. OS=fedora, OS_VER=32)." 20 | exit 1 21 | fi 22 | 23 | if [[ -z "${CONTAINER_REG}" ]]; then 24 | echo "ERROR: CONTAINER_REG environment variable is not set " \ 25 | "(e.g. \"//\")." 26 | exit 1 27 | fi 28 | 29 | if [[ -z "${CONTAINER_REG_USER}" || -z "${CONTAINER_REG_PASS}" ]]; then 30 | echo "ERROR: variables CONTAINER_REG_USER=\"${CONTAINER_REG_USER}\" " \ 31 | "and CONTAINER_REG_PASS=\"${CONTAINER_REG_PASS}\"" \ 32 | "have to be set properly to allow login to the Container Registry." 33 | exit 1 34 | fi 35 | 36 | echo "Check if the image tagged with ${CONTAINER_REG}:${TAG} exists locally" 37 | if [[ ! $(docker images -a | awk -v pattern="^${CONTAINER_REG}:${TAG}\$" \ 38 | '$1":"$2 ~ pattern') ]] 39 | then 40 | echo "ERROR: Docker image tagged ${CONTAINER_REG}:${TAG} does not exist locally." 41 | exit 1 42 | fi 43 | 44 | echo "Log in to the Container Registry: ${CONTAINER_REG}" 45 | echo "${CONTAINER_REG_PASS}" | docker login "${CONTAINER_REG}" -u="${CONTAINER_REG_USER}" --password-stdin 46 | 47 | echo "Push the image '${CONTAINER_REG}:${TAG}' to the Container Registry." 48 | docker push ${CONTAINER_REG}:${TAG} 49 | echo "Image pushed." 50 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.iterators/cend.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using C = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s1, s2; 25 | }; 26 | 27 | template 28 | void 29 | test(const S &s) 30 | { 31 | typename S::const_iterator ce = s.cend(); 32 | UT_ASSERT(ce == s.end()); 33 | } 34 | 35 | static void 36 | test(int argc, char *argv[]) 37 | { 38 | if (argc < 2) { 39 | UT_FATAL("usage: %s file-name", argv[0]); 40 | } 41 | 42 | auto path = argv[1]; 43 | auto pop = nvobj::pool::create( 44 | path, "StringTest", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 45 | 46 | auto r = pop.root(); 47 | 48 | try { 49 | nvobj::transaction::run(pop, [&] { 50 | r->s1 = nvobj::make_persistent(); 51 | r->s2 = nvobj::make_persistent("123"); 52 | }); 53 | 54 | test(*r->s1); 55 | test(*r->s2); 56 | 57 | nvobj::transaction::run(pop, [&] { 58 | nvobj::delete_persistent(r->s1); 59 | nvobj::delete_persistent(r->s2); 60 | }); 61 | } catch (std::exception &e) { 62 | UT_FATALexc(e); 63 | } 64 | 65 | pop.close(); 66 | } 67 | 68 | int 69 | main(int argc, char *argv[]) 70 | { 71 | return run_test([&] { test(argc, argv); }); 72 | } 73 | -------------------------------------------------------------------------------- /tests/external/libcxx/string.view/string.view.access/index.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | // 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright 2020, Intel Corporation 10 | // 11 | // Modified to test pmem::obj containers 12 | // 13 | 14 | // 15 | 16 | // constexpr const _CharT& operator[](size_type _pos) const; 17 | 18 | #include "unittest.hpp" 19 | 20 | #include 21 | 22 | #include 23 | 24 | template 25 | void 26 | test(const CharT *s, size_t len) 27 | { 28 | typedef pmem::obj::basic_string_view SV; 29 | SV sv(s, len); 30 | static_assert(std::is_same::value, 32 | "must be const_reference"); 33 | UT_ASSERT(noexcept(sv[0]) == true); 34 | UT_ASSERT(sv.length() == len); 35 | for (size_t i = 0; i < len; ++i) { 36 | UT_ASSERT(sv[i] == s[i]); 37 | UT_ASSERT(&sv[i] == s + i); 38 | } 39 | } 40 | 41 | static void 42 | run() 43 | { 44 | test("ABCDE", 5); 45 | test("a", 1); 46 | 47 | test(L"ABCDE", 5); 48 | test(L"a", 1); 49 | 50 | test(u"ABCDE", 5); 51 | test(u"a", 1); 52 | 53 | test(U"ABCDE", 5); 54 | test(U"a", 1); 55 | 56 | { 57 | constexpr pmem::obj::basic_string_view sv("ABC", 2); 58 | static_assert(sv.length() == 2, ""); 59 | static_assert(sv[0] == 'A', ""); 60 | static_assert(sv[1] == 'B', ""); 61 | } 62 | } 63 | 64 | int 65 | main(int argc, char *argv[]) 66 | { 67 | return run_test([&] { run(); }); 68 | } 69 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.capacity/max_size.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | #include 20 | 21 | namespace nvobj = pmem::obj; 22 | 23 | using C = container_t; 24 | 25 | struct root { 26 | nvobj::persistent_ptr v; 27 | }; 28 | 29 | static void 30 | test(int argc, char *argv[]) 31 | { 32 | if (argc < 2) { 33 | UT_FATAL("usage: %s file-name", argv[0]); 34 | } 35 | 36 | auto path = argv[1]; 37 | auto pop = nvobj::pool::create(path, "VectorTest: max_size", 38 | PMEMOBJ_MIN_POOL * 2, 39 | S_IWUSR | S_IRUSR); 40 | 41 | auto r = pop.root(); 42 | 43 | try { 44 | const C::difference_type max_dist = 45 | static_cast( 46 | std::numeric_limits::max()); 47 | 48 | nvobj::transaction::run( 49 | pop, [&] { r->v = nvobj::make_persistent(); }); 50 | 51 | UT_ASSERT(r->v->max_size() <= max_dist); 52 | 53 | nvobj::transaction::run( 54 | pop, [&] { nvobj::delete_persistent(r->v); }); 55 | 56 | } catch (std::exception &e) { 57 | UT_FATALexc(e); 58 | } 59 | 60 | pop.close(); 61 | } 62 | 63 | int 64 | main(int argc, char *argv[]) 65 | { 66 | return run_test([&] { test(argc, argv); }); 67 | } 68 | -------------------------------------------------------------------------------- /tests/external/libcxx/basic_string/string.iterators/crend.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "unittest.hpp" 16 | 17 | #include 18 | 19 | namespace nvobj = pmem::obj; 20 | 21 | using C = pmem::obj::string; 22 | 23 | struct root { 24 | nvobj::persistent_ptr s1, s2; 25 | }; 26 | 27 | template 28 | void 29 | test(const S &s) 30 | { 31 | typename S::const_reverse_iterator ce = s.crend(); 32 | UT_ASSERT(ce == s.rend()); 33 | } 34 | 35 | static void 36 | test(int argc, char *argv[]) 37 | { 38 | if (argc < 2) { 39 | UT_FATAL("usage: %s file-name", argv[0]); 40 | } 41 | 42 | auto path = argv[1]; 43 | auto pop = nvobj::pool::create( 44 | path, "StringTest", PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); 45 | 46 | auto r = pop.root(); 47 | 48 | try { 49 | nvobj::transaction::run(pop, [&] { 50 | r->s1 = nvobj::make_persistent(); 51 | r->s2 = nvobj::make_persistent("123"); 52 | }); 53 | 54 | test(*r->s1); 55 | test(*r->s2); 56 | 57 | nvobj::transaction::run(pop, [&] { 58 | nvobj::delete_persistent(r->s1); 59 | nvobj::delete_persistent(r->s2); 60 | }); 61 | } catch (std::exception &e) { 62 | UT_FATALexc(e); 63 | } 64 | 65 | pop.close(); 66 | } 67 | 68 | int 69 | main(int argc, char *argv[]) 70 | { 71 | return run_test([&] { test(argc, argv); }); 72 | } 73 | -------------------------------------------------------------------------------- /tests/external/libcxx/vector/vector.cons/op_equal_initializer_list.pass.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Copyright 2019-2020, Intel Corporation 11 | // 12 | // Modified to test pmem::obj containers 13 | // 14 | 15 | #include "list_wrapper.hpp" 16 | #include "unittest.hpp" 17 | 18 | #include 19 | #include 20 | 21 | namespace nvobj = pmem::obj; 22 | using C = container_t; 23 | 24 | struct root { 25 | nvobj::persistent_ptr d; 26 | }; 27 | 28 | static void 29 | test(int argc, char *argv[]) 30 | { 31 | if (argc < 2) { 32 | UT_FATAL("usage: %s file-name", argv[0]); 33 | } 34 | auto path = argv[1]; 35 | auto pop = nvobj::pool::create( 36 | path, "VectorTest: op_equal_initializer_list.pass", 37 | PMEMOBJ_MIN_POOL * 2, S_IWUSR | S_IRUSR); 38 | 39 | auto r = pop.root(); 40 | 41 | try { 42 | nvobj::transaction::run( 43 | pop, [&] { r->d = nvobj::make_persistent(); }); 44 | *r->d = {3, 4, 5, 6}; 45 | 46 | UT_ASSERT(r->d->size() == 4); 47 | UT_ASSERT((*r->d)[0] == 3); 48 | UT_ASSERT((*r->d)[1] == 4); 49 | UT_ASSERT((*r->d)[2] == 5); 50 | UT_ASSERT((*r->d)[3] == 6); 51 | 52 | nvobj::transaction::run( 53 | pop, [&] { nvobj::delete_persistent(r->d); }); 54 | } catch (std::exception &e) { 55 | UT_FATALexc(e); 56 | } 57 | 58 | pop.close(); 59 | } 60 | 61 | int 62 | main(int argc, char *argv[]) 63 | { 64 | return run_test([&] { test(argc, argv); }); 65 | } 66 | --------------------------------------------------------------------------------