repo
stringlengths 1
152
⌀ | file
stringlengths 15
205
| code
stringlengths 0
41.6M
| file_length
int64 0
41.6M
| avg_line_length
float64 0
1.81M
| max_line_length
int64 0
12.7M
| extension_type
stringclasses 90
values |
---|---|---|---|---|---|---|
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/obj_basic_integration/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017, Intel Corporation
#
#
# obj_basic_integration/config.sh -- test configuration
#
# Extend timeout for this test, as it may take a few minutes
# when run on a non-pmem file system.
CONF_GLOBAL_TIMEOUT='10m'
| 286 | 19.5 | 60 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmempool_feature/common.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2020, Intel Corporation
#
# src/test/pmempool_feature/common.sh -- common part of pmempool_feature tests
#
# for feature values please see: pmempool feature help
PART_SIZE=$(convert_to_bytes 10M)
# define files and directories
POOLSET=$DIR/testset
TEST_SET_LOCAL=testset_local
TEST_SET_REMOTE=testset_remote
LOG=grep${UNITTEST_NUM}.log
pmempool_exe=$PMEMPOOL$EXESUFFIX
exit_func=expect_normal_exit
sds_enabled=$(is_ndctl_enabled $pmempool_exe; echo $?)
# pmempool_feature_query -- query feature
#
# usage: pmempool_feature_query <feature> [<query-exit-type>]
function pmempool_feature_query() {
query_exit_type=${2-normal}
query_exit_func=expect_${query_exit_type}_exit
val=$($query_exit_func $pmempool_exe feature -q $1 $POOLSET 2>> $LOG)
if [ "$query_exit_type" == "normal" ]; then
echo "query $1 result is $val" &>> $LOG
fi
}
# pmempool_feature_enable -- enable feature
#
# usage: pmempool_feature_enable <feature> [no-query]
function pmempool_feature_enable() {
$exit_func $pmempool_exe feature -e $1 $POOLSET &>> $LOG
if [ "x$2" != "xno-query" ]; then
pmempool_feature_query $1
fi
}
# pmempool_feature_disable -- disable feature
#
# usage: pmempool_feature_disable <feature> [no-query]
function pmempool_feature_disable() {
$exit_func $pmempool_exe feature -d $1 $POOLSET '&>>' $LOG
if [ "x$2" != "xno-query" ]; then
pmempool_feature_query $1
fi
}
# pmempool_feature_create_poolset -- create poolset
#
# usage: pmempool_feature_create_poolset <poolset-type>
function pmempool_feature_create_poolset() {
POOLSET_TYPE=$1
case "$1" in
"no_dax_device")
create_poolset $POOLSET \
$PART_SIZE:$DIR/testfile11:x \
$PART_SIZE:$DIR/testfile12:x \
r \
$PART_SIZE:$DIR/testfile21:x \
$PART_SIZE:$DIR/testfile22:x \
r \
$PART_SIZE:$DIR/testfile31:x
;;
"dax_device")
create_poolset $POOLSET \
AUTO:$DEVICE_DAX_PATH
;;
"remote")
create_poolset $DIR/$TEST_SET_LOCAL \
$PART_SIZE:${NODE_DIR[1]}/testfile_local11:x \
$PART_SIZE:${NODE_DIR[1]}/testfile_local12:x \
m ${NODE_ADDR[0]}:$TEST_SET_REMOTE
create_poolset $DIR/$TEST_SET_REMOTE \
$PART_SIZE:${NODE_DIR[0]}/testfile_remote21:x \
$PART_SIZE:${NODE_DIR[0]}/testfile_remote22:x
copy_files_to_node 0 ${NODE_DIR[0]} $DIR/$TEST_SET_REMOTE
copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$TEST_SET_LOCAL
rm_files_from_node 1 \
${NODE_DIR[1]}testfile_local11 ${NODE_DIR[1]}testfile_local12
rm_files_from_node 0 \
${NODE_DIR[0]}testfile_remote21 ${NODE_DIR[0]}testfile_remote22
POOLSET="${NODE_DIR[1]}/$TEST_SET_LOCAL"
;;
esac
expect_normal_exit $pmempool_exe rm -f $POOLSET
# create pool
# pmempool create under valgrind pmemcheck takes too long
# it is not part of the test so it is run here without valgrind
VALGRIND_DISABLED=y expect_normal_exit $pmempool_exe create obj $POOLSET
}
# pmempool_feature_test_SINGLEHDR -- test SINGLEHDR
function pmempool_feature_test_SINGLEHDR() {
exit_func=expect_abnormal_exit
pmempool_feature_enable "SINGLEHDR" "no-query" # UNSUPPORTED
pmempool_feature_disable "SINGLEHDR" "no-query" # UNSUPPORTED
exit_func=expect_normal_exit
pmempool_feature_query "SINGLEHDR"
}
# pmempool_feature_test_CKSUM_2K -- test CKSUM_2K
function pmempool_feature_test_CKSUM_2K() {
# PMEMPOOL_FEAT_CHCKSUM_2K is enabled by default
pmempool_feature_query "CKSUM_2K"
# SHUTDOWN_STATE is disabled on Linux if PMDK is compiled with old ndctl
# enable it to interfere toggling CKSUM_2K
if [ $sds_enabled -eq 1 ]; then
pmempool_feature_enable SHUTDOWN_STATE "no-query"
fi
# disable PMEMPOOL_FEAT_SHUTDOWN_STATE prior to success
exit_func=expect_abnormal_exit
pmempool_feature_disable "CKSUM_2K" # should fail
exit_func=expect_normal_exit
pmempool_feature_disable "SHUTDOWN_STATE"
pmempool_feature_disable "CKSUM_2K" # should succeed
pmempool_feature_enable "CKSUM_2K"
}
# pmempool_feature_test_SHUTDOWN_STATE -- test SHUTDOWN_STATE
function pmempool_feature_test_SHUTDOWN_STATE() {
pmempool_feature_query "SHUTDOWN_STATE"
if [ $sds_enabled -eq 0 ]; then
pmempool_feature_disable SHUTDOWN_STATE
fi
# PMEMPOOL_FEAT_SHUTDOWN_STATE requires PMEMPOOL_FEAT_CHCKSUM_2K
pmempool_feature_disable "CKSUM_2K"
exit_func=expect_abnormal_exit
pmempool_feature_enable "SHUTDOWN_STATE" # should fail
exit_func=expect_normal_exit
pmempool_feature_enable "CKSUM_2K"
pmempool_feature_enable "SHUTDOWN_STATE" # should succeed
}
# pmempool_feature_test_CHECK_BAD_BLOCKS -- test SHUTDOWN_STATE
function pmempool_feature_test_CHECK_BAD_BLOCKS() {
# PMEMPOOL_FEAT_CHECK_BAD_BLOCKS is disabled by default
pmempool_feature_query "CHECK_BAD_BLOCKS"
pmempool_feature_enable "CHECK_BAD_BLOCKS"
pmempool_feature_disable "CHECK_BAD_BLOCKS"
}
# pmempool_feature_remote_init -- initialization remote replics
function pmempool_feature_remote_init() {
require_nodes 2
require_node_libfabric 0 $RPMEM_PROVIDER
require_node_libfabric 1 $RPMEM_PROVIDER
init_rpmem_on_node 1 0
pmempool_exe="run_on_node 1 ../pmempool"
}
# pmempool_feature_test_remote -- run remote tests
function pmempool_feature_test_remote() {
# create pool
expect_normal_exit $pmempool_exe rm -f $POOLSET
expect_normal_exit $pmempool_exe create obj $POOLSET
# poolset with remote replicas are not supported
exit_func=expect_abnormal_exit
pmempool_feature_enable $1 no-query
pmempool_feature_disable $1 no-query
pmempool_feature_query $1 abnormal
}
| 5,473 | 28.430108 | 78 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmempool_info_remote/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017, Intel Corporation
#
#
# pmempool_info_remote/config.sh -- test configuration
#
set -e
CONF_GLOBAL_FS_TYPE=any
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
CONF_GLOBAL_RPMEM_PROVIDER=sockets
CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
| 297 | 18.866667 | 54 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/ex_librpmem_basic/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019, Intel Corporation
#
#
# ex_librpmem_basic/config.sh -- test configuration
#
# Filesystem-DAX cannot be used for RDMA
# since it is missing support in Linux kernel
CONF_GLOBAL_FS_TYPE=non-pmem
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
CONF_GLOBAL_TEST_TYPE=short
CONF_GLOBAL_RPMEM_PROVIDER=all
CONF_GLOBAL_RPMEM_PMETHOD=all
| 402 | 21.388889 | 51 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmempool_transform_remote/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017, Intel Corporation
#
#
# pmempool_transform_remote/config.sh -- configuration of unit tests
#
CONF_GLOBAL_FS_TYPE=any
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
CONF_GLOBAL_RPMEM_PROVIDER=all
CONF_GLOBAL_RPMEM_PMETHOD=all
| 298 | 20.357143 | 68 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmempool_transform_remote/common.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2018, Intel Corporation
#
#
# pmempool_transform_remote/common.sh -- commons for pmempool transform tests
# with remote replication
#
set -e
require_nodes 2
require_node_libfabric 0 $RPMEM_PROVIDER
require_node_libfabric 1 $RPMEM_PROVIDER
setup
init_rpmem_on_node 1 0
require_node_log_files 1 pmemobj$UNITTEST_NUM.log
require_node_log_files 1 pmempool$UNITTEST_NUM.log
LOG=out${UNITTEST_NUM}.log
LOG_TEMP=out${UNITTEST_NUM}_part.log
rm -f $LOG && touch $LOG
rm -f $LOG_TEMP && touch $LOG_TEMP
rm_files_from_node 0 ${NODE_TEST_DIR[0]}/$LOG
rm_files_from_node 1 ${NODE_TEST_DIR[1]}/$LOG
LAYOUT=OBJ_LAYOUT
POOLSET_LOCAL_IN=poolset.in
POOLSET_LOCAL_OUT=poolset.out
POOLSET_REMOTE=poolset.remote
POOLSET_REMOTE1=poolset.remote1
POOLSET_REMOTE2=poolset.remote2
# CLI scripts for writing and reading some data hitting all the parts
WRITE_SCRIPT="pmemobjcli.write.script"
READ_SCRIPT="pmemobjcli.read.script"
copy_files_to_node 1 ${NODE_DIR[1]} $WRITE_SCRIPT $READ_SCRIPT
DUMP_INFO_LOG="../pmempool info"
DUMP_INFO_LOG_REMOTE="$DUMP_INFO_LOG -f obj"
DUMP_INFO_SED="sed -e '/^Checksum/d' -e '/^Creation/d' -e '/^Previous replica UUID/d' -e '/^Next replica UUID/d'"
DUMP_INFO_SED_REMOTE="$DUMP_INFO_SED -e '/^Previous part UUID/d' -e '/^Next part UUID/d'"
function dump_info_log() {
local node=$1
local poolset=$2
local name=$3
local ignore=$4
local sed_cmd="$DUMP_INFO_SED"
if [ -n "$ignore" ]; then
sed_cmd="$sed_cmd -e '/^$ignore/d'"
fi
expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG $poolset | $sed_cmd >> $name\""
}
function dump_info_log_remote() {
local node=$1
local poolset=$2
local name=$3
local ignore=$4
local sed_cmd="$DUMP_INFO_SED_REMOTE"
if [ -n "$ignore" ]; then
sed_cmd="$sed_cmd -e '/^$ignore/d'"
fi
expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG_REMOTE $poolset | $sed_cmd >> $name\""
}
function diff_log() {
local node=$1
local f1=$2
local f2=$3
expect_normal_exit run_on_node $node "\"[ -s $f1 ] && [ -s $f2 ] && diff $f1 $f2\""
}
exec_pmemobjcli_script() {
local node=$1
local script=$2
local poolset=$3
local out=$4
expect_normal_exit run_on_node $node "\"../pmemobjcli -s $script $poolset > $out \""
}
| 2,298 | 23.98913 | 113 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmempool_feature_remote/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018, Intel Corporation
#
#
# pmempool_feature_remote/config.sh -- test configuration
#
CONF_GLOBAL_FS_TYPE=any
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
# pmempool feature does not support poolsets with remote replicas
# unittest contains only negative scenarios so no point to loop over
# all providers and persistency methods
CONF_GLOBAL_RPMEM_PROVIDER=sockets
CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
| 468 | 26.588235 | 68 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/rpmem_basic/common_pm_policy.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2018, Intel Corporation
#
# src/test/rpmem_basic/common_pm_policy.sh -- common part for TEST[10-11] scripts
#
set -e
LOG=rpmemd$UNITTEST_NUM.log
OUT=out$UNITTEST_NUM.log
rm -f $OUT
# create poolset and upload
run_on_node 0 "rm -rf ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${NODE_DIR[0]}$POOLS_PART"
create_poolset $DIR/pool.set 8M:$PART_DIR/pool.part0 8M:$PART_DIR/pool.part1
copy_files_to_node 0 ${RPMEM_POOLSET_DIR[0]} $DIR/pool.set
# create pool and close it - local pool from file
SIMPLE_ARGS="test_create 0 pool.set ${NODE_ADDR[0]} pool 8M none test_close 0"
function test_pm_policy()
{
# initialize pmem
PMEM_IS_PMEM_FORCE=$1
export_vars_node 0 PMEM_IS_PMEM_FORCE
init_rpmem_on_node 1 0
# remove rpmemd log and pool parts
run_on_node 0 "rm -rf $PART_DIR && mkdir -p $PART_DIR && rm -f $LOG"
# execute, get log
expect_normal_exit run_on_node 1 ./rpmem_basic$EXESUFFIX $SIMPLE_ARGS
copy_files_from_node 0 . ${NODE_TEST_DIR[0]}/$LOG
# extract persist method and flush function
cat $LOG | $GREP -A2 "persistency policy:" >> $OUT
}
| 1,160 | 28.769231 | 120 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/rpmem_basic/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# rpmem_basic/config.sh -- test configuration
#
CONF_GLOBAL_FS_TYPE=any
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
CONF_GLOBAL_RPMEM_PROVIDER=all
CONF_GLOBAL_RPMEM_PMETHOD=all
CONF_RPMEM_PMETHOD[10]=APM
CONF_RPMEM_PMETHOD[11]=GPSPM
# Sockets provider does not detect fi_cq_signal so it does not return
# from fi_cq_sread. It causes this test to hang sporadically.
# https://github.com/ofiwg/libfabric/pull/3645
CONF_RPMEM_PROVIDER[12]=verbs
| 547 | 23.909091 | 69 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/rpmem_basic/setup2to1.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2017, Intel Corporation
#
# src/test/rpmem_basic/setup2to1.sh -- common part for TEST[7-] scripts
#
POOLS_DIR=pools
POOLS_PART=pool_parts
TEST_LOG_FILE=test$UNITTEST_NUM.log
TEST_LOG_LEVEL=3
#
# This unit test requires 4 nodes, but nodes #0 and #3 should be the same
# physical machine - they should have the same NODE[n] addresses but
# different NODE_ADDR[n] addresses in order to test "2-to-1" configuration.
# Node #1 is being replicated to the node #0 and node #2 is being replicated
# to the node #3.
#
require_nodes 4
REPLICA[1]=0
REPLICA[2]=3
for node in 1 2; do
require_node_libfabric ${node} $RPMEM_PROVIDER
require_node_libfabric ${REPLICA[${node}]} $RPMEM_PROVIDER
export_vars_node ${node} TEST_LOG_FILE
export_vars_node ${node} TEST_LOG_LEVEL
require_node_log_files ${node} $PMEM_LOG_FILE
require_node_log_files ${node} $RPMEM_LOG_FILE
require_node_log_files ${node} $TEST_LOG_FILE
require_node_log_files ${REPLICA[${node}]} $RPMEMD_LOG_FILE
REP_ADDR[${node}]=${NODE_ADDR[${REPLICA[${node}]}]}
PART_DIR[${node}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_PART
RPMEM_POOLSET_DIR[${REPLICA[${node}]}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_DIR
init_rpmem_on_node ${node} ${REPLICA[${node}]}
PID_FILE[${node}]="pidfile${UNITTEST_NUM}-${node}.pid"
clean_remote_node ${node} ${PID_FILE[${node}]}
done
| 1,484 | 29.306122 | 82 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/rpmem_basic/setup.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2017, Intel Corporation
#
# src/test/rpmem_basic/setup.sh -- common part for TEST* scripts
#
set -e
require_nodes 2
require_node_libfabric 0 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION
require_node_libfabric 1 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION
require_node_log_files 0 $RPMEMD_LOG_FILE
require_node_log_files 1 $RPMEM_LOG_FILE
require_node_log_files 1 $PMEM_LOG_FILE
POOLS_DIR=pools
POOLS_PART=pool_parts
PART_DIR=${NODE_DIR[0]}/$POOLS_PART
RPMEM_POOLSET_DIR[0]=${NODE_DIR[0]}$POOLS_DIR
if [ -z "$SETUP_MANUAL_INIT_RPMEM" ]; then
init_rpmem_on_node 1 0
fi
| 642 | 24.72 | 65 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/pmem2_memmove/memmove_common.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/*
* memmove_common.h -- header file for common memmove_common test utilities
*/
#ifndef MEMMOVE_COMMON_H
#define MEMMOVE_COMMON_H 1
#include "unittest.h"
#include "file.h"
extern unsigned Flags[10];
#define USAGE() do { UT_FATAL("usage: %s file b:length [d:{offset}] "\
"[s:{offset}] [o:{0|1}]", argv[0]); } while (0)
typedef void *(*memmove_fn)(void *pmemdest, const void *src, size_t len,
unsigned flags);
typedef void (*persist_fn)(const void *ptr, size_t len);
void do_memmove(char *dst, char *src, const char *file_name,
size_t dest_off, size_t src_off, size_t bytes,
memmove_fn fn, unsigned flags, persist_fn p);
void verify_contents(const char *file_name, int test, const char *buf1,
const char *buf2, size_t len);
#endif
| 832 | 25.870968 | 75 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/obj_rpmem_heap_interrupt/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2017, Intel Corporation
#
#
# src/test/obj_rpmem_heap_interrupt/config.sh -- test configuration
#
CONF_GLOBAL_FS_TYPE=pmem
CONF_GLOBAL_BUILD_TYPE="debug nondebug"
CONF_GLOBAL_RPMEM_PROVIDER=all
CONF_GLOBAL_RPMEM_PMETHOD=all
| 303 | 20.714286 | 67 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/libpmempool_backup/config.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017, Intel Corporation
#
#
# libpmempool_backup/config.sh -- test configuration
#
# Extend timeout for TEST0, as it may take more than a minute
# when run on a non-pmem file system.
CONF_TIMEOUT[0]='10m'
| 280 | 19.071429 | 61 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/libpmempool_backup/common.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# libpmempool_backup/common.sh -- functions for libpmempool_backup unittest
#
set -e
POOLSET=$DIR/pool.set
BACKUP=_backup
REPLICA=_replica
POOL_PART=$DIR/pool.part
OUT=out${UNITTEST_NUM}.log
OUT_TEMP=out${UNITTEST_NUM}_temp.log
DIFF=diff${UNITTEST_NUM}.log
rm -f $LOG $DIFF $OUT_TEMP && touch $LOG $DIFF $OUT_TEMP
# params for blk, log and obj pools
POOL_TYPES=( blk log obj )
POOL_CREATE_PARAMS=( "--write-layout 512" "" "--layout test_layout" )
POOL_CHECK_PARAMS=( "-smgB" "-s" "-soOaAbZH -l -C" )
POOL_OBJ=2
# create_poolset_variation -- create one from the tested poolset variation
# usage: create_poolset_variation <variation-id> [<suffix>]
#
function create_poolset_variation() {
local sfx=""
local variation=$1
shift
if [ $# -gt 0 ]; then
sfx=$1
fi
case "$variation"
in
1)
# valid poolset file
create_poolset $POOLSET$sfx \
20M:${POOL_PART}1$sfx:x \
20M:${POOL_PART}2$sfx:x \
20M:${POOL_PART}3$sfx:x \
20M:${POOL_PART}4$sfx:x
;;
2)
# valid poolset file with replica
create_poolset $POOLSET$sfx \
20M:${POOL_PART}1$sfx:x \
20M:${POOL_PART}2$sfx:x \
20M:${POOL_PART}3$sfx:x \
20M:${POOL_PART}4$sfx:x \
r 80M:${POOL_PART}${REPLICA}$sfx:x
;;
3)
# other number of parts
create_poolset $POOLSET$sfx \
20M:${POOL_PART}1$sfx:x \
20M:${POOL_PART}2$sfx:x \
40M:${POOL_PART}3$sfx:x
;;
4)
# no poolset
# return without check_file
return
;;
5)
# empty
create_poolset $POOLSET$sfx
;;
6)
# other size of part
create_poolset $POOLSET$sfx \
20M:${POOL_PART}1$sfx:x \
20M:${POOL_PART}2$sfx:x \
20M:${POOL_PART}3$sfx:x \
21M:${POOL_PART}4$sfx:x
;;
esac
check_file $POOLSET$sfx
}
#
# backup_and_compare -- perform backup and compare backup result with original
# if compare parameters are provided
# usage: backup_and_compare <poolset> <type> [<compare-params>]
#
function backup_and_compare () {
local poolset=$1
local type=$2
shift 2
# backup
expect_normal_exit ../libpmempool_api/libpmempool_test$EXESUFFIX \
-b $poolset$BACKUP -t $type -r 1 $poolset
cat $OUT >> $OUT_TEMP
# compare
if [ $# -gt 0 ]; then
compare_replicas "$1" $poolset $poolset$BACKUP >> $DIFF
fi
}
ALL_POOL_PARTS="${POOL_PART}1 ${POOL_PART}2 ${POOL_PART}3 ${POOL_PART}4 \
${POOL_PART}${REPLICA}"
ALL_POOL_BACKUP_PARTS="${POOL_PART}1$BACKUP ${POOL_PART}2$BACKUP \
${POOL_PART}3$BACKUP ${POOL_PART}4$BACKUP \
${POOL_PART}${BACKUP}${REPLICA}"
#
# backup_cleanup -- perform cleanup between test cases
#
function backup_cleanup() {
rm -f $POOLSET$BACKUP $ALL_POOL_PARTS $ALL_POOL_BACKUP_PARTS
}
| 2,691 | 21.621849 | 78 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/test/obj_sync/mocks_windows.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2017, Intel Corporation */
/*
* Copyright (c) 2016, Microsoft Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* mocks_windows.h -- redefinitions of pthread functions
*
* This file is Windows-specific.
*
* This file should be included (i.e. using Forced Include) by libpmemobj
* files, when compiled for the purpose of obj_sync test.
* It would replace default implementation with mocked functions defined
* in obj_sync.c.
*
* These defines could be also passed as preprocessor definitions.
*/
#ifndef WRAP_REAL
#define os_mutex_init __wrap_os_mutex_init
#define os_rwlock_init __wrap_os_rwlock_init
#define os_cond_init __wrap_os_cond_init
#endif
| 2,265 | 41.754717 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_fip_common.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* rpmem_fip_common.h -- common definitions for librpmem and rpmemd
*/
#ifndef RPMEM_FIP_COMMON_H
#define RPMEM_FIP_COMMON_H 1
#include <string.h>
#include <netinet/in.h>
#include <rdma/fabric.h>
#include <rdma/fi_cm.h>
#include <rdma/fi_rma.h>
#ifdef __cplusplus
extern "C" {
#endif
#define RPMEM_FIVERSION FI_VERSION(1, 4)
#define RPMEM_FIP_CQ_WAIT_MS 100
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
/*
* rpmem_fip_node -- client or server node type
*/
enum rpmem_fip_node {
RPMEM_FIP_NODE_CLIENT,
RPMEM_FIP_NODE_SERVER,
MAX_RPMEM_FIP_NODE,
};
/*
* rpmem_fip_probe -- list of providers
*/
struct rpmem_fip_probe {
unsigned providers;
size_t max_wq_size[MAX_RPMEM_PROV];
};
/*
* rpmem_fip_probe -- returns true if specified provider is available
*/
static inline int
rpmem_fip_probe(struct rpmem_fip_probe probe, enum rpmem_provider provider)
{
return (probe.providers & (1U << provider)) != 0;
}
/*
* rpmem_fip_probe_any -- returns true if any provider is available
*/
static inline int
rpmem_fip_probe_any(struct rpmem_fip_probe probe)
{
return probe.providers != 0;
}
int rpmem_fip_probe_get(const char *target, struct rpmem_fip_probe *probe);
struct fi_info *rpmem_fip_get_hints(enum rpmem_provider provider);
int rpmem_fip_read_eq_check(struct fid_eq *eq, struct fi_eq_cm_entry *entry,
uint32_t exp_event, fid_t exp_fid, int timeout);
int rpmem_fip_read_eq(struct fid_eq *eq, struct fi_eq_cm_entry *entry,
uint32_t *event, int timeout);
size_t rpmem_fip_cq_size(enum rpmem_persist_method pm,
enum rpmem_fip_node node);
size_t rpmem_fip_wq_size(enum rpmem_persist_method pm,
enum rpmem_fip_node node);
size_t rpmem_fip_rx_size(enum rpmem_persist_method pm,
enum rpmem_fip_node node);
size_t rpmem_fip_max_nlanes(struct fi_info *fi);
void rpmem_fip_print_info(struct fi_info *fi);
#ifdef __cplusplus
}
#endif
#endif
| 1,992 | 21.144444 | 76 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_common_log.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016, Intel Corporation */
/*
* rpmem_common_log.h -- common log macros for librpmem and rpmemd
*/
#if defined(RPMEMC_LOG_RPMEM) && defined(RPMEMC_LOG_RPMEMD)
#error Both RPMEMC_LOG_RPMEM and RPMEMC_LOG_RPMEMD defined
#elif !defined(RPMEMC_LOG_RPMEM) && !defined(RPMEMC_LOG_RPMEMD)
#define RPMEMC_LOG(level, fmt, args...) do {} while (0)
#define RPMEMC_DBG(level, fmt, args...) do {} while (0)
#define RPMEMC_FATAL(fmt, args...) do {} while (0)
#define RPMEMC_ASSERT(cond) do {} while (0)
#elif defined(RPMEMC_LOG_RPMEM)
#include "out.h"
#include "rpmem_util.h"
#define RPMEMC_LOG(level, fmt, args...) RPMEM_LOG(level, fmt, ## args)
#define RPMEMC_DBG(level, fmt, args...) RPMEM_DBG(fmt, ## args)
#define RPMEMC_FATAL(fmt, args...) RPMEM_FATAL(fmt, ## args)
#define RPMEMC_ASSERT(cond) RPMEM_ASSERT(cond)
#else
#include "rpmemd_log.h"
#define RPMEMC_LOG(level, fmt, args...) RPMEMD_LOG(level, fmt, ## args)
#define RPMEMC_DBG(level, fmt, args...) RPMEMD_DBG(fmt, ## args)
#define RPMEMC_FATAL(fmt, args...) RPMEMD_FATAL(fmt, ## args)
#define RPMEMC_ASSERT(cond) RPMEMD_ASSERT(cond)
#endif
| 1,160 | 28.769231 | 71 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_common.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* rpmem_common.h -- common definitions for librpmem and rpmemd
*/
#ifndef RPMEM_COMMON_H
#define RPMEM_COMMON_H 1
/*
* Values for SO_KEEPALIVE socket option
*/
#define RPMEM_CMD_ENV "RPMEM_CMD"
#define RPMEM_SSH_ENV "RPMEM_SSH"
#define RPMEM_DEF_CMD "rpmemd"
#define RPMEM_DEF_SSH "ssh"
#define RPMEM_PROV_SOCKET_ENV "RPMEM_ENABLE_SOCKETS"
#define RPMEM_PROV_VERBS_ENV "RPMEM_ENABLE_VERBS"
#define RPMEM_MAX_NLANES_ENV "RPMEM_MAX_NLANES"
#define RPMEM_WQ_SIZE_ENV "RPMEM_WORK_QUEUE_SIZE"
#define RPMEM_ACCEPT_TIMEOUT 30000
#define RPMEM_CONNECT_TIMEOUT 30000
#define RPMEM_MONITOR_TIMEOUT 1000
#include <stdint.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* rpmem_err -- error codes
*/
enum rpmem_err {
RPMEM_SUCCESS = 0,
RPMEM_ERR_BADPROTO = 1,
RPMEM_ERR_BADNAME = 2,
RPMEM_ERR_BADSIZE = 3,
RPMEM_ERR_BADNLANES = 4,
RPMEM_ERR_BADPROVIDER = 5,
RPMEM_ERR_FATAL = 6,
RPMEM_ERR_FATAL_CONN = 7,
RPMEM_ERR_BUSY = 8,
RPMEM_ERR_EXISTS = 9,
RPMEM_ERR_PROVNOSUP = 10,
RPMEM_ERR_NOEXIST = 11,
RPMEM_ERR_NOACCESS = 12,
RPMEM_ERR_POOL_CFG = 13,
MAX_RPMEM_ERR,
};
/*
* rpmem_persist_method -- remote persist operation method
*/
enum rpmem_persist_method {
RPMEM_PM_GPSPM = 1, /* General Purpose Server Persistency Method */
RPMEM_PM_APM = 2, /* Appliance Persistency Method */
MAX_RPMEM_PM,
};
const char *rpmem_persist_method_to_str(enum rpmem_persist_method pm);
/*
* rpmem_provider -- supported providers
*/
enum rpmem_provider {
RPMEM_PROV_UNKNOWN = 0,
RPMEM_PROV_LIBFABRIC_VERBS = 1,
RPMEM_PROV_LIBFABRIC_SOCKETS = 2,
MAX_RPMEM_PROV,
};
enum rpmem_provider rpmem_provider_from_str(const char *str);
const char *rpmem_provider_to_str(enum rpmem_provider provider);
/*
* rpmem_req_attr -- arguments for open/create request
*/
struct rpmem_req_attr {
size_t pool_size;
unsigned nlanes;
size_t buff_size;
enum rpmem_provider provider;
const char *pool_desc;
};
/*
* rpmem_resp_attr -- return arguments from open/create request
*/
struct rpmem_resp_attr {
unsigned short port;
uint64_t rkey;
uint64_t raddr;
unsigned nlanes;
enum rpmem_persist_method persist_method;
};
#define RPMEM_HAS_USER 0x1
#define RPMEM_HAS_SERVICE 0x2
#define RPMEM_FLAGS_USE_IPV4 0x4
#define RPMEM_MAX_USER (32 + 1) /* see useradd(8) + 1 for '\0' */
#define RPMEM_MAX_NODE (255 + 1) /* see gethostname(2) + 1 for '\0' */
#define RPMEM_MAX_SERVICE (NI_MAXSERV + 1) /* + 1 for '\0' */
#define RPMEM_HDR_SIZE 4096
#define RPMEM_CLOSE_FLAGS_REMOVE 0x1
#define RPMEM_DEF_BUFF_SIZE 8192
struct rpmem_target_info {
char user[RPMEM_MAX_USER];
char node[RPMEM_MAX_NODE];
char service[RPMEM_MAX_SERVICE];
unsigned flags;
};
extern unsigned Rpmem_max_nlanes;
extern unsigned Rpmem_wq_size;
extern int Rpmem_fork_unsafe;
int rpmem_b64_write(int sockfd, const void *buf, size_t len, int flags);
int rpmem_b64_read(int sockfd, void *buf, size_t len, int flags);
const char *rpmem_get_ip_str(const struct sockaddr *addr);
struct rpmem_target_info *rpmem_target_parse(const char *target);
void rpmem_target_free(struct rpmem_target_info *info);
int rpmem_xwrite(int fd, const void *buf, size_t len, int flags);
int rpmem_xread(int fd, void *buf, size_t len, int flags);
char *rpmem_get_ssh_conn_addr(void);
#ifdef __cplusplus
}
#endif
#endif
| 3,404 | 23.321429 | 72 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_proto.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* rpmem_proto.h -- rpmem protocol definitions
*/
#ifndef RPMEM_PROTO_H
#define RPMEM_PROTO_H 1
#include <stdint.h>
#include <endian.h>
#include "librpmem.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PACKED __attribute__((packed))
#define RPMEM_PROTO "tcp"
#define RPMEM_PROTO_MAJOR 0
#define RPMEM_PROTO_MINOR 1
#define RPMEM_SIG_SIZE 8
#define RPMEM_UUID_SIZE 16
#define RPMEM_PROV_SIZE 32
#define RPMEM_USER_SIZE 16
/*
* rpmem_msg_type -- type of messages
*/
enum rpmem_msg_type {
RPMEM_MSG_TYPE_CREATE = 1, /* create request */
RPMEM_MSG_TYPE_CREATE_RESP = 2, /* create request response */
RPMEM_MSG_TYPE_OPEN = 3, /* open request */
RPMEM_MSG_TYPE_OPEN_RESP = 4, /* open request response */
RPMEM_MSG_TYPE_CLOSE = 5, /* close request */
RPMEM_MSG_TYPE_CLOSE_RESP = 6, /* close request response */
RPMEM_MSG_TYPE_SET_ATTR = 7, /* set attributes request */
/* set attributes request response */
RPMEM_MSG_TYPE_SET_ATTR_RESP = 8,
MAX_RPMEM_MSG_TYPE,
};
/*
* rpmem_pool_attr_packed -- a packed version
*/
struct rpmem_pool_attr_packed {
char signature[RPMEM_POOL_HDR_SIG_LEN]; /* pool signature */
uint32_t major; /* format major version number */
uint32_t compat_features; /* mask: compatible "may" features */
uint32_t incompat_features; /* mask: "must support" features */
uint32_t ro_compat_features; /* mask: force RO if unsupported */
unsigned char poolset_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* pool uuid */
unsigned char uuid[RPMEM_POOL_HDR_UUID_LEN]; /* first part uuid */
unsigned char next_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* next pool uuid */
unsigned char prev_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* prev pool uuid */
unsigned char user_flags[RPMEM_POOL_USER_FLAGS_LEN]; /* user flags */
} PACKED;
/*
* rpmem_msg_ibc_attr -- in-band connection attributes
*
* Used by create request response and open request response.
* Contains essential information to proceed with in-band connection
* initialization.
*/
struct rpmem_msg_ibc_attr {
uint32_t port; /* RDMA connection port */
uint32_t persist_method; /* persist method */
uint64_t rkey; /* remote key */
uint64_t raddr; /* remote address */
uint32_t nlanes; /* number of lanes */
} PACKED;
/*
* rpmem_msg_pool_desc -- remote pool descriptor
*/
struct rpmem_msg_pool_desc {
uint32_t size; /* size of pool descriptor */
uint8_t desc[0]; /* pool descriptor, null-terminated string */
} PACKED;
/*
* rpmem_msg_hdr -- message header which consists of type and size of message
*
* The type must be one of the rpmem_msg_type values.
*/
struct rpmem_msg_hdr {
uint32_t type; /* type of message */
uint64_t size; /* size of message */
uint8_t body[0];
} PACKED;
/*
* rpmem_msg_hdr_resp -- message response header which consists of type, size
* and status.
*
* The type must be one of the rpmem_msg_type values.
*/
struct rpmem_msg_hdr_resp {
uint32_t status; /* response status */
uint32_t type; /* type of message */
uint64_t size; /* size of message */
} PACKED;
/*
* rpmem_msg_common -- common fields for open/create messages
*/
struct rpmem_msg_common {
uint16_t major; /* protocol version major number */
uint16_t minor; /* protocol version minor number */
uint64_t pool_size; /* minimum required size of a pool */
uint32_t nlanes; /* number of lanes used by initiator */
uint32_t provider; /* provider */
uint64_t buff_size; /* buffer size for inline persist */
} PACKED;
/*
* rpmem_msg_create -- create request message
*
* The type of message must be set to RPMEM_MSG_TYPE_CREATE.
* The size of message must be set to
* sizeof(struct rpmem_msg_create) + pool_desc_size
*/
struct rpmem_msg_create {
struct rpmem_msg_hdr hdr; /* message header */
struct rpmem_msg_common c;
struct rpmem_pool_attr_packed pool_attr; /* pool attributes */
struct rpmem_msg_pool_desc pool_desc; /* pool descriptor */
} PACKED;
/*
* rpmem_msg_create_resp -- create request response message
*
* The type of message must be set to RPMEM_MSG_TYPE_CREATE_RESP.
* The size of message must be set to sizeof(struct rpmem_msg_create_resp).
*/
struct rpmem_msg_create_resp {
struct rpmem_msg_hdr_resp hdr; /* message header */
struct rpmem_msg_ibc_attr ibc; /* in-band connection attributes */
} PACKED;
/*
* rpmem_msg_open -- open request message
*
* The type of message must be set to RPMEM_MSG_TYPE_OPEN.
* The size of message must be set to
* sizeof(struct rpmem_msg_open) + pool_desc_size
*/
struct rpmem_msg_open {
struct rpmem_msg_hdr hdr; /* message header */
struct rpmem_msg_common c;
struct rpmem_msg_pool_desc pool_desc; /* pool descriptor */
} PACKED;
/*
* rpmem_msg_open_resp -- open request response message
*
* The type of message must be set to RPMEM_MSG_TYPE_OPEN_RESP.
* The size of message must be set to sizeof(struct rpmem_msg_open_resp)
*/
struct rpmem_msg_open_resp {
struct rpmem_msg_hdr_resp hdr; /* message header */
struct rpmem_msg_ibc_attr ibc; /* in-band connection attributes */
struct rpmem_pool_attr_packed pool_attr; /* pool attributes */
} PACKED;
/*
* rpmem_msg_close -- close request message
*
* The type of message must be set to RPMEM_MSG_TYPE_CLOSE
* The size of message must be set to sizeof(struct rpmem_msg_close)
*/
struct rpmem_msg_close {
struct rpmem_msg_hdr hdr; /* message header */
uint32_t flags; /* flags */
} PACKED;
/*
* rpmem_msg_close_resp -- close request response message
*
* The type of message must be set to RPMEM_MSG_TYPE_CLOSE_RESP
* The size of message must be set to sizeof(struct rpmem_msg_close_resp)
*/
struct rpmem_msg_close_resp {
struct rpmem_msg_hdr_resp hdr; /* message header */
/* no more fields */
} PACKED;
#define RPMEM_FLUSH_WRITE 0U /* flush / persist using RDMA WRITE */
#define RPMEM_DEEP_PERSIST 1U /* deep persist operation */
#define RPMEM_PERSIST_SEND 2U /* persist using RDMA SEND */
#define RPMEM_COMPLETION 4U /* schedule command with a completion */
/* the two least significant bits are reserved for mode of persist */
#define RPMEM_FLUSH_PERSIST_MASK 0x3U
#define RPMEM_PERSIST_MAX 2U /* maximum valid persist value */
/*
* rpmem_msg_persist -- remote persist message
*/
struct rpmem_msg_persist {
uint32_t flags; /* lane flags */
uint32_t lane; /* lane identifier */
uint64_t addr; /* remote memory address */
uint64_t size; /* remote memory size */
uint8_t data[];
};
/*
* rpmem_msg_persist_resp -- remote persist response message
*/
struct rpmem_msg_persist_resp {
uint32_t flags; /* lane flags */
uint32_t lane; /* lane identifier */
};
/*
* rpmem_msg_set_attr -- set attributes request message
*
* The type of message must be set to RPMEM_MSG_TYPE_SET_ATTR.
* The size of message must be set to sizeof(struct rpmem_msg_set_attr)
*/
struct rpmem_msg_set_attr {
struct rpmem_msg_hdr hdr; /* message header */
struct rpmem_pool_attr_packed pool_attr; /* pool attributes */
} PACKED;
/*
* rpmem_msg_set_attr_resp -- set attributes request response message
*
* The type of message must be set to RPMEM_MSG_TYPE_SET_ATTR_RESP.
* The size of message must be set to sizeof(struct rpmem_msg_set_attr_resp).
*/
struct rpmem_msg_set_attr_resp {
struct rpmem_msg_hdr_resp hdr; /* message header */
} PACKED;
/*
* XXX Begin: Suppress gcc conversion warnings for FreeBSD be*toh macros.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
/*
* rpmem_ntoh_msg_ibc_attr -- convert rpmem_msg_ibc attr to host byte order
*/
static inline void
rpmem_ntoh_msg_ibc_attr(struct rpmem_msg_ibc_attr *ibc)
{
ibc->port = be32toh(ibc->port);
ibc->persist_method = be32toh(ibc->persist_method);
ibc->rkey = be64toh(ibc->rkey);
ibc->raddr = be64toh(ibc->raddr);
}
/*
* rpmem_ntoh_msg_pool_desc -- convert rpmem_msg_pool_desc to host byte order
*/
static inline void
rpmem_ntoh_msg_pool_desc(struct rpmem_msg_pool_desc *pool_desc)
{
pool_desc->size = be32toh(pool_desc->size);
}
/*
* rpmem_ntoh_pool_attr -- convert rpmem_pool_attr to host byte order
*/
static inline void
rpmem_ntoh_pool_attr(struct rpmem_pool_attr_packed *attr)
{
attr->major = be32toh(attr->major);
attr->ro_compat_features = be32toh(attr->ro_compat_features);
attr->incompat_features = be32toh(attr->incompat_features);
attr->compat_features = be32toh(attr->compat_features);
}
/*
* rpmem_ntoh_msg_hdr -- convert rpmem_msg_hdr to host byte order
*/
static inline void
rpmem_ntoh_msg_hdr(struct rpmem_msg_hdr *hdrp)
{
hdrp->type = be32toh(hdrp->type);
hdrp->size = be64toh(hdrp->size);
}
/*
* rpmem_hton_msg_hdr -- convert rpmem_msg_hdr to network byte order
*/
static inline void
rpmem_hton_msg_hdr(struct rpmem_msg_hdr *hdrp)
{
rpmem_ntoh_msg_hdr(hdrp);
}
/*
* rpmem_ntoh_msg_hdr_resp -- convert rpmem_msg_hdr_resp to host byte order
*/
static inline void
rpmem_ntoh_msg_hdr_resp(struct rpmem_msg_hdr_resp *hdrp)
{
hdrp->status = be32toh(hdrp->status);
hdrp->type = be32toh(hdrp->type);
hdrp->size = be64toh(hdrp->size);
}
/*
* rpmem_hton_msg_hdr_resp -- convert rpmem_msg_hdr_resp to network byte order
*/
static inline void
rpmem_hton_msg_hdr_resp(struct rpmem_msg_hdr_resp *hdrp)
{
rpmem_ntoh_msg_hdr_resp(hdrp);
}
/*
* rpmem_ntoh_msg_common -- convert rpmem_msg_common to host byte order
*/
static inline void
rpmem_ntoh_msg_common(struct rpmem_msg_common *msg)
{
msg->major = be16toh(msg->major);
msg->minor = be16toh(msg->minor);
msg->pool_size = be64toh(msg->pool_size);
msg->nlanes = be32toh(msg->nlanes);
msg->provider = be32toh(msg->provider);
msg->buff_size = be64toh(msg->buff_size);
}
/*
* rpmem_hton_msg_common -- convert rpmem_msg_common to network byte order
*/
static inline void
rpmem_hton_msg_common(struct rpmem_msg_common *msg)
{
rpmem_ntoh_msg_common(msg);
}
/*
* rpmem_ntoh_msg_create -- convert rpmem_msg_create to host byte order
*/
static inline void
rpmem_ntoh_msg_create(struct rpmem_msg_create *msg)
{
rpmem_ntoh_msg_hdr(&msg->hdr);
rpmem_ntoh_msg_common(&msg->c);
rpmem_ntoh_pool_attr(&msg->pool_attr);
rpmem_ntoh_msg_pool_desc(&msg->pool_desc);
}
/*
* rpmem_hton_msg_create -- convert rpmem_msg_create to network byte order
*/
static inline void
rpmem_hton_msg_create(struct rpmem_msg_create *msg)
{
rpmem_ntoh_msg_create(msg);
}
/*
* rpmem_ntoh_msg_create_resp -- convert rpmem_msg_create_resp to host byte
* order
*/
static inline void
rpmem_ntoh_msg_create_resp(struct rpmem_msg_create_resp *msg)
{
rpmem_ntoh_msg_hdr_resp(&msg->hdr);
rpmem_ntoh_msg_ibc_attr(&msg->ibc);
}
/*
* rpmem_hton_msg_create_resp -- convert rpmem_msg_create_resp to network byte
* order
*/
static inline void
rpmem_hton_msg_create_resp(struct rpmem_msg_create_resp *msg)
{
rpmem_ntoh_msg_create_resp(msg);
}
/*
* rpmem_ntoh_msg_open -- convert rpmem_msg_open to host byte order
*/
static inline void
rpmem_ntoh_msg_open(struct rpmem_msg_open *msg)
{
rpmem_ntoh_msg_hdr(&msg->hdr);
rpmem_ntoh_msg_common(&msg->c);
rpmem_ntoh_msg_pool_desc(&msg->pool_desc);
}
/*
* XXX End: Suppress gcc conversion warnings for FreeBSD be*toh macros
*/
#pragma GCC diagnostic pop
/*
* rpmem_hton_msg_open -- convert rpmem_msg_open to network byte order
*/
static inline void
rpmem_hton_msg_open(struct rpmem_msg_open *msg)
{
rpmem_ntoh_msg_open(msg);
}
/*
* rpmem_ntoh_msg_open_resp -- convert rpmem_msg_open_resp to host byte order
*/
static inline void
rpmem_ntoh_msg_open_resp(struct rpmem_msg_open_resp *msg)
{
rpmem_ntoh_msg_hdr_resp(&msg->hdr);
rpmem_ntoh_msg_ibc_attr(&msg->ibc);
rpmem_ntoh_pool_attr(&msg->pool_attr);
}
/*
* rpmem_hton_msg_open_resp -- convert rpmem_msg_open_resp to network byte order
*/
static inline void
rpmem_hton_msg_open_resp(struct rpmem_msg_open_resp *msg)
{
rpmem_ntoh_msg_open_resp(msg);
}
/*
* rpmem_ntoh_msg_set_attr -- convert rpmem_msg_set_attr to host byte order
*/
static inline void
rpmem_ntoh_msg_set_attr(struct rpmem_msg_set_attr *msg)
{
rpmem_ntoh_msg_hdr(&msg->hdr);
rpmem_ntoh_pool_attr(&msg->pool_attr);
}
/*
* rpmem_hton_msg_set_attr -- convert rpmem_msg_set_attr to network byte order
*/
static inline void
rpmem_hton_msg_set_attr(struct rpmem_msg_set_attr *msg)
{
rpmem_ntoh_msg_set_attr(msg);
}
/*
* rpmem_ntoh_msg_set_attr_resp -- convert rpmem_msg_set_attr_resp to host byte
* order
*/
static inline void
rpmem_ntoh_msg_set_attr_resp(struct rpmem_msg_set_attr_resp *msg)
{
rpmem_ntoh_msg_hdr_resp(&msg->hdr);
}
/*
* rpmem_hton_msg_set_attr_resp -- convert rpmem_msg_set_attr_resp to network
* byte order
*/
static inline void
rpmem_hton_msg_set_attr_resp(struct rpmem_msg_set_attr_resp *msg)
{
rpmem_hton_msg_hdr_resp(&msg->hdr);
}
/*
* rpmem_ntoh_msg_close -- convert rpmem_msg_close to host byte order
*/
static inline void
rpmem_ntoh_msg_close(struct rpmem_msg_close *msg)
{
rpmem_ntoh_msg_hdr(&msg->hdr);
}
/*
* rpmem_hton_msg_close -- convert rpmem_msg_close to network byte order
*/
static inline void
rpmem_hton_msg_close(struct rpmem_msg_close *msg)
{
rpmem_ntoh_msg_close(msg);
}
/*
* rpmem_ntoh_msg_close_resp -- convert rpmem_msg_close_resp to host byte order
*/
static inline void
rpmem_ntoh_msg_close_resp(struct rpmem_msg_close_resp *msg)
{
rpmem_ntoh_msg_hdr_resp(&msg->hdr);
}
/*
* rpmem_hton_msg_close_resp -- convert rpmem_msg_close_resp to network byte
* order
*/
static inline void
rpmem_hton_msg_close_resp(struct rpmem_msg_close_resp *msg)
{
rpmem_ntoh_msg_close_resp(msg);
}
/*
* pack_rpmem_pool_attr -- copy pool attributes to a packed structure
*/
static inline void
pack_rpmem_pool_attr(const struct rpmem_pool_attr *src,
struct rpmem_pool_attr_packed *dst)
{
memcpy(dst->signature, src->signature, sizeof(src->signature));
dst->major = src->major;
dst->compat_features = src->compat_features;
dst->incompat_features = src->incompat_features;
dst->ro_compat_features = src->ro_compat_features;
memcpy(dst->poolset_uuid, src->poolset_uuid, sizeof(dst->poolset_uuid));
memcpy(dst->uuid, src->uuid, sizeof(dst->uuid));
memcpy(dst->next_uuid, src->next_uuid, sizeof(dst->next_uuid));
memcpy(dst->prev_uuid, src->prev_uuid, sizeof(dst->prev_uuid));
memcpy(dst->user_flags, src->user_flags, sizeof(dst->user_flags));
}
/*
* unpack_rpmem_pool_attr -- copy pool attributes to an unpacked structure
*/
static inline void
unpack_rpmem_pool_attr(const struct rpmem_pool_attr_packed *src,
struct rpmem_pool_attr *dst)
{
memcpy(dst->signature, src->signature, sizeof(src->signature));
dst->major = src->major;
dst->compat_features = src->compat_features;
dst->incompat_features = src->incompat_features;
dst->ro_compat_features = src->ro_compat_features;
memcpy(dst->poolset_uuid, src->poolset_uuid, sizeof(dst->poolset_uuid));
memcpy(dst->uuid, src->uuid, sizeof(dst->uuid));
memcpy(dst->next_uuid, src->next_uuid, sizeof(dst->next_uuid));
memcpy(dst->prev_uuid, src->prev_uuid, sizeof(dst->prev_uuid));
memcpy(dst->user_flags, src->user_flags, sizeof(dst->user_flags));
}
#ifdef __cplusplus
}
#endif
#endif
| 15,016 | 26.503663 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_fip_lane.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2017, Intel Corporation */
/*
* rpmem_fip_lane.h -- rpmem fabric provider lane definition
*/
#include <sched.h>
#include <stdint.h>
#include "sys_util.h"
/*
* rpmem_fip_lane -- basic lane structure
*
* This structure consist of a synchronization object and a return value.
* It is possible to wait on the lane for specified event. The event can be
* signalled by another thread which can pass the return value if required.
*
* The sync variable can store up to 64 different events, each event on
* separate bit.
*/
struct rpmem_fip_lane {
os_spinlock_t lock;
int ret;
uint64_t sync;
};
/*
* rpmem_fip_lane_init -- initialize basic lane structure
*/
static inline int
rpmem_fip_lane_init(struct rpmem_fip_lane *lanep)
{
lanep->ret = 0;
lanep->sync = 0;
return util_spin_init(&lanep->lock, PTHREAD_PROCESS_PRIVATE);
}
/*
* rpmem_fip_lane_fini -- deinitialize basic lane structure
*/
static inline void
rpmem_fip_lane_fini(struct rpmem_fip_lane *lanep)
{
util_spin_destroy(&lanep->lock);
}
/*
* rpmem_fip_lane_busy -- return true if lane has pending events
*/
static inline int
rpmem_fip_lane_busy(struct rpmem_fip_lane *lanep)
{
util_spin_lock(&lanep->lock);
int ret = lanep->sync != 0;
util_spin_unlock(&lanep->lock);
return ret;
}
/*
* rpmem_fip_lane_begin -- begin waiting for specified event(s)
*/
static inline void
rpmem_fip_lane_begin(struct rpmem_fip_lane *lanep, uint64_t sig)
{
util_spin_lock(&lanep->lock);
lanep->ret = 0;
lanep->sync |= sig;
util_spin_unlock(&lanep->lock);
}
static inline int
rpmem_fip_lane_is_busy(struct rpmem_fip_lane *lanep, uint64_t sig)
{
util_spin_lock(&lanep->lock);
int ret = (lanep->sync & sig) != 0;
util_spin_unlock(&lanep->lock);
return ret;
}
static inline int
rpmem_fip_lane_ret(struct rpmem_fip_lane *lanep)
{
util_spin_lock(&lanep->lock);
int ret = lanep->ret;
util_spin_unlock(&lanep->lock);
return ret;
}
/*
* rpmem_fip_lane_wait -- wait for specified event(s)
*/
static inline int
rpmem_fip_lane_wait(struct rpmem_fip_lane *lanep, uint64_t sig)
{
while (rpmem_fip_lane_is_busy(lanep, sig))
sched_yield();
return rpmem_fip_lane_ret(lanep);
}
/*
* rpmem_fip_lane_signal -- signal lane about specified event
*/
static inline void
rpmem_fip_lane_signal(struct rpmem_fip_lane *lanep, uint64_t sig)
{
util_spin_lock(&lanep->lock);
lanep->sync &= ~sig;
util_spin_unlock(&lanep->lock);
}
/*
* rpmem_fip_lane_signal -- signal lane about specified event and store
* return value
*/
static inline void
rpmem_fip_lane_sigret(struct rpmem_fip_lane *lanep, uint64_t sig, int ret)
{
util_spin_lock(&lanep->lock);
lanep->ret = ret;
lanep->sync &= ~sig;
util_spin_unlock(&lanep->lock);
}
| 2,754 | 20.523438 | 75 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/rpmem_common/rpmem_fip_msg.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018, Intel Corporation */
/*
* rpmem_fip_msg.h -- simple wrappers for fi_rma(3) and fi_msg(3) functions
*/
#ifndef RPMEM_FIP_MSG_H
#define RPMEM_FIP_MSG_H 1
#include <rdma/fi_rma.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* rpmem_fip_rma -- helper struct for RMA operation
*/
struct rpmem_fip_rma {
struct fi_msg_rma msg; /* message structure */
struct iovec msg_iov; /* IO vector buffer */
struct fi_rma_iov rma_iov; /* RMA IO vector buffer */
void *desc; /* local memory descriptor */
uint64_t flags; /* RMA operation flags */
};
/*
* rpmem_fip_msg -- helper struct for MSG operation
*/
struct rpmem_fip_msg {
struct fi_msg msg; /* message structure */
struct iovec iov; /* IO vector buffer */
void *desc; /* local memory descriptor */
uint64_t flags; /* MSG operation flags */
};
/*
* rpmem_fip_rma_init -- initialize RMA helper struct
*/
static inline void
rpmem_fip_rma_init(struct rpmem_fip_rma *rma, void *desc,
fi_addr_t addr, uint64_t rkey, void *context, uint64_t flags)
{
memset(rma, 0, sizeof(*rma));
rma->desc = desc;
rma->flags = flags;
rma->rma_iov.key = rkey;
rma->msg.context = context;
rma->msg.addr = addr;
rma->msg.desc = &rma->desc;
rma->msg.rma_iov = &rma->rma_iov;
rma->msg.rma_iov_count = 1;
rma->msg.msg_iov = &rma->msg_iov;
rma->msg.iov_count = 1;
}
/*
* rpmem_fip_msg_init -- initialize MSG helper struct
*/
static inline void
rpmem_fip_msg_init(struct rpmem_fip_msg *msg, void *desc, fi_addr_t addr,
void *context, void *buff, size_t len, uint64_t flags)
{
memset(msg, 0, sizeof(*msg));
msg->desc = desc;
msg->flags = flags;
msg->iov.iov_base = buff;
msg->iov.iov_len = len;
msg->msg.context = context;
msg->msg.addr = addr;
msg->msg.desc = &msg->desc;
msg->msg.msg_iov = &msg->iov;
msg->msg.iov_count = 1;
}
/*
* rpmem_fip_writemsg -- wrapper for fi_writemsg
*/
static inline int
rpmem_fip_writemsg(struct fid_ep *ep, struct rpmem_fip_rma *rma,
const void *buff, size_t len, uint64_t addr)
{
rma->rma_iov.addr = addr;
rma->rma_iov.len = len;
rma->msg_iov.iov_base = (void *)buff;
rma->msg_iov.iov_len = len;
return (int)fi_writemsg(ep, &rma->msg, rma->flags);
}
/*
* rpmem_fip_readmsg -- wrapper for fi_readmsg
*/
static inline int
rpmem_fip_readmsg(struct fid_ep *ep, struct rpmem_fip_rma *rma,
void *buff, size_t len, uint64_t addr)
{
rma->rma_iov.addr = addr;
rma->rma_iov.len = len;
rma->msg_iov.iov_base = buff;
rma->msg_iov.iov_len = len;
return (int)fi_readmsg(ep, &rma->msg, rma->flags);
}
/*
* rpmem_fip_sendmsg -- wrapper for fi_sendmsg
*/
static inline int
rpmem_fip_sendmsg(struct fid_ep *ep, struct rpmem_fip_msg *msg, size_t len)
{
msg->iov.iov_len = len;
return (int)fi_sendmsg(ep, &msg->msg, msg->flags);
}
/*
* rpmem_fip_recvmsg -- wrapper for fi_recvmsg
*/
static inline int
rpmem_fip_recvmsg(struct fid_ep *ep, struct rpmem_fip_msg *msg)
{
return (int)fi_recvmsg(ep, &msg->msg, msg->flags);
}
/*
* rpmem_fip_msg_get_pmsg -- returns message buffer as a persist message
*/
static inline struct rpmem_msg_persist *
rpmem_fip_msg_get_pmsg(struct rpmem_fip_msg *msg)
{
return (struct rpmem_msg_persist *)msg->iov.iov_base;
}
/*
* rpmem_fip_msg_get_pres -- returns message buffer as a persist response
*/
static inline struct rpmem_msg_persist_resp *
rpmem_fip_msg_get_pres(struct rpmem_fip_msg *msg)
{
return (struct rpmem_msg_persist_resp *)msg->iov.iov_base;
}
#ifdef __cplusplus
}
#endif
#endif
| 3,494 | 22.77551 | 75 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmempool/replica.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2020, Intel Corporation */
/*
* replica.h -- module for synchronizing and transforming poolset
*/
#ifndef REPLICA_H
#define REPLICA_H
#include "libpmempool.h"
#include "pool.h"
#include "badblocks.h"
#ifdef __cplusplus
extern "C" {
#endif
#define UNDEF_REPLICA UINT_MAX
#define UNDEF_PART UINT_MAX
/*
* A part marked as broken does not exist or is damaged so that
* it cannot be opened and has to be recreated.
*/
#define IS_BROKEN (1U << 0)
/*
* A replica marked as inconsistent exists but has inconsistent metadata
* (e.g. inconsistent parts or replicas linkage)
*/
#define IS_INCONSISTENT (1U << 1)
/*
* A part or replica marked in this way has bad blocks inside.
*/
#define HAS_BAD_BLOCKS (1U << 2)
/*
* A part marked in this way has bad blocks in the header
*/
#define HAS_CORRUPTED_HEADER (1U << 3)
/*
* A flag which can be passed to sync_replica() to indicate that the function is
* called by pmempool_transform
*/
#define IS_TRANSFORMED (1U << 10)
/*
* Number of lanes utilized when working with remote replicas
*/
#define REMOTE_NLANES 1
/*
* Helping structures for storing part's health status
*/
struct part_health_status {
unsigned flags;
struct badblocks bbs; /* structure with bad blocks */
char *recovery_file_name; /* name of bad block recovery file */
int recovery_file_exists; /* bad block recovery file exists */
};
/*
* Helping structures for storing replica and poolset's health status
*/
struct replica_health_status {
unsigned nparts;
unsigned nhdrs;
/* a flag for the replica */
unsigned flags;
/* effective size of a pool, valid only for healthy replica */
size_t pool_size;
/* flags for each part */
struct part_health_status part[];
};
struct poolset_health_status {
unsigned nreplicas;
/* a flag for the poolset */
unsigned flags;
/* health statuses for each replica */
struct replica_health_status *replica[];
};
/* get index of the (r)th replica health status */
static inline unsigned
REP_HEALTHidx(struct poolset_health_status *set, unsigned r)
{
ASSERTne(set->nreplicas, 0);
return (set->nreplicas + r) % set->nreplicas;
}
/* get index of the (r + 1)th replica health status */
static inline unsigned
REPN_HEALTHidx(struct poolset_health_status *set, unsigned r)
{
ASSERTne(set->nreplicas, 0);
return (set->nreplicas + r + 1) % set->nreplicas;
}
/* get (p)th part health status */
static inline unsigned
PART_HEALTHidx(struct replica_health_status *rep, unsigned p)
{
ASSERTne(rep->nparts, 0);
return (rep->nparts + p) % rep->nparts;
}
/* get (r)th replica health status */
static inline struct replica_health_status *
REP_HEALTH(struct poolset_health_status *set, unsigned r)
{
return set->replica[REP_HEALTHidx(set, r)];
}
/* get (p)th part health status */
static inline unsigned
PART_HEALTH(struct replica_health_status *rep, unsigned p)
{
return rep->part[PART_HEALTHidx(rep, p)].flags;
}
uint64_t replica_get_part_offset(struct pool_set *set,
unsigned repn, unsigned partn);
void replica_align_badblock_offset_length(size_t *offset, size_t *length,
struct pool_set *set_in, unsigned repn, unsigned partn);
size_t replica_get_part_data_len(struct pool_set *set_in, unsigned repn,
unsigned partn);
uint64_t replica_get_part_data_offset(struct pool_set *set_in, unsigned repn,
unsigned part);
/*
* is_dry_run -- (internal) check whether only verification mode is enabled
*/
static inline bool
is_dry_run(unsigned flags)
{
/*
* PMEMPOOL_SYNC_DRY_RUN and PMEMPOOL_TRANSFORM_DRY_RUN
* have to have the same value in order to use this common function.
*/
ASSERT_COMPILE_ERROR_ON(PMEMPOOL_SYNC_DRY_RUN !=
PMEMPOOL_TRANSFORM_DRY_RUN);
return flags & PMEMPOOL_SYNC_DRY_RUN;
}
/*
* fix_bad_blocks -- (internal) fix bad blocks - it causes reading or creating
* bad blocks recovery files
* (depending on if they exist or not)
*/
static inline bool
fix_bad_blocks(unsigned flags)
{
return flags & PMEMPOOL_SYNC_FIX_BAD_BLOCKS;
}
int replica_remove_all_recovery_files(struct poolset_health_status *set_hs);
int replica_remove_part(struct pool_set *set, unsigned repn, unsigned partn,
int fix_bad_blocks);
int replica_create_poolset_health_status(struct pool_set *set,
struct poolset_health_status **set_hsp);
void replica_free_poolset_health_status(struct poolset_health_status *set_s);
int replica_check_poolset_health(struct pool_set *set,
struct poolset_health_status **set_hs,
int called_from_sync, unsigned flags);
int replica_is_part_broken(unsigned repn, unsigned partn,
struct poolset_health_status *set_hs);
int replica_has_bad_blocks(unsigned repn, struct poolset_health_status *set_hs);
int replica_part_has_bad_blocks(struct part_health_status *phs);
int replica_part_has_corrupted_header(unsigned repn, unsigned partn,
struct poolset_health_status *set_hs);
unsigned replica_find_unbroken_part(unsigned repn,
struct poolset_health_status *set_hs);
int replica_is_replica_broken(unsigned repn,
struct poolset_health_status *set_hs);
int replica_is_replica_consistent(unsigned repn,
struct poolset_health_status *set_hs);
int replica_is_replica_healthy(unsigned repn,
struct poolset_health_status *set_hs);
unsigned replica_find_healthy_replica(
struct poolset_health_status *set_hs);
unsigned replica_find_replica_healthy_header(
struct poolset_health_status *set_hs);
int replica_is_poolset_healthy(struct poolset_health_status *set_hs);
int replica_is_poolset_transformed(unsigned flags);
ssize_t replica_get_pool_size(struct pool_set *set, unsigned repn);
int replica_check_part_sizes(struct pool_set *set, size_t min_size);
int replica_check_part_dirs(struct pool_set *set);
int replica_check_local_part_dir(struct pool_set *set, unsigned repn,
unsigned partn);
int replica_open_replica_part_files(struct pool_set *set, unsigned repn);
int replica_open_poolset_part_files(struct pool_set *set);
int replica_sync(struct pool_set *set_in, struct poolset_health_status *set_hs,
unsigned flags);
int replica_transform(struct pool_set *set_in, struct pool_set *set_out,
unsigned flags);
#ifdef __cplusplus
}
#endif
#endif
| 6,216 | 28.325472 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmempool/check.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018, Intel Corporation */
/*
* check.h -- internal definitions for logic performing check
*/
#ifndef CHECK_H
#define CHECK_H
#ifdef __cplusplus
extern "C" {
#endif
int check_init(PMEMpoolcheck *ppc);
struct check_status *check_step(PMEMpoolcheck *ppc);
void check_fini(PMEMpoolcheck *ppc);
int check_is_end(struct check_data *data);
struct pmempool_check_status *check_status_get(struct check_status *status);
#ifdef _WIN32
void convert_status_cache(PMEMpoolcheck *ppc, char *buf, size_t size);
#endif
#ifdef __cplusplus
}
#endif
#endif
| 607 | 18.612903 | 76 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmempool/check_util.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018, Intel Corporation */
/*
* check_util.h -- internal definitions check util
*/
#ifndef CHECK_UTIL_H
#define CHECK_UTIL_H
#include <time.h>
#include <limits.h>
#include <sys/param.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CHECK_STEP_COMPLETE UINT_MAX
#define CHECK_INVALID_QUESTION UINT_MAX
#define REQUIRE_ADVANCED "the following error can be fixed using " \
"PMEMPOOL_CHECK_ADVANCED flag"
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
/* check control context */
struct check_data;
struct arena;
/* queue of check statuses */
struct check_status;
/* container storing state of all check steps */
#define PREFIX_MAX_SIZE 30
typedef struct {
unsigned init_done;
unsigned step;
unsigned replica;
unsigned part;
int single_repl;
int single_part;
struct pool_set *set;
int is_dev_dax;
struct pool_hdr *hdrp;
/* copy of the pool header in host byte order */
struct pool_hdr hdr;
int hdr_valid;
/*
* If pool header has been modified this field indicates that
* the pool parameters structure requires refresh.
*/
int pool_hdr_modified;
unsigned healthy_replicas;
struct pool_hdr *next_part_hdrp;
struct pool_hdr *prev_part_hdrp;
struct pool_hdr *next_repl_hdrp;
struct pool_hdr *prev_repl_hdrp;
int next_part_hdr_valid;
int prev_part_hdr_valid;
int next_repl_hdr_valid;
int prev_repl_hdr_valid;
/* valid poolset uuid */
uuid_t *valid_puuid;
/* valid part uuid */
uuid_t *valid_uuid;
/* valid part pool header */
struct pool_hdr *valid_part_hdrp;
int valid_part_done;
unsigned valid_part_replica;
char prefix[PREFIX_MAX_SIZE];
struct arena *arenap;
uint64_t offset;
uint32_t narena;
uint8_t *bitmap;
uint8_t *dup_bitmap;
uint8_t *fbitmap;
struct list *list_inval;
struct list *list_flog_inval;
struct list *list_unmap;
struct {
int btti_header;
int btti_backup;
} valid;
struct {
struct btt_info btti;
uint64_t btti_offset;
} pool_valid;
} location;
/* check steps */
void check_bad_blocks(PMEMpoolcheck *ppc);
void check_backup(PMEMpoolcheck *ppc);
void check_pool_hdr(PMEMpoolcheck *ppc);
void check_pool_hdr_uuids(PMEMpoolcheck *ppc);
void check_sds(PMEMpoolcheck *ppc);
void check_log(PMEMpoolcheck *ppc);
void check_blk(PMEMpoolcheck *ppc);
void check_btt_info(PMEMpoolcheck *ppc);
void check_btt_map_flog(PMEMpoolcheck *ppc);
void check_write(PMEMpoolcheck *ppc);
struct check_data *check_data_alloc(void);
void check_data_free(struct check_data *data);
uint32_t check_step_get(struct check_data *data);
void check_step_inc(struct check_data *data);
location *check_get_step_data(struct check_data *data);
void check_end(struct check_data *data);
int check_is_end_util(struct check_data *data);
int check_status_create(PMEMpoolcheck *ppc, enum pmempool_check_msg_type type,
uint32_t arg, const char *fmt, ...) FORMAT_PRINTF(4, 5);
void check_status_release(PMEMpoolcheck *ppc, struct check_status *status);
void check_clear_status_cache(struct check_data *data);
struct check_status *check_pop_question(struct check_data *data);
struct check_status *check_pop_error(struct check_data *data);
struct check_status *check_pop_info(struct check_data *data);
bool check_has_error(struct check_data *data);
bool check_has_answer(struct check_data *data);
int check_push_answer(PMEMpoolcheck *ppc);
struct pmempool_check_status *check_status_get_util(
struct check_status *status);
int check_status_is(struct check_status *status,
enum pmempool_check_msg_type type);
/* create info status */
#define CHECK_INFO(ppc, ...)\
check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_INFO, 0, __VA_ARGS__)
/* create info status and append error message based on errno */
#define CHECK_INFO_ERRNO(ppc, ...)\
check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_INFO,\
(uint32_t)errno, __VA_ARGS__)
/* create error status */
#define CHECK_ERR(ppc, ...)\
check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_ERROR, 0, __VA_ARGS__)
/* create question status */
#define CHECK_ASK(ppc, question, ...)\
check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_QUESTION, question,\
__VA_ARGS__)
#define CHECK_NOT_COMPLETE(loc, steps)\
((loc)->step != CHECK_STEP_COMPLETE &&\
((steps)[(loc)->step].check != NULL ||\
(steps)[(loc)->step].fix != NULL))
int check_answer_loop(PMEMpoolcheck *ppc, location *data,
void *ctx, int fail_on_no,
int (*callback)(PMEMpoolcheck *, location *, uint32_t, void *ctx));
int check_questions_sequence_validate(PMEMpoolcheck *ppc);
const char *check_get_time_str(time_t time);
const char *check_get_uuid_str(uuid_t uuid);
const char *check_get_pool_type_str(enum pool_type type);
void check_insert_arena(PMEMpoolcheck *ppc, struct arena *arenap);
#ifdef _WIN32
void cache_to_utf8(struct check_data *data, char *buf, size_t size);
#endif
#define CHECK_IS(ppc, flag)\
util_flag_isset((ppc)->args.flags, PMEMPOOL_CHECK_ ## flag)
#define CHECK_IS_NOT(ppc, flag)\
util_flag_isclr((ppc)->args.flags, PMEMPOOL_CHECK_ ## flag)
#define CHECK_WITHOUT_FIXING(ppc)\
CHECK_IS_NOT(ppc, REPAIR) || CHECK_IS(ppc, DRY_RUN)
#ifdef __cplusplus
}
#endif
#endif
| 5,143 | 25.111675 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmempool/pmempool.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018, Intel Corporation */
/*
* pmempool.h -- internal definitions for libpmempool
*/
#ifndef PMEMPOOL_H
#define PMEMPOOL_H
#ifdef __cplusplus
extern "C" {
#endif
#define PMEMPOOL_LOG_PREFIX "libpmempool"
#define PMEMPOOL_LOG_LEVEL_VAR "PMEMPOOL_LOG_LEVEL"
#define PMEMPOOL_LOG_FILE_VAR "PMEMPOOL_LOG_FILE"
enum check_result {
CHECK_RESULT_CONSISTENT,
CHECK_RESULT_NOT_CONSISTENT,
CHECK_RESULT_ASK_QUESTIONS,
CHECK_RESULT_PROCESS_ANSWERS,
CHECK_RESULT_REPAIRED,
CHECK_RESULT_CANNOT_REPAIR,
CHECK_RESULT_ERROR,
CHECK_RESULT_INTERNAL_ERROR
};
/*
* pmempool_check_ctx -- context and arguments for check command
*/
struct pmempool_check_ctx {
struct pmempool_check_args args;
char *path;
char *backup_path;
struct check_data *data;
struct pool_data *pool;
enum check_result result;
unsigned sync_required;
};
#ifdef __cplusplus
}
#endif
#endif
| 927 | 17.938776 | 64 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmempool/pool.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* pool.h -- internal definitions for pool processing functions
*/
#ifndef POOL_H
#define POOL_H
#include <stdbool.h>
#include <sys/types.h>
#include "libpmemobj.h"
#include "queue.h"
#include "set.h"
#include "log.h"
#include "blk.h"
#include "btt_layout.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "alloc.h"
#include "fault_injection.h"
enum pool_type {
POOL_TYPE_UNKNOWN = (1 << 0),
POOL_TYPE_LOG = (1 << 1),
POOL_TYPE_BLK = (1 << 2),
POOL_TYPE_OBJ = (1 << 3),
POOL_TYPE_BTT = (1 << 4),
POOL_TYPE_ANY = POOL_TYPE_UNKNOWN | POOL_TYPE_LOG |
POOL_TYPE_BLK | POOL_TYPE_OBJ | POOL_TYPE_BTT,
};
struct pool_params {
enum pool_type type;
char signature[POOL_HDR_SIG_LEN];
features_t features;
size_t size;
mode_t mode;
int is_poolset;
int is_part;
int is_dev_dax;
int is_pmem;
union {
struct {
uint64_t bsize;
} blk;
struct {
char layout[PMEMOBJ_MAX_LAYOUT];
} obj;
};
};
struct pool_set_file {
int fd;
char *fname;
void *addr;
size_t size;
struct pool_set *poolset;
time_t mtime;
mode_t mode;
};
struct arena {
PMDK_TAILQ_ENTRY(arena) next;
struct btt_info btt_info;
uint32_t id;
bool valid;
bool zeroed;
uint64_t offset;
uint8_t *flog;
size_t flogsize;
uint32_t *map;
size_t mapsize;
};
struct pool_data {
struct pool_params params;
struct pool_set_file *set_file;
int blk_no_layout;
union {
struct pool_hdr pool;
struct pmemlog log;
struct pmemblk blk;
} hdr;
enum {
UUID_NOP = 0,
UUID_FROM_BTT,
UUID_NOT_FROM_BTT,
} uuid_op;
struct arena bttc;
PMDK_TAILQ_HEAD(arenashead, arena) arenas;
uint32_t narenas;
};
struct pool_data *pool_data_alloc(PMEMpoolcheck *ppc);
void pool_data_free(struct pool_data *pool);
void pool_params_from_header(struct pool_params *params,
const struct pool_hdr *hdr);
int pool_set_parse(struct pool_set **setp, const char *path);
void *pool_set_file_map(struct pool_set_file *file, uint64_t offset);
int pool_read(struct pool_data *pool, void *buff, size_t nbytes,
uint64_t off);
int pool_write(struct pool_data *pool, const void *buff, size_t nbytes,
uint64_t off);
int pool_copy(struct pool_data *pool, const char *dst_path, int overwrite);
int pool_set_part_copy(struct pool_set_part *dpart,
struct pool_set_part *spart, int overwrite);
int pool_memset(struct pool_data *pool, uint64_t off, int c, size_t count);
unsigned pool_set_files_count(struct pool_set_file *file);
int pool_set_file_map_headers(struct pool_set_file *file, int rdonly, int prv);
void pool_set_file_unmap_headers(struct pool_set_file *file);
void pool_hdr_default(enum pool_type type, struct pool_hdr *hdrp);
enum pool_type pool_hdr_get_type(const struct pool_hdr *hdrp);
enum pool_type pool_set_type(struct pool_set *set);
const char *pool_get_pool_type_str(enum pool_type type);
int pool_btt_info_valid(struct btt_info *infop);
int pool_blk_get_first_valid_arena(struct pool_data *pool,
struct arena *arenap);
int pool_blk_bsize_valid(uint32_t bsize, uint64_t fsize);
uint64_t pool_next_arena_offset(struct pool_data *pool, uint64_t header_offset);
uint64_t pool_get_first_valid_btt(struct pool_data *pool,
struct btt_info *infop, uint64_t offset, bool *zeroed);
size_t pool_get_min_size(enum pool_type);
#if FAULT_INJECTION
void
pmempool_inject_fault_at(enum pmem_allocation_type type, int nth,
const char *at);
int
pmempool_fault_injection_enabled(void);
#else
static inline void
pmempool_inject_fault_at(enum pmem_allocation_type type, int nth,
const char *at)
{
abort();
}
static inline int
pmempool_fault_injection_enabled(void)
{
return 0;
}
#endif
#ifdef __cplusplus
}
#endif
#endif
| 3,712 | 21.640244 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem/pmem.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* pmem.h -- internal definitions for libpmem
*/
#ifndef PMEM_H
#define PMEM_H
#include <stddef.h>
#include "alloc.h"
#include "fault_injection.h"
#include "util.h"
#include "valgrind_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PMEM_LOG_PREFIX "libpmem"
#define PMEM_LOG_LEVEL_VAR "PMEM_LOG_LEVEL"
#define PMEM_LOG_FILE_VAR "PMEM_LOG_FILE"
typedef int (*is_pmem_func)(const void *addr, size_t len);
void pmem_init(void);
void pmem_os_init(is_pmem_func *func);
int is_pmem_detect(const void *addr, size_t len);
void *pmem_map_register(int fd, size_t len, const char *path, int is_dev_dax);
#if FAULT_INJECTION
void
pmem_inject_fault_at(enum pmem_allocation_type type, int nth,
const char *at);
int
pmem_fault_injection_enabled(void);
#else
static inline void
pmem_inject_fault_at(enum pmem_allocation_type type, int nth,
const char *at)
{
abort();
}
static inline int
pmem_fault_injection_enabled(void)
{
return 0;
}
#endif
#ifdef __cplusplus
}
#endif
#endif
| 1,089 | 17.474576 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/auto_flush_windows.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2019, Intel Corporation */
#ifndef PMEM2_AUTO_FLUSH_WINDOWS_H
#define PMEM2_AUTO_FLUSH_WINDOWS_H 1
#define ACPI_SIGNATURE 0x41435049 /* hex value of ACPI signature */
#define NFIT_REV_SIGNATURE 0x5449464e /* hex value of htonl(NFIT) signature */
#define NFIT_STR_SIGNATURE "NFIT"
#define NFIT_SIGNATURE_LEN 4
#define NFIT_OEM_ID_LEN 6
#define NFIT_OEM_TABLE_ID_LEN 8
#define NFIT_MAX_STRUCTURES 8
#define PCS_RESERVED 3
#define PCS_RESERVED_2 4
#define PCS_TYPE_NUMBER 7
/* check if bit on 'bit' position in number 'num' is set */
#define CHECK_BIT(num, bit) (((num) >> (bit)) & 1)
/*
* sets alignment of members of structure
*/
#pragma pack(1)
struct platform_capabilities
{
uint16_t type;
uint16_t length;
uint8_t highest_valid;
uint8_t reserved[PCS_RESERVED];
uint32_t capabilities;
uint8_t reserved2[PCS_RESERVED_2];
};
struct nfit_header
{
uint8_t signature[NFIT_SIGNATURE_LEN];
uint32_t length;
uint8_t revision;
uint8_t checksum;
uint8_t oem_id[NFIT_OEM_ID_LEN];
uint8_t oem_table_id[NFIT_OEM_TABLE_ID_LEN];
uint32_t oem_revision;
uint8_t creator_id[4];
uint32_t creator_revision;
uint32_t reserved;
};
#pragma pack()
#endif
| 1,215 | 22.843137 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/region_namespace.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/*
* region_namespace.h -- internal definitions for libpmem2
* common region related functions
*/
#ifndef PMDK_REGION_NAMESPACE_H
#define PMDK_REGION_NAMESPACE_H 1
#include "os.h"
#include "pmem2_utils.h"
#include "source.h"
#ifdef __cplusplus
extern "C" {
#endif
int pmem2_get_region_id(const struct pmem2_source *src, unsigned *region_id);
#ifdef __cplusplus
}
#endif
#endif /* PMDK_REGION_NAMESPACE_H */
| 520 | 18.296296 | 77 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/config.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2020, Intel Corporation */
/*
* config.h -- internal definitions for pmem2_config
*/
#ifndef PMEM2_CONFIG_H
#define PMEM2_CONFIG_H
#include "libpmem2.h"
#define PMEM2_GRANULARITY_INVALID ((enum pmem2_granularity) (-1))
#define PMEM2_ADDRESS_ANY 0 /* default value of the address request type */
struct pmem2_config {
/* offset from the beginning of the file */
size_t offset;
size_t length; /* length of the mapping */
/* persistence granularity requested by user */
void *addr; /* address of the mapping */
int addr_request; /* address request type */
enum pmem2_granularity requested_max_granularity;
enum pmem2_sharing_type sharing; /* the way the file will be mapped */
unsigned protection_flag;
};
void pmem2_config_init(struct pmem2_config *cfg);
int pmem2_config_validate_length(const struct pmem2_config *cfg,
size_t file_len, size_t alignment);
int pmem2_config_validate_addr_alignment(const struct pmem2_config *cfg,
const struct pmem2_source *src);
#endif /* PMEM2_CONFIG_H */
| 1,070 | 28.75 | 75 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/auto_flush.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2019, Intel Corporation */
/*
* auto_flush.h -- auto flush detection functionality
*/
#ifndef PMEM2_AUTO_FLUSH_H
#define PMEM2_AUTO_FLUSH_H 1
#ifdef __cplusplus
extern "C" {
#endif
int pmem2_auto_flush(void);
#ifdef __cplusplus
}
#endif
#endif
| 311 | 13.181818 | 53 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/map.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2020, Intel Corporation */
/*
* map.h -- internal definitions for libpmem2
*/
#ifndef PMEM2_MAP_H
#define PMEM2_MAP_H
#include <stddef.h>
#include <stdbool.h>
#include "libpmem2.h"
#include "os.h"
#include "source.h"
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*pmem2_deep_flush_fn)(struct pmem2_map *map,
void *ptr, size_t size);
struct pmem2_map {
void *addr; /* base address */
size_t reserved_length; /* length of the mapping reservation */
size_t content_length; /* length of the mapped content */
/* effective persistence granularity */
enum pmem2_granularity effective_granularity;
pmem2_persist_fn persist_fn;
pmem2_flush_fn flush_fn;
pmem2_drain_fn drain_fn;
pmem2_deep_flush_fn deep_flush_fn;
pmem2_memmove_fn memmove_fn;
pmem2_memcpy_fn memcpy_fn;
pmem2_memset_fn memset_fn;
struct pmem2_source source;
};
enum pmem2_granularity get_min_granularity(bool eADR, bool is_pmem,
enum pmem2_sharing_type sharing);
struct pmem2_map *pmem2_map_find(const void *addr, size_t len);
int pmem2_register_mapping(struct pmem2_map *map);
int pmem2_unregister_mapping(struct pmem2_map *map);
void pmem2_map_init(void);
void pmem2_map_fini(void);
int pmem2_validate_offset(const struct pmem2_config *cfg,
size_t *offset, size_t alignment);
#ifdef __cplusplus
}
#endif
#endif /* map.h */
| 1,426 | 22.016129 | 67 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/deep_flush.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/*
* deep_flush.h -- functions for deep flush functionality
*/
#ifndef PMEM2_DEEP_FLUSH_H
#define PMEM2_DEEP_FLUSH_H 1
#include "map.h"
#ifdef __cplusplus
extern "C" {
#endif
int pmem2_deep_flush_write(unsigned region_id);
int pmem2_deep_flush_dax(struct pmem2_map *map, void *ptr, size_t size);
int pmem2_deep_flush_page(struct pmem2_map *map, void *ptr, size_t size);
int pmem2_deep_flush_cache(struct pmem2_map *map, void *ptr, size_t size);
int pmem2_deep_flush_byte(struct pmem2_map *map, void *ptr, size_t size);
#ifdef __cplusplus
}
#endif
#endif
| 644 | 22.035714 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/ravl_interval.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/*
* ravl_interval.h -- internal definitions for ravl_interval
*/
#ifndef RAVL_INTERVAL_H
#define RAVL_INTERVAL_H
#include "libpmem2.h"
#include "os_thread.h"
#include "ravl.h"
struct ravl_interval;
struct ravl_interval_node;
typedef size_t ravl_interval_min(void *addr);
typedef size_t ravl_interval_max(void *addr);
struct ravl_interval *ravl_interval_new(ravl_interval_min *min,
ravl_interval_min *max);
void ravl_interval_delete(struct ravl_interval *ri);
int ravl_interval_insert(struct ravl_interval *ri, void *addr);
int ravl_interval_remove(struct ravl_interval *ri,
struct ravl_interval_node *rin);
struct ravl_interval_node *ravl_interval_find_equal(struct ravl_interval *ri,
void *addr);
struct ravl_interval_node *ravl_interval_find(struct ravl_interval *ri,
void *addr);
void *ravl_interval_data(struct ravl_interval_node *rin);
#endif
| 947 | 27.727273 | 77 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/pmem2_arch.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* pmem2_arch.h -- core-arch interface
*/
#ifndef PMEM2_ARCH_H
#define PMEM2_ARCH_H
#include <stddef.h>
#include "libpmem2.h"
#include "util.h"
#include "valgrind_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
struct pmem2_arch_info;
typedef void (*fence_func)(void);
typedef void (*flush_func)(const void *, size_t);
typedef void *(*memmove_nodrain_func)(void *pmemdest, const void *src,
size_t len, unsigned flags, flush_func flush);
typedef void *(*memset_nodrain_func)(void *pmemdest, int c, size_t len,
unsigned flags, flush_func flush);
struct pmem2_arch_info {
memmove_nodrain_func memmove_nodrain;
memmove_nodrain_func memmove_nodrain_eadr;
memset_nodrain_func memset_nodrain;
memset_nodrain_func memset_nodrain_eadr;
flush_func flush;
fence_func fence;
int flush_has_builtin_fence;
};
void pmem2_arch_init(struct pmem2_arch_info *info);
/*
* flush_empty_nolog -- (internal) do not flush the CPU cache
*/
static force_inline void
flush_empty_nolog(const void *addr, size_t len)
{
/* NOP, but tell pmemcheck about it */
VALGRIND_DO_FLUSH(addr, len);
}
void *memmove_nodrain_generic(void *pmemdest, const void *src, size_t len,
unsigned flags, flush_func flush);
void *memset_nodrain_generic(void *pmemdest, int c, size_t len, unsigned flags,
flush_func flush);
#ifdef __cplusplus
}
#endif
#endif
| 1,427 | 22.8 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/persist.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2020, Intel Corporation */
/*
* persist.h -- internal definitions for libpmem2 persist module
*/
#ifndef PMEM2_PERSIST_H
#define PMEM2_PERSIST_H
#include <stddef.h>
#include "map.h"
#ifdef __cplusplus
extern "C" {
#endif
void pmem2_persist_init(void);
int pmem2_flush_file_buffers_os(struct pmem2_map *map, const void *addr,
size_t len, int autorestart);
void pmem2_set_flush_fns(struct pmem2_map *map);
void pmem2_set_mem_fns(struct pmem2_map *map);
#ifdef __cplusplus
}
#endif
#endif
| 557 | 17.6 | 72 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/source.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
#ifndef PMEM2_SOURCE_H
#define PMEM2_SOURCE_H
#include "os.h"
#define INVALID_FD (-1)
enum pmem2_file_type {
PMEM2_FTYPE_REG = 1,
PMEM2_FTYPE_DEVDAX = 2,
PMEM2_FTYPE_DIR = 3,
};
enum pmem2_source_type {
PMEM2_SOURCE_UNSPECIFIED,
PMEM2_SOURCE_ANON,
PMEM2_SOURCE_FD,
PMEM2_SOURCE_HANDLE,
MAX_PMEM2_SOURCE_TYPE
};
struct pmem2_source {
/* a source file descriptor / handle for the designed mapping */
enum pmem2_source_type type;
struct {
enum pmem2_file_type ftype;
union {
/* PMEM2_SOURCE_ANON */
size_t size;
#ifdef _WIN32
/* PMEM2_SOURCE_HANDLE */
HANDLE handle;
#else
/* PMEM2_SOURCE_FD */
struct {
int fd;
dev_t st_rdev;
dev_t st_dev;
};
#endif
};
} value;
};
#endif /* PMEM2_SOURCE_H */
| 831 | 15.64 | 65 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/pmem2.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019, Intel Corporation */
/*
* pmem2.h -- internal definitions for libpmem2
*/
#ifndef PMEM2_H
#define PMEM2_H
#include "libpmem2.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PMEM2_MAJOR_VERSION 0
#define PMEM2_MINOR_VERSION 0
#define PMEM2_LOG_PREFIX "libpmem2"
#define PMEM2_LOG_LEVEL_VAR "PMEM2_LOG_LEVEL"
#define PMEM2_LOG_FILE_VAR "PMEM2_LOG_FILE"
#ifdef __cplusplus
}
#endif
#endif
| 457 | 15.357143 | 47 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/pmem2_utils.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2020, Intel Corporation */
/*
* pmem2_utils.h -- libpmem2 utilities functions
*/
#ifndef PMEM2_UTILS_H
#define PMEM2_UTILS_H 1
#include <errno.h>
#include "os.h"
#include "out.h"
#include "source.h"
static inline int
pmem2_assert_errno(void)
{
if (!errno) {
ERR("errno is not set");
ASSERTinfo(0, "errno is not set");
return -EINVAL;
}
return -errno;
}
#define PMEM2_E_ERRNO (pmem2_assert_errno())
void *pmem2_malloc(size_t size, int *err);
void *pmem2_zalloc(size_t size, int *err);
void *pmem2_realloc(void *ptr, size_t size, int *err);
#ifdef _WIN32
int pmem2_lasterror_to_err();
#endif
int pmem2_get_type_from_stat(const os_stat_t *st, enum pmem2_file_type *type);
int pmem2_device_dax_size(const struct pmem2_source *src, size_t *size);
int pmem2_device_dax_alignment(const struct pmem2_source *src,
size_t *alignment);
#endif /* PMEM2_UTILS_H */
| 935 | 19.8 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/region_namespace_ndctl.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
/*
* region_namespace_ndctl.h -- internal definitions for libpmem2
* common ndctl functions
*/
#ifndef PMDK_REGION_NAMESPACE_NDCTL_H
#define PMDK_REGION_NAMESPACE_NDCTL_H 1
#include "os.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FOREACH_BUS_REGION_NAMESPACE(ctx, bus, region, ndns) \
ndctl_bus_foreach(ctx, bus) \
ndctl_region_foreach(bus, region) \
ndctl_namespace_foreach(region, ndns)
int pmem2_region_namespace(struct ndctl_ctx *ctx,
const struct pmem2_source *src,
struct ndctl_region **pregion,
struct ndctl_namespace **pndns);
#ifdef __cplusplus
}
#endif
#endif /* PMDK_REGION_NAMESPACE_NDCTL_H */
| 754 | 21.878788 | 64 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/extent.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2020, Intel Corporation */
/*
* extent.h -- fs extent query API
*/
#ifndef PMDK_EXTENT_H
#define PMDK_EXTENT_H 1
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
struct extent {
uint64_t offset_physical;
uint64_t offset_logical;
uint64_t length;
};
struct extents {
uint64_t blksize;
uint32_t extents_count;
struct extent *extents;
};
int pmem2_extents_create_get(int fd, struct extents **exts);
void pmem2_extents_destroy(struct extents **exts);
#ifdef __cplusplus
}
#endif
#endif /* PMDK_EXTENT_H */
| 608 | 15.026316 | 60 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/flush.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
#ifndef X86_64_FLUSH_H
#define X86_64_FLUSH_H
#include <emmintrin.h>
#include <stddef.h>
#include <stdint.h>
#include "util.h"
#include "valgrind_internal.h"
#define FLUSH_ALIGN ((uintptr_t)64)
static force_inline void
pmem_clflush(const void *addr)
{
_mm_clflush(addr);
}
#ifdef _MSC_VER
static force_inline void
pmem_clflushopt(const void *addr)
{
_mm_clflushopt(addr);
}
static force_inline void
pmem_clwb(const void *addr)
{
_mm_clwb(addr);
}
#else
/*
* The x86 memory instructions are new enough that the compiler
* intrinsic functions are not always available. The intrinsic
* functions are defined here in terms of asm statements for now.
*/
static force_inline void
pmem_clflushopt(const void *addr)
{
asm volatile(".byte 0x66; clflush %0" : "+m" \
(*(volatile char *)(addr)));
}
static force_inline void
pmem_clwb(const void *addr)
{
asm volatile(".byte 0x66; xsaveopt %0" : "+m" \
(*(volatile char *)(addr)));
}
#endif /* _MSC_VER */
typedef void flush_fn(const void *, size_t);
/*
* flush_clflush_nolog -- flush the CPU cache, using clflush
*/
static force_inline void
flush_clflush_nolog(const void *addr, size_t len)
{
uintptr_t uptr;
/*
* Loop through cache-line-size (typically 64B) aligned chunks
* covering the given range.
*/
for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1);
uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN)
_mm_clflush((char *)uptr);
}
/*
* flush_clflushopt_nolog -- flush the CPU cache, using clflushopt
*/
static force_inline void
flush_clflushopt_nolog(const void *addr, size_t len)
{
uintptr_t uptr;
/*
* Loop through cache-line-size (typically 64B) aligned chunks
* covering the given range.
*/
for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1);
uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) {
pmem_clflushopt((char *)uptr);
}
}
/*
* flush_clwb_nolog -- flush the CPU cache, using clwb
*/
static force_inline void
flush_clwb_nolog(const void *addr, size_t len)
{
uintptr_t uptr;
/*
* Loop through cache-line-size (typically 64B) aligned chunks
* covering the given range.
*/
for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1);
uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) {
pmem_clwb((char *)uptr);
}
}
/*
* flush64b_empty -- (internal) do not flush the CPU cache
*/
static force_inline void
flush64b_empty(const void *addr)
{
/* NOP, but tell pmemcheck about it */
VALGRIND_DO_FLUSH(addr, 64);
}
#endif
| 2,521 | 20.193277 | 66 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/cpu.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2020, Intel Corporation */
#ifndef PMDK_CPU_H
#define PMDK_CPU_H 1
/*
* cpu.h -- definitions for "cpu" module
*/
int is_cpu_genuine_intel(void);
int is_cpu_clflush_present(void);
int is_cpu_clflushopt_present(void);
int is_cpu_clwb_present(void);
int is_cpu_avx_present(void);
int is_cpu_avx512f_present(void);
#endif
| 383 | 19.210526 | 44 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/avx.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2018, Intel Corporation */
#ifndef PMEM_AVX_H
#define PMEM_AVX_H
#include <immintrin.h>
#include "util.h"
/*
* avx_zeroupper -- _mm256_zeroupper wrapper
*
* _mm256_zeroupper clears upper parts of avx registers.
*
* It's needed for 2 reasons:
* - it improves performance of non-avx code after avx
* - it works around problem discovered by Valgrind
*
* In optimized builds gcc inserts VZEROUPPER automatically before
* calling non-avx code (or at the end of the function). But in release
* builds it doesn't, so if we don't do this by ourselves, then when
* someone memcpy'ies uninitialized data, Valgrind complains whenever
* someone reads those registers.
*
* One notable example is loader, which tries to detect whether it
* needs to save whole ymm registers by looking at their current
* (possibly uninitialized) value.
*
* Valgrind complains like that:
* Conditional jump or move depends on uninitialised value(s)
* at 0x4015CC9: _dl_runtime_resolve_avx_slow
* (in /lib/x86_64-linux-gnu/ld-2.24.so)
* by 0x10B531: test_realloc_api (obj_basic_integration.c:185)
* by 0x10F1EE: main (obj_basic_integration.c:594)
*
* Note: We have to be careful to not read AVX registers after this
* intrinsic, because of this stupid gcc bug:
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82735
*/
static force_inline void
avx_zeroupper(void)
{
_mm256_zeroupper();
}
static force_inline __m128i
m256_get16b(__m256i ymm)
{
return _mm256_extractf128_si256(ymm, 0);
}
#ifdef _MSC_VER
static force_inline uint64_t
m256_get8b(__m256i ymm)
{
return (uint64_t)_mm_extract_epi64(m256_get16b(ymm), 0);
}
static force_inline uint32_t
m256_get4b(__m256i ymm)
{
return (uint32_t)m256_get8b(ymm);
}
static force_inline uint16_t
m256_get2b(__m256i ymm)
{
return (uint16_t)m256_get8b(ymm);
}
#else
static force_inline uint64_t
m256_get8b(__m256i ymm)
{
return (uint64_t)_mm256_extract_epi64(ymm, 0);
}
static force_inline uint32_t
m256_get4b(__m256i ymm)
{
return (uint32_t)_mm256_extract_epi32(ymm, 0);
}
static force_inline uint16_t
m256_get2b(__m256i ymm)
{
return (uint16_t)_mm256_extract_epi16(ymm, 0);
}
#endif
#endif
| 2,238 | 24.735632 | 72 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memcpy_memset.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
#ifndef MEMCPY_MEMSET_H
#define MEMCPY_MEMSET_H
#include <stddef.h>
#include <xmmintrin.h>
#include "pmem2_arch.h"
typedef void barrier_fn(void);
typedef void flush64b_fn(const void *);
static inline void
barrier_after_ntstores(void)
{
/*
* In this configuration pmem_drain does not contain sfence, so we have
* to serialize non-temporal store instructions.
*/
_mm_sfence();
}
static inline void
no_barrier_after_ntstores(void)
{
/*
* In this configuration pmem_drain contains sfence, so we don't have
* to serialize non-temporal store instructions
*/
}
static inline void
noflush(const void *addr, size_t len)
{
/* NOP, not even pmemcheck annotation */
}
static inline void
noflush64b(const void *addr)
{
/* NOP, not even pmemcheck annotation */
}
typedef void perf_barrier_fn(void);
static force_inline void
wc_barrier(void)
{
/*
* Currently, for SSE2 and AVX code paths, use of non-temporal stores
* on all generations of CPUs must be limited to the number of
* write-combining buffers (12) because otherwise, suboptimal eviction
* policy might impact performance when writing more data than WC
* buffers can simultaneously hold.
*
* The AVX512 code path is not affected, probably because we are
* overwriting whole cache lines.
*/
_mm_sfence();
}
static force_inline void
no_barrier(void)
{
}
#ifndef AVX512F_AVAILABLE
/*
* XXX not supported in MSVC version we currently use.
* Enable Windows tests pmem2_mem_ext when MSVC we
* use will support AVX512F.
*/
#ifdef _MSC_VER
#define AVX512F_AVAILABLE 0
#else
#define AVX512F_AVAILABLE 1
#endif
#endif
#ifndef AVX_AVAILABLE
#define AVX_AVAILABLE 1
#endif
#ifndef SSE2_AVAILABLE
#define SSE2_AVAILABLE 1
#endif
#if SSE2_AVAILABLE
void memmove_mov_sse2_clflush(char *dest, const char *src, size_t len);
void memmove_mov_sse2_clflushopt(char *dest, const char *src, size_t len);
void memmove_mov_sse2_clwb(char *dest, const char *src, size_t len);
void memmove_mov_sse2_empty(char *dest, const char *src, size_t len);
void memmove_mov_sse2_noflush(char *dest, const char *src, size_t len);
void memmove_movnt_sse2_clflush_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_clflushopt_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_clwb_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_empty_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_noflush_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_clflush_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_clflushopt_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_clwb_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_empty_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_sse2_noflush_wcbarrier(char *dest, const char *src,
size_t len);
void memset_mov_sse2_clflush(char *dest, int c, size_t len);
void memset_mov_sse2_clflushopt(char *dest, int c, size_t len);
void memset_mov_sse2_clwb(char *dest, int c, size_t len);
void memset_mov_sse2_empty(char *dest, int c, size_t len);
void memset_mov_sse2_noflush(char *dest, int c, size_t len);
void memset_movnt_sse2_clflush_nobarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_clflushopt_nobarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_clwb_nobarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_empty_nobarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_noflush_nobarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_clflush_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_clflushopt_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_clwb_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_empty_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_sse2_noflush_wcbarrier(char *dest, int c, size_t len);
#endif
#if AVX_AVAILABLE
void memmove_mov_avx_clflush(char *dest, const char *src, size_t len);
void memmove_mov_avx_clflushopt(char *dest, const char *src, size_t len);
void memmove_mov_avx_clwb(char *dest, const char *src, size_t len);
void memmove_mov_avx_empty(char *dest, const char *src, size_t len);
void memmove_mov_avx_noflush(char *dest, const char *src, size_t len);
void memmove_movnt_avx_clflush_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_clflushopt_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_clwb_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_empty_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_noflush_nobarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_clflush_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_clflushopt_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_clwb_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_empty_wcbarrier(char *dest, const char *src,
size_t len);
void memmove_movnt_avx_noflush_wcbarrier(char *dest, const char *src,
size_t len);
void memset_mov_avx_clflush(char *dest, int c, size_t len);
void memset_mov_avx_clflushopt(char *dest, int c, size_t len);
void memset_mov_avx_clwb(char *dest, int c, size_t len);
void memset_mov_avx_empty(char *dest, int c, size_t len);
void memset_mov_avx_noflush(char *dest, int c, size_t len);
void memset_movnt_avx_clflush_nobarrier(char *dest, int c, size_t len);
void memset_movnt_avx_clflushopt_nobarrier(char *dest, int c, size_t len);
void memset_movnt_avx_clwb_nobarrier(char *dest, int c, size_t len);
void memset_movnt_avx_empty_nobarrier(char *dest, int c, size_t len);
void memset_movnt_avx_noflush_nobarrier(char *dest, int c, size_t len);
void memset_movnt_avx_clflush_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_avx_clflushopt_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_avx_clwb_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_avx_empty_wcbarrier(char *dest, int c, size_t len);
void memset_movnt_avx_noflush_wcbarrier(char *dest, int c, size_t len);
#endif
#if AVX512F_AVAILABLE
void memmove_mov_avx512f_clflush(char *dest, const char *src, size_t len);
void memmove_mov_avx512f_clflushopt(char *dest, const char *src, size_t len);
void memmove_mov_avx512f_clwb(char *dest, const char *src, size_t len);
void memmove_mov_avx512f_empty(char *dest, const char *src, size_t len);
void memmove_mov_avx512f_noflush(char *dest, const char *src, size_t len);
void memmove_movnt_avx512f_clflush(char *dest, const char *src, size_t len);
void memmove_movnt_avx512f_clflushopt(char *dest, const char *src, size_t len);
void memmove_movnt_avx512f_clwb(char *dest, const char *src, size_t len);
void memmove_movnt_avx512f_empty(char *dest, const char *src, size_t len);
void memmove_movnt_avx512f_noflush(char *dest, const char *src, size_t len);
void memset_mov_avx512f_clflush(char *dest, int c, size_t len);
void memset_mov_avx512f_clflushopt(char *dest, int c, size_t len);
void memset_mov_avx512f_clwb(char *dest, int c, size_t len);
void memset_mov_avx512f_empty(char *dest, int c, size_t len);
void memset_mov_avx512f_noflush(char *dest, int c, size_t len);
void memset_movnt_avx512f_clflush(char *dest, int c, size_t len);
void memset_movnt_avx512f_clflushopt(char *dest, int c, size_t len);
void memset_movnt_avx512f_clwb(char *dest, int c, size_t len);
void memset_movnt_avx512f_empty(char *dest, int c, size_t len);
void memset_movnt_avx512f_noflush(char *dest, int c, size_t len);
#endif
extern size_t Movnt_threshold;
/*
* SSE2/AVX1 only:
*
* How much data WC buffers can hold at the same time, after which sfence
* is needed to flush them.
*
* For some reason sfence affects performance of reading from DRAM, so we have
* to prefetch the source data earlier.
*/
#define PERF_BARRIER_SIZE (12 * CACHELINE_SIZE /* 768 */)
/*
* How much to prefetch initially.
* Cannot be bigger than the size of L1 (32kB) - PERF_BARRIER_SIZE.
*/
#define INI_PREFETCH_SIZE (64 * CACHELINE_SIZE /* 4096 */)
static force_inline void
prefetch(const char *addr)
{
_mm_prefetch(addr, _MM_HINT_T0);
}
static force_inline void
prefetch_ini_fw(const char *src, size_t len)
{
size_t pref = MIN(len, INI_PREFETCH_SIZE);
for (size_t i = 0; i < pref; i += CACHELINE_SIZE)
prefetch(src + i);
}
static force_inline void
prefetch_ini_bw(const char *src, size_t len)
{
size_t pref = MIN(len, INI_PREFETCH_SIZE);
for (size_t i = 0; i < pref; i += CACHELINE_SIZE)
prefetch(src - i);
}
static force_inline void
prefetch_next_fw(const char *src, const char *srcend)
{
const char *begin = src + INI_PREFETCH_SIZE;
const char *end = begin + PERF_BARRIER_SIZE;
if (end > srcend)
end = srcend;
for (const char *addr = begin; addr < end; addr += CACHELINE_SIZE)
prefetch(addr);
}
static force_inline void
prefetch_next_bw(const char *src, const char *srcbegin)
{
const char *begin = src - INI_PREFETCH_SIZE;
const char *end = begin - PERF_BARRIER_SIZE;
if (end < srcbegin)
end = srcbegin;
for (const char *addr = begin; addr >= end; addr -= CACHELINE_SIZE)
prefetch(addr);
}
#endif
| 9,351 | 33.131387 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memset/memset_avx512f.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMSET_AVX512F_H
#define PMEM2_MEMSET_AVX512F_H
#include <stddef.h>
#include "memset_avx.h"
static force_inline void
memset_small_avx512f(char *dest, __m256i ymm, size_t len, flush_fn flush)
{
/* We can't do better than AVX here. */
memset_small_avx(dest, ymm, len, flush);
}
#endif
| 390 | 19.578947 | 73 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memset/memset_avx.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMSET_AVX_H
#define PMEM2_MEMSET_AVX_H
#include <immintrin.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "avx.h"
#include "out.h"
static force_inline void
memset_small_avx_noflush(char *dest, __m256i ymm, size_t len)
{
ASSERT(len <= 64);
if (len <= 8)
goto le8;
if (len <= 32)
goto le32;
/* 33..64 */
_mm256_storeu_si256((__m256i *)dest, ymm);
_mm256_storeu_si256((__m256i *)(dest + len - 32), ymm);
return;
le32:
if (len > 16) {
/* 17..32 */
__m128i xmm = m256_get16b(ymm);
_mm_storeu_si128((__m128i *)dest, xmm);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm);
return;
}
/* 9..16 */
uint64_t d8 = m256_get8b(ymm);
*(ua_uint64_t *)dest = d8;
*(ua_uint64_t *)(dest + len - 8) = d8;
return;
le8:
if (len <= 2)
goto le2;
if (len > 4) {
/* 5..8 */
uint32_t d = m256_get4b(ymm);
*(ua_uint32_t *)dest = d;
*(ua_uint32_t *)(dest + len - 4) = d;
return;
}
/* 3..4 */
uint16_t d2 = m256_get2b(ymm);
*(ua_uint16_t *)dest = d2;
*(ua_uint16_t *)(dest + len - 2) = d2;
return;
le2:
if (len == 2) {
uint16_t d2 = m256_get2b(ymm);
*(ua_uint16_t *)dest = d2;
return;
}
*(uint8_t *)dest = (uint8_t)m256_get2b(ymm);
}
static force_inline void
memset_small_avx(char *dest, __m256i ymm, size_t len, flush_fn flush)
{
/*
* pmemcheck complains about "overwritten stores before they were made
* persistent" for overlapping stores (last instruction in each code
* path) in the optimized version.
* libc's memset also does that, so we can't use it here.
*/
if (On_pmemcheck) {
memset_nodrain_generic(dest, (uint8_t)m256_get2b(ymm),
len, PMEM2_F_MEM_NOFLUSH, NULL);
} else {
memset_small_avx_noflush(dest, ymm, len);
}
flush(dest, len);
}
#endif
| 1,856 | 17.94898 | 71 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memset/memset_sse2.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMSET_SSE2_H
#define PMEM2_MEMSET_SSE2_H
#include <xmmintrin.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "out.h"
static force_inline void
memset_small_sse2_noflush(char *dest, __m128i xmm, size_t len)
{
ASSERT(len <= 64);
if (len <= 8)
goto le8;
if (len <= 32)
goto le32;
if (len > 48) {
/* 49..64 */
_mm_storeu_si128((__m128i *)(dest + 0), xmm);
_mm_storeu_si128((__m128i *)(dest + 16), xmm);
_mm_storeu_si128((__m128i *)(dest + 32), xmm);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm);
return;
}
/* 33..48 */
_mm_storeu_si128((__m128i *)(dest + 0), xmm);
_mm_storeu_si128((__m128i *)(dest + 16), xmm);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm);
return;
le32:
if (len > 16) {
/* 17..32 */
_mm_storeu_si128((__m128i *)(dest + 0), xmm);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm);
return;
}
/* 9..16 */
uint64_t d8 = (uint64_t)_mm_cvtsi128_si64(xmm);
*(ua_uint64_t *)dest = d8;
*(ua_uint64_t *)(dest + len - 8) = d8;
return;
le8:
if (len <= 2)
goto le2;
if (len > 4) {
/* 5..8 */
uint32_t d4 = (uint32_t)_mm_cvtsi128_si32(xmm);
*(ua_uint32_t *)dest = d4;
*(ua_uint32_t *)(dest + len - 4) = d4;
return;
}
/* 3..4 */
uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm);
*(ua_uint16_t *)dest = d2;
*(ua_uint16_t *)(dest + len - 2) = d2;
return;
le2:
if (len == 2) {
uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm);
*(ua_uint16_t *)dest = d2;
return;
}
*(uint8_t *)dest = (uint8_t)_mm_cvtsi128_si32(xmm);
}
static force_inline void
memset_small_sse2(char *dest, __m128i xmm, size_t len, flush_fn flush)
{
/*
* pmemcheck complains about "overwritten stores before they were made
* persistent" for overlapping stores (last instruction in each code
* path) in the optimized version.
* libc's memset also does that, so we can't use it here.
*/
if (On_pmemcheck) {
memset_nodrain_generic(dest, (uint8_t)_mm_cvtsi128_si32(xmm),
len, PMEM2_F_MEM_NOFLUSH, NULL);
} else {
memset_small_sse2_noflush(dest, xmm, len);
}
flush(dest, len);
}
#endif
| 2,213 | 20.085714 | 71 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memcpy/memcpy_avx.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMCPY_AVX_H
#define PMEM2_MEMCPY_AVX_H
#include <immintrin.h>
#include <stddef.h>
#include <stdint.h>
#include "out.h"
static force_inline void
memmove_small_avx_noflush(char *dest, const char *src, size_t len)
{
ASSERT(len <= 64);
if (len <= 8)
goto le8;
if (len <= 32)
goto le32;
/* 33..64 */
__m256i ymm0 = _mm256_loadu_si256((__m256i *)src);
__m256i ymm1 = _mm256_loadu_si256((__m256i *)(src + len - 32));
_mm256_storeu_si256((__m256i *)dest, ymm0);
_mm256_storeu_si256((__m256i *)(dest + len - 32), ymm1);
return;
le32:
if (len > 16) {
/* 17..32 */
__m128i xmm0 = _mm_loadu_si128((__m128i *)src);
__m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16));
_mm_storeu_si128((__m128i *)dest, xmm0);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm1);
return;
}
/* 9..16 */
ua_uint64_t d80 = *(ua_uint64_t *)src;
ua_uint64_t d81 = *(ua_uint64_t *)(src + len - 8);
*(ua_uint64_t *)dest = d80;
*(ua_uint64_t *)(dest + len - 8) = d81;
return;
le8:
if (len <= 2)
goto le2;
if (len > 4) {
/* 5..8 */
ua_uint32_t d40 = *(ua_uint32_t *)src;
ua_uint32_t d41 = *(ua_uint32_t *)(src + len - 4);
*(ua_uint32_t *)dest = d40;
*(ua_uint32_t *)(dest + len - 4) = d41;
return;
}
/* 3..4 */
ua_uint16_t d20 = *(ua_uint16_t *)src;
ua_uint16_t d21 = *(ua_uint16_t *)(src + len - 2);
*(ua_uint16_t *)dest = d20;
*(ua_uint16_t *)(dest + len - 2) = d21;
return;
le2:
if (len == 2) {
*(ua_uint16_t *)dest = *(ua_uint16_t *)src;
return;
}
*(uint8_t *)dest = *(uint8_t *)src;
}
static force_inline void
memmove_small_avx(char *dest, const char *src, size_t len, flush_fn flush)
{
/*
* pmemcheck complains about "overwritten stores before they were made
* persistent" for overlapping stores (last instruction in each code
* path) in the optimized version.
* libc's memcpy also does that, so we can't use it here.
*/
if (On_pmemcheck) {
memmove_nodrain_generic(dest, src, len, PMEM2_F_MEM_NOFLUSH,
NULL);
} else {
memmove_small_avx_noflush(dest, src, len);
}
flush(dest, len);
}
#endif
| 2,173 | 20.524752 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memcpy/memcpy_sse2.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMCPY_SSE2_H
#define PMEM2_MEMCPY_SSE2_H
#include <xmmintrin.h>
#include <stddef.h>
#include <stdint.h>
#include "out.h"
static force_inline void
memmove_small_sse2_noflush(char *dest, const char *src, size_t len)
{
ASSERT(len <= 64);
if (len <= 8)
goto le8;
if (len <= 32)
goto le32;
if (len > 48) {
/* 49..64 */
__m128i xmm0 = _mm_loadu_si128((__m128i *)src);
__m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16));
__m128i xmm2 = _mm_loadu_si128((__m128i *)(src + 32));
__m128i xmm3 = _mm_loadu_si128((__m128i *)(src + len - 16));
_mm_storeu_si128((__m128i *)dest, xmm0);
_mm_storeu_si128((__m128i *)(dest + 16), xmm1);
_mm_storeu_si128((__m128i *)(dest + 32), xmm2);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm3);
return;
}
/* 33..48 */
__m128i xmm0 = _mm_loadu_si128((__m128i *)src);
__m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16));
__m128i xmm2 = _mm_loadu_si128((__m128i *)(src + len - 16));
_mm_storeu_si128((__m128i *)dest, xmm0);
_mm_storeu_si128((__m128i *)(dest + 16), xmm1);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm2);
return;
le32:
if (len > 16) {
/* 17..32 */
__m128i xmm0 = _mm_loadu_si128((__m128i *)src);
__m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16));
_mm_storeu_si128((__m128i *)dest, xmm0);
_mm_storeu_si128((__m128i *)(dest + len - 16), xmm1);
return;
}
/* 9..16 */
uint64_t d80 = *(ua_uint64_t *)src;
uint64_t d81 = *(ua_uint64_t *)(src + len - 8);
*(ua_uint64_t *)dest = d80;
*(ua_uint64_t *)(dest + len - 8) = d81;
return;
le8:
if (len <= 2)
goto le2;
if (len > 4) {
/* 5..8 */
uint32_t d40 = *(ua_uint32_t *)src;
uint32_t d41 = *(ua_uint32_t *)(src + len - 4);
*(ua_uint32_t *)dest = d40;
*(ua_uint32_t *)(dest + len - 4) = d41;
return;
}
/* 3..4 */
uint16_t d20 = *(ua_uint16_t *)src;
uint16_t d21 = *(ua_uint16_t *)(src + len - 2);
*(ua_uint16_t *)dest = d20;
*(ua_uint16_t *)(dest + len - 2) = d21;
return;
le2:
if (len == 2) {
*(ua_uint16_t *)dest = *(ua_uint16_t *)src;
return;
}
*(uint8_t *)dest = *(uint8_t *)src;
}
static force_inline void
memmove_small_sse2(char *dest, const char *src, size_t len, flush_fn flush)
{
/*
* pmemcheck complains about "overwritten stores before they were made
* persistent" for overlapping stores (last instruction in each code
* path) in the optimized version.
* libc's memcpy also does that, so we can't use it here.
*/
if (On_pmemcheck) {
memmove_nodrain_generic(dest, src, len, PMEM2_F_MEM_NOFLUSH,
NULL);
} else {
memmove_small_sse2_noflush(dest, src, len);
}
flush(dest, len);
}
#endif
| 2,726 | 22.307692 | 75 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/x86_64/memcpy/memcpy_avx512f.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
#ifndef PMEM2_MEMCPY_AVX512F_H
#define PMEM2_MEMCPY_AVX512F_H
#include <stddef.h>
#include "memcpy_avx.h"
static force_inline void
memmove_small_avx512f(char *dest, const char *src, size_t len, flush_fn flush)
{
/* We can't do better than AVX here. */
memmove_small_avx(dest, src, len, flush);
}
#endif
| 396 | 19.894737 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/aarch64/flush.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
#ifndef ARM64_FLUSH_H
#define ARM64_FLUSH_H
#include <stdint.h>
#include "arm_cacheops.h"
#include "util.h"
#define FLUSH_ALIGN ((uintptr_t)64)
/*
* flush_dcache_nolog -- flush the CPU cache, using DC CVAC
*/
static force_inline void
flush_dcache_nolog(const void *addr, size_t len)
{
uintptr_t uptr;
/*
* Loop through cache-line-size (typically 64B) aligned chunks
* covering the given range.
*/
for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1);
uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) {
arm_clean_va_to_poc((char *)uptr);
}
}
#endif
| 654 | 19.46875 | 63 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/libpmem2/aarch64/arm_cacheops.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* ARM inline assembly to flush and invalidate caches
* clwb => dc cvac
* clflushopt => dc civac
* fence => dmb ish
* sfence => dmb ishst
*/
/*
* Cache instructions on ARM:
* ARMv8.0-a DC CVAC - cache clean to Point of Coherency
* Meant for thread synchronization, usually implies
* real memory flush but may mean less.
* ARMv8.2-a DC CVAP - cache clean to Point of Persistency
* Meant exactly for our use.
* ARMv8.5-a DC CVADP - cache clean to Point of Deep Persistency
* As of mid-2019 not on any commercially available CPU.
* Any of the above may be disabled for EL0, but it's probably safe to consider
* that a system configuration error.
* Other flags include I (like "DC CIVAC") that invalidates the cache line, but
* we don't want that.
*
* Memory fences:
* * DMB [ISH] MFENCE
* * DMB [ISH]ST SFENCE
* * DMB [ISH]LD LFENCE
*
* Memory domains (cache coherency):
* * non-shareable - local to a single core
* * inner shareable (ISH) - a group of CPU clusters/sockets/other hardware
* Linux requires that anything within one operating system/hypervisor
* is within the same Inner Shareable domain.
* * outer shareable (OSH) - one or more separate ISH domains
* * full system (SY) - anything that can possibly access memory
* Docs: ARM DDI 0487E.a page B2-144.
*
* Exception (privilege) levels:
* * EL0 - userspace (ring 3)
* * EL1 - kernel (ring 0)
* * EL2 - hypervisor (ring -1)
* * EL3 - "secure world" (ring -3)
*/
#ifndef AARCH64_CACHEOPS_H
#define AARCH64_CACHEOPS_H
#include <stdlib.h>
static inline void
arm_clean_va_to_poc(void const *p __attribute__((unused)))
{
asm volatile("dc cvac, %0" : : "r" (p) : "memory");
}
static inline void
arm_store_memory_barrier(void)
{
asm volatile("dmb ishst" : : : "memory");
}
#endif
| 1,988 | 30.571429 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/getopt/getopt.h | /*
* *Copyright (c) 2012, Kim Gräsman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Kim Gräsman nor the
* names of contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef INCLUDED_GETOPT_PORT_H
#define INCLUDED_GETOPT_PORT_H
#if defined(__cplusplus)
extern "C" {
#endif
#define no_argument 0
#define required_argument 1
#define optional_argument 2
extern char* optarg;
extern int optind, opterr, optopt;
struct option {
const char* name;
int has_arg;
int* flag;
int val;
};
int getopt(int argc, char* const argv[], const char* optstring);
int getopt_long(int argc, char* const argv[],
const char* optstring, const struct option* longopts, int* longindex);
#if defined(__cplusplus)
}
#endif
#endif // INCLUDED_GETOPT_PORT_H
| 2,137 | 35.237288 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/err.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018, Intel Corporation */
/*
* err.h - error and warning messages
*/
#ifndef ERR_H
#define ERR_H 1
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
/*
* err - windows implementation of unix err function
*/
__declspec(noreturn) static void
err(int eval, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
vfprintf(stderr, fmt, vl);
va_end(vl);
exit(eval);
}
/*
* warn - windows implementation of unix warn function
*/
static void
warn(const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
fprintf(stderr, "Warning: ");
vfprintf(stderr, fmt, vl);
va_end(vl);
}
#endif /* ERR_H */
| 675 | 15.095238 | 54 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sched.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017, Intel Corporation */
/*
* fake sched.h
*/
| 105 | 14.142857 | 40 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/win_mmap.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2019, Intel Corporation */
/*
* Copyright (c) 2016, Microsoft Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* win_mmap.h -- (internal) tracks the regions mapped by mmap
*/
#ifndef WIN_MMAP_H
#define WIN_MMAP_H 1
#include "queue.h"
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#define rounddown(x, y) (((x) / (y)) * (y))
void win_mmap_init(void);
void win_mmap_fini(void);
/* allocation/mmap granularity */
extern unsigned long long Mmap_align;
typedef enum FILE_MAPPING_TRACKER_FLAGS {
FILE_MAPPING_TRACKER_FLAG_DIRECT_MAPPED = 0x0001,
/*
* This should hold the value of all flags ORed for debug purpose.
*/
FILE_MAPPING_TRACKER_FLAGS_MASK =
FILE_MAPPING_TRACKER_FLAG_DIRECT_MAPPED
} FILE_MAPPING_TRACKER_FLAGS;
/*
* this structure tracks the file mappings outstanding per file handle
*/
typedef struct FILE_MAPPING_TRACKER {
PMDK_SORTEDQ_ENTRY(FILE_MAPPING_TRACKER) ListEntry;
HANDLE FileHandle;
HANDLE FileMappingHandle;
void *BaseAddress;
void *EndAddress;
DWORD Access;
os_off_t Offset;
size_t FileLen;
FILE_MAPPING_TRACKER_FLAGS Flags;
} FILE_MAPPING_TRACKER, *PFILE_MAPPING_TRACKER;
extern SRWLOCK FileMappingQLock;
extern PMDK_SORTEDQ_HEAD(FMLHead, FILE_MAPPING_TRACKER) FileMappingQHead;
#endif /* WIN_MMAP_H */
| 2,871 | 34.02439 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/platform.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2020, Intel Corporation */
/*
* Copyright (c) 2016, Microsoft Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* platform.h -- dirty hacks to compile Linux code on Windows using VC++
*
* This is included to each source file using "/FI" (forced include) option.
*
* XXX - it is a subject for refactoring
*/
#ifndef PLATFORM_H
#define PLATFORM_H 1
#pragma warning(disable : 4996)
#pragma warning(disable : 4200) /* allow flexible array member */
#pragma warning(disable : 4819) /* non unicode characters */
#ifdef __cplusplus
extern "C" {
#endif
/* Prevent PMDK compilation for 32-bit platforms */
#if defined(_WIN32) && !defined(_WIN64)
#error "32-bit builds of PMDK are not supported!"
#endif
#define _CRT_RAND_S /* rand_s() */
#include <windows.h>
#include <stdint.h>
#include <time.h>
#include <io.h>
#include <process.h>
#include <fcntl.h>
#include <sys/types.h>
#include <malloc.h>
#include <signal.h>
#include <intrin.h>
#include <direct.h>
/* use uuid_t definition from util.h */
#ifdef uuid_t
#undef uuid_t
#endif
/* a few trivial substitutions */
#define PATH_MAX MAX_PATH
#define __thread __declspec(thread)
#define __func__ __FUNCTION__
#ifdef _DEBUG
#define DEBUG
#endif
/*
* The inline keyword is available only in VC++.
* https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx
*/
#ifndef __cplusplus
#define inline __inline
#endif
/* XXX - no equivalents in VC++ */
#define __attribute__(a)
#define __builtin_constant_p(cnd) 0
/*
* missing definitions
*/
/* errno.h */
#define ELIBACC 79 /* cannot access a needed shared library */
/* sys/stat.h */
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
#define S_IRGRP S_IRUSR
#define S_IWGRP S_IWUSR
#define O_SYNC 0
typedef int mode_t;
#define fchmod(fd, mode) 0 /* XXX - dummy */
#define setlinebuf(fp) setvbuf(fp, NULL, _IOLBF, BUFSIZ);
/* unistd.h */
typedef long long os_off_t;
typedef long long ssize_t;
int setenv(const char *name, const char *value, int overwrite);
int unsetenv(const char *name);
/* fcntl.h */
int posix_fallocate(int fd, os_off_t offset, os_off_t len);
/* string.h */
#define strtok_r strtok_s
/* time.h */
#define CLOCK_MONOTONIC 1
#define CLOCK_REALTIME 2
int clock_gettime(int id, struct timespec *ts);
/* signal.h */
typedef unsigned long long sigset_t; /* one bit for each signal */
C_ASSERT(NSIG <= sizeof(sigset_t) * 8);
struct sigaction {
void (*sa_handler) (int signum);
/* void (*sa_sigaction)(int, siginfo_t *, void *); */
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer) (void);
};
__inline int
sigemptyset(sigset_t *set)
{
*set = 0;
return 0;
}
__inline int
sigfillset(sigset_t *set)
{
*set = ~0;
return 0;
}
__inline int
sigaddset(sigset_t *set, int signum)
{
if (signum <= 0 || signum >= NSIG) {
errno = EINVAL;
return -1;
}
*set |= (1ULL << (signum - 1));
return 0;
}
__inline int
sigdelset(sigset_t *set, int signum)
{
if (signum <= 0 || signum >= NSIG) {
errno = EINVAL;
return -1;
}
*set &= ~(1ULL << (signum - 1));
return 0;
}
__inline int
sigismember(const sigset_t *set, int signum)
{
if (signum <= 0 || signum >= NSIG) {
errno = EINVAL;
return -1;
}
return ((*set & (1ULL << (signum - 1))) ? 1 : 0);
}
/* sched.h */
/*
* sched_yield -- yield the processor
*/
__inline int
sched_yield(void)
{
SwitchToThread();
return 0; /* always succeeds */
}
/*
* helper macros for library ctor/dtor function declarations
*/
#define MSVC_CONSTR(func) \
void func(void); \
__pragma(comment(linker, "/include:_" #func)) \
__pragma(section(".CRT$XCU", read)) \
__declspec(allocate(".CRT$XCU")) \
const void (WINAPI *_##func)(void) = (const void (WINAPI *)(void))func;
#define MSVC_DESTR(func) \
void func(void); \
static void _##func##_reg(void) { atexit(func); }; \
MSVC_CONSTR(_##func##_reg)
#ifdef __cplusplus
}
#endif
#endif /* PLATFORM_H */
| 5,431 | 22.929515 | 76 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/libgen.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016, Intel Corporation */
/*
* fake libgen.h
*/
| 106 | 14.285714 | 40 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/endian.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* endian.h -- convert values between host and big-/little-endian byte order
*/
#ifndef ENDIAN_H
#define ENDIAN_H 1
/*
* XXX: On Windows we can assume little-endian architecture
*/
#include <intrin.h>
#define htole16(a) (a)
#define htole32(a) (a)
#define htole64(a) (a)
#define le16toh(a) (a)
#define le32toh(a) (a)
#define le64toh(a) (a)
#define htobe16(x) _byteswap_ushort(x)
#define htobe32(x) _byteswap_ulong(x)
#define htobe64(x) _byteswap_uint64(x)
#define be16toh(x) _byteswap_ushort(x)
#define be32toh(x) _byteswap_ulong(x)
#define be64toh(x) _byteswap_uint64(x)
#endif /* ENDIAN_H */
| 696 | 20.121212 | 76 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/features.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016, Intel Corporation */
/*
* fake features.h
*/
| 108 | 14.571429 | 40 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/unistd.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* unistd.h -- compatibility layer for POSIX operating system API
*/
#ifndef UNISTD_H
#define UNISTD_H 1
#include <stdio.h>
#define _SC_PAGESIZE 0
#define _SC_NPROCESSORS_ONLN 1
#define R_OK 04
#define W_OK 02
#define X_OK 00 /* execute permission doesn't exist on Windows */
#define F_OK 00
/*
* sysconf -- get configuration information at run time
*/
static __inline long
sysconf(int p)
{
SYSTEM_INFO si;
int ret = 0;
switch (p) {
case _SC_PAGESIZE:
GetSystemInfo(&si);
return si.dwPageSize;
case _SC_NPROCESSORS_ONLN:
for (int i = 0; i < GetActiveProcessorGroupCount(); i++) {
ret += GetActiveProcessorCount(i);
}
return ret;
default:
return 0;
}
}
#define getpid _getpid
/*
* pread -- read from a file descriptor at given offset
*/
static ssize_t
pread(int fd, void *buf, size_t count, os_off_t offset)
{
__int64 position = _lseeki64(fd, 0, SEEK_CUR);
_lseeki64(fd, offset, SEEK_SET);
int ret = _read(fd, buf, (unsigned)count);
_lseeki64(fd, position, SEEK_SET);
return ret;
}
/*
* pwrite -- write to a file descriptor at given offset
*/
static ssize_t
pwrite(int fd, const void *buf, size_t count, os_off_t offset)
{
__int64 position = _lseeki64(fd, 0, SEEK_CUR);
_lseeki64(fd, offset, SEEK_SET);
int ret = _write(fd, buf, (unsigned)count);
_lseeki64(fd, position, SEEK_SET);
return ret;
}
#define S_ISBLK(x) 0 /* BLK devices not exist on Windows */
/*
* basename -- parse pathname and return filename component
*/
static char *
basename(char *path)
{
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(path, NULL, NULL, fname, ext);
sprintf(path, "%s%s", fname, ext);
return path;
}
/*
* dirname -- parse pathname and return directory component
*/
static char *
dirname(char *path)
{
if (path == NULL)
return ".";
size_t len = strlen(path);
if (len == 0)
return ".";
char *end = path + len;
/* strip trailing forslashes and backslashes */
while ((--end) > path) {
if (*end != '\\' && *end != '/') {
*(end + 1) = '\0';
break;
}
}
/* strip basename */
while ((--end) > path) {
if (*end == '\\' || *end == '/') {
*end = '\0';
break;
}
}
if (end != path) {
return path;
/* handle edge cases */
} else if (*end == '\\' || *end == '/') {
*(end + 1) = '\0';
} else {
*end++ = '.';
*end = '\0';
}
return path;
}
#endif /* UNISTD_H */
| 2,447 | 16.868613 | 65 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/strings.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* fake strings.h
*/
| 112 | 15.142857 | 44 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/dirent.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* fake dirent.h
*/
| 111 | 15 | 44 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/uio.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2018, Intel Corporation */
/*
* sys/uio.h -- definition of iovec structure
*/
#ifndef SYS_UIO_H
#define SYS_UIO_H 1
#include <pmemcompat.h>
#ifdef __cplusplus
extern "C" {
#endif
ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
#ifdef __cplusplus
}
#endif
#endif /* SYS_UIO_H */
| 359 | 14 | 60 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/file.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2018, Intel Corporation */
/*
* Copyright (c) 2016, Microsoft Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* sys/file.h -- file locking
*/
| 1,750 | 45.078947 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/statvfs.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016, Intel Corporation */
/*
* fake statvfs.h
*/
| 107 | 14.428571 | 40 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/param.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2018, Intel Corporation */
/*
* sys/param.h -- a few useful macros
*/
#ifndef SYS_PARAM_H
#define SYS_PARAM_H 1
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#define BPB 8 /* bits per byte */
#define setbit(b, i) ((b)[(i) / BPB] |= 1 << ((i) % BPB))
#define isset(b, i) ((b)[(i) / BPB] & (1 << ((i) % BPB)))
#define isclr(b, i) (((b)[(i) / BPB] & (1 << ((i) % BPB))) == 0)
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif /* SYS_PARAM_H */
| 612 | 24.541667 | 64 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/mount.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* fake sys/mount.h
*/
| 114 | 15.428571 | 44 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/mman.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2018, Intel Corporation */
/*
* sys/mman.h -- memory-mapped files for Windows
*/
#ifndef SYS_MMAN_H
#define SYS_MMAN_H 1
#ifdef __cplusplus
extern "C" {
#endif
#define PROT_NONE 0x0
#define PROT_READ 0x1
#define PROT_WRITE 0x2
#define PROT_EXEC 0x4
#define MAP_SHARED 0x1
#define MAP_PRIVATE 0x2
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_NORESERVE 0x04000
#define MS_ASYNC 1
#define MS_SYNC 4
#define MS_INVALIDATE 2
#define MAP_FAILED ((void *)(-1))
void *mmap(void *addr, size_t len, int prot, int flags,
int fd, os_off_t offset);
int munmap(void *addr, size_t len);
int msync(void *addr, size_t len, int flags);
int mprotect(void *addr, size_t len, int prot);
#ifdef __cplusplus
}
#endif
#endif /* SYS_MMAN_H */
| 842 | 16.93617 | 55 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/resource.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018, Intel Corporation */
/*
* fake sys/resource.h
*/
| 112 | 15.142857 | 40 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/sys/wait.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* fake sys/wait.h
*/
| 113 | 15.285714 | 44 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/windows/include/linux/limits.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* linux/limits.h -- fake header file
*/
/*
* XXX - The only purpose of this empty file is to avoid preprocessor
* errors when including a Linux-specific header file that has no equivalent
* on Windows. With this cheap trick, we don't need a lot of preprocessor
* conditionals in all the source code files.
*
* In the future, this will be addressed in some other way.
*/
| 471 | 28.5 | 76 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemblk.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemblk.h -- definitions of libpmemblk entry points
*
* This library provides support for programming with persistent memory (pmem).
*
* libpmemblk provides support for arrays of atomically-writable blocks.
*
* See libpmemblk(7) for details.
*/
#ifndef LIBPMEMBLK_H
#define LIBPMEMBLK_H 1
#include <sys/types.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmemblk_open pmemblk_openW
#define pmemblk_create pmemblk_createW
#define pmemblk_check pmemblk_checkW
#define pmemblk_check_version pmemblk_check_versionW
#define pmemblk_errormsg pmemblk_errormsgW
#define pmemblk_ctl_get pmemblk_ctl_getW
#define pmemblk_ctl_set pmemblk_ctl_setW
#define pmemblk_ctl_exec pmemblk_ctl_execW
#else
#define pmemblk_open pmemblk_openU
#define pmemblk_create pmemblk_createU
#define pmemblk_check pmemblk_checkU
#define pmemblk_check_version pmemblk_check_versionU
#define pmemblk_errormsg pmemblk_errormsgU
#define pmemblk_ctl_get pmemblk_ctl_getU
#define pmemblk_ctl_set pmemblk_ctl_setU
#define pmemblk_ctl_exec pmemblk_ctl_execU
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* opaque type, internal to libpmemblk
*/
typedef struct pmemblk PMEMblkpool;
/*
* PMEMBLK_MAJOR_VERSION and PMEMBLK_MINOR_VERSION provide the current version
* of the libpmemblk API as provided by this header file. Applications can
* verify that the version available at run-time is compatible with the version
* used at compile-time by passing these defines to pmemblk_check_version().
*/
#define PMEMBLK_MAJOR_VERSION 1
#define PMEMBLK_MINOR_VERSION 1
#ifndef _WIN32
const char *pmemblk_check_version(unsigned major_required,
unsigned minor_required);
#else
const char *pmemblk_check_versionU(unsigned major_required,
unsigned minor_required);
const wchar_t *pmemblk_check_versionW(unsigned major_required,
unsigned minor_required);
#endif
/* XXX - unify minimum pool size for both OS-es */
#ifndef _WIN32
#if defined(__x86_64__) || defined(__M_X64__) || defined(__aarch64__)
/* minimum pool size: 16MiB + 4KiB (minimum BTT size + mmap alignment) */
#define PMEMBLK_MIN_POOL ((size_t)((1u << 20) * 16 + (1u << 10) * 8))
#elif defined(__PPC64__)
/* minimum pool size: 16MiB + 128KiB (minimum BTT size + mmap alignment) */
#define PMEMBLK_MIN_POOL ((size_t)((1u << 20) * 16 + (1u << 10) * 128))
#else
#error unable to recognize ISA at compile time
#endif
#else
/* minimum pool size: 16MiB + 64KiB (minimum BTT size + mmap alignment) */
#define PMEMBLK_MIN_POOL ((size_t)((1u << 20) * 16 + (1u << 10) * 64))
#endif
/*
* This limit is set arbitrary to incorporate a pool header and required
* alignment plus supply.
*/
#define PMEMBLK_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
#define PMEMBLK_MIN_BLK ((size_t)512)
#ifndef _WIN32
PMEMblkpool *pmemblk_open(const char *path, size_t bsize);
#else
PMEMblkpool *pmemblk_openU(const char *path, size_t bsize);
PMEMblkpool *pmemblk_openW(const wchar_t *path, size_t bsize);
#endif
#ifndef _WIN32
PMEMblkpool *pmemblk_create(const char *path, size_t bsize,
size_t poolsize, mode_t mode);
#else
PMEMblkpool *pmemblk_createU(const char *path, size_t bsize,
size_t poolsize, mode_t mode);
PMEMblkpool *pmemblk_createW(const wchar_t *path, size_t bsize,
size_t poolsize, mode_t mode);
#endif
#ifndef _WIN32
int pmemblk_check(const char *path, size_t bsize);
#else
int pmemblk_checkU(const char *path, size_t bsize);
int pmemblk_checkW(const wchar_t *path, size_t bsize);
#endif
void pmemblk_close(PMEMblkpool *pbp);
size_t pmemblk_bsize(PMEMblkpool *pbp);
size_t pmemblk_nblock(PMEMblkpool *pbp);
int pmemblk_read(PMEMblkpool *pbp, void *buf, long long blockno);
int pmemblk_write(PMEMblkpool *pbp, const void *buf, long long blockno);
int pmemblk_set_zero(PMEMblkpool *pbp, long long blockno);
int pmemblk_set_error(PMEMblkpool *pbp, long long blockno);
/*
* Passing NULL to pmemblk_set_funcs() tells libpmemblk to continue to use the
* default for that function. The replacement functions must not make calls
* back into libpmemblk.
*/
void pmemblk_set_funcs(
void *(*malloc_func)(size_t size),
void (*free_func)(void *ptr),
void *(*realloc_func)(void *ptr, size_t size),
char *(*strdup_func)(const char *s));
#ifndef _WIN32
const char *pmemblk_errormsg(void);
#else
const char *pmemblk_errormsgU(void);
const wchar_t *pmemblk_errormsgW(void);
#endif
#ifndef _WIN32
/* EXPERIMENTAL */
int pmemblk_ctl_get(PMEMblkpool *pbp, const char *name, void *arg);
int pmemblk_ctl_set(PMEMblkpool *pbp, const char *name, void *arg);
int pmemblk_ctl_exec(PMEMblkpool *pbp, const char *name, void *arg);
#else
int pmemblk_ctl_getU(PMEMblkpool *pbp, const char *name, void *arg);
int pmemblk_ctl_getW(PMEMblkpool *pbp, const wchar_t *name, void *arg);
int pmemblk_ctl_setU(PMEMblkpool *pbp, const char *name, void *arg);
int pmemblk_ctl_setW(PMEMblkpool *pbp, const wchar_t *name, void *arg);
int pmemblk_ctl_execU(PMEMblkpool *pbp, const char *name, void *arg);
int pmemblk_ctl_execW(PMEMblkpool *pbp, const wchar_t *name, void *arg);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmemblk.h */
| 5,183 | 30.418182 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmempool.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* libpmempool.h -- definitions of libpmempool entry points
*
* See libpmempool(7) for details.
*/
#ifndef LIBPMEMPOOL_H
#define LIBPMEMPOOL_H 1
#include <stdint.h>
#include <stddef.h>
#include <limits.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmempool_check_status pmempool_check_statusW
#define pmempool_check_args pmempool_check_argsW
#define pmempool_check_init pmempool_check_initW
#define pmempool_check pmempool_checkW
#define pmempool_sync pmempool_syncW
#define pmempool_transform pmempool_transformW
#define pmempool_rm pmempool_rmW
#define pmempool_check_version pmempool_check_versionW
#define pmempool_errormsg pmempool_errormsgW
#define pmempool_feature_enable pmempool_feature_enableW
#define pmempool_feature_disable pmempool_feature_disableW
#define pmempool_feature_query pmempool_feature_queryW
#else
#define pmempool_check_status pmempool_check_statusU
#define pmempool_check_args pmempool_check_argsU
#define pmempool_check_init pmempool_check_initU
#define pmempool_check pmempool_checkU
#define pmempool_sync pmempool_syncU
#define pmempool_transform pmempool_transformU
#define pmempool_rm pmempool_rmU
#define pmempool_check_version pmempool_check_versionU
#define pmempool_errormsg pmempool_errormsgU
#define pmempool_feature_enable pmempool_feature_enableU
#define pmempool_feature_disable pmempool_feature_disableU
#define pmempool_feature_query pmempool_feature_queryU
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* PMEMPOOL CHECK */
/*
* pool types
*/
enum pmempool_pool_type {
PMEMPOOL_POOL_TYPE_DETECT,
PMEMPOOL_POOL_TYPE_LOG,
PMEMPOOL_POOL_TYPE_BLK,
PMEMPOOL_POOL_TYPE_OBJ,
PMEMPOOL_POOL_TYPE_BTT,
PMEMPOOL_POOL_TYPE_RESERVED1, /* used to be cto */
};
/*
* perform repairs
*/
#define PMEMPOOL_CHECK_REPAIR (1U << 0)
/*
* emulate repairs
*/
#define PMEMPOOL_CHECK_DRY_RUN (1U << 1)
/*
* perform hazardous repairs
*/
#define PMEMPOOL_CHECK_ADVANCED (1U << 2)
/*
* do not ask before repairs
*/
#define PMEMPOOL_CHECK_ALWAYS_YES (1U << 3)
/*
* generate info statuses
*/
#define PMEMPOOL_CHECK_VERBOSE (1U << 4)
/*
* generate string format statuses
*/
#define PMEMPOOL_CHECK_FORMAT_STR (1U << 5)
/*
* types of check statuses
*/
enum pmempool_check_msg_type {
PMEMPOOL_CHECK_MSG_TYPE_INFO,
PMEMPOOL_CHECK_MSG_TYPE_ERROR,
PMEMPOOL_CHECK_MSG_TYPE_QUESTION,
};
/*
* check result types
*/
enum pmempool_check_result {
PMEMPOOL_CHECK_RESULT_CONSISTENT,
PMEMPOOL_CHECK_RESULT_NOT_CONSISTENT,
PMEMPOOL_CHECK_RESULT_REPAIRED,
PMEMPOOL_CHECK_RESULT_CANNOT_REPAIR,
PMEMPOOL_CHECK_RESULT_ERROR,
PMEMPOOL_CHECK_RESULT_SYNC_REQ,
};
/*
* check context
*/
typedef struct pmempool_check_ctx PMEMpoolcheck;
/*
* finalize the check and get the result
*/
enum pmempool_check_result pmempool_check_end(PMEMpoolcheck *ppc);
/* PMEMPOOL RM */
#define PMEMPOOL_RM_FORCE (1U << 0) /* ignore any errors */
#define PMEMPOOL_RM_POOLSET_LOCAL (1U << 1) /* remove local poolsets */
#define PMEMPOOL_RM_POOLSET_REMOTE (1U << 2) /* remove remote poolsets */
/*
* LIBPMEMPOOL SYNC
*/
/*
* fix bad blocks - it requires creating or reading special recovery files
*/
#define PMEMPOOL_SYNC_FIX_BAD_BLOCKS (1U << 0)
/*
* do not apply changes, only check if operation is viable
*/
#define PMEMPOOL_SYNC_DRY_RUN (1U << 1)
/*
* LIBPMEMPOOL TRANSFORM
*/
/*
* do not apply changes, only check if operation is viable
*/
#define PMEMPOOL_TRANSFORM_DRY_RUN (1U << 1)
/*
* PMEMPOOL_MAJOR_VERSION and PMEMPOOL_MINOR_VERSION provide the current version
* of the libpmempool API as provided by this header file. Applications can
* verify that the version available at run-time is compatible with the version
* used at compile-time by passing these defines to pmempool_check_version().
*/
#define PMEMPOOL_MAJOR_VERSION 1
#define PMEMPOOL_MINOR_VERSION 3
/*
* check status
*/
struct pmempool_check_statusU {
enum pmempool_check_msg_type type;
struct {
const char *msg;
const char *answer;
} str;
};
#ifndef _WIN32
#define pmempool_check_status pmempool_check_statusU
#else
struct pmempool_check_statusW {
enum pmempool_check_msg_type type;
struct {
const wchar_t *msg;
const wchar_t *answer;
} str;
};
#endif
/*
* check context arguments
*/
struct pmempool_check_argsU {
const char *path;
const char *backup_path;
enum pmempool_pool_type pool_type;
unsigned flags;
};
#ifndef _WIN32
#define pmempool_check_args pmempool_check_argsU
#else
struct pmempool_check_argsW {
const wchar_t *path;
const wchar_t *backup_path;
enum pmempool_pool_type pool_type;
unsigned flags;
};
#endif
/*
* initialize a check context
*/
#ifndef _WIN32
PMEMpoolcheck *
pmempool_check_init(struct pmempool_check_args *args, size_t args_size);
#else
PMEMpoolcheck *
pmempool_check_initU(struct pmempool_check_argsU *args, size_t args_size);
PMEMpoolcheck *
pmempool_check_initW(struct pmempool_check_argsW *args, size_t args_size);
#endif
/*
* start / resume the check
*/
#ifndef _WIN32
struct pmempool_check_status *pmempool_check(PMEMpoolcheck *ppc);
#else
struct pmempool_check_statusU *pmempool_checkU(PMEMpoolcheck *ppc);
struct pmempool_check_statusW *pmempool_checkW(PMEMpoolcheck *ppc);
#endif
/*
* LIBPMEMPOOL SYNC & TRANSFORM
*/
/*
* Synchronize data between replicas within a poolset.
*
* EXPERIMENTAL
*/
#ifndef _WIN32
int pmempool_sync(const char *poolset_file, unsigned flags);
#else
int pmempool_syncU(const char *poolset_file, unsigned flags);
int pmempool_syncW(const wchar_t *poolset_file, unsigned flags);
#endif
/*
* Modify internal structure of a poolset.
*
* EXPERIMENTAL
*/
#ifndef _WIN32
int pmempool_transform(const char *poolset_file_src,
const char *poolset_file_dst, unsigned flags);
#else
int pmempool_transformU(const char *poolset_file_src,
const char *poolset_file_dst, unsigned flags);
int pmempool_transformW(const wchar_t *poolset_file_src,
const wchar_t *poolset_file_dst, unsigned flags);
#endif
/* PMEMPOOL feature enable, disable, query */
/*
* feature types
*/
enum pmempool_feature {
PMEMPOOL_FEAT_SINGLEHDR,
PMEMPOOL_FEAT_CKSUM_2K,
PMEMPOOL_FEAT_SHUTDOWN_STATE,
PMEMPOOL_FEAT_CHECK_BAD_BLOCKS,
};
/* PMEMPOOL FEATURE ENABLE */
#ifndef _WIN32
int pmempool_feature_enable(const char *path, enum pmempool_feature feature,
unsigned flags);
#else
int pmempool_feature_enableU(const char *path, enum pmempool_feature feature,
unsigned flags);
int pmempool_feature_enableW(const wchar_t *path,
enum pmempool_feature feature, unsigned flags);
#endif
/* PMEMPOOL FEATURE DISABLE */
#ifndef _WIN32
int pmempool_feature_disable(const char *path, enum pmempool_feature feature,
unsigned flags);
#else
int pmempool_feature_disableU(const char *path, enum pmempool_feature feature,
unsigned flags);
int pmempool_feature_disableW(const wchar_t *path,
enum pmempool_feature feature, unsigned flags);
#endif
/* PMEMPOOL FEATURE QUERY */
#ifndef _WIN32
int pmempool_feature_query(const char *path, enum pmempool_feature feature,
unsigned flags);
#else
int pmempool_feature_queryU(const char *path, enum pmempool_feature feature,
unsigned flags);
int pmempool_feature_queryW(const wchar_t *path,
enum pmempool_feature feature, unsigned flags);
#endif
/* PMEMPOOL RM */
#ifndef _WIN32
int pmempool_rm(const char *path, unsigned flags);
#else
int pmempool_rmU(const char *path, unsigned flags);
int pmempool_rmW(const wchar_t *path, unsigned flags);
#endif
#ifndef _WIN32
const char *pmempool_check_version(unsigned major_required,
unsigned minor_required);
#else
const char *pmempool_check_versionU(unsigned major_required,
unsigned minor_required);
const wchar_t *pmempool_check_versionW(unsigned major_required,
unsigned minor_required);
#endif
#ifndef _WIN32
const char *pmempool_errormsg(void);
#else
const char *pmempool_errormsgU(void);
const wchar_t *pmempool_errormsgW(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmempool.h */
| 8,009 | 22.910448 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/librpmem.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2019, Intel Corporation */
/*
* librpmem.h -- definitions of librpmem entry points (EXPERIMENTAL)
*
* This library provides low-level support for remote access to persistent
* memory utilizing RDMA-capable RNICs.
*
* See librpmem(7) for details.
*/
#ifndef LIBRPMEM_H
#define LIBRPMEM_H 1
#include <sys/types.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct rpmem_pool RPMEMpool;
#define RPMEM_POOL_HDR_SIG_LEN 8
#define RPMEM_POOL_HDR_UUID_LEN 16 /* uuid byte length */
#define RPMEM_POOL_USER_FLAGS_LEN 16
struct rpmem_pool_attr {
char signature[RPMEM_POOL_HDR_SIG_LEN]; /* pool signature */
uint32_t major; /* format major version number */
uint32_t compat_features; /* mask: compatible "may" features */
uint32_t incompat_features; /* mask: "must support" features */
uint32_t ro_compat_features; /* mask: force RO if unsupported */
unsigned char poolset_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* pool uuid */
unsigned char uuid[RPMEM_POOL_HDR_UUID_LEN]; /* first part uuid */
unsigned char next_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* next pool uuid */
unsigned char prev_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* prev pool uuid */
unsigned char user_flags[RPMEM_POOL_USER_FLAGS_LEN]; /* user flags */
};
RPMEMpool *rpmem_create(const char *target, const char *pool_set_name,
void *pool_addr, size_t pool_size, unsigned *nlanes,
const struct rpmem_pool_attr *create_attr);
RPMEMpool *rpmem_open(const char *target, const char *pool_set_name,
void *pool_addr, size_t pool_size, unsigned *nlanes,
struct rpmem_pool_attr *open_attr);
int rpmem_set_attr(RPMEMpool *rpp, const struct rpmem_pool_attr *attr);
int rpmem_close(RPMEMpool *rpp);
#define RPMEM_PERSIST_RELAXED (1U << 0)
#define RPMEM_FLUSH_RELAXED (1U << 0)
int rpmem_flush(RPMEMpool *rpp, size_t offset, size_t length, unsigned lane,
unsigned flags);
int rpmem_drain(RPMEMpool *rpp, unsigned lane, unsigned flags);
int rpmem_persist(RPMEMpool *rpp, size_t offset, size_t length,
unsigned lane, unsigned flags);
int rpmem_read(RPMEMpool *rpp, void *buff, size_t offset, size_t length,
unsigned lane);
int rpmem_deep_persist(RPMEMpool *rpp, size_t offset, size_t length,
unsigned lane);
#define RPMEM_REMOVE_FORCE 0x1
#define RPMEM_REMOVE_POOL_SET 0x2
int rpmem_remove(const char *target, const char *pool_set, int flags);
/*
* RPMEM_MAJOR_VERSION and RPMEM_MINOR_VERSION provide the current version of
* the librpmem API as provided by this header file. Applications can verify
* that the version available at run-time is compatible with the version used
* at compile-time by passing these defines to rpmem_check_version().
*/
#define RPMEM_MAJOR_VERSION 1
#define RPMEM_MINOR_VERSION 3
const char *rpmem_check_version(unsigned major_required,
unsigned minor_required);
const char *rpmem_errormsg(void);
/* minimum size of a pool */
#define RPMEM_MIN_POOL ((size_t)(1024 * 8)) /* 8 KB */
/*
* This limit is set arbitrary to incorporate a pool header and required
* alignment plus supply.
*/
#define RPMEM_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
#ifdef __cplusplus
}
#endif
#endif /* librpmem.h */
| 3,197 | 31.30303 | 77 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj.h -- definitions of libpmemobj entry points
*
* This library provides support for programming with persistent memory (pmem).
*
* libpmemobj provides a pmem-resident transactional object store.
*
* See libpmemobj(7) for details.
*/
#ifndef LIBPMEMOBJ_H
#define LIBPMEMOBJ_H 1
#include <libpmemobj/action.h>
#include <libpmemobj/atomic.h>
#include <libpmemobj/ctl.h>
#include <libpmemobj/iterator.h>
#include <libpmemobj/lists_atomic.h>
#include <libpmemobj/pool.h>
#include <libpmemobj/thread.h>
#include <libpmemobj/tx.h>
#endif /* libpmemobj.h */
| 662 | 23.555556 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemlog.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemlog.h -- definitions of libpmemlog entry points
*
* This library provides support for programming with persistent memory (pmem).
*
* libpmemlog provides support for pmem-resident log files.
*
* See libpmemlog(7) for details.
*/
#ifndef LIBPMEMLOG_H
#define LIBPMEMLOG_H 1
#include <sys/types.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmemlog_open pmemlog_openW
#define pmemlog_create pmemlog_createW
#define pmemlog_check pmemlog_checkW
#define pmemlog_check_version pmemlog_check_versionW
#define pmemlog_errormsg pmemlog_errormsgW
#define pmemlog_ctl_get pmemlog_ctl_getW
#define pmemlog_ctl_set pmemlog_ctl_setW
#define pmemlog_ctl_exec pmemlog_ctl_execW
#else
#define pmemlog_open pmemlog_openU
#define pmemlog_create pmemlog_createU
#define pmemlog_check pmemlog_checkU
#define pmemlog_check_version pmemlog_check_versionU
#define pmemlog_errormsg pmemlog_errormsgU
#define pmemlog_ctl_get pmemlog_ctl_getU
#define pmemlog_ctl_set pmemlog_ctl_setU
#define pmemlog_ctl_exec pmemlog_ctl_execU
#endif
#else
#include <sys/uio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* opaque type, internal to libpmemlog
*/
typedef struct pmemlog PMEMlogpool;
/*
* PMEMLOG_MAJOR_VERSION and PMEMLOG_MINOR_VERSION provide the current
* version of the libpmemlog API as provided by this header file.
* Applications can verify that the version available at run-time
* is compatible with the version used at compile-time by passing
* these defines to pmemlog_check_version().
*/
#define PMEMLOG_MAJOR_VERSION 1
#define PMEMLOG_MINOR_VERSION 1
#ifndef _WIN32
const char *pmemlog_check_version(unsigned major_required,
unsigned minor_required);
#else
const char *pmemlog_check_versionU(unsigned major_required,
unsigned minor_required);
const wchar_t *pmemlog_check_versionW(unsigned major_required,
unsigned minor_required);
#endif
/*
* support for PMEM-resident log files...
*/
#define PMEMLOG_MIN_POOL ((size_t)(1024 * 1024 * 2)) /* min pool size: 2MiB */
/*
* This limit is set arbitrary to incorporate a pool header and required
* alignment plus supply.
*/
#define PMEMLOG_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
#ifndef _WIN32
PMEMlogpool *pmemlog_open(const char *path);
#else
PMEMlogpool *pmemlog_openU(const char *path);
PMEMlogpool *pmemlog_openW(const wchar_t *path);
#endif
#ifndef _WIN32
PMEMlogpool *pmemlog_create(const char *path, size_t poolsize, mode_t mode);
#else
PMEMlogpool *pmemlog_createU(const char *path, size_t poolsize, mode_t mode);
PMEMlogpool *pmemlog_createW(const wchar_t *path, size_t poolsize, mode_t mode);
#endif
#ifndef _WIN32
int pmemlog_check(const char *path);
#else
int pmemlog_checkU(const char *path);
int pmemlog_checkW(const wchar_t *path);
#endif
void pmemlog_close(PMEMlogpool *plp);
size_t pmemlog_nbyte(PMEMlogpool *plp);
int pmemlog_append(PMEMlogpool *plp, const void *buf, size_t count);
int pmemlog_appendv(PMEMlogpool *plp, const struct iovec *iov, int iovcnt);
long long pmemlog_tell(PMEMlogpool *plp);
void pmemlog_rewind(PMEMlogpool *plp);
void pmemlog_walk(PMEMlogpool *plp, size_t chunksize,
int (*process_chunk)(const void *buf, size_t len, void *arg),
void *arg);
/*
* Passing NULL to pmemlog_set_funcs() tells libpmemlog to continue to use the
* default for that function. The replacement functions must not make calls
* back into libpmemlog.
*/
void pmemlog_set_funcs(
void *(*malloc_func)(size_t size),
void (*free_func)(void *ptr),
void *(*realloc_func)(void *ptr, size_t size),
char *(*strdup_func)(const char *s));
#ifndef _WIN32
const char *pmemlog_errormsg(void);
#else
const char *pmemlog_errormsgU(void);
const wchar_t *pmemlog_errormsgW(void);
#endif
#ifndef _WIN32
/* EXPERIMENTAL */
int pmemlog_ctl_get(PMEMlogpool *plp, const char *name, void *arg);
int pmemlog_ctl_set(PMEMlogpool *plp, const char *name, void *arg);
int pmemlog_ctl_exec(PMEMlogpool *plp, const char *name, void *arg);
#else
int pmemlog_ctl_getU(PMEMlogpool *plp, const char *name, void *arg);
int pmemlog_ctl_getW(PMEMlogpool *plp, const wchar_t *name, void *arg);
int pmemlog_ctl_setU(PMEMlogpool *plp, const char *name, void *arg);
int pmemlog_ctl_setW(PMEMlogpool *plp, const wchar_t *name, void *arg);
int pmemlog_ctl_execU(PMEMlogpool *plp, const char *name, void *arg);
int pmemlog_ctl_execW(PMEMlogpool *plp, const wchar_t *name, void *arg);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmemlog.h */
| 4,540 | 28.679739 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmem.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmem.h -- definitions of libpmem entry points
*
* This library provides support for programming with persistent memory (pmem).
*
* libpmem provides support for using raw pmem directly.
*
* See libpmem(7) for details.
*/
#ifndef LIBPMEM_H
#define LIBPMEM_H 1
#include <sys/types.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmem_map_file pmem_map_fileW
#define pmem_check_version pmem_check_versionW
#define pmem_errormsg pmem_errormsgW
#else
#define pmem_map_file pmem_map_fileU
#define pmem_check_version pmem_check_versionU
#define pmem_errormsg pmem_errormsgU
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* This limit is set arbitrary to incorporate a pool header and required
* alignment plus supply.
*/
#define PMEM_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
/*
* flags supported by pmem_map_file()
*/
#define PMEM_FILE_CREATE (1 << 0)
#define PMEM_FILE_EXCL (1 << 1)
#define PMEM_FILE_SPARSE (1 << 2)
#define PMEM_FILE_TMPFILE (1 << 3)
#ifndef _WIN32
void *pmem_map_file(const char *path, size_t len, int flags, mode_t mode,
size_t *mapped_lenp, int *is_pmemp);
#else
void *pmem_map_fileU(const char *path, size_t len, int flags, mode_t mode,
size_t *mapped_lenp, int *is_pmemp);
void *pmem_map_fileW(const wchar_t *path, size_t len, int flags, mode_t mode,
size_t *mapped_lenp, int *is_pmemp);
#endif
int pmem_unmap(void *addr, size_t len);
int pmem_is_pmem(const void *addr, size_t len);
void pmem_persist(const void *addr, size_t len);
int pmem_msync(const void *addr, size_t len);
int pmem_has_auto_flush(void);
void pmem_flush(const void *addr, size_t len);
void pmem_deep_flush(const void *addr, size_t len);
int pmem_deep_drain(const void *addr, size_t len);
int pmem_deep_persist(const void *addr, size_t len);
void pmem_drain(void);
int pmem_has_hw_drain(void);
void *pmem_memmove_persist(void *pmemdest, const void *src, size_t len);
void *pmem_memcpy_persist(void *pmemdest, const void *src, size_t len);
void *pmem_memset_persist(void *pmemdest, int c, size_t len);
void *pmem_memmove_nodrain(void *pmemdest, const void *src, size_t len);
void *pmem_memcpy_nodrain(void *pmemdest, const void *src, size_t len);
void *pmem_memset_nodrain(void *pmemdest, int c, size_t len);
#define PMEM_F_MEM_NODRAIN (1U << 0)
#define PMEM_F_MEM_NONTEMPORAL (1U << 1)
#define PMEM_F_MEM_TEMPORAL (1U << 2)
#define PMEM_F_MEM_WC (1U << 3)
#define PMEM_F_MEM_WB (1U << 4)
#define PMEM_F_MEM_NOFLUSH (1U << 5)
#define PMEM_F_MEM_VALID_FLAGS (PMEM_F_MEM_NODRAIN | \
PMEM_F_MEM_NONTEMPORAL | \
PMEM_F_MEM_TEMPORAL | \
PMEM_F_MEM_WC | \
PMEM_F_MEM_WB | \
PMEM_F_MEM_NOFLUSH)
void *pmem_memmove(void *pmemdest, const void *src, size_t len, unsigned flags);
void *pmem_memcpy(void *pmemdest, const void *src, size_t len, unsigned flags);
void *pmem_memset(void *pmemdest, int c, size_t len, unsigned flags);
/*
* PMEM_MAJOR_VERSION and PMEM_MINOR_VERSION provide the current version of the
* libpmem API as provided by this header file. Applications can verify that
* the version available at run-time is compatible with the version used at
* compile-time by passing these defines to pmem_check_version().
*/
#define PMEM_MAJOR_VERSION 1
#define PMEM_MINOR_VERSION 1
#ifndef _WIN32
const char *pmem_check_version(unsigned major_required,
unsigned minor_required);
#else
const char *pmem_check_versionU(unsigned major_required,
unsigned minor_required);
const wchar_t *pmem_check_versionW(unsigned major_required,
unsigned minor_required);
#endif
#ifndef _WIN32
const char *pmem_errormsg(void);
#else
const char *pmem_errormsgU(void);
const wchar_t *pmem_errormsgW(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmem.h */
| 3,829 | 28.015152 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmem2.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2019-2020, Intel Corporation */
/*
* libpmem2.h -- definitions of libpmem2 entry points (EXPERIMENTAL)
*
* This library provides support for programming with persistent memory (pmem).
*
* libpmem2 provides support for using raw pmem directly.
*
* See libpmem2(7) for details.
*/
#ifndef LIBPMEM2_H
#define LIBPMEM2_H 1
#include <stddef.h>
#include <stdint.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmem2_source_device_id pmem2_source_device_idW
#define pmem2_errormsg pmem2_errormsgW
#define pmem2_perror pmem2_perrorW
#else
#define pmem2_source_device_id pmem2_source_device_idU
#define pmem2_errormsg pmem2_errormsgU
#define pmem2_perror pmem2_perrorU
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define PMEM2_E_UNKNOWN (-100000)
#define PMEM2_E_NOSUPP (-100001)
#define PMEM2_E_FILE_HANDLE_NOT_SET (-100003)
#define PMEM2_E_INVALID_FILE_HANDLE (-100004)
#define PMEM2_E_INVALID_FILE_TYPE (-100005)
#define PMEM2_E_MAP_RANGE (-100006)
#define PMEM2_E_MAPPING_EXISTS (-100007)
#define PMEM2_E_GRANULARITY_NOT_SET (-100008)
#define PMEM2_E_GRANULARITY_NOT_SUPPORTED (-100009)
#define PMEM2_E_OFFSET_OUT_OF_RANGE (-100010)
#define PMEM2_E_OFFSET_UNALIGNED (-100011)
#define PMEM2_E_INVALID_ALIGNMENT_FORMAT (-100012)
#define PMEM2_E_INVALID_ALIGNMENT_VALUE (-100013)
#define PMEM2_E_INVALID_SIZE_FORMAT (-100014)
#define PMEM2_E_LENGTH_UNALIGNED (-100015)
#define PMEM2_E_MAPPING_NOT_FOUND (-100016)
#define PMEM2_E_BUFFER_TOO_SMALL (-100017)
#define PMEM2_E_SOURCE_EMPTY (-100018)
#define PMEM2_E_INVALID_SHARING_VALUE (-100019)
#define PMEM2_E_SRC_DEVDAX_PRIVATE (-100020)
#define PMEM2_E_INVALID_ADDRESS_REQUEST_TYPE (-100021)
#define PMEM2_E_ADDRESS_UNALIGNED (-100022)
#define PMEM2_E_ADDRESS_NULL (-100023)
#define PMEM2_E_DEEP_FLUSH_RANGE (-100024)
#define PMEM2_E_INVALID_REGION_FORMAT (-100025)
#define PMEM2_E_DAX_REGION_NOT_FOUND (-100026)
#define PMEM2_E_INVALID_DEV_FORMAT (-100027)
#define PMEM2_E_CANNOT_READ_BOUNDS (-100028)
#define PMEM2_E_NO_BAD_BLOCK_FOUND (-100029)
#define PMEM2_E_LENGTH_OUT_OF_RANGE (-100030)
#define PMEM2_E_INVALID_PROT_FLAG (-100031)
#define PMEM2_E_NO_ACCESS (-100032)
/* source setup */
struct pmem2_source;
int pmem2_source_from_fd(struct pmem2_source **src, int fd);
int pmem2_source_from_anon(struct pmem2_source **src, size_t size);
#ifdef _WIN32
int pmem2_source_from_handle(struct pmem2_source **src, HANDLE handle);
#endif
int pmem2_source_size(const struct pmem2_source *src, size_t *size);
int pmem2_source_alignment(const struct pmem2_source *src,
size_t *alignment);
int pmem2_source_delete(struct pmem2_source **src);
/* vm reservation setup */
struct pmem2_vm_reservation;
int pmem2_vm_reservation_new(struct pmem2_vm_reservation **rsv,
size_t size, void *address);
int pmem2_vm_reservation_delete(struct pmem2_vm_reservation **rsv);
/* config setup */
struct pmem2_config;
int pmem2_config_new(struct pmem2_config **cfg);
int pmem2_config_delete(struct pmem2_config **cfg);
enum pmem2_granularity {
PMEM2_GRANULARITY_BYTE,
PMEM2_GRANULARITY_CACHE_LINE,
PMEM2_GRANULARITY_PAGE,
};
int pmem2_config_set_required_store_granularity(struct pmem2_config *cfg,
enum pmem2_granularity g);
int pmem2_config_set_offset(struct pmem2_config *cfg, size_t offset);
int pmem2_config_set_length(struct pmem2_config *cfg, size_t length);
enum pmem2_sharing_type {
PMEM2_SHARED,
PMEM2_PRIVATE,
};
int pmem2_config_set_sharing(struct pmem2_config *cfg,
enum pmem2_sharing_type type);
#define PMEM2_PROT_EXEC (1U << 29)
#define PMEM2_PROT_READ (1U << 30)
#define PMEM2_PROT_WRITE (1U << 31)
#define PMEM2_PROT_NONE 0
int pmem2_config_set_protection(struct pmem2_config *cfg,
unsigned prot);
enum pmem2_address_request_type {
PMEM2_ADDRESS_FIXED_REPLACE = 1,
PMEM2_ADDRESS_FIXED_NOREPLACE = 2,
};
int pmem2_config_set_address(struct pmem2_config *cfg, void *addr,
enum pmem2_address_request_type request_type);
int pmem2_config_set_vm_reservation(struct pmem2_config *cfg,
struct pmem2_vm_reservation *rsv, size_t offset);
void pmem2_config_clear_address(struct pmem2_config *cfg);
/* mapping */
struct pmem2_map;
int pmem2_map(const struct pmem2_config *cfg, const struct pmem2_source *src,
struct pmem2_map **map_ptr);
int pmem2_unmap(struct pmem2_map **map_ptr);
void *pmem2_map_get_address(struct pmem2_map *map);
size_t pmem2_map_get_size(struct pmem2_map *map);
enum pmem2_granularity pmem2_map_get_store_granularity(struct pmem2_map *map);
/* flushing */
typedef void (*pmem2_persist_fn)(const void *ptr, size_t size);
typedef void (*pmem2_flush_fn)(const void *ptr, size_t size);
typedef void (*pmem2_drain_fn)(void);
pmem2_persist_fn pmem2_get_persist_fn(struct pmem2_map *map);
pmem2_flush_fn pmem2_get_flush_fn(struct pmem2_map *map);
pmem2_drain_fn pmem2_get_drain_fn(struct pmem2_map *map);
#define PMEM2_F_MEM_NODRAIN (1U << 0)
#define PMEM2_F_MEM_NONTEMPORAL (1U << 1)
#define PMEM2_F_MEM_TEMPORAL (1U << 2)
#define PMEM2_F_MEM_WC (1U << 3)
#define PMEM2_F_MEM_WB (1U << 4)
#define PMEM2_F_MEM_NOFLUSH (1U << 5)
#define PMEM2_F_MEM_VALID_FLAGS (PMEM2_F_MEM_NODRAIN | \
PMEM2_F_MEM_NONTEMPORAL | \
PMEM2_F_MEM_TEMPORAL | \
PMEM2_F_MEM_WC | \
PMEM2_F_MEM_WB | \
PMEM2_F_MEM_NOFLUSH)
typedef void *(*pmem2_memmove_fn)(void *pmemdest, const void *src, size_t len,
unsigned flags);
typedef void *(*pmem2_memcpy_fn)(void *pmemdest, const void *src, size_t len,
unsigned flags);
typedef void *(*pmem2_memset_fn)(void *pmemdest, int c, size_t len,
unsigned flags);
pmem2_memmove_fn pmem2_get_memmove_fn(struct pmem2_map *map);
pmem2_memcpy_fn pmem2_get_memcpy_fn(struct pmem2_map *map);
pmem2_memset_fn pmem2_get_memset_fn(struct pmem2_map *map);
/* RAS */
int pmem2_deep_flush(struct pmem2_map *map, void *ptr, size_t size);
#ifndef _WIN32
int pmem2_source_device_id(const struct pmem2_source *src,
char *id, size_t *len);
#else
int pmem2_source_device_idW(const struct pmem2_source *src,
wchar_t *id, size_t *len);
int pmem2_source_device_idU(const struct pmem2_source *src,
char *id, size_t *len);
#endif
int pmem2_source_device_usc(const struct pmem2_source *src, uint64_t *usc);
struct pmem2_badblock_context;
struct pmem2_badblock {
size_t offset;
size_t length;
};
int pmem2_badblock_context_new(const struct pmem2_source *src,
struct pmem2_badblock_context **bbctx);
int pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb);
void pmem2_badblock_context_delete(
struct pmem2_badblock_context **bbctx);
int pmem2_badblock_clear(struct pmem2_badblock_context *bbctx,
const struct pmem2_badblock *bb);
/* error handling */
#ifndef _WIN32
const char *pmem2_errormsg(void);
#else
const char *pmem2_errormsgU(void);
const wchar_t *pmem2_errormsgW(void);
#endif
int pmem2_err_to_errno(int);
#ifndef _WIN32
void pmem2_perror(const char *format,
...) __attribute__((__format__(__printf__, 1, 2)));
#else
void pmem2_perrorU(const char *format, ...);
void pmem2_perrorW(const wchar_t *format, ...);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmem2.h */
| 7,202 | 25.677778 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/pmemcompat.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2017, Intel Corporation */
/*
* pmemcompat.h -- compatibility layer for libpmem* libraries
*/
#ifndef PMEMCOMPAT_H
#define PMEMCOMPAT_H
#include <windows.h>
/* for backward compatibility */
#ifdef NVML_UTF8_API
#pragma message( "NVML_UTF8_API macro is obsolete, please use PMDK_UTF8_API instead." )
#ifndef PMDK_UTF8_API
#define PMDK_UTF8_API
#endif
#endif
struct iovec {
void *iov_base;
size_t iov_len;
};
typedef int mode_t;
/*
* XXX: this code will not work on windows if our library is included in
* an extern block.
*/
#if defined(__cplusplus) && defined(_MSC_VER) && !defined(__typeof__)
#include <type_traits>
/*
* These templates are used to remove a type reference(T&) which, in some
* cases, is returned by decltype
*/
namespace pmem {
namespace detail {
template<typename T>
struct get_type {
using type = T;
};
template<typename T>
struct get_type<T*> {
using type = T*;
};
template<typename T>
struct get_type<T&> {
using type = T;
};
} /* namespace detail */
} /* namespace pmem */
#define __typeof__(p) pmem::detail::get_type<decltype(p)>::type
#endif
#endif
| 1,161 | 17.15625 | 87 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/ctl.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2019, Intel Corporation */
/*
* libpmemobj/ctl.h -- definitions of pmemobj_ctl related entry points
*/
#ifndef LIBPMEMOBJ_CTL_H
#define LIBPMEMOBJ_CTL_H 1
#include <stddef.h>
#include <sys/types.h>
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Allocation class interface
*
* When requesting an object from the allocator, the first step is to determine
* which allocation class best approximates the size of the object.
* Once found, the appropriate free list, called bucket, for that
* class is selected in a fashion that minimizes contention between threads.
* Depending on the requested size and the allocation class, it might happen
* that the object size (including required metadata) would be bigger than the
* allocation class size - called unit size. In those situations, the object is
* constructed from two or more units (up to 64).
*
* If the requested number of units cannot be retrieved from the selected
* bucket, the thread reaches out to the global, shared, heap which manages
* memory in 256 kilobyte chunks and gives it out in a best-fit fashion. This
* operation must be performed under an exclusive lock.
* Once the thread is in the possession of a chunk, the lock is dropped, and the
* memory is split into units that repopulate the bucket.
*
* These are the CTL entry points that control allocation classes:
* - heap.alloc_class.[class_id].desc
* Creates/retrieves allocation class information
*
* It's VERY important to remember that the allocation classes are a RUNTIME
* property of the allocator - they are NOT stored persistently in the pool.
* It's recommended to always create custom allocation classes immediately after
* creating or opening the pool, before any use.
* If there are existing objects created using a class that is no longer stored
* in the runtime state of the allocator, they can be normally freed, but
* allocating equivalent objects will be done using the allocation class that
* is currently defined for that size.
*
* Please see the libpmemobj man page for more information about entry points.
*/
/*
* Persistent allocation header
*/
enum pobj_header_type {
/*
* 64-byte header used up until the version 1.3 of the library,
* functionally equivalent to the compact header.
* It's not recommended to create any new classes with this header.
*/
POBJ_HEADER_LEGACY,
/*
* 16-byte header used by the default allocation classes. All library
* metadata is by default allocated using this header.
* Supports type numbers and variably sized allocations.
*/
POBJ_HEADER_COMPACT,
/*
* 0-byte header with metadata stored exclusively in a bitmap. This
* ensures that objects are allocated in memory contiguously and
* without attached headers.
* This can be used to create very small allocation classes, but it
* does not support type numbers.
* Additionally, allocations with this header can only span a single
* unit.
* Objects allocated with this header do show up when iterating through
* the heap using pmemobj_first/pmemobj_next functions, but have a
* type_num equal 0.
*/
POBJ_HEADER_NONE,
MAX_POBJ_HEADER_TYPES
};
/*
* Description of allocation classes
*/
struct pobj_alloc_class_desc {
/*
* The number of bytes in a single unit of allocation. A single
* allocation can span up to 64 units (or 1 in the case of no header).
* If one creates an allocation class with a certain unit size and
* forces it to handle bigger sizes, more than one unit
* will be used.
* For example, an allocation class with a compact header and 128 bytes
* unit size, for a request of 200 bytes will create a memory block
* containing 256 bytes that spans two units. The usable size of that
* allocation will be 240 bytes: 2 * 128 - 16 (header).
*/
size_t unit_size;
/*
* Desired alignment of objects from the allocation class.
* If non zero, must be a power of two and an even divisor of unit size.
*
* All allocation classes have default alignment
* of 64. User data alignment is affected by the size of a header. For
* compact one this means that the alignment is 48 bytes.
*
*/
size_t alignment;
/*
* The minimum number of units that must be present in a
* single, contiguous, memory block.
* Those blocks (internally called runs), are fetched on demand from the
* heap. Accessing that global state is a serialization point for the
* allocator and thus it is imperative for performance and scalability
* that a reasonable amount of memory is fetched in a single call.
* Threads generally do not share memory blocks from which they
* allocate, but blocks do go back to the global heap if they are no
* longer actively used for allocation.
*/
unsigned units_per_block;
/*
* The header of allocations that originate from this allocation class.
*/
enum pobj_header_type header_type;
/*
* The identifier of this allocation class.
*/
unsigned class_id;
};
enum pobj_stats_enabled {
POBJ_STATS_ENABLED_TRANSIENT,
POBJ_STATS_ENABLED_BOTH,
POBJ_STATS_ENABLED_PERSISTENT,
POBJ_STATS_DISABLED,
};
#ifndef _WIN32
/* EXPERIMENTAL */
int pmemobj_ctl_get(PMEMobjpool *pop, const char *name, void *arg);
int pmemobj_ctl_set(PMEMobjpool *pop, const char *name, void *arg);
int pmemobj_ctl_exec(PMEMobjpool *pop, const char *name, void *arg);
#else
int pmemobj_ctl_getU(PMEMobjpool *pop, const char *name, void *arg);
int pmemobj_ctl_getW(PMEMobjpool *pop, const wchar_t *name, void *arg);
int pmemobj_ctl_setU(PMEMobjpool *pop, const char *name, void *arg);
int pmemobj_ctl_setW(PMEMobjpool *pop, const wchar_t *name, void *arg);
int pmemobj_ctl_execU(PMEMobjpool *pop, const char *name, void *arg);
int pmemobj_ctl_execW(PMEMobjpool *pop, const wchar_t *name, void *arg);
#ifndef PMDK_UTF8_API
#define pmemobj_ctl_get pmemobj_ctl_getW
#define pmemobj_ctl_set pmemobj_ctl_setW
#define pmemobj_ctl_exec pmemobj_ctl_execW
#else
#define pmemobj_ctl_get pmemobj_ctl_getU
#define pmemobj_ctl_set pmemobj_ctl_setU
#define pmemobj_ctl_exec pmemobj_ctl_execU
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/ctl.h */
| 6,198 | 34.221591 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/lists_atomic.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2017, Intel Corporation */
/*
* libpmemobj/lists_atomic.h -- definitions of libpmemobj atomic lists macros
*/
#ifndef LIBPMEMOBJ_LISTS_ATOMIC_H
#define LIBPMEMOBJ_LISTS_ATOMIC_H 1
#include <libpmemobj/lists_atomic_base.h>
#include <libpmemobj/thread.h>
#include <libpmemobj/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Non-transactional persistent atomic circular doubly-linked list
*/
#define POBJ_LIST_ENTRY(type)\
struct {\
TOID(type) pe_next;\
TOID(type) pe_prev;\
}
#define POBJ_LIST_HEAD(name, type)\
struct name {\
TOID(type) pe_first;\
PMEMmutex lock;\
}
#define POBJ_LIST_FIRST(head) ((head)->pe_first)
#define POBJ_LIST_LAST(head, field) (\
TOID_IS_NULL((head)->pe_first) ?\
(head)->pe_first :\
D_RO((head)->pe_first)->field.pe_prev)
#define POBJ_LIST_EMPTY(head) (TOID_IS_NULL((head)->pe_first))
#define POBJ_LIST_NEXT(elm, field) (D_RO(elm)->field.pe_next)
#define POBJ_LIST_PREV(elm, field) (D_RO(elm)->field.pe_prev)
#define POBJ_LIST_DEST_HEAD 1
#define POBJ_LIST_DEST_TAIL 0
#define POBJ_LIST_DEST_BEFORE 1
#define POBJ_LIST_DEST_AFTER 0
#define POBJ_LIST_FOREACH(var, head, field)\
for (_pobj_debug_notice("POBJ_LIST_FOREACH", __FILE__, __LINE__),\
(var) = POBJ_LIST_FIRST((head));\
TOID_IS_NULL((var)) == 0;\
TOID_EQUALS(POBJ_LIST_NEXT((var), field),\
POBJ_LIST_FIRST((head))) ?\
TOID_ASSIGN((var), OID_NULL) :\
((var) = POBJ_LIST_NEXT((var), field)))
#define POBJ_LIST_FOREACH_REVERSE(var, head, field)\
for (_pobj_debug_notice("POBJ_LIST_FOREACH_REVERSE", __FILE__, __LINE__),\
(var) = POBJ_LIST_LAST((head), field);\
TOID_IS_NULL((var)) == 0;\
TOID_EQUALS(POBJ_LIST_PREV((var), field),\
POBJ_LIST_LAST((head), field)) ?\
TOID_ASSIGN((var), OID_NULL) :\
((var) = POBJ_LIST_PREV((var), field)))
#define POBJ_LIST_INSERT_HEAD(pop, head, elm, field)\
pmemobj_list_insert((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), OID_NULL,\
POBJ_LIST_DEST_HEAD, (elm).oid)
#define POBJ_LIST_INSERT_TAIL(pop, head, elm, field)\
pmemobj_list_insert((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), OID_NULL,\
POBJ_LIST_DEST_TAIL, (elm).oid)
#define POBJ_LIST_INSERT_AFTER(pop, head, listelm, elm, field)\
pmemobj_list_insert((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), (listelm).oid,\
0 /* after */, (elm).oid)
#define POBJ_LIST_INSERT_BEFORE(pop, head, listelm, elm, field)\
pmemobj_list_insert((pop), \
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), (listelm).oid,\
1 /* before */, (elm).oid)
#define POBJ_LIST_INSERT_NEW_HEAD(pop, head, field, size, constr, arg)\
pmemobj_list_insert_new((pop),\
TOID_OFFSETOF((head)->pe_first, field),\
(head), OID_NULL, POBJ_LIST_DEST_HEAD, (size),\
TOID_TYPE_NUM_OF((head)->pe_first), (constr), (arg))
#define POBJ_LIST_INSERT_NEW_TAIL(pop, head, field, size, constr, arg)\
pmemobj_list_insert_new((pop),\
TOID_OFFSETOF((head)->pe_first, field),\
(head), OID_NULL, POBJ_LIST_DEST_TAIL, (size),\
TOID_TYPE_NUM_OF((head)->pe_first), (constr), (arg))
#define POBJ_LIST_INSERT_NEW_AFTER(pop, head, listelm, field, size,\
constr, arg)\
pmemobj_list_insert_new((pop),\
TOID_OFFSETOF((head)->pe_first, field),\
(head), (listelm).oid, 0 /* after */, (size),\
TOID_TYPE_NUM_OF((head)->pe_first), (constr), (arg))
#define POBJ_LIST_INSERT_NEW_BEFORE(pop, head, listelm, field, size,\
constr, arg)\
pmemobj_list_insert_new((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), (listelm).oid, 1 /* before */, (size),\
TOID_TYPE_NUM_OF((head)->pe_first), (constr), (arg))
#define POBJ_LIST_REMOVE(pop, head, elm, field)\
pmemobj_list_remove((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), (elm).oid, 0 /* no free */)
#define POBJ_LIST_REMOVE_FREE(pop, head, elm, field)\
pmemobj_list_remove((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head), (elm).oid, 1 /* free */)
#define POBJ_LIST_MOVE_ELEMENT_HEAD(pop, head, head_new, elm, field, field_new)\
pmemobj_list_move((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head_new), field_new),\
(head_new), OID_NULL, POBJ_LIST_DEST_HEAD, (elm).oid)
#define POBJ_LIST_MOVE_ELEMENT_TAIL(pop, head, head_new, elm, field, field_new)\
pmemobj_list_move((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head_new), field_new),\
(head_new), OID_NULL, POBJ_LIST_DEST_TAIL, (elm).oid)
#define POBJ_LIST_MOVE_ELEMENT_AFTER(pop,\
head, head_new, listelm, elm, field, field_new)\
pmemobj_list_move((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head_new), field_new),\
(head_new),\
(listelm).oid,\
0 /* after */, (elm).oid)
#define POBJ_LIST_MOVE_ELEMENT_BEFORE(pop,\
head, head_new, listelm, elm, field, field_new)\
pmemobj_list_move((pop),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head), field),\
(head),\
TOID_OFFSETOF(POBJ_LIST_FIRST(head_new), field_new),\
(head_new),\
(listelm).oid,\
1 /* before */, (elm).oid)
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/lists_atomic.h */
| 5,121 | 30.042424 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/iterator.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj/iterator.h -- definitions of libpmemobj iterator macros
*/
#ifndef LIBPMEMOBJ_ITERATOR_H
#define LIBPMEMOBJ_ITERATOR_H 1
#include <libpmemobj/iterator_base.h>
#include <libpmemobj/types.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline PMEMoid
POBJ_FIRST_TYPE_NUM(PMEMobjpool *pop, uint64_t type_num)
{
PMEMoid _pobj_ret = pmemobj_first(pop);
while (!OID_IS_NULL(_pobj_ret) &&
pmemobj_type_num(_pobj_ret) != type_num) {
_pobj_ret = pmemobj_next(_pobj_ret);
}
return _pobj_ret;
}
static inline PMEMoid
POBJ_NEXT_TYPE_NUM(PMEMoid o)
{
PMEMoid _pobj_ret = o;
do {
_pobj_ret = pmemobj_next(_pobj_ret);\
} while (!OID_IS_NULL(_pobj_ret) &&
pmemobj_type_num(_pobj_ret) != pmemobj_type_num(o));
return _pobj_ret;
}
#define POBJ_FIRST(pop, t) ((TOID(t))POBJ_FIRST_TYPE_NUM(pop, TOID_TYPE_NUM(t)))
#define POBJ_NEXT(o) ((__typeof__(o))POBJ_NEXT_TYPE_NUM((o).oid))
/*
* Iterates through every existing allocated object.
*/
#define POBJ_FOREACH(pop, varoid)\
for (_pobj_debug_notice("POBJ_FOREACH", __FILE__, __LINE__),\
varoid = pmemobj_first(pop);\
(varoid).off != 0; varoid = pmemobj_next(varoid))
/*
* Safe variant of POBJ_FOREACH in which pmemobj_free on varoid is allowed
*/
#define POBJ_FOREACH_SAFE(pop, varoid, nvaroid)\
for (_pobj_debug_notice("POBJ_FOREACH_SAFE", __FILE__, __LINE__),\
varoid = pmemobj_first(pop);\
(varoid).off != 0 && (nvaroid = pmemobj_next(varoid), 1);\
varoid = nvaroid)
/*
* Iterates through every object of the specified type.
*/
#define POBJ_FOREACH_TYPE(pop, var)\
POBJ_FOREACH(pop, (var).oid)\
if (pmemobj_type_num((var).oid) == TOID_TYPE_NUM_OF(var))
/*
* Safe variant of POBJ_FOREACH_TYPE in which pmemobj_free on var
* is allowed.
*/
#define POBJ_FOREACH_SAFE_TYPE(pop, var, nvar)\
POBJ_FOREACH_SAFE(pop, (var).oid, (nvar).oid)\
if (pmemobj_type_num((var).oid) == TOID_TYPE_NUM_OF(var))
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/iterator.h */
| 2,041 | 23.60241 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/lists_atomic_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2017, Intel Corporation */
/*
* libpmemobj/lists_atomic_base.h -- definitions of libpmemobj atomic lists
*/
#ifndef LIBPMEMOBJ_LISTS_ATOMIC_BASE_H
#define LIBPMEMOBJ_LISTS_ATOMIC_BASE_H 1
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Non-transactional persistent atomic circular doubly-linked list
*/
int pmemobj_list_insert(PMEMobjpool *pop, size_t pe_offset, void *head,
PMEMoid dest, int before, PMEMoid oid);
PMEMoid pmemobj_list_insert_new(PMEMobjpool *pop, size_t pe_offset, void *head,
PMEMoid dest, int before, size_t size, uint64_t type_num,
pmemobj_constr constructor, void *arg);
int pmemobj_list_remove(PMEMobjpool *pop, size_t pe_offset, void *head,
PMEMoid oid, int free);
int pmemobj_list_move(PMEMobjpool *pop, size_t pe_old_offset,
void *head_old, size_t pe_new_offset, void *head_new,
PMEMoid dest, int before, PMEMoid oid);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/lists_atomic_base.h */
| 1,022 | 24.575 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/tx_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* libpmemobj/tx_base.h -- definitions of libpmemobj transactional entry points
*/
#ifndef LIBPMEMOBJ_TX_BASE_H
#define LIBPMEMOBJ_TX_BASE_H 1
#include <setjmp.h>
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Transactions
*
* Stages are changed only by the pmemobj_tx_* functions, each transition
* to the TX_STAGE_ONABORT is followed by a longjmp to the jmp_buf provided in
* the pmemobj_tx_begin function.
*/
enum pobj_tx_stage {
TX_STAGE_NONE, /* no transaction in this thread */
TX_STAGE_WORK, /* transaction in progress */
TX_STAGE_ONCOMMIT, /* successfully committed */
TX_STAGE_ONABORT, /* tx_begin failed or transaction aborted */
TX_STAGE_FINALLY, /* always called */
MAX_TX_STAGE
};
/*
* Always returns the current transaction stage for a thread.
*/
enum pobj_tx_stage pmemobj_tx_stage(void);
enum pobj_tx_param {
TX_PARAM_NONE,
TX_PARAM_MUTEX, /* PMEMmutex */
TX_PARAM_RWLOCK, /* PMEMrwlock */
TX_PARAM_CB, /* pmemobj_tx_callback cb, void *arg */
};
enum pobj_log_type {
TX_LOG_TYPE_SNAPSHOT,
TX_LOG_TYPE_INTENT,
};
enum pobj_tx_failure_behavior {
POBJ_TX_FAILURE_ABORT,
POBJ_TX_FAILURE_RETURN,
};
#if !defined(pmdk_use_attr_deprec_with_msg) && defined(__COVERITY__)
#define pmdk_use_attr_deprec_with_msg 0
#endif
#if !defined(pmdk_use_attr_deprec_with_msg) && defined(__clang__)
#if __has_extension(attribute_deprecated_with_message)
#define pmdk_use_attr_deprec_with_msg 1
#else
#define pmdk_use_attr_deprec_with_msg 0
#endif
#endif
#if !defined(pmdk_use_attr_deprec_with_msg) && \
defined(__GNUC__) && !defined(__INTEL_COMPILER)
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 601 /* 6.1 */
#define pmdk_use_attr_deprec_with_msg 1
#else
#define pmdk_use_attr_deprec_with_msg 0
#endif
#endif
#if !defined(pmdk_use_attr_deprec_with_msg)
#define pmdk_use_attr_deprec_with_msg 0
#endif
#if pmdk_use_attr_deprec_with_msg
#define tx_lock_deprecated __attribute__((deprecated(\
"enum pobj_tx_lock is deprecated, use enum pobj_tx_param")))
#else
#define tx_lock_deprecated
#endif
/* deprecated, do not use */
enum tx_lock_deprecated pobj_tx_lock {
TX_LOCK_NONE tx_lock_deprecated = TX_PARAM_NONE,
TX_LOCK_MUTEX tx_lock_deprecated = TX_PARAM_MUTEX,
TX_LOCK_RWLOCK tx_lock_deprecated = TX_PARAM_RWLOCK,
};
typedef void (*pmemobj_tx_callback)(PMEMobjpool *pop, enum pobj_tx_stage stage,
void *);
#define POBJ_TX_XALLOC_VALID_FLAGS (POBJ_XALLOC_ZERO |\
POBJ_XALLOC_NO_FLUSH |\
POBJ_XALLOC_ARENA_MASK |\
POBJ_XALLOC_CLASS_MASK |\
POBJ_XALLOC_NO_ABORT)
#define POBJ_XADD_NO_FLUSH POBJ_FLAG_NO_FLUSH
#define POBJ_XADD_NO_SNAPSHOT POBJ_FLAG_NO_SNAPSHOT
#define POBJ_XADD_ASSUME_INITIALIZED POBJ_FLAG_ASSUME_INITIALIZED
#define POBJ_XADD_NO_ABORT POBJ_FLAG_TX_NO_ABORT
#define POBJ_XADD_VALID_FLAGS (POBJ_XADD_NO_FLUSH |\
POBJ_XADD_NO_SNAPSHOT |\
POBJ_XADD_ASSUME_INITIALIZED |\
POBJ_XADD_NO_ABORT)
#define POBJ_XLOCK_NO_ABORT POBJ_FLAG_TX_NO_ABORT
#define POBJ_XLOCK_VALID_FLAGS (POBJ_XLOCK_NO_ABORT)
#define POBJ_XFREE_NO_ABORT POBJ_FLAG_TX_NO_ABORT
#define POBJ_XFREE_VALID_FLAGS (POBJ_XFREE_NO_ABORT)
#define POBJ_XPUBLISH_NO_ABORT POBJ_FLAG_TX_NO_ABORT
#define POBJ_XPUBLISH_VALID_FLAGS (POBJ_XPUBLISH_NO_ABORT)
#define POBJ_XLOG_APPEND_BUFFER_NO_ABORT POBJ_FLAG_TX_NO_ABORT
#define POBJ_XLOG_APPEND_BUFFER_VALID_FLAGS (POBJ_XLOG_APPEND_BUFFER_NO_ABORT)
/*
* Starts a new transaction in the current thread.
* If called within an open transaction, starts a nested transaction.
*
* If successful, transaction stage changes to TX_STAGE_WORK and function
* returns zero. Otherwise, stage changes to TX_STAGE_ONABORT and an error
* number is returned.
*/
int pmemobj_tx_begin(PMEMobjpool *pop, jmp_buf env, ...);
/*
* Adds lock of given type to current transaction.
* 'Flags' is a bitmask of the following values:
* - POBJ_XLOCK_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*/
int pmemobj_tx_xlock(enum pobj_tx_param type, void *lockp, uint64_t flags);
/*
* Adds lock of given type to current transaction.
*/
int pmemobj_tx_lock(enum pobj_tx_param type, void *lockp);
/*
* Aborts current transaction
*
* Causes transition to TX_STAGE_ONABORT.
*
* This function must be called during TX_STAGE_WORK.
*/
void pmemobj_tx_abort(int errnum);
/*
* Commits current transaction
*
* This function must be called during TX_STAGE_WORK.
*/
void pmemobj_tx_commit(void);
/*
* Cleanups current transaction. Must always be called after pmemobj_tx_begin,
* even if starting the transaction failed.
*
* If called during TX_STAGE_NONE, has no effect.
*
* Always causes transition to TX_STAGE_NONE.
*
* If transaction was successful, returns 0. Otherwise returns error code set
* by pmemobj_tx_abort.
*
* This function must *not* be called during TX_STAGE_WORK.
*/
int pmemobj_tx_end(void);
/*
* Performs the actions associated with current stage of the transaction,
* and makes the transition to the next stage. Current stage must always
* be obtained by calling pmemobj_tx_stage.
*
* This function must be called in transaction.
*/
void pmemobj_tx_process(void);
/*
* Returns last transaction error code.
*/
int pmemobj_tx_errno(void);
/*
* Takes a "snapshot" of the memory block of given size and located at given
* offset 'off' in the object 'oid' and saves it in the undo log.
* The application is then free to directly modify the object in that memory
* range. In case of failure or abort, all the changes within this range will
* be rolled-back automatically.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_add_range(PMEMoid oid, uint64_t off, size_t size);
/*
* Takes a "snapshot" of the given memory region and saves it in the undo log.
* The application is then free to directly modify the object in that memory
* range. In case of failure or abort, all the changes within this range will
* be rolled-back automatically. The supplied block of memory has to be within
* the given pool.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_add_range_direct(const void *ptr, size_t size);
/*
* Behaves exactly the same as pmemobj_tx_add_range when 'flags' equals 0.
* 'Flags' is a bitmask of the following values:
* - POBJ_XADD_NO_FLUSH - skips flush on commit
* - POBJ_XADD_NO_SNAPSHOT - added range will not be snapshotted
* - POBJ_XADD_ASSUME_INITIALIZED - added range is assumed to be initialized
* - POBJ_XADD_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*/
int pmemobj_tx_xadd_range(PMEMoid oid, uint64_t off, size_t size,
uint64_t flags);
/*
* Behaves exactly the same as pmemobj_tx_add_range_direct when 'flags' equals
* 0. 'Flags' is a bitmask of the following values:
* - POBJ_XADD_NO_FLUSH - skips flush on commit
* - POBJ_XADD_NO_SNAPSHOT - added range will not be snapshotted
* - POBJ_XADD_ASSUME_INITIALIZED - added range is assumed to be initialized
* - POBJ_XADD_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*/
int pmemobj_tx_xadd_range_direct(const void *ptr, size_t size, uint64_t flags);
/*
* Transactionally allocates a new object.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_alloc(size_t size, uint64_t type_num);
/*
* Transactionally allocates a new object.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
* 'Flags' is a bitmask of the following values:
* - POBJ_XALLOC_ZERO - zero the allocated object
* - POBJ_XALLOC_NO_FLUSH - skip flush on commit
* - POBJ_XALLOC_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_xalloc(size_t size, uint64_t type_num, uint64_t flags);
/*
* Transactionally allocates new zeroed object.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_zalloc(size_t size, uint64_t type_num);
/*
* Transactionally resizes an existing object.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_realloc(PMEMoid oid, size_t size, uint64_t type_num);
/*
* Transactionally resizes an existing object, if extended new space is zeroed.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_zrealloc(PMEMoid oid, size_t size, uint64_t type_num);
/*
* Transactionally allocates a new object with duplicate of the string s.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_strdup(const char *s, uint64_t type_num);
/*
* Transactionally allocates a new object with duplicate of the string s.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
* 'Flags' is a bitmask of the following values:
* - POBJ_XALLOC_ZERO - zero the allocated object
* - POBJ_XALLOC_NO_FLUSH - skip flush on commit
* - POBJ_XALLOC_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_xstrdup(const char *s, uint64_t type_num, uint64_t flags);
/*
* Transactionally allocates a new object with duplicate of the wide character
* string s.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_wcsdup(const wchar_t *s, uint64_t type_num);
/*
* Transactionally allocates a new object with duplicate of the wide character
* string s.
*
* If successful, returns PMEMoid.
* Otherwise, stage changes to TX_STAGE_ONABORT and an OID_NULL is returned.
* 'Flags' is a bitmask of the following values:
* - POBJ_XALLOC_ZERO - zero the allocated object
* - POBJ_XALLOC_NO_FLUSH - skip flush on commit
* - POBJ_XALLOC_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*
* This function must be called during TX_STAGE_WORK.
*/
PMEMoid pmemobj_tx_xwcsdup(const wchar_t *s, uint64_t type_num, uint64_t flags);
/*
* Transactionally frees an existing object.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_free(PMEMoid oid);
/*
* Transactionally frees an existing object.
*
* If successful, returns zero.
* Otherwise, the stage changes to TX_STAGE_ONABORT and the error number is
* returned.
* 'Flags' is a bitmask of the following values:
* - POBJ_XFREE_NO_ABORT - if the function does not end successfully,
* do not abort the transaction and return the error number.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_xfree(PMEMoid oid, uint64_t flags);
/*
* Append user allocated buffer to the ulog.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_log_append_buffer(enum pobj_log_type type,
void *addr, size_t size);
/*
* Append user allocated buffer to the ulog.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
* 'Flags' is a bitmask of the following values:
* - POBJ_XLOG_APPEND_BUFFER_NO_ABORT - if the function does not end
* successfully, do not abort the transaction and return the error number.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_xlog_append_buffer(enum pobj_log_type type,
void *addr, size_t size, uint64_t flags);
/*
* Enables or disables automatic ulog allocations.
*
* If successful, returns zero.
* Otherwise, stage changes to TX_STAGE_ONABORT and an error number is returned.
*
* This function must be called during TX_STAGE_WORK.
*/
int pmemobj_tx_log_auto_alloc(enum pobj_log_type type, int on_off);
/*
* Calculates and returns size for user buffers for snapshots.
*/
size_t pmemobj_tx_log_snapshots_max_size(size_t *sizes, size_t nsizes);
/*
* Calculates and returns size for user buffers for intents.
*/
size_t pmemobj_tx_log_intents_max_size(size_t nintents);
/*
* Sets volatile pointer to the user data for the current transaction.
*/
void pmemobj_tx_set_user_data(void *data);
/*
* Gets volatile pointer to the user data associated with the current
* transaction.
*/
void *pmemobj_tx_get_user_data(void);
/*
* Sets the failure behavior of transactional functions.
*
* This function must be called during TX_STAGE_WORK.
*/
void pmemobj_tx_set_failure_behavior(enum pobj_tx_failure_behavior behavior);
/*
* Returns failure behavior for the current transaction.
*
* This function must be called during TX_STAGE_WORK.
*/
enum pobj_tx_failure_behavior pmemobj_tx_get_failure_behavior(void);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/tx_base.h */
| 14,087 | 30.237251 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/pool_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* libpmemobj/pool_base.h -- definitions of libpmemobj pool entry points
*/
#ifndef LIBPMEMOBJ_POOL_BASE_H
#define LIBPMEMOBJ_POOL_BASE_H 1
#include <stddef.h>
#include <sys/types.h>
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
//NEW
//#define _GNU_SOURCE
//#include <sys/types.h>
//#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
//int __real_open(const char *__path, int __oflag);
//int __wrap_open(const char *__path, int __oflag);
void* open_device(const char* pathname);
//END NEW
#define PMEMOBJ_MIN_POOL ((size_t)(1024 * 1024 * 256)) /* 8 MiB */
/*
* This limit is set arbitrary to incorporate a pool header and required
* alignment plus supply.
*/
#define PMEMOBJ_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
/*
* Pool management.
*/
#ifdef _WIN32
#ifndef PMDK_UTF8_API
#define pmemobj_open pmemobj_openW
#define pmemobj_create pmemobj_createW
#define pmemobj_check pmemobj_checkW
#else
#define pmemobj_open pmemobj_openU
#define pmemobj_create pmemobj_createU
#define pmemobj_check pmemobj_checkU
#endif
#endif
#ifndef _WIN32
PMEMobjpool *pmemobj_open(const char *path, const char *layout);
#else
PMEMobjpool *pmemobj_openU(const char *path, const char *layout);
PMEMobjpool *pmemobj_openW(const wchar_t *path, const wchar_t *layout);
#endif
#ifndef _WIN32
PMEMobjpool *pmemobj_create(const char *path, const char *layout,
size_t poolsize, mode_t mode);
#else
PMEMobjpool *pmemobj_createU(const char *path, const char *layout,
size_t poolsize, mode_t mode);
PMEMobjpool *pmemobj_createW(const wchar_t *path, const wchar_t *layout,
size_t poolsize, mode_t mode);
#endif
#ifndef _WIN32
int pmemobj_check(const char *path, const char *layout);
#else
int pmemobj_checkU(const char *path, const char *layout);
int pmemobj_checkW(const wchar_t *path, const wchar_t *layout);
#endif
void pmemobj_close(PMEMobjpool *pop);
/*
* If called for the first time on a newly created pool, the root object
* of given size is allocated. Otherwise, it returns the existing root object.
* In such case, the size must be not less than the actual root object size
* stored in the pool. If it's larger, the root object is automatically
* resized.
*
* This function is thread-safe.
*/
PMEMoid pmemobj_root(PMEMobjpool *pop, size_t size);
/*
* Same as above, but calls the constructor function when the object is first
* created and on all subsequent reallocations.
*/
PMEMoid pmemobj_root_construct(PMEMobjpool *pop, size_t size,
pmemobj_constr constructor, void *arg);
/*
* Returns the size in bytes of the root object. Always equal to the requested
* size.
*/
size_t pmemobj_root_size(PMEMobjpool *pop);
/*
* Sets volatile pointer to the user data for specified pool.
*/
void pmemobj_set_user_data(PMEMobjpool *pop, void *data);
/*
* Gets volatile pointer to the user data associated with the specified pool.
*/
void *pmemobj_get_user_data(PMEMobjpool *pop);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/pool_base.h */
| 3,095 | 24.377049 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/action_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2020, Intel Corporation */
/*
* libpmemobj/action_base.h -- definitions of libpmemobj action interface
*/
#ifndef LIBPMEMOBJ_ACTION_BASE_H
#define LIBPMEMOBJ_ACTION_BASE_H 1
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
enum pobj_action_type {
/* a heap action (e.g., alloc) */
POBJ_ACTION_TYPE_HEAP,
/* a single memory operation (e.g., value set) */
POBJ_ACTION_TYPE_MEM,
POBJ_MAX_ACTION_TYPE
};
struct pobj_action_heap {
/* offset to the element being freed/allocated */
uint64_t offset;
/* usable size of the element being allocated */
uint64_t usable_size;
};
struct pobj_action {
/*
* These fields are internal for the implementation and are not
* guaranteed to be stable across different versions of the API.
* Use with caution.
*
* This structure should NEVER be stored on persistent memory!
*/
enum pobj_action_type type;
uint32_t data[3];
union {
struct pobj_action_heap heap;
uint64_t data2[14];
};
};
#define POBJ_ACTION_XRESERVE_VALID_FLAGS\
(POBJ_XALLOC_CLASS_MASK |\
POBJ_XALLOC_ARENA_MASK |\
POBJ_XALLOC_ZERO)
PMEMoid pmemobj_reserve(PMEMobjpool *pop, struct pobj_action *act,
size_t size, uint64_t type_num);
PMEMoid pmemobj_xreserve(PMEMobjpool *pop, struct pobj_action *act,
size_t size, uint64_t type_num, uint64_t flags);
void pmemobj_set_value(PMEMobjpool *pop, struct pobj_action *act,
uint64_t *ptr, uint64_t value);
void pmemobj_defer_free(PMEMobjpool *pop, PMEMoid oid, struct pobj_action *act);
int pmemobj_publish(PMEMobjpool *pop, struct pobj_action *actv,
size_t actvcnt);
int pmemobj_tx_publish(struct pobj_action *actv, size_t actvcnt);
int pmemobj_tx_xpublish(struct pobj_action *actv, size_t actvcnt,
uint64_t flags);
void pmemobj_cancel(PMEMobjpool *pop, struct pobj_action *actv, size_t actvcnt);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/action_base.h */
| 1,935 | 24.813333 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/types.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2020, Intel Corporation */
/*
* libpmemobj/types.h -- definitions of libpmemobj type-safe macros
*/
#ifndef LIBPMEMOBJ_TYPES_H
#define LIBPMEMOBJ_TYPES_H 1
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TOID_NULL(t) ((TOID(t))OID_NULL)
#define PMEMOBJ_MAX_LAYOUT ((size_t)1024)
/*
* Type safety macros
*/
#if !(defined _MSC_VER || defined __clang__)
#define TOID_ASSIGN(o, value)(\
{\
(o).oid = value;\
(o); /* to avoid "error: statement with no effect" */\
})
#else /* _MSC_VER or __clang__ */
#define TOID_ASSIGN(o, value) ((o).oid = value, (o))
#endif
#if (defined _MSC_VER && _MSC_VER < 1912)
/*
* XXX - workaround for offsetof issue in VS 15.3,
* it has been fixed since Visual Studio 2017 Version 15.5
* (_MSC_VER == 1912)
*/
#ifdef PMEMOBJ_OFFSETOF_WA
#ifdef _CRT_USE_BUILTIN_OFFSETOF
#undef offsetof
#define offsetof(s, m) ((size_t)&reinterpret_cast < char const volatile& > \
((((s *)0)->m)))
#endif
#else
#ifdef _CRT_USE_BUILTIN_OFFSETOF
#error "Invalid definition of offsetof() macro - see: \
https://developercommunity.visualstudio.com/content/problem/96174/\
offsetof-macro-is-broken-for-nested-objects.html \
Please upgrade your VS, fix offsetof as described under the link or define \
PMEMOBJ_OFFSETOF_WA to enable workaround in libpmemobj.h"
#endif
#endif
#endif /* _MSC_VER */
#define TOID_EQUALS(lhs, rhs)\
((lhs).oid.off == (rhs).oid.off &&\
(lhs).oid.pool_uuid_lo == (rhs).oid.pool_uuid_lo)
/* type number of root object */
#define POBJ_ROOT_TYPE_NUM 0
#define _toid_struct
#define _toid_union
#define _toid_enum
#define _POBJ_LAYOUT_REF(name) (sizeof(_pobj_layout_##name##_ref))
/*
* Typed OID
*/
#define TOID(t)\
union _toid_##t##_toid
#ifdef __cplusplus
#define _TOID_CONSTR(t)\
_toid_##t##_toid()\
{ }\
_toid_##t##_toid(PMEMoid _oid) : oid(_oid)\
{ }
#else
#define _TOID_CONSTR(t)
#endif
/*
* Declaration of typed OID
*/
#define _TOID_DECLARE(t, i)\
typedef uint8_t _toid_##t##_toid_type_num[(i) + 1];\
TOID(t)\
{\
_TOID_CONSTR(t)\
PMEMoid oid;\
t *_type;\
_toid_##t##_toid_type_num *_type_num;\
}
/*
* Declaration of typed OID of an object
*/
#define TOID_DECLARE(t, i) _TOID_DECLARE(t, i)
/*
* Declaration of typed OID of a root object
*/
#define TOID_DECLARE_ROOT(t) _TOID_DECLARE(t, POBJ_ROOT_TYPE_NUM)
/*
* Type number of specified type
*/
#define TOID_TYPE_NUM(t) (sizeof(_toid_##t##_toid_type_num) - 1)
/*
* Type number of object read from typed OID
*/
#define TOID_TYPE_NUM_OF(o) (sizeof(*(o)._type_num) - 1)
/*
* NULL check
*/
#define TOID_IS_NULL(o) ((o).oid.off == 0)
/*
* Validates whether type number stored in typed OID is the same
* as type number stored in object's metadata
*/
#define TOID_VALID(o) (TOID_TYPE_NUM_OF(o) == pmemobj_type_num((o).oid))
/*
* Checks whether the object is of a given type
*/
#define OID_INSTANCEOF(o, t) (TOID_TYPE_NUM(t) == pmemobj_type_num(o))
/*
* Begin of layout declaration
*/
#define POBJ_LAYOUT_BEGIN(name)\
typedef uint8_t _pobj_layout_##name##_ref[__COUNTER__ + 1]
/*
* End of layout declaration
*/
#define POBJ_LAYOUT_END(name)\
typedef char _pobj_layout_##name##_cnt[__COUNTER__ + 1 -\
_POBJ_LAYOUT_REF(name)];
/*
* Number of types declared inside layout without the root object
*/
#define POBJ_LAYOUT_TYPES_NUM(name) (sizeof(_pobj_layout_##name##_cnt) - 1)
/*
* Declaration of typed OID inside layout declaration
*/
#define POBJ_LAYOUT_TOID(name, t)\
TOID_DECLARE(t, (__COUNTER__ + 1 - _POBJ_LAYOUT_REF(name)));
/*
* Declaration of typed OID of root inside layout declaration
*/
#define POBJ_LAYOUT_ROOT(name, t)\
TOID_DECLARE_ROOT(t);
/*
* Name of declared layout
*/
#define POBJ_LAYOUT_NAME(name) #name
#define TOID_TYPEOF(o) __typeof__(*(o)._type)
#define TOID_OFFSETOF(o, field) offsetof(TOID_TYPEOF(o), field)
/*
* XXX - DIRECT_RW and DIRECT_RO are not available when compiled using VC++
* as C code (/TC). Use /TP option.
*/
#ifndef _MSC_VER
#define DIRECT_RW(o) (\
{__typeof__(o) _o; _o._type = NULL; (void)_o;\
(__typeof__(*(o)._type) *)pmemobj_direct((o).oid); })
#define DIRECT_RO(o) ((const __typeof__(*(o)._type) *)pmemobj_direct((o).oid))
#elif defined(__cplusplus)
/*
* XXX - On Windows, these macros do not behave exactly the same as on Linux.
*/
#define DIRECT_RW(o) \
(reinterpret_cast < __typeof__((o)._type) > (pmemobj_direct((o).oid)))
#define DIRECT_RO(o) \
(reinterpret_cast < const __typeof__((o)._type) > \
(pmemobj_direct((o).oid)))
#endif /* (defined(_MSC_VER) || defined(__cplusplus)) */
#define D_RW DIRECT_RW
#define D_RO DIRECT_RO
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/types.h */
| 4,701 | 21.825243 | 78 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj/base.h -- definitions of base libpmemobj entry points
*/
#ifndef LIBPMEMOBJ_BASE_H
#define LIBPMEMOBJ_BASE_H 1
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <stddef.h>
#include <stdint.h>
#ifdef _WIN32
#include <pmemcompat.h>
#ifndef PMDK_UTF8_API
#define pmemobj_check_version pmemobj_check_versionW
#define pmemobj_errormsg pmemobj_errormsgW
#else
#define pmemobj_check_version pmemobj_check_versionU
#define pmemobj_errormsg pmemobj_errormsgU
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* opaque type internal to libpmemobj
*/
typedef struct pmemobjpool PMEMobjpool;
#define PMEMOBJ_MAX_ALLOC_SIZE ((size_t)0x3FFDFFFC0)
/*
* allocation functions flags
*/
#define POBJ_FLAG_ZERO (((uint64_t)1) << 0)
#define POBJ_FLAG_NO_FLUSH (((uint64_t)1) << 1)
#define POBJ_FLAG_NO_SNAPSHOT (((uint64_t)1) << 2)
#define POBJ_FLAG_ASSUME_INITIALIZED (((uint64_t)1) << 3)
#define POBJ_FLAG_TX_NO_ABORT (((uint64_t)1) << 4)
#define POBJ_CLASS_ID(id) (((uint64_t)(id)) << 48)
#define POBJ_ARENA_ID(id) (((uint64_t)(id)) << 32)
#define POBJ_XALLOC_CLASS_MASK ((((uint64_t)1 << 16) - 1) << 48)
#define POBJ_XALLOC_ARENA_MASK ((((uint64_t)1 << 16) - 1) << 32)
#define POBJ_XALLOC_ZERO POBJ_FLAG_ZERO
#define POBJ_XALLOC_NO_FLUSH POBJ_FLAG_NO_FLUSH
#define POBJ_XALLOC_NO_ABORT POBJ_FLAG_TX_NO_ABORT
/*
* pmemobj_mem* flags
*/
#define PMEMOBJ_F_MEM_NODRAIN (1U << 0)
#define PMEMOBJ_F_MEM_NONTEMPORAL (1U << 1)
#define PMEMOBJ_F_MEM_TEMPORAL (1U << 2)
#define PMEMOBJ_F_MEM_WC (1U << 3)
#define PMEMOBJ_F_MEM_WB (1U << 4)
#define PMEMOBJ_F_MEM_NOFLUSH (1U << 5)
/*
* pmemobj_mem*, pmemobj_xflush & pmemobj_xpersist flags
*/
#define PMEMOBJ_F_RELAXED (1U << 31)
/*
* Persistent memory object
*/
/*
* Object handle
*/
typedef struct pmemoid {
uint64_t pool_uuid_lo;
uint64_t off;
} PMEMoid;
static const PMEMoid OID_NULL = { 0, 0 };
#define OID_IS_NULL(o) ((o).off == 0)
#define OID_EQUALS(lhs, rhs)\
((lhs).off == (rhs).off &&\
(lhs).pool_uuid_lo == (rhs).pool_uuid_lo)
PMEMobjpool *pmemobj_pool_by_ptr(const void *addr);
PMEMobjpool *pmemobj_pool_by_oid(PMEMoid oid);
#ifndef _WIN32
extern int _pobj_cache_invalidate;
extern __thread struct _pobj_pcache {
PMEMobjpool *pop;
uint64_t uuid_lo;
int invalidate;
} _pobj_cached_pool;
/*
* Returns the direct pointer of an object.
*/
static inline void *
pmemobj_direct_inline(PMEMoid oid)
{
if (oid.off == 0 || oid.pool_uuid_lo == 0)
return NULL;
struct _pobj_pcache *cache = &_pobj_cached_pool;
if (_pobj_cache_invalidate != cache->invalidate ||
cache->uuid_lo != oid.pool_uuid_lo) {
cache->invalidate = _pobj_cache_invalidate;
if (!(cache->pop = pmemobj_pool_by_oid(oid))) {
cache->uuid_lo = 0;
return NULL;
}
cache->uuid_lo = oid.pool_uuid_lo;
}
return (void *)((uintptr_t)cache->pop + oid.off);
}
#endif /* _WIN32 */
/*
* Returns the direct pointer of an object.
*/
#if defined(_WIN32) || defined(_PMEMOBJ_INTRNL) ||\
defined(PMEMOBJ_DIRECT_NON_INLINE)
void *pmemobj_direct(PMEMoid oid);
#else
#define pmemobj_direct pmemobj_direct_inline
#endif
struct pmemvlt {
uint64_t runid;
};
#define PMEMvlt(T)\
struct {\
struct pmemvlt vlt;\
T value;\
}
/*
* Returns lazily initialized volatile variable. (EXPERIMENTAL)
*/
void *pmemobj_volatile(PMEMobjpool *pop, struct pmemvlt *vlt,
void *ptr, size_t size,
int (*constr)(void *ptr, void *arg), void *arg);
/*
* Returns the OID of the object pointed to by addr.
*/
PMEMoid pmemobj_oid(const void *addr);
/*
* Returns the number of usable bytes in the object. May be greater than
* the requested size of the object because of internal alignment.
*
* Can be used with objects allocated by any of the available methods.
*/
size_t pmemobj_alloc_usable_size(PMEMoid oid);
/*
* Returns the type number of the object.
*/
uint64_t pmemobj_type_num(PMEMoid oid);
/*
* Pmemobj specific low-level memory manipulation functions.
*
* These functions are meant to be used with pmemobj pools, because they provide
* additional functionality specific to this type of pool. These may include
* for example replication support. They also take advantage of the knowledge
* of the type of memory in the pool (pmem/non-pmem) to assure persistence.
*/
/*
* Pmemobj version of memcpy. Data copied is made persistent.
*/
void *pmemobj_memcpy_persist(PMEMobjpool *pop, void *dest, const void *src,
size_t len);
/*
* Pmemobj version of memset. Data range set is made persistent.
*/
void *pmemobj_memset_persist(PMEMobjpool *pop, void *dest, int c, size_t len);
/*
* Pmemobj version of memcpy. Data copied is made persistent (unless opted-out
* using flags).
*/
void *pmemobj_memcpy(PMEMobjpool *pop, void *dest, const void *src, size_t len,
unsigned flags);
/*
* Pmemobj version of memmove. Data copied is made persistent (unless opted-out
* using flags).
*/
void *pmemobj_memmove(PMEMobjpool *pop, void *dest, const void *src, size_t len,
unsigned flags);
/*
* Pmemobj version of memset. Data range set is made persistent (unless
* opted-out using flags).
*/
void *pmemobj_memset(PMEMobjpool *pop, void *dest, int c, size_t len,
unsigned flags);
/*
* Pmemobj version of pmem_persist.
*/
void pmemobj_persist(PMEMobjpool *pop, const void *addr, size_t len);
/*
* Pmemobj version of pmem_persist with additional flags argument.
*/
int pmemobj_xpersist(PMEMobjpool *pop, const void *addr, size_t len,
unsigned flags);
/*
* Pmemobj version of pmem_flush.
*/
void pmemobj_flush(PMEMobjpool *pop, const void *addr, size_t len);
/*
* Pmemobj version of pmem_flush with additional flags argument.
*/
int pmemobj_xflush(PMEMobjpool *pop, const void *addr, size_t len,
unsigned flags);
/*
* Pmemobj version of pmem_drain.
*/
void pmemobj_drain(PMEMobjpool *pop);
/*
* Version checking.
*/
/*
* PMEMOBJ_MAJOR_VERSION and PMEMOBJ_MINOR_VERSION provide the current version
* of the libpmemobj API as provided by this header file. Applications can
* verify that the version available at run-time is compatible with the version
* used at compile-time by passing these defines to pmemobj_check_version().
*/
#define PMEMOBJ_MAJOR_VERSION 2
#define PMEMOBJ_MINOR_VERSION 4
#ifndef _WIN32
const char *pmemobj_check_version(unsigned major_required,
unsigned minor_required);
#else
const char *pmemobj_check_versionU(unsigned major_required,
unsigned minor_required);
const wchar_t *pmemobj_check_versionW(unsigned major_required,
unsigned minor_required);
#endif
/*
* Passing NULL to pmemobj_set_funcs() tells libpmemobj to continue to use the
* default for that function. The replacement functions must not make calls
* back into libpmemobj.
*/
void pmemobj_set_funcs(
void *(*malloc_func)(size_t size),
void (*free_func)(void *ptr),
void *(*realloc_func)(void *ptr, size_t size),
char *(*strdup_func)(const char *s));
typedef int (*pmemobj_constr)(PMEMobjpool *pop, void *ptr, void *arg);
/*
* (debug helper function) logs notice message if used inside a transaction
*/
void _pobj_debug_notice(const char *func_name, const char *file, int line);
#ifndef _WIN32
const char *pmemobj_errormsg(void);
#else
const char *pmemobj_errormsgU(void);
const wchar_t *pmemobj_errormsgW(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/base.h */
| 7,415 | 23.72 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/tx.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj/tx.h -- definitions of libpmemobj transactional macros
*/
#ifndef LIBPMEMOBJ_TX_H
#define LIBPMEMOBJ_TX_H 1
#include <errno.h>
#include <string.h>
#include <libpmemobj/tx_base.h>
#include <libpmemobj/types.h>
extern uint64_t waitCycles;
extern uint64_t resetCycles;
//extern int current_tx1 = 1 ;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef POBJ_TX_CRASH_ON_NO_ONABORT
#define TX_ONABORT_CHECK do {\
if (_stage == TX_STAGE_ONABORT)\
abort();\
} while (0)
#else
#define TX_ONABORT_CHECK do {} while (0)
#endif
#define _POBJ_TX_BEGIN(pop, ...)\
{\
jmp_buf _tx_env;\
enum pobj_tx_stage _stage;\
int _pobj_errno;\
if (setjmp(_tx_env)) {\
errno = pmemobj_tx_errno();\
} else {\
_pobj_errno = pmemobj_tx_begin(pop, _tx_env, __VA_ARGS__,\
TX_PARAM_NONE);\
if (_pobj_errno)\
errno = _pobj_errno;\
}\
while ((_stage = pmemobj_tx_stage()) != TX_STAGE_NONE) {\
switch (_stage) {\
case TX_STAGE_WORK:
#define TX_BEGIN_PARAM(pop, ...)\
_POBJ_TX_BEGIN(pop, ##__VA_ARGS__)
#define TX_BEGIN_LOCK TX_BEGIN_PARAM
/* Just to let compiler warn when incompatible function pointer is used */
static inline pmemobj_tx_callback
_pobj_validate_cb_sig(pmemobj_tx_callback cb)
{
return cb;
}
#define TX_BEGIN_CB(pop, cb, arg, ...) _POBJ_TX_BEGIN(pop, TX_PARAM_CB,\
_pobj_validate_cb_sig(cb), arg, ##__VA_ARGS__)
#define TX_BEGIN(pop) _POBJ_TX_BEGIN(pop, TX_PARAM_NONE)
#define TX_ONABORT\
pmemobj_tx_process();\
break;\
case TX_STAGE_ONABORT:
#define TX_ONCOMMIT\
pmemobj_tx_process();\
break;\
case TX_STAGE_ONCOMMIT:
#define TX_FINALLY\
pmemobj_tx_process();\
break;\
case TX_STAGE_FINALLY:
#define TX_END\
pmemobj_tx_process();\
break;\
default:\
TX_ONABORT_CHECK;\
pmemobj_tx_process();\
break;\
}\
}\
_pobj_errno = pmemobj_tx_end();\
if (_pobj_errno)\
errno = _pobj_errno;\
}
#define TX_ADD(o)\
pmemobj_tx_add_range((o).oid, 0, sizeof(*(o)._type))
#define TX_ADD_FIELD(o, field)\
TX_ADD_DIRECT(&(D_RO(o)->field))
#define TX_ADD_DIRECT(p)\
pmemobj_tx_add_range_direct(p, sizeof(*(p)))
#define TX_ADD_FIELD_DIRECT(p, field)\
pmemobj_tx_add_range_direct(&(p)->field, sizeof((p)->field))
#define TX_XADD(o, flags)\
pmemobj_tx_xadd_range((o).oid, 0, sizeof(*(o)._type), flags)
#define TX_XADD_FIELD(o, field, flags)\
TX_XADD_DIRECT(&(D_RO(o)->field), flags)
#define TX_XADD_DIRECT(p, flags)\
pmemobj_tx_xadd_range_direct(p, sizeof(*(p)), flags)
#define TX_XADD_FIELD_DIRECT(p, field, flags)\
pmemobj_tx_xadd_range_direct(&(p)->field, sizeof((p)->field), flags)
#define TX_NEW(t)\
((TOID(t))pmemobj_tx_alloc(sizeof(t), TOID_TYPE_NUM(t)))
#define TX_ALLOC(t, size)\
((TOID(t))pmemobj_tx_alloc(size, TOID_TYPE_NUM(t)))
#define TX_ZNEW(t)\
((TOID(t))pmemobj_tx_zalloc(sizeof(t), TOID_TYPE_NUM(t)))
#define TX_ZALLOC(t, size)\
((TOID(t))pmemobj_tx_zalloc(size, TOID_TYPE_NUM(t)))
#define TX_XALLOC(t, size, flags)\
((TOID(t))pmemobj_tx_xalloc(size, TOID_TYPE_NUM(t), flags))
/* XXX - not available when compiled with VC++ as C code (/TC) */
#if !defined(_MSC_VER) || defined(__cplusplus)
#define TX_REALLOC(o, size)\
((__typeof__(o))pmemobj_tx_realloc((o).oid, size, TOID_TYPE_NUM_OF(o)))
#define TX_ZREALLOC(o, size)\
((__typeof__(o))pmemobj_tx_zrealloc((o).oid, size, TOID_TYPE_NUM_OF(o)))
#endif /* !defined(_MSC_VER) || defined(__cplusplus) */
#define TX_STRDUP(s, type_num)\
pmemobj_tx_strdup(s, type_num)
#define TX_XSTRDUP(s, type_num, flags)\
pmemobj_tx_xstrdup(s, type_num, flags)
#define TX_WCSDUP(s, type_num)\
pmemobj_tx_wcsdup(s, type_num)
#define TX_XWCSDUP(s, type_num, flags)\
pmemobj_tx_xwcsdup(s, type_num, flags)
#define TX_FREE(o)\
pmemobj_tx_free((o).oid)
#define TX_XFREE(o, flags)\
pmemobj_tx_xfree((o).oid, flags)
#define TX_SET(o, field, value) (\
TX_ADD_FIELD(o, field),\
D_RW(o)->field = (value))
#define TX_SET_DIRECT(p, field, value) (\
TX_ADD_FIELD_DIRECT(p, field),\
(p)->field = (value))
static inline void *
TX_MEMCPY(void *dest, const void *src, size_t num)
{
pmemobj_tx_add_range_direct(dest, num);
return memcpy(dest, src, num);
}
static inline void *
TX_MEMSET(void *dest, int c, size_t num)
{
pmemobj_tx_add_range_direct(dest, num);
return memset(dest, c, num);
}
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/tx.h */
| 4,386 | 21.848958 | 74 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/atomic_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj/atomic_base.h -- definitions of libpmemobj atomic entry points
*/
#ifndef LIBPMEMOBJ_ATOMIC_BASE_H
#define LIBPMEMOBJ_ATOMIC_BASE_H 1
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Non-transactional atomic allocations
*
* Those functions can be used outside transactions. The allocations are always
* aligned to the cache-line boundary.
*/
#define POBJ_XALLOC_VALID_FLAGS (POBJ_XALLOC_ZERO |\
POBJ_XALLOC_CLASS_MASK)
/*
* Allocates a new object from the pool and calls a constructor function before
* returning. It is guaranteed that allocated object is either properly
* initialized, or if it's interrupted before the constructor completes, the
* memory reserved for the object is automatically reclaimed.
*/
int pmemobj_alloc(PMEMobjpool *pop, PMEMoid *oidp, size_t size,
uint64_t type_num, pmemobj_constr constructor, void *arg);
/*
* Allocates with flags a new object from the pool.
*/
int pmemobj_xalloc(PMEMobjpool *pop, PMEMoid *oidp, size_t size,
uint64_t type_num, uint64_t flags,
pmemobj_constr constructor, void *arg);
/*
* Allocates a new zeroed object from the pool.
*/
int pmemobj_zalloc(PMEMobjpool *pop, PMEMoid *oidp, size_t size,
uint64_t type_num);
/*
* Resizes an existing object.
*/
int pmemobj_realloc(PMEMobjpool *pop, PMEMoid *oidp, size_t size,
uint64_t type_num);
/*
* Resizes an existing object, if extended new space is zeroed.
*/
int pmemobj_zrealloc(PMEMobjpool *pop, PMEMoid *oidp, size_t size,
uint64_t type_num);
/*
* Allocates a new object with duplicate of the string s.
*/
int pmemobj_strdup(PMEMobjpool *pop, PMEMoid *oidp, const char *s,
uint64_t type_num);
/*
* Allocates a new object with duplicate of the wide character string s.
*/
int pmemobj_wcsdup(PMEMobjpool *pop, PMEMoid *oidp, const wchar_t *s,
uint64_t type_num);
/*
* Frees an existing object.
*/
void pmemobj_free(PMEMoid *oidp);
struct pobj_defrag_result {
size_t total; /* number of processed objects */
size_t relocated; /* number of relocated objects */
};
/*
* Performs defragmentation on the provided array of objects.
*/
int pmemobj_defrag(PMEMobjpool *pop, PMEMoid **oidv, size_t oidcnt,
struct pobj_defrag_result *result);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/atomic_base.h */
| 2,386 | 24.393617 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/thread.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2017, Intel Corporation */
/*
* libpmemobj/thread.h -- definitions of libpmemobj thread/locking entry points
*/
#ifndef LIBPMEMOBJ_THREAD_H
#define LIBPMEMOBJ_THREAD_H 1
#include <time.h>
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Locking.
*/
#define _POBJ_CL_SIZE 64 /* cache line size */
typedef union {
long long align;
char padding[_POBJ_CL_SIZE];
} PMEMmutex;
typedef union {
long long align;
char padding[_POBJ_CL_SIZE];
} PMEMrwlock;
typedef union {
long long align;
char padding[_POBJ_CL_SIZE];
} PMEMcond;
void pmemobj_mutex_zero(PMEMobjpool *pop, PMEMmutex *mutexp);
int pmemobj_mutex_lock(PMEMobjpool *pop, PMEMmutex *mutexp);
int pmemobj_mutex_timedlock(PMEMobjpool *pop, PMEMmutex *__restrict mutexp,
const struct timespec *__restrict abs_timeout);
int pmemobj_mutex_trylock(PMEMobjpool *pop, PMEMmutex *mutexp);
int pmemobj_mutex_unlock(PMEMobjpool *pop, PMEMmutex *mutexp);
void pmemobj_rwlock_zero(PMEMobjpool *pop, PMEMrwlock *rwlockp);
int pmemobj_rwlock_rdlock(PMEMobjpool *pop, PMEMrwlock *rwlockp);
int pmemobj_rwlock_wrlock(PMEMobjpool *pop, PMEMrwlock *rwlockp);
int pmemobj_rwlock_timedrdlock(PMEMobjpool *pop,
PMEMrwlock *__restrict rwlockp,
const struct timespec *__restrict abs_timeout);
int pmemobj_rwlock_timedwrlock(PMEMobjpool *pop,
PMEMrwlock *__restrict rwlockp,
const struct timespec *__restrict abs_timeout);
int pmemobj_rwlock_tryrdlock(PMEMobjpool *pop, PMEMrwlock *rwlockp);
int pmemobj_rwlock_trywrlock(PMEMobjpool *pop, PMEMrwlock *rwlockp);
int pmemobj_rwlock_unlock(PMEMobjpool *pop, PMEMrwlock *rwlockp);
void pmemobj_cond_zero(PMEMobjpool *pop, PMEMcond *condp);
int pmemobj_cond_broadcast(PMEMobjpool *pop, PMEMcond *condp);
int pmemobj_cond_signal(PMEMobjpool *pop, PMEMcond *condp);
int pmemobj_cond_timedwait(PMEMobjpool *pop, PMEMcond *__restrict condp,
PMEMmutex *__restrict mutexp,
const struct timespec *__restrict abs_timeout);
int pmemobj_cond_wait(PMEMobjpool *pop, PMEMcond *condp,
PMEMmutex *__restrict mutexp);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/thread.h */
| 2,150 | 28.875 | 79 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/action.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2017-2018, Intel Corporation */
/*
* libpmemobj/action.h -- definitions of libpmemobj action interface
*/
#ifndef LIBPMEMOBJ_ACTION_H
#define LIBPMEMOBJ_ACTION_H 1
#include <libpmemobj/action_base.h>
#ifdef __cplusplus
extern "C" {
#endif
#define POBJ_RESERVE_NEW(pop, t, act)\
((TOID(t))pmemobj_reserve(pop, act, sizeof(t), TOID_TYPE_NUM(t)))
#define POBJ_RESERVE_ALLOC(pop, t, size, act)\
((TOID(t))pmemobj_reserve(pop, act, size, TOID_TYPE_NUM(t)))
#define POBJ_XRESERVE_NEW(pop, t, act, flags)\
((TOID(t))pmemobj_xreserve(pop, act, sizeof(t), TOID_TYPE_NUM(t), flags))
#define POBJ_XRESERVE_ALLOC(pop, t, size, act, flags)\
((TOID(t))pmemobj_xreserve(pop, act, size, TOID_TYPE_NUM(t), flags))
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/action_base.h */
| 829 | 23.411765 | 73 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/atomic.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2017, Intel Corporation */
/*
* libpmemobj/atomic.h -- definitions of libpmemobj atomic macros
*/
#ifndef LIBPMEMOBJ_ATOMIC_H
#define LIBPMEMOBJ_ATOMIC_H 1
#include <libpmemobj/atomic_base.h>
#include <libpmemobj/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define POBJ_NEW(pop, o, t, constr, arg)\
pmemobj_alloc((pop), (PMEMoid *)(o), sizeof(t), TOID_TYPE_NUM(t),\
(constr), (arg))
#define POBJ_ALLOC(pop, o, t, size, constr, arg)\
pmemobj_alloc((pop), (PMEMoid *)(o), (size), TOID_TYPE_NUM(t),\
(constr), (arg))
#define POBJ_ZNEW(pop, o, t)\
pmemobj_zalloc((pop), (PMEMoid *)(o), sizeof(t), TOID_TYPE_NUM(t))
#define POBJ_ZALLOC(pop, o, t, size)\
pmemobj_zalloc((pop), (PMEMoid *)(o), (size), TOID_TYPE_NUM(t))
#define POBJ_REALLOC(pop, o, t, size)\
pmemobj_realloc((pop), (PMEMoid *)(o), (size), TOID_TYPE_NUM(t))
#define POBJ_ZREALLOC(pop, o, t, size)\
pmemobj_zrealloc((pop), (PMEMoid *)(o), (size), TOID_TYPE_NUM(t))
#define POBJ_FREE(o)\
pmemobj_free((PMEMoid *)(o))
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/atomic.h */
| 1,115 | 23.26087 | 66 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/pool.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2017, Intel Corporation */
/*
* libpmemobj/pool.h -- definitions of libpmemobj pool macros
*/
#ifndef LIBPMEMOBJ_POOL_H
#define LIBPMEMOBJ_POOL_H 1
#include <libpmemobj/pool_base.h>
#include <libpmemobj/types.h>
#define POBJ_ROOT(pop, t) (\
(TOID(t))pmemobj_root((pop), sizeof(t)))
#endif /* libpmemobj/pool.h */
| 379 | 20.111111 | 61 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/src/include/libpmemobj/iterator_base.h | // SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2019, Intel Corporation */
/*
* libpmemobj/iterator_base.h -- definitions of libpmemobj iterator entry points
*/
#ifndef LIBPMEMOBJ_ITERATOR_BASE_H
#define LIBPMEMOBJ_ITERATOR_BASE_H 1
#include <libpmemobj/base.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The following functions allow access to the entire collection of objects.
*
* Use with conjunction with non-transactional allocations. Pmemobj pool acts
* as a generic container (list) of objects that are not assigned to any
* user-defined data structures.
*/
/*
* Returns the first object of the specified type number.
*/
PMEMoid pmemobj_first(PMEMobjpool *pop);
/*
* Returns the next object of the same type.
*/
PMEMoid pmemobj_next(PMEMoid oid);
#ifdef __cplusplus
}
#endif
#endif /* libpmemobj/iterator_base.h */
| 855 | 20.4 | 80 | h |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/utils/magic-install.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2017, Intel Corporation
#
# magic-install.sh -- Script for installing magic script
#
set -e
if ! grep -q "File: pmdk" /etc/magic
then
echo "Appending PMDK magic to /etc/magic"
cat /usr/share/pmdk/pmdk.magic >> /etc/magic
else
echo "PMDK magic already exists"
fi
| 343 | 20.5 | 56 | sh |
null | NearPMSW-main/nearpm/checkpointing/pmdkArrSwap-checkpoint/utils/md2man.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
#
# md2man.sh -- convert markdown to groff man pages
#
# usage: md2man.sh file template outfile
#
# This script converts markdown file into groff man page using pandoc.
# It performs some pre- and post-processing for better results:
# - uses m4 to preprocess OS-specific directives. See doc/macros.man.
# - parse input file for YAML metadata block and read man page title,
# section and version
# - cut-off metadata block and license
# - unindent code blocks
# - cut-off windows and web specific parts of documentation
#
# If the TESTOPTS variable is set, generates a preprocessed markdown file
# with the header stripped off for testing purposes.
#
set -e
set -o pipefail
filename=$1
template=$2
outfile=$3
title=`sed -n 's/^title:\ _MP(*\([A-Za-z0-9_-]*\).*$/\1/p' $filename`
section=`sed -n 's/^title:.*\([0-9]\))$/\1/p' $filename`
version=`sed -n 's/^date:\ *\(.*\)$/\1/p' $filename`
if [ "$TESTOPTS" != "" ]; then
m4 $TESTOPTS macros.man $filename | sed -n -e '/# NAME #/,$p' > $outfile
else
OPTS=
if [ "$WIN32" == 1 ]; then
OPTS="$OPTS -DWIN32"
else
OPTS="$OPTS -UWIN32"
fi
if [ "$(uname -s)" == "FreeBSD" ]; then
OPTS="$OPTS -DFREEBSD"
else
OPTS="$OPTS -UFREEBSD"
fi
if [ "$WEB" == 1 ]; then
OPTS="$OPTS -DWEB"
mkdir -p "$(dirname $outfile)"
m4 $OPTS macros.man $filename | sed -n -e '/---/,$p' > $outfile
else
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
COPYRIGHT=$(grep -rwI "\[comment]: <> (Copyright" $filename |\
sed "s/\[comment\]: <> (\([^)]*\))/\1/")
dt=$(date -u -d "@$SOURCE_DATE_EPOCH" +%F 2>/dev/null ||
date -u -r "$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u +%F)
m4 $OPTS macros.man $filename | sed -n -e '/# NAME #/,$p' |\
pandoc -s -t man -o $outfile --template=$template \
-V title=$title -V section=$section \
-V date="$dt" -V version="$version" \
-V copyright="$COPYRIGHT"
fi
fi
| 1,955 | 27.764706 | 73 | sh |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.