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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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/shadow/pmdk-sd/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 |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check-area.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2020, Intel Corporation
#
# Finds applicable area name for specified commit id.
#
if [ -z "$1" ]; then
echo "Missing commit id argument."
exit 1
fi
files=$(git show $1 --format=oneline --name-only | grep -v -e "$1")
git show -q $1 | cat
echo
echo "Modified files:"
echo "$files"
function categorize() {
category=$1
shift
cat_files=`echo "$files" | grep $*`
if [ -n "${cat_files}" ]; then
echo "$category"
files=`echo "$files" | grep -v $*`
fi
}
echo
echo "Areas computed basing on the list of modified files: (see utils/check-area.sh for full algorithm)"
categorize core -e "^src/core/"
categorize pmem -e "^src/libpmem/" -e "^src/include/libpmem.h"
categorize pmem2 -e "^src/libpmem2/" -e "^src/include/libpmem2.h"
categorize rpmem -e "^src/librpmem/" -e "^src/include/librpmem.h" -e "^src/tools/rpmemd/" -e "^src/rpmem_common/"
categorize log -e "^src/libpmemlog/" -e "^src/include/libpmemlog.h"
categorize blk -e "^src/libpmemblk/" -e "^src/include/libpmemblk.h"
categorize obj -e "^src/libpmemobj/" -e "^src/include/libpmemobj.h" -e "^src/include/libpmemobj/"
categorize pool -e "^src/libpmempool/" -e "^src/include/libpmempool.h" -e "^src/tools/pmempool/"
categorize benchmark -e "^src/benchmarks/"
categorize examples -e "^src/examples/"
categorize daxio -e "^src/tools/daxio/"
categorize pmreorder -e "^src/tools/pmreorder/"
categorize test -e "^src/test/"
categorize doc -e "^doc/" -e ".md\$" -e "^ChangeLog" -e "README"
categorize common -e "^src/common/" \
-e "^utils/" \
-e ".inc\$" \
-e ".yml\$" \
-e ".gitattributes" \
-e ".gitignore" \
-e "^.mailmap\$" \
-e "^src/PMDK.sln\$" \
-e "Makefile\$" \
-e "^src/freebsd/" \
-e "^src/windows/" \
-e "^src/include/pmemcompat.h"
echo
echo "If the above list contains more than 1 entry, please consider splitting"
echo "your change into more commits, unless those changes don't make sense "
echo "individually (they do not build, tests do not pass, etc)."
echo "For example, it's perfectly fine to use 'obj' prefix for one commit that"
echo "changes libpmemobj source code, its tests and documentation."
if [ -n "$files" ]; then
echo
echo "Uncategorized files:"
echo "$files"
fi
| 2,340 | 30.213333 | 120 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check-shebang.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# utils/check-shebang.sh -- interpreter directive check script
#
set -e
err_count=0
for file in $@ ; do
[ ! -f $file ] && continue
SHEBANG=`head -n1 $file | cut -d" " -f1`
[ "${SHEBANG:0:2}" != "#!" ] && continue
if [ "$SHEBANG" != "#!/usr/bin/env" -a $SHEBANG != "#!/bin/sh" ]; then
INTERP=`echo $SHEBANG | rev | cut -d"/" -f1 | rev`
echo "$file:1: error: invalid interpreter directive:" >&2
echo " (is: \"$SHEBANG\", should be: \"#!/usr/bin/env $INTERP\")" >&2
((err_count+=1))
fi
done
if [ "$err_count" == "0" ]; then
echo "Interpreter directives are OK."
else
echo "Found $err_count errors in interpreter directives!" >&2
err_count=1
fi
exit $err_count
| 787 | 24.419355 | 71 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check-commits.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# Used to check whether all the commit messages in a pull request
# follow the GIT/PMDK guidelines.
#
# usage: ./check-commits.sh [range]
#
if [ -z "$1" ]; then
# on CI run this check only for pull requests
if [ -n "$CI_REPO_SLUG" ]; then
if [[ "$CI_REPO_SLUG" != "$GITHUB_REPO" \
|| $CI_EVENT_TYPE != "pull_request" ]];
then
echo "SKIP: $0 can only be executed for pull requests to $GITHUB_REPO"
exit 0
fi
fi
# CI_COMMIT_RANGE can be invalid for force pushes - use another
# method to determine the list of commits
if [[ $(git rev-list $CI_COMMIT_RANGE 2>/dev/null) || -n "$CI_COMMIT_RANGE" ]]; then
MERGE_BASE=$(echo $CI_COMMIT_RANGE | cut -d. -f1)
[ -z $MERGE_BASE ] && \
MERGE_BASE=$(git log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2)
RANGE=$MERGE_BASE..$CI_COMMIT
else
MERGE_BASE=$(git log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2)
RANGE=$MERGE_BASE..HEAD
fi
else
RANGE="$1"
fi
COMMITS=$(git log --pretty=%H $RANGE)
set -e
for commit in $COMMITS; do
`dirname $0`/check-commit.sh $commit
done
| 1,174 | 25.704545 | 85 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/get_aliases.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2020, Intel Corporation
#
#
# get_aliases.sh -- generate map of manuals functions and libraries
#
# usage: run from /pmdk/doc/generated location without parameters:
# ./../../utils/get_aliases.sh
#
# This script searches manpages from section 7 then
# takes all functions from each section using specified pattern
# and at the end to every function it assign real markdown file
# representation based on *.gz file content
#
# Generated libs_map.yml file is used on gh-pages
# to handle functions and their aliases
#
list=("$@")
man_child=("$@")
function search_aliases {
children=$1
parent=$2
for i in ${children[@]}
do
if [ -e ../$parent/$i ]
then
echo "Man: $i"
content=$(head -c 150 ../$parent/$i)
if [[ "$content" == ".so "* ]] ;
then
content=$(basename ${content#".so"})
i="${i%.*}"
echo " $i: $content" >> $map_file
else
r="${i%.*}"
echo " $r: $i" >> $map_file
fi
fi
done
}
function list_pages {
parent="${1%.*}"
list=("$@")
man_child=("$@")
if [ "$parent" == "libpmem" ]; then
man_child=($(ls -1 ../libpmem | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "libpmem2" ]; then
man_child=($(ls -1 ../libpmem2 | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "libpmemblk" ]; then
man_child=($(ls -1 ../libpmemblk | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "libpmemlog" ]; then
man_child=($(ls -1 ../libpmemlog | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "libpmemobj" ]; then
man_child=($(ls -1 ../libpmemobj | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "libpmempool" ]; then
man_child=($(ls -1 ../libpmempool | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ "$parent" == "librpmem" ]; then
man_child=($(ls -1 ../librpmem | grep -e ".*\.3$"))
echo -n "- $parent: " >> $map_file
echo "${man_child[@]}" >> $map_file
fi
if [ ${#man_child[@]} -ne 0 ]
then
list=${man_child[@]}
search_aliases "${list[@]}" "$parent"
fi
}
man7=($(ls -1 ../*/ | grep -e ".*\.7$"))
map_file=libs_map.yml
[ -e $map_file ] && rm $map_file
touch $map_file
for i in "${man7[@]}"
do
echo "Library: $i"
list_pages $i
done
| 2,570 | 22.162162 | 67 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/copy-source.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018, Intel Corporation
#
# utils/copy-source.sh -- copy source files (from HEAD) to 'path_to_dir/pmdk'
# directory whether in git repository or not.
#
# usage: ./copy-source.sh [path_to_dir] [srcversion]
set -e
DESTDIR="$1"
SRCVERSION=$2
if [ -d .git ]; then
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Working directory is dirty: $(git status --porcelain)"
exit 1
fi
else
echo "Warning: You are not in git repository, working directory might be dirty."
fi
mkdir -p "$DESTDIR"/pmdk
echo -n $SRCVERSION > "$DESTDIR"/pmdk/.version
if [ -d .git ]; then
git archive HEAD | tar -x -C "$DESTDIR"/pmdk
else
find . \
-maxdepth 1 \
-not -name $(basename "$DESTDIR") \
-not -name . \
-exec cp -r "{}" "$DESTDIR"/pmdk \;
fi
| 818 | 21.135135 | 81 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check-commit.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# Used to check whether all the commit messages in a pull request
# follow the GIT/PMDK guidelines.
#
# usage: ./check-commit.sh commit
#
if [ -z "$1" ]; then
echo "Usage: check-commit.sh commit-id"
exit 1
fi
echo "Checking $1"
subject=$(git log --format="%s" -n 1 $1)
if [[ $subject =~ ^Merge.* ]]; then
# skip
exit 0
fi
if [[ $subject =~ ^Revert.* ]]; then
# skip
exit 0
fi
# valid area names
AREAS="pmem\|pmem2\|rpmem\|log\|blk\|obj\|pool\|test\|benchmark\|examples\|doc\|core\|common\|daxio\|pmreorder"
prefix=$(echo $subject | sed -n "s/^\($AREAS\)\:.*/\1/p")
if [ "$prefix" = "" ]; then
echo "FAIL: subject line in commit message does not contain valid area name"
echo
`dirname $0`/check-area.sh $1
exit 1
fi
commit_len=$(git log --format="%s%n%b" -n 1 $1 | wc -L)
if [ $commit_len -gt 73 ]; then
echo "FAIL: commit message exceeds 72 chars per line (commit_len)"
echo
git log -n 1 $1 | cat
exit 1
fi
| 1,035 | 19.313725 | 111 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/build-rpm.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2019, Intel Corporation
#
# build-rpm.sh - Script for building rpm packages
#
set -e
SCRIPT_DIR=$(dirname $0)
source $SCRIPT_DIR/pkg-common.sh
check_tool rpmbuild
check_file $SCRIPT_DIR/pkg-config.sh
source $SCRIPT_DIR/pkg-config.sh
#
# usage -- print usage message and exit
#
usage()
{
[ "$1" ] && echo Error: $1
cat >&2 <<EOF
Usage: $0 [ -h ] -t version-tag -s source-dir -w working-dir -o output-dir
[ -d distro ] [ -e build-experimental ] [ -c run-check ]
[ -r build-rpmem ] [ -n with-ndctl ] [ -f testconfig-file ]
[ -p build-libpmem2 ]
-h print this help message
-t version-tag source version tag
-s source-dir source directory
-w working-dir working directory
-o output-dir output directory
-d distro Linux distro name
-e build-experimental build experimental packages
-c run-check run package check
-r build-rpmem build librpmem and rpmemd packages
-n with-ndctl build with libndctl
-f testconfig-file custom testconfig.sh
-p build-libpmem2 build libpmem2 packages
EOF
exit 1
}
#
# command-line argument processing...
#
args=`getopt he:c:r:n:t:d:s:w:o:f:p: $*`
[ $? != 0 ] && usage
set -- $args
for arg
do
receivetype=auto
case "$arg"
in
-e)
EXPERIMENTAL="$2"
shift 2
;;
-c)
BUILD_PACKAGE_CHECK="$2"
shift 2
;;
-f)
TEST_CONFIG_FILE="$2"
shift 2
;;
-r)
BUILD_RPMEM="$2"
shift 2
;;
-n)
NDCTL_ENABLE="$2"
shift 2
;;
-t)
PACKAGE_VERSION_TAG="$2"
shift 2
;;
-s)
SOURCE="$2"
shift 2
;;
-w)
WORKING_DIR="$2"
shift 2
;;
-o)
OUT_DIR="$2"
shift 2
;;
-d)
DISTRO="$2"
shift 2
;;
-p)
PMEM2_INSTALL="$2"
shift 2
;;
--)
shift
break
;;
esac
done
# check for mandatory arguments
if [ -z "$PACKAGE_VERSION_TAG" -o -z "$SOURCE" -o -z "$WORKING_DIR" -o -z "$OUT_DIR" ]
then
error "Mandatory arguments missing"
usage
fi
# detected distro or defined in cmd
if [ -z "${DISTRO}" ]
then
OS=$(get_os)
if [ "$OS" != "1" ]
then
echo "Detected OS: $OS"
DISTRO=$OS
else
error "Unknown distribution"
exit 1
fi
fi
if [ "$EXTRA_CFLAGS_RELEASE" = "" ]; then
export EXTRA_CFLAGS_RELEASE="-ggdb -fno-omit-frame-pointer"
fi
LIBFABRIC_MIN_VERSION=1.4.2
NDCTL_MIN_VERSION=60.1
RPMBUILD_OPTS=( )
PACKAGE_VERSION=$(get_version $PACKAGE_VERSION_TAG)
if [ -z "$PACKAGE_VERSION" ]
then
error "Can not parse version from '${PACKAGE_VERSION_TAG}'"
exit 1
fi
PACKAGE_SOURCE=${PACKAGE_NAME}-${PACKAGE_VERSION}
SOURCE=$PACKAGE_NAME
PACKAGE_TARBALL=$PACKAGE_SOURCE.tar.gz
RPM_SPEC_FILE=$PACKAGE_SOURCE/$PACKAGE_NAME.spec
MAGIC_INSTALL=$PACKAGE_SOURCE/utils/magic-install.sh
MAGIC_UNINSTALL=$PACKAGE_SOURCE/utils/magic-uninstall.sh
OLDPWD=$PWD
[ -d $WORKING_DIR ] || mkdir -v $WORKING_DIR
[ -d $OUT_DIR ] || mkdir $OUT_DIR
cd $WORKING_DIR
check_dir $SOURCE
mv $SOURCE $PACKAGE_SOURCE
if [ "$DISTRO" = "SLES_like" ]
then
RPM_LICENSE="BSD-3-Clause"
RPM_GROUP_SYS_BASE="System\/Base"
RPM_GROUP_SYS_LIBS="System\/Libraries"
RPM_GROUP_DEV_LIBS="Development\/Libraries\/C and C++"
RPM_PKG_NAME_SUFFIX="1"
RPM_MAKE_FLAGS="BINDIR=""%_bindir"" NORPATH=1"
RPM_MAKE_INSTALL="%fdupes %{buildroot}\/%{_prefix}"
else
RPM_LICENSE="BSD"
RPM_GROUP_SYS_BASE="System Environment\/Base"
RPM_GROUP_SYS_LIBS="System Environment\/Libraries"
RPM_GROUP_DEV_LIBS="Development\/Libraries"
RPM_PKG_NAME_SUFFIX=""
RPM_MAKE_FLAGS="NORPATH=1"
RPM_MAKE_INSTALL=""
fi
#
# Create parametrized spec file required by rpmbuild.
# Most of variables are set in pkg-config.sh file in order to
# keep descriptive values separately from this script.
#
sed -e "s/__VERSION__/$PACKAGE_VERSION/g" \
-e "s/__LICENSE__/$RPM_LICENSE/g" \
-e "s/__PACKAGE_MAINTAINER__/$PACKAGE_MAINTAINER/g" \
-e "s/__PACKAGE_SUMMARY__/$PACKAGE_SUMMARY/g" \
-e "s/__GROUP_SYS_BASE__/$RPM_GROUP_SYS_BASE/g" \
-e "s/__GROUP_SYS_LIBS__/$RPM_GROUP_SYS_LIBS/g" \
-e "s/__GROUP_DEV_LIBS__/$RPM_GROUP_DEV_LIBS/g" \
-e "s/__PKG_NAME_SUFFIX__/$RPM_PKG_NAME_SUFFIX/g" \
-e "s/__MAKE_FLAGS__/$RPM_MAKE_FLAGS/g" \
-e "s/__MAKE_INSTALL_FDUPES__/$RPM_MAKE_INSTALL/g" \
-e "s/__LIBFABRIC_MIN_VER__/$LIBFABRIC_MIN_VERSION/g" \
-e "s/__NDCTL_MIN_VER__/$NDCTL_MIN_VERSION/g" \
$OLDPWD/$SCRIPT_DIR/pmdk.spec.in > $RPM_SPEC_FILE
if [ "$DISTRO" = "SLES_like" ]
then
sed -i '/^#.*bugzilla.redhat/d' $RPM_SPEC_FILE
fi
# do not split on space
IFS=$'\n'
# experimental features
if [ "${EXPERIMENTAL}" = "y" ]
then
# no experimental features for now
RPMBUILD_OPTS+=( )
fi
# libpmem2
if [ "${PMEM2_INSTALL}" == "y" ]
then
RPMBUILD_OPTS+=(--define "_pmem2_install 1")
fi
# librpmem & rpmemd
if [ "${BUILD_RPMEM}" = "y" ]
then
RPMBUILD_OPTS+=(--with fabric)
else
RPMBUILD_OPTS+=(--without fabric)
fi
# daxio & RAS
if [ "${NDCTL_ENABLE}" = "n" ]
then
RPMBUILD_OPTS+=(--without ndctl)
else
RPMBUILD_OPTS+=(--with ndctl)
fi
# use specified testconfig file or default
if [[( -n "${TEST_CONFIG_FILE}") && ( -f "$TEST_CONFIG_FILE" ) ]]
then
echo "Test config file: $TEST_CONFIG_FILE"
RPMBUILD_OPTS+=(--define "_testconfig $TEST_CONFIG_FILE")
else
echo -e "Test config file $TEST_CONFIG_FILE does not exist.\n"\
"Default test config will be used."
fi
# run make check or not
if [ "${BUILD_PACKAGE_CHECK}" == "n" ]
then
RPMBUILD_OPTS+=(--define "_skip_check 1")
fi
tar zcf $PACKAGE_TARBALL $PACKAGE_SOURCE
# Create directory structure for rpmbuild
mkdir -v BUILD SPECS
echo "opts: ${RPMBUILD_OPTS[@]}"
rpmbuild --define "_topdir `pwd`"\
--define "_rpmdir ${OUT_DIR}"\
--define "_srcrpmdir ${OUT_DIR}"\
-ta $PACKAGE_TARBALL \
${RPMBUILD_OPTS[@]}
echo "Building rpm packages done"
exit 0
| 5,618 | 19.966418 | 86 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/pkg-common.sh | # SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2019, Intel Corporation
#
# pkg-common.sh - common functions and variables for building packages
#
export LC_ALL="C"
function error() {
echo -e "error: $@"
}
function check_dir() {
if [ ! -d $1 ]
then
error "Directory '$1' does not exist."
exit 1
fi
}
function check_file() {
if [ ! -f $1 ]
then
error "File '$1' does not exist."
exit 1
fi
}
function check_tool() {
local tool=$1
if [ -z "$(which $tool 2>/dev/null)" ]
then
error "'${tool}' not installed or not in PATH"
exit 1
fi
}
function get_version() {
echo -n $1 | sed "s/-rc/~rc/"
}
function get_os() {
if [ -f /etc/os-release ]
then
local OS=$(cat /etc/os-release | grep -m1 -o -P '(?<=NAME=).*($)')
[[ "$OS" =~ SLES|openSUSE ]] && echo -n "SLES_like" ||
([[ "$OS" =~ "Fedora"|"Red Hat"|"CentOS" ]] && echo -n "RHEL_like" || echo 1)
else
echo 1
fi
}
REGEX_DATE_AUTHOR="([a-zA-Z]{3} [a-zA-Z]{3} [0-9]{2} [0-9]{4})\s*(.*)"
REGEX_MESSAGE_START="\s*\*\s*(.*)"
REGEX_MESSAGE="\s*(\S.*)"
| 1,042 | 17.298246 | 79 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/build-dpkg.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2020, Intel Corporation
#
# build-dpkg.sh - Script for building deb packages
#
set -e
SCRIPT_DIR=$(dirname $0)
source $SCRIPT_DIR/pkg-common.sh
#
# usage -- print usage message and exit
#
usage()
{
[ "$1" ] && echo Error: $1
cat >&2 <<EOF
Usage: $0 [ -h ] -t version-tag -s source-dir -w working-dir -o output-dir
[ -e build-experimental ] [ -c run-check ]
[ -n with-ndctl ] [ -f testconfig-file ]
[ -p build-libpmem2 ]
-h print this help message
-t version-tag source version tag
-s source-dir source directory
-w working-dir working directory
-o output-dir output directory
-e build-experimental build experimental packages
-c run-check run package check
-n with-ndctl build with libndctl
-f testconfig-file custom testconfig.sh
-p build-libpmem2 build libpmem2 packages
EOF
exit 1
}
#
# command-line argument processing...
#
args=`getopt he:c:r:n:t:d:s:w:o:f:p: $*`
[ $? != 0 ] && usage
set -- $args
for arg
do
receivetype=auto
case "$arg"
in
-e)
EXPERIMENTAL="$2"
shift 2
;;
-c)
BUILD_PACKAGE_CHECK="$2"
shift 2
;;
-f)
TEST_CONFIG_FILE="$2"
shift 2
;;
-r)
BUILD_RPMEM="$2"
shift 2
;;
-n)
NDCTL_ENABLE="$2"
shift 2
;;
-t)
PACKAGE_VERSION_TAG="$2"
shift 2
;;
-s)
SOURCE="$2"
shift 2
;;
-w)
WORKING_DIR="$2"
shift 2
;;
-o)
OUT_DIR="$2"
shift 2
;;
-p)
PMEM2_INSTALL="$2"
shift 2
;;
--)
shift
break
;;
esac
done
# check for mandatory arguments
if [ -z "$PACKAGE_VERSION_TAG" -o -z "$SOURCE" -o -z "$WORKING_DIR" -o -z "$OUT_DIR" ]
then
error "Mandatory arguments missing"
usage
fi
PREFIX=usr
LIB_DIR=$PREFIX/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)
INC_DIR=$PREFIX/include
MAN1_DIR=$PREFIX/share/man/man1
MAN3_DIR=$PREFIX/share/man/man3
MAN5_DIR=$PREFIX/share/man/man5
MAN7_DIR=$PREFIX/share/man/man7
DOC_DIR=$PREFIX/share/doc
if [ "$EXTRA_CFLAGS_RELEASE" = "" ]; then
export EXTRA_CFLAGS_RELEASE="-ggdb -fno-omit-frame-pointer"
fi
LIBFABRIC_MIN_VERSION=1.4.2
NDCTL_MIN_VERSION=60.1
function convert_changelog() {
while read line
do
if [[ $line =~ $REGEX_DATE_AUTHOR ]]
then
DATE="${BASH_REMATCH[1]}"
AUTHOR="${BASH_REMATCH[2]}"
echo " * ${DATE} ${AUTHOR}"
elif [[ $line =~ $REGEX_MESSAGE_START ]]
then
MESSAGE="${BASH_REMATCH[1]}"
echo " - ${MESSAGE}"
elif [[ $line =~ $REGEX_MESSAGE ]]
then
MESSAGE="${BASH_REMATCH[1]}"
echo " ${MESSAGE}"
fi
done < $1
}
function rpmem_install_triggers_overrides() {
cat << EOF > debian/librpmem.install
$LIB_DIR/librpmem.so.*
EOF
cat << EOF > debian/librpmem.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
librpmem: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/librpmem-dev.install
$LIB_DIR/pmdk_debug/librpmem.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/librpmem.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/librpmem.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/librpmem.so
$LIB_DIR/pkgconfig/librpmem.pc
$INC_DIR/librpmem.h
$MAN7_DIR/librpmem.7
$MAN3_DIR/rpmem_*.3
EOF
cat << EOF > debian/librpmem-dev.triggers
interest man-db
EOF
cat << EOF > debian/librpmem-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
EOF
cat << EOF > debian/rpmemd.install
usr/bin/rpmemd
$MAN1_DIR/rpmemd.1
EOF
cat << EOF > debian/rpmemd.triggers
interest man-db
EOF
cat << EOF > debian/rpmemd.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
EOF
}
function append_rpmem_control() {
cat << EOF >> $CONTROL_FILE
Package: librpmem
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory remote access support library
librpmem provides low-level support for remote access to persistent memory
(pmem) utilizing RDMA-capable RNICs. The library can be used to replicate
remotely a memory region over RDMA protocol. It utilizes appropriate
persistency mechanism based on remote node’s platform capabilities. The
librpmem utilizes the ssh client to authenticate a user on remote node and for
encryption of connection’s out-of-band configuration data.
.
This library is for applications that use remote persistent memory directly,
without the help of any library-supplied transactions or memory allocation.
Higher-level libraries that build on libpmem are available and are recommended
for most applications.
Package: librpmem-dev
Section: libdevel
Architecture: any
Depends: librpmem (=\${binary:Version}), libpmem-dev, \${shlibs:Depends}, \${misc:Depends}
Description: Development files for librpmem
librpmem provides low-level support for remote access to persistent memory
(pmem) utilizing RDMA-capable RNICs.
.
This package contains libraries and header files used for linking programs
against librpmem.
Package: rpmemd
Section: misc
Architecture: any
Priority: optional
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: rpmem daemon
Daemon for Remote Persistent Memory support.
EOF
}
function libpmem2_install_triggers_overrides() {
cat << EOF > debian/libpmem2.install
$LIB_DIR/libpmem2.so.*
EOF
cat << EOF > debian/libpmem2.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmem2: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmem2-dev.install
$LIB_DIR/pmdk_debug/libpmem2.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmem2.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmem2.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmem2.so
$LIB_DIR/pkgconfig/libpmem2.pc
$INC_DIR/libpmem2.h
$MAN7_DIR/libpmem2.7
$MAN3_DIR/pmem2_*.3
EOF
cat << EOF > debian/libpmem2-dev.triggers
interest man-db
EOF
cat << EOF > debian/libpmem2-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
EOF
}
function append_libpmem2_control() {
cat << EOF >> $CONTROL_FILE
Package: libpmem2
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory low level support library
libpmem2 provides low level persistent memory support. In particular, support
for the persistent memory instructions for flushing changes to pmem is
provided. (EXPERIMENTAL)
Package: libpmem2-dev
Section: libdevel
Architecture: any
Depends: libpmem2 (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmem2
libpmem2 provides low level persistent memory support. In particular, support
for the persistent memory instructions for flushing changes to pmem is
provided. (EXPERIMENTAL)
EOF
}
function daxio_install_triggers_overrides() {
cat << EOF > debian/daxio.install
usr/bin/daxio
$MAN1_DIR/daxio.1
EOF
cat << EOF > debian/daxio.triggers
interest man-db
EOF
cat << EOF > debian/daxio.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
EOF
}
function append_daxio_control() {
cat << EOF >> $CONTROL_FILE
Package: daxio
Section: misc
Architecture: any
Priority: optional
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: dd-like tool to read/write to a devdax device
The daxio utility performs I/O on Device DAX devices or zeroes a Device
DAX device. Since the standard I/O APIs (read/write) cannot be used
with Device DAX, data transfer is performed on a memory-mapped device.
The daxio may be used to dump Device DAX data to a file, restore data from
a backup copy, move/copy data to another device or to erase data from
a device.
EOF
}
if [ "${BUILD_PACKAGE_CHECK}" == "y" ]
then
CHECK_CMD="
override_dh_auto_test:
dh_auto_test
if [ -f $TEST_CONFIG_FILE ]; then\
cp $TEST_CONFIG_FILE src/test/testconfig.sh;\
else\
echo 'PMEM_FS_DIR=/tmp' > src/test/testconfig.sh; \
echo 'PMEM_FS_DIR_FORCE_PMEM=1' >> src/test/testconfig.sh; \
echo 'TEST_BUILD=\"debug nondebug\"' >> src/test/testconfig.sh; \
echo 'TEST_FS=\"pmem any none\"' >> src/test/testconfig.sh; \
fi
make pcheck ${PCHECK_OPTS}
"
else
CHECK_CMD="
override_dh_auto_test:
"
fi
check_tool debuild
check_tool dch
check_file $SCRIPT_DIR/pkg-config.sh
source $SCRIPT_DIR/pkg-config.sh
PACKAGE_VERSION=$(get_version $PACKAGE_VERSION_TAG)
PACKAGE_RELEASE=1
PACKAGE_SOURCE=${PACKAGE_NAME}-${PACKAGE_VERSION}
PACKAGE_TARBALL_ORIG=${PACKAGE_NAME}_${PACKAGE_VERSION}.orig.tar.gz
MAGIC_INSTALL=utils/magic-install.sh
MAGIC_UNINSTALL=utils/magic-uninstall.sh
CONTROL_FILE=debian/control
[ -d $WORKING_DIR ] || mkdir $WORKING_DIR
[ -d $OUT_DIR ] || mkdir $OUT_DIR
OLD_DIR=$PWD
cd $WORKING_DIR
check_dir $SOURCE
mv $SOURCE $PACKAGE_SOURCE
tar zcf $PACKAGE_TARBALL_ORIG $PACKAGE_SOURCE
cd $PACKAGE_SOURCE
rm -rf debian
mkdir debian
# Generate compat file
cat << EOF > debian/compat
9
EOF
# Generate control file
cat << EOF > $CONTROL_FILE
Source: $PACKAGE_NAME
Maintainer: $PACKAGE_MAINTAINER
Section: libs
Priority: optional
Standards-version: 4.1.4
Build-Depends: debhelper (>= 9)
Homepage: https://pmem.io/pmdk/
Package: libpmem
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory low level support library
libpmem provides low level persistent memory support. In particular, support
for the persistent memory instructions for flushing changes to pmem is
provided.
Package: libpmem-dev
Section: libdevel
Architecture: any
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmem
libpmem provides low level persistent memory support. In particular, support
for the persistent memory instructions for flushing changes to pmem is
provided.
Package: libpmemblk
Architecture: any
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory block array support library
libpmemblk implements a pmem-resident array of blocks, all the same size, where
a block is updated atomically with respect to power failure or program
interruption (no torn blocks).
Package: libpmemblk-dev
Section: libdevel
Architecture: any
Depends: libpmemblk (=\${binary:Version}), libpmem-dev, \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmemblk
libpmemblk implements a pmem-resident array of blocks, all the same size, where
a block is updated atomically with respect to power failure or program
interruption (no torn blocks).
Package: libpmemlog
Architecture: any
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory log file support library
libpmemlog implements a pmem-resident log file.
Package: libpmemlog-dev
Section: libdevel
Architecture: any
Depends: libpmemlog (=\${binary:Version}), libpmem-dev, \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmemlog
libpmemlog implements a pmem-resident log file.
Package: libpmemobj
Architecture: any
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory object store support library
libpmemobj turns a persistent memory file into a flexible object store,
supporting transactions, memory management, locking, lists, and a number of
other features.
Package: libpmemobj-dev
Section: libdevel
Architecture: any
Depends: libpmemobj (=\${binary:Version}), libpmem-dev, \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmemobj
libpmemobj turns a persistent memory file into a flexible object store,
supporting transactions, memory management, locking, lists, and a number of
other features.
.
This package contains libraries and header files used for linking programs
against libpmemobj.
Package: libpmempool
Architecture: any
Depends: libpmem (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends}
Description: Persistent Memory pool management support library
libpmempool provides a set of utilities for management, diagnostics and repair
of persistent memory pools. A pool in this context means a pmemobj pool,
pmemblk pool, pmemlog pool or BTT layout, independent of the underlying
storage. The libpmempool is for applications that need high reliability or
built-in troubleshooting. It may be useful for testing and debugging purposes
also.
Package: libpmempool-dev
Section: libdevel
Architecture: any
Depends: libpmempool (=\${binary:Version}), libpmem-dev, \${shlibs:Depends}, \${misc:Depends}
Description: Development files for libpmempool
libpmempool provides a set of utilities for management, diagnostics and repair
of persistent memory pools.
.
This package contains libraries and header files used for linking programs
against libpmempool.
Package: $PACKAGE_NAME-dbg
Section: debug
Priority: optional
Architecture: any
Depends: libpmem (=\${binary:Version}), libpmemblk (=\${binary:Version}), libpmemlog (=\${binary:Version}), libpmemobj (=\${binary:Version}), libpmempool (=\${binary:Version}), \${misc:Depends}
Description: Debug symbols for PMDK libraries
Debug symbols for all PMDK libraries.
Package: pmempool
Section: misc
Architecture: any
Priority: optional
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: utility for management and off-line analysis of PMDK memory pools
This utility is a standalone tool that manages Persistent Memory pools
created by PMDK libraries. It provides a set of utilities for
administration and diagnostics of Persistent Memory pools. Pmempool may be
useful for troubleshooting by system administrators and users of the
applications based on PMDK libraries.
Package: pmreorder
Section: misc
Architecture: any
Priority: optional
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: tool to parse and replay pmemcheck logs
Pmreorder is tool that parses and replays log of operations collected by
pmemcheck -- a atandalone tool which is a collection of python scripts designed
to parse and replay operations logged by pmemcheck - a persistent memory
checking tool. Pmreorder performs the store reordering between persistent
memory barriers - a sequence of flush-fence operations. It uses a
consistency checking routine provided in the command line options to check
whether files are in a consistent state.
EOF
cp LICENSE debian/copyright
if [ -n "$NDCTL_ENABLE" ]; then
pass_ndctl_enable="NDCTL_ENABLE=$NDCTL_ENABLE"
else
pass_ndctl_enable=""
fi
cat << EOF > debian/rules
#!/usr/bin/make -f
#export DH_VERBOSE=1
%:
dh \$@
override_dh_strip:
dh_strip --dbg-package=$PACKAGE_NAME-dbg
override_dh_auto_build:
dh_auto_build -- EXPERIMENTAL=${EXPERIMENTAL} prefix=/$PREFIX libdir=/$LIB_DIR includedir=/$INC_DIR docdir=/$DOC_DIR man1dir=/$MAN1_DIR man3dir=/$MAN3_DIR man5dir=/$MAN5_DIR man7dir=/$MAN7_DIR sysconfdir=/etc bashcompdir=/usr/share/bash-completion/completions NORPATH=1 ${pass_ndctl_enable} SRCVERSION=$SRCVERSION PMEM2_INSTALL=${PMEM2_INSTALL}
override_dh_auto_install:
dh_auto_install -- EXPERIMENTAL=${EXPERIMENTAL} prefix=/$PREFIX libdir=/$LIB_DIR includedir=/$INC_DIR docdir=/$DOC_DIR man1dir=/$MAN1_DIR man3dir=/$MAN3_DIR man5dir=/$MAN5_DIR man7dir=/$MAN7_DIR sysconfdir=/etc bashcompdir=/usr/share/bash-completion/completions NORPATH=1 ${pass_ndctl_enable} SRCVERSION=$SRCVERSION PMEM2_INSTALL=${PMEM2_INSTALL}
find -path './debian/*usr/share/man/man*/*.gz' -exec gunzip {} \;
override_dh_install:
mkdir -p debian/tmp/usr/share/pmdk/
cp utils/pmdk.magic debian/tmp/usr/share/pmdk/
dh_install
${CHECK_CMD}
EOF
chmod +x debian/rules
mkdir debian/source
ITP_BUG_EXCUSE="# This is our first package but we do not want to upload it yet.
# Please refer to Debian Developer's Reference section 5.1 (New packages) for details:
# https://www.debian.org/doc/manuals/developers-reference/pkgs.html#newpackage"
cat << EOF > debian/source/format
3.0 (quilt)
EOF
cat << EOF > debian/libpmem.install
$LIB_DIR/libpmem.so.*
usr/share/pmdk/pmdk.magic
$MAN5_DIR/poolset.5
EOF
cat $MAGIC_INSTALL > debian/libpmem.postinst
sed -i '1s/.*/\#\!\/bin\/bash/' debian/libpmem.postinst
echo $'\n#DEBHELPER#\n' >> debian/libpmem.postinst
cat $MAGIC_UNINSTALL > debian/libpmem.prerm
sed -i '1s/.*/\#\!\/bin\/bash/' debian/libpmem.prerm
echo $'\n#DEBHELPER#\n' >> debian/libpmem.prerm
cat << EOF > debian/libpmem.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmem: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmem-dev.install
$LIB_DIR/pmdk_debug/libpmem.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmem.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmem.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmem.so
$LIB_DIR/pkgconfig/libpmem.pc
$INC_DIR/libpmem.h
$MAN7_DIR/libpmem.7
$MAN3_DIR/pmem_*.3
EOF
cat << EOF > debian/libpmem-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
# pmdk provides second set of libraries for debugging.
# These are in /usr/lib/$arch/pmdk_dbg/, but still trigger ldconfig.
# Related issue: https://github.com/pmem/issues/issues/841
libpmem-dev: package-has-unnecessary-activation-of-ldconfig-trigger
EOF
cat << EOF > debian/libpmemblk.install
$LIB_DIR/libpmemblk.so.*
EOF
cat << EOF > debian/libpmemblk.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmemblk: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmemblk-dev.install
$LIB_DIR/pmdk_debug/libpmemblk.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemblk.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemblk.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmemblk.so
$LIB_DIR/pkgconfig/libpmemblk.pc
$INC_DIR/libpmemblk.h
$MAN7_DIR/libpmemblk.7
$MAN3_DIR/pmemblk_*.3
EOF
cat << EOF > debian/libpmemblk-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
# pmdk provides second set of libraries for debugging.
# These are in /usr/lib/$arch/pmdk_dbg/, but still trigger ldconfig.
# Related issue: https://github.com/pmem/issues/issues/841
libpmemblk-dev: package-has-unnecessary-activation-of-ldconfig-trigger
EOF
cat << EOF > debian/libpmemlog.install
$LIB_DIR/libpmemlog.so.*
EOF
cat << EOF > debian/libpmemlog.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmemlog: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmemlog-dev.install
$LIB_DIR/pmdk_debug/libpmemlog.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemlog.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemlog.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmemlog.so
$LIB_DIR/pkgconfig/libpmemlog.pc
$INC_DIR/libpmemlog.h
$MAN7_DIR/libpmemlog.7
$MAN3_DIR/pmemlog_*.3
EOF
cat << EOF > debian/libpmemlog-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
# pmdk provides second set of libraries for debugging.
# These are in /usr/lib/$arch/pmdk_dbg/, but still trigger ldconfig.
# Related issue: https://github.com/pmem/issues/issues/841
libpmemlog-dev: package-has-unnecessary-activation-of-ldconfig-trigger
EOF
cat << EOF > debian/libpmemobj.install
$LIB_DIR/libpmemobj.so.*
EOF
cat << EOF > debian/libpmemobj.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmemobj: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmemobj-dev.install
$LIB_DIR/pmdk_debug/libpmemobj.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemobj.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmemobj.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmemobj.so
$LIB_DIR/pkgconfig/libpmemobj.pc
$INC_DIR/libpmemobj.h
$INC_DIR/libpmemobj/*.h
$MAN7_DIR/libpmemobj.7
$MAN3_DIR/pmemobj_*.3
$MAN3_DIR/pobj_*.3
$MAN3_DIR/oid_*.3
$MAN3_DIR/toid*.3
$MAN3_DIR/direct_*.3
$MAN3_DIR/d_r*.3
$MAN3_DIR/tx_*.3
EOF
cat << EOF > debian/libpmemobj-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
# pmdk provides second set of libraries for debugging.
# These are in /usr/lib/$arch/pmdk_dbg/, but still trigger ldconfig.
# Related issue: https://github.com/pmem/issues/issues/841
libpmemobj-dev: package-has-unnecessary-activation-of-ldconfig-trigger
EOF
cat << EOF > debian/libpmempool.install
$LIB_DIR/libpmempool.so.*
EOF
cat << EOF > debian/libpmempool.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
libpmempool: package-name-doesnt-match-sonames
EOF
cat << EOF > debian/libpmempool-dev.install
$LIB_DIR/pmdk_debug/libpmempool.a $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmempool.so $LIB_DIR/pmdk_dbg/
$LIB_DIR/pmdk_debug/libpmempool.so.* $LIB_DIR/pmdk_dbg/
$LIB_DIR/libpmempool.so
$LIB_DIR/pkgconfig/libpmempool.pc
$INC_DIR/libpmempool.h
$MAN7_DIR/libpmempool.7
$MAN3_DIR/pmempool_*.3
EOF
cat << EOF > debian/libpmempool-dev.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
# The following warnings are triggered by a bug in debhelper:
# https://bugs.debian.org/204975
postinst-has-useless-call-to-ldconfig
postrm-has-useless-call-to-ldconfig
# We do not want to compile with -O2 for debug version
hardening-no-fortify-functions $LIB_DIR/pmdk_dbg/*
# pmdk provides second set of libraries for debugging.
# These are in /usr/lib/$arch/pmdk_dbg/, but still trigger ldconfig.
# Related issue: https://github.com/pmem/issues/issues/841
libpmempool-dev: package-has-unnecessary-activation-of-ldconfig-trigger
EOF
cat << EOF > debian/$PACKAGE_NAME-dbg.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
EOF
cat << EOF > debian/pmempool.install
usr/bin/pmempool
$MAN1_DIR/pmempool.1
$MAN1_DIR/pmempool-*.1
usr/share/bash-completion/completions/pmempool
EOF
cat << EOF > debian/pmempool.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
EOF
cat << EOF > debian/pmreorder.install
usr/bin/pmreorder
usr/share/pmreorder/*.py
$MAN1_DIR/pmreorder.1
EOF
cat << EOF > debian/pmreorder.lintian-overrides
$ITP_BUG_EXCUSE
new-package-should-close-itp-bug
EOF
# librpmem & rpmemd
if [ "${BUILD_RPMEM}" = "y" -a "${RPMEM_DPKG}" = "y" ]
then
append_rpmem_control;
rpmem_install_triggers_overrides;
fi
# libpmem2
if [ "${PMEM2_INSTALL}" == "y" ]
then
append_libpmem2_control;
libpmem2_install_triggers_overrides;
fi
# daxio
if [ "${NDCTL_ENABLE}" != "n" ]
then
append_daxio_control;
daxio_install_triggers_overrides;
fi
# Convert ChangeLog to debian format
CHANGELOG_TMP=changelog.tmp
dch --create --empty --package $PACKAGE_NAME -v $PACKAGE_VERSION-$PACKAGE_RELEASE -M -c $CHANGELOG_TMP
touch debian/changelog
head -n1 $CHANGELOG_TMP >> debian/changelog
echo "" >> debian/changelog
convert_changelog ChangeLog >> debian/changelog
echo "" >> debian/changelog
tail -n1 $CHANGELOG_TMP >> debian/changelog
rm $CHANGELOG_TMP
# This is our first release but we do
debuild --preserve-envvar=EXTRA_CFLAGS_RELEASE \
--preserve-envvar=EXTRA_CFLAGS_DEBUG \
--preserve-envvar=EXTRA_CFLAGS \
--preserve-envvar=EXTRA_CXXFLAGS \
--preserve-envvar=EXTRA_LDFLAGS \
--preserve-envvar=NDCTL_ENABLE \
-us -uc -b
cd $OLD_DIR
find $WORKING_DIR -name "*.deb"\
-or -name "*.dsc"\
-or -name "*.changes"\
-or -name "*.orig.tar.gz"\
-or -name "*.debian.tar.gz" | while read FILE
do
mv -v $FILE $OUT_DIR/
done
exit 0
| 24,325 | 27.925089 | 347 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check-os.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# Used to check if there are no banned functions in .o file
#
# usage: ./check-os.sh [os.h path] [.o file] [.c file]
EXCLUDE="os_posix|os_thread_posix"
if [[ $2 =~ $EXCLUDE ]]; then
echo "skip $2"
exit 0
fi
symbols=$(nm --demangle --undefined-only --format=posix $2 | sed 's/ U *//g')
functions=$(cat $1 | tr '\n' '|')
functions=${functions%?} # remove trailing | character
out=$(
for sym in $symbols
do
grep -wE $functions <<<"$sym"
done | sed 's/$/\(\)/g')
[[ ! -z $out ]] &&
echo -e "`pwd`/$3:1: non wrapped function(s):\n$out\nplease use os wrappers" &&
rm -f $2 && # remove .o file as it don't match requirements
exit 1
exit 0
| 750 | 23.225806 | 80 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/magic-uninstall.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2017, Intel Corporation
#
# magic-uninstall.sh -- Script for uninstalling magic script
#
set -e
HDR_LOCAL=$(grep "File: pmdk" /etc/magic)
HDR_PKG=$(grep "File: pmdk" /usr/share/pmdk/pmdk.magic)
if [[ $HDR_LOCAL == $HDR_PKG ]]
then
echo "Removing PMDK magic from /etc/magic"
HDR_LINE=$(grep -n "File: pmdk" /etc/magic | cut -f1 -d:)
HDR_PKG_LINE=$(grep -n "File: pmdk" /usr/share/pmdk/pmdk.magic | cut -f1 -d:)
HDR_LINES=$(cat /usr/share/pmdk/pmdk.magic | wc -l)
HDR_FIRST=$(($HDR_LINE - $HDR_PKG_LINE + 1))
HDR_LAST=$(($HDR_FIRST + $HDR_LINES))
sed -i "${HDR_FIRST},${HDR_LAST}d" /etc/magic
fi
| 680 | 29.954545 | 78 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/pkg-config.sh | # SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2020, Intel Corporation
# Name of package
PACKAGE_NAME="pmdk"
# Name and email of package maintainer
PACKAGE_MAINTAINER="Piotr Balcer <[email protected]>"
# Brief description of the package
PACKAGE_SUMMARY="Persistent Memory Development Kit"
# Full description of the package
PACKAGE_DESCRIPTION="The collection of libraries and utilities for Persistent Memory Programming"
# Website
PACKAGE_URL="https://pmem.io/pmdk"
| 486 | 26.055556 | 97 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/style_check.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# utils/style_check.sh -- common style checking script
#
set -e
ARGS=("$@")
CSTYLE_ARGS=()
CLANG_ARGS=()
FLAKE8_ARGS=()
CHECK_TYPE=$1
[ -z "$clang_format_bin" ] && which clang-format-9 >/dev/null &&
clang_format_bin=clang-format-9
[ -z "$clang_format_bin" ] && which clang-format >/dev/null &&
clang_format_bin=clang-format
[ -z "$clang_format_bin" ] && clang_format_bin=clang-format
#
# print script usage
#
function usage() {
echo "$0 <check|format> [C/C++ files]"
}
#
# require clang-format version 9.0
#
function check_clang_version() {
set +e
which ${clang_format_bin} &> /dev/null && ${clang_format_bin} --version |\
grep "version 9\.0"\
&> /dev/null
if [ $? -ne 0 ]; then
echo "SKIP: requires clang-format version 9.0"
exit 0
fi
set -e
}
#
# run old cstyle check
#
function run_cstyle() {
if [ $# -eq 0 ]; then
return
fi
${cstyle_bin} -pP $@
}
#
# generate diff with clang-format rules
#
function run_clang_check() {
if [ $# -eq 0 ]; then
return
fi
check_clang_version
for file in $@
do
LINES=$(${clang_format_bin} -style=file $file |\
git diff --no-index $file - | wc -l)
if [ $LINES -ne 0 ]; then
${clang_format_bin} -style=file $file | git diff --no-index $file -
fi
done
}
#
# in-place format according to clang-format rules
#
function run_clang_format() {
if [ $# -eq 0 ]; then
return
fi
check_clang_version
${clang_format_bin} -style=file -i $@
}
function run_flake8() {
if [ $# -eq 0 ]; then
return
fi
${flake8_bin} --exclude=testconfig.py,envconfig.py $@
}
for ((i=1; i<$#; i++)) {
IGNORE="$(dirname ${ARGS[$i]})/.cstyleignore"
if [ -e $IGNORE ]; then
if grep -q ${ARGS[$i]} $IGNORE ; then
echo "SKIP ${ARGS[$i]}"
continue
fi
fi
case ${ARGS[$i]} in
*.[ch]pp)
CLANG_ARGS+="${ARGS[$i]} "
;;
*.[ch])
CSTYLE_ARGS+="${ARGS[$i]} "
;;
*.py)
FLAKE8_ARGS+="${ARGS[$i]} "
;;
*)
echo "Unknown argument"
exit 1
;;
esac
}
case $CHECK_TYPE in
check)
run_cstyle ${CSTYLE_ARGS}
run_clang_check ${CLANG_ARGS}
run_flake8 ${FLAKE8_ARGS}
;;
format)
run_clang_format ${CLANG_ARGS}
;;
*)
echo "Invalid parameters"
usage
exit 1
;;
esac
| 2,274 | 15.485507 | 75 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/version.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2020, Intel Corporation
#
# utils/version.sh -- determine project's version
#
set -e
if [ -f "$1/VERSION" ]; then
cat "$1/VERSION"
exit 0
fi
if [ -f $1/GIT_VERSION ]; then
echo -n "\$Format:%h\$" | cmp -s $1/GIT_VERSION - && true
if [ $? -eq 0 ]; then
PARSE_GIT_VERSION=0
else
PARSE_GIT_VERSION=1
fi
else
PARSE_GIT_VERSION=0
fi
LATEST_RELEASE=$(cat $1/ChangeLog | grep "* Version" | cut -d " " -f 3 | sort -rd | head -n1)
if [ $PARSE_GIT_VERSION -eq 1 ]; then
GIT_VERSION_HASH=$(cat $1/GIT_VERSION)
if [ -n "$GIT_VERSION_HASH" ]; then
echo "$LATEST_RELEASE+git.$GIT_VERSION_HASH"
exit 0
fi
fi
cd "$1"
GIT_DESCRIBE=$(git describe 2>/dev/null) && true
if [ -n "$GIT_DESCRIBE" ]; then
# 1.5-19-gb8f78a329 -> 1.5+git19.gb8f78a329
# 1.5-rc1-19-gb8f78a329 -> 1.5-rc1+git19.gb8f78a329
echo "$GIT_DESCRIBE" | sed "s/\([0-9.]*\)-rc\([0-9]*\)-\([0-9]*\)-\([0-9a-g]*\)/\1-rc\2+git\3.\4/" | sed "s/\([0-9.]*\)-\([0-9]*\)-\([0-9a-g]*\)/\1+git\2.\3/"
exit 0
fi
# try commit it, git describe can fail when there are no tags (e.g. with shallow clone, like on Travis)
GIT_COMMIT=$(git log -1 --format=%h) && true
if [ -n "$GIT_COMMIT" ]; then
echo "$LATEST_RELEASE+git.$GIT_COMMIT"
exit 0
fi
cd - >/dev/null
# If nothing works, try to get version from directory name
VER=$(basename `realpath "$1"` | sed 's/pmdk[-]*\([0-9a-z.+-]*\).*/\1/')
if [ -n "$VER" ]; then
echo "$VER"
exit 0
fi
exit 1
| 1,489 | 22.650794 | 159 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check_license/file-exceptions.sh | #!/bin/sh -e
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
# file-exceptions.sh - filter out files not checked for copyright and license
grep -v -E -e '/queue.h$' -e '/getopt.h$' -e '/getopt.c$' -e 'src/core/valgrind/' -e '/testconfig\...$'
| 278 | 33.875 | 103 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check_license/check-headers.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
# check-headers.sh - check copyright and license in source files
SELF=$0
function usage() {
echo "Usage: $SELF <source_root_path> <license_tag> [-h|-v|-a]"
echo " -h, --help this help message"
echo " -v, --verbose verbose mode"
echo " -a, --all check all files (only modified files are checked by default)"
}
if [ "$#" -lt 2 ]; then
usage >&2
exit 2
fi
SOURCE_ROOT=$1
shift
LICENSE=$1
shift
PATTERN=`mktemp`
TMP=`mktemp`
TMP2=`mktemp`
TEMPFILE=`mktemp`
rm -f $PATTERN $TMP $TMP2
if [ "$1" == "-h" -o "$1" == "--help" ]; then
usage
exit 0
fi
export GIT="git -C ${SOURCE_ROOT}"
$GIT rev-parse || exit 1
if [ -f $SOURCE_ROOT/.git/shallow ]; then
SHALLOW_CLONE=1
echo
echo "Warning: This is a shallow clone. Checking dates in copyright headers"
echo " will be skipped in case of files that have no history."
echo
else
SHALLOW_CLONE=0
fi
VERBOSE=0
CHECK_ALL=0
while [ "$1" != "" ]; do
case $1 in
-v|--verbose)
VERBOSE=1
;;
-a|--all)
CHECK_ALL=1
;;
esac
shift
done
if [ $CHECK_ALL -eq 0 ]; then
CURRENT_COMMIT=$($GIT log --pretty=%H -1)
MERGE_BASE=$($GIT merge-base HEAD origin/master 2>/dev/null)
[ -z $MERGE_BASE ] && \
MERGE_BASE=$($GIT log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2)
[ -z $MERGE_BASE -o "$CURRENT_COMMIT" = "$MERGE_BASE" ] && \
CHECK_ALL=1
fi
if [ $CHECK_ALL -eq 1 ]; then
echo "Checking copyright headers of all files..."
GIT_COMMAND="ls-tree -r --name-only HEAD"
else
if [ $VERBOSE -eq 1 ]; then
echo
echo "Warning: will check copyright headers of modified files only,"
echo " in order to check all files issue the following command:"
echo " $ $SELF <source_root_path> <license_tag> -a"
echo " (e.g.: $ $SELF $SOURCE_ROOT $LICENSE -a)"
echo
fi
echo "Checking copyright headers of modified files only..."
GIT_COMMAND="diff --name-only $MERGE_BASE $CURRENT_COMMIT"
fi
FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/utils/check_license/file-exceptions.sh | \
grep -E -e '*\.[chs]$' -e '*\.[ch]pp$' -e '*\.sh$' \
-e '*\.py$' -e '*\.link$' -e 'Makefile*' -e 'TEST*' \
-e '/common.inc$' -e '/match$' -e '/check_whitespace$' \
-e 'LICENSE$' -e 'CMakeLists.txt$' -e '*\.cmake$' | \
xargs)
RV=0
for file in $FILES ; do
# The src_path is a path which should be used in every command except git.
# git is called with -C flag so filepaths should be relative to SOURCE_ROOT
src_path="${SOURCE_ROOT}/$file"
[ ! -f $src_path ] && continue
# ensure that file is UTF-8 encoded
ENCODING=`file -b --mime-encoding $src_path`
iconv -f $ENCODING -t "UTF-8" $src_path > $TEMPFILE
if ! grep -q "SPDX-License-Identifier: $LICENSE" $src_path; then
echo >&2 "$src_path:1: no $LICENSE SPDX tag found "
RV=1
fi
if [ $SHALLOW_CLONE -eq 0 ]; then
$GIT log --no-merges --format="%ai %aE" -- $file | sort > $TMP
else
# mark the grafted commits (commits with no parents)
$GIT log --no-merges --format="%ai %aE grafted-%p-commit" -- $file | sort > $TMP
fi
# skip checking dates for non-Intel commits
[[ ! $(tail -n1 $TMP) =~ "@intel.com" ]] && continue
# skip checking dates for new files
[ $(cat $TMP | wc -l) -le 1 ] && continue
# grep out the grafted commits (commits with no parents)
# and skip checking dates for non-Intel commits
grep -v -e "grafted--commit" $TMP | grep -e "@intel.com" > $TMP2
[ $(cat $TMP2 | wc -l) -eq 0 ] && continue
FIRST=`head -n1 $TMP2`
LAST=` tail -n1 $TMP2`
YEARS=`sed '
/Copyright [0-9-]\+.*, Intel Corporation/!d
s/.*Copyright \([0-9]\+\)-\([0-9]\+\),.*/\1-\2/
s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path`
if [ -z "$YEARS" ]; then
echo >&2 "$src_path:1: No copyright years found"
RV=1
continue
fi
HEADER_FIRST=`echo $YEARS | cut -d"-" -f1`
HEADER_LAST=` echo $YEARS | cut -d"-" -f2`
COMMIT_FIRST=`echo $FIRST | cut -d"-" -f1`
COMMIT_LAST=` echo $LAST | cut -d"-" -f1`
if [ "$COMMIT_FIRST" != "" -a "$COMMIT_LAST" != "" ]; then
if [ $HEADER_LAST -lt $COMMIT_LAST ]; then
if [ $HEADER_FIRST -lt $COMMIT_FIRST ]; then
COMMIT_FIRST=$HEADER_FIRST
fi
COMMIT_LAST=`date +%G`
if [ $COMMIT_FIRST -eq $COMMIT_LAST ]; then
NEW=$COMMIT_LAST
else
NEW=$COMMIT_FIRST-$COMMIT_LAST
fi
echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2
RV=1
fi
else
echo "$file:1: unknown commit dates" >&2
RV=1
fi
done
rm -f $TMP $TMP2 $TEMPFILE
$(dirname "$0")/check-ms-license.pl $FILES
# check if error found
if [ $RV -eq 0 ]; then
echo "Copyright headers are OK."
else
echo "Error(s) in copyright headers found!" >&2
fi
exit $RV
| 4,703 | 25.426966 | 87 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/build-local.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2020, Intel Corporation
#
# build-local.sh - runs a Docker container from a Docker image with environment
# prepared for building PMDK project and starts building PMDK
#
# this script is for building PMDK locally (not on Travis)
#
# Notes:
# - run this script from its location or set the variable 'HOST_WORKDIR' to
# where the root of the PMDK project is on the host machine,
# - set variables 'OS' and 'OS_VER' properly to a system you want to build PMDK
# on (for proper values take a look on the list of Dockerfiles at the
# utils/docker/images directory), eg. OS=ubuntu, OS_VER=16.04.
# - set 'KEEP_TEST_CONFIG' variable to 1 if you do not want the tests to be
# reconfigured (your current test configuration will be preserved and used)
# - tests with Device Dax are not supported by pcheck yet, so do not provide
# these devices in your configuration
#
set -e
# Environment variables that can be customized (default values are after dash):
export KEEP_CONTAINER=${KEEP_CONTAINER:-0}
export KEEP_TEST_CONFIG=${KEEP_TEST_CONFIG:-0}
export TEST_BUILD=${TEST_BUILD:-all}
export REMOTE_TESTS=${REMOTE_TESTS:-1}
export MAKE_PKG=${MAKE_PKG:-0}
export EXTRA_CFLAGS=${EXTRA_CFLAGS}
export EXTRA_CXXFLAGS=${EXTRA_CXXFLAGS:-}
export PMDK_CC=${PMDK_CC:-gcc}
export PMDK_CXX=${PMDK_CXX:-g++}
export EXPERIMENTAL=${EXPERIMENTAL:-n}
export VALGRIND=${VALGRIND:-1}
export DOCKERHUB_REPO=${DOCKERHUB_REPO:-pmem/pmdk}
export GITHUB_REPO=${GITHUB_REPO:-pmem/pmdk}
if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi
if [[ -z "$HOST_WORKDIR" ]]; then
HOST_WORKDIR=$(readlink -f ../..)
fi
if [[ "$KEEP_CONTAINER" != "1" ]]; then
RM_SETTING=" --rm"
fi
imageName=${DOCKERHUB_REPO}:1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}
containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 1 ]] ; then
command="./run-build-package.sh"
else
command="./run-build.sh"
fi
if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi
if [ -z "$NDCTL_ENABLE" ]; then ndctl_enable=; else ndctl_enable="--env NDCTL_ENABLE=$NDCTL_ENABLE"; fi
WORKDIR=/pmdk
SCRIPTSDIR=$WORKDIR/utils/docker
# Check if we are running on a CI (Travis or GitHub Actions)
[ -n "$GITHUB_ACTIONS" -o -n "$TRAVIS" ] && CI_RUN="YES" || CI_RUN="NO"
echo Building ${OS}-${OS_VER}
# Run a container with
# - environment variables set (--env)
# - host directory containing PMDK source mounted (-v)
# - a tmpfs /tmp with the necessary size and permissions (--tmpfs)*
# - working directory set (-w)
#
# * We need a tmpfs /tmp inside docker but we cannot run it with --privileged
# and do it from inside, so we do using this docker-run option.
# By default --tmpfs add nosuid,nodev,noexec to the mount flags, we don't
# want that and just to make sure we add the usually default rw,relatime just
# in case docker change the defaults.
docker run --name=$containerName -ti \
$RM_SETTING \
$DNS_SETTING \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env CC=$PMDK_CC \
--env CXX=$PMDK_CXX \
--env VALGRIND=$VALGRIND \
--env EXTRA_CFLAGS=$EXTRA_CFLAGS \
--env EXTRA_CXXFLAGS=$EXTRA_CXXFLAGS \
--env EXTRA_LDFLAGS=$EXTRA_LDFLAGS \
--env REMOTE_TESTS=$REMOTE_TESTS \
--env CONFIGURE_TESTS=$CONFIGURE_TESTS \
--env TEST_BUILD=$TEST_BUILD \
--env WORKDIR=$WORKDIR \
--env EXPERIMENTAL=$EXPERIMENTAL \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env KEEP_TEST_CONFIG=$KEEP_TEST_CONFIG \
--env CI_RUN=$CI_RUN \
--env BLACKLIST_FILE=$BLACKLIST_FILE \
$ndctl_enable \
--tmpfs /tmp:rw,relatime,suid,dev,exec,size=6G \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
$DAX_SETTING \
-w $SCRIPTSDIR \
$imageName $command
| 3,812 | 33.044643 | 103 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/run-build.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# run-build.sh - is called inside a Docker container; prepares the environment
# and starts a build of PMDK project.
#
set -e
# Prepare build environment
./prepare-for-build.sh
# Build all and run tests
cd $WORKDIR
if [ "$SRC_CHECKERS" != "0" ]; then
make -j$(nproc) check-license
make -j$(nproc) cstyle
fi
make -j$(nproc)
make -j$(nproc) test
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pcheck TEST_BUILD=$TEST_BUILD
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pycheck
make -j$(nproc) DESTDIR=/tmp source
# Create PR with generated docs
if [[ "$AUTO_DOC_UPDATE" == "1" ]]; then
echo "Running auto doc update"
./utils/docker/run-doc-update.sh
fi
| 848 | 23.257143 | 78 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/prepare-for-build.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# prepare-for-build.sh - is called inside a Docker container; prepares
# the environment inside a Docker container for
# running build of PMDK project.
#
set -e
# This should be run only on CIs
if [ "$CI_RUN" == "YES" ]; then
# Make sure $WORKDIR has correct access rights
# - set them to the current UID and GID
echo $USERPASS | sudo -S chown -R $(id -u).$(id -g) $WORKDIR
fi
# Configure tests (e.g. ssh for remote tests) unless the current configuration
# should be preserved
KEEP_TEST_CONFIG=${KEEP_TEST_CONFIG:-0}
if [[ "$KEEP_TEST_CONFIG" == 0 ]]; then
./configure-tests.sh
fi
| 739 | 27.461538 | 78 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/set-ci-vars.sh | #!/usr/bin/env bash
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2020, Intel Corporation
#
# set-ci-vars.sh -- set CI variables common for both:
# Travis and GitHub Actions CIs
#
set -e
function get_commit_range_from_last_merge {
# get commit id of the last merge
LAST_MERGE=$(git log --merges --pretty=%H -1)
LAST_COMMIT=$(git log --pretty=%H -1)
if [ "$LAST_MERGE" == "$LAST_COMMIT" ]; then
# GitHub Actions commits its own merge in case of pull requests
# so the first merge commit has to be skipped.
LAST_MERGE=$(git log --merges --pretty=%H -2 | tail -n1)
fi
if [ "$LAST_MERGE" == "" ]; then
# possible in case of shallow clones
# or new repos with no merge commits yet
# - pick up the first commit
LAST_MERGE=$(git log --pretty=%H | tail -n1)
fi
COMMIT_RANGE="$LAST_MERGE..HEAD"
# make sure it works now
if ! git rev-list $COMMIT_RANGE >/dev/null; then
COMMIT_RANGE=""
fi
echo $COMMIT_RANGE
}
COMMIT_RANGE_FROM_LAST_MERGE=$(get_commit_range_from_last_merge)
if [ -n "$TRAVIS" ]; then
CI_COMMIT=$TRAVIS_COMMIT
CI_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}"
CI_BRANCH=$TRAVIS_BRANCH
CI_EVENT_TYPE=$TRAVIS_EVENT_TYPE
CI_REPO_SLUG=$TRAVIS_REPO_SLUG
# CI_COMMIT_RANGE is usually invalid for force pushes - fix it when used
# with non-upstream repository
if [ -n "$CI_COMMIT_RANGE" -a "$CI_REPO_SLUG" != "$GITHUB_REPO" ]; then
if ! git rev-list $CI_COMMIT_RANGE; then
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
fi
fi
case "$TRAVIS_CPU_ARCH" in
"amd64")
CI_CPU_ARCH="x86_64"
;;
*)
CI_CPU_ARCH=$TRAVIS_CPU_ARCH
;;
esac
elif [ -n "$GITHUB_ACTIONS" ]; then
CI_COMMIT=$GITHUB_SHA
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
CI_BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3)
CI_REPO_SLUG=$GITHUB_REPOSITORY
CI_CPU_ARCH="x86_64" # GitHub Actions supports only x86_64
case "$GITHUB_EVENT_NAME" in
"schedule")
CI_EVENT_TYPE="cron"
;;
*)
CI_EVENT_TYPE=$GITHUB_EVENT_NAME
;;
esac
else
CI_COMMIT=$(git log --pretty=%H -1)
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
CI_CPU_ARCH="x86_64"
fi
export CI_COMMIT=$CI_COMMIT
export CI_COMMIT_RANGE=$CI_COMMIT_RANGE
export CI_BRANCH=$CI_BRANCH
export CI_EVENT_TYPE=$CI_EVENT_TYPE
export CI_REPO_SLUG=$CI_REPO_SLUG
export CI_CPU_ARCH=$CI_CPU_ARCH
echo CI_COMMIT=$CI_COMMIT
echo CI_COMMIT_RANGE=$CI_COMMIT_RANGE
echo CI_BRANCH=$CI_BRANCH
echo CI_EVENT_TYPE=$CI_EVENT_TYPE
echo CI_REPO_SLUG=$CI_REPO_SLUG
echo CI_CPU_ARCH=$CI_CPU_ARCH
| 2,481 | 24.587629 | 73 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/build-CI.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# build-CI.sh - runs a Docker container from a Docker image with environment
# prepared for building PMDK project and starts building PMDK
#
# this script is used for building PMDK on Travis and GitHub Actions CIs
#
set -e
source $(dirname $0)/set-ci-vars.sh
source $(dirname $0)/set-vars.sh
source $(dirname $0)/valid-branches.sh
if [[ "$CI_EVENT_TYPE" != "cron" && "$CI_BRANCH" != "coverity_scan" \
&& "$COVERITY" -eq 1 ]]; then
echo "INFO: Skip Coverity scan job if build is triggered neither by " \
"'cron' nor by a push to 'coverity_scan' branch"
exit 0
fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -ne 1 ]]; then
echo "INFO: Skip regular jobs if build is triggered either by 'cron'" \
" or by a push to 'coverity_scan' branch"
exit 0
fi
if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set properly " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi
if [[ -z "$HOST_WORKDIR" ]]; then
echo "ERROR: The variable HOST_WORKDIR has to contain a path to " \
"the root of the PMDK project on the host machine"
exit 1
fi
if [[ -z "$TEST_BUILD" ]]; then
TEST_BUILD=all
fi
imageName=${DOCKERHUB_REPO}:1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}
containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi
if [[ $MAKE_PKG -eq 1 ]] ; then command="./run-build-package.sh"; fi
if [[ $COVERAGE -eq 1 ]] ; then command="./run-coverage.sh"; ci_env=`bash <(curl -s https://codecov.io/env)`; fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -eq 1 ]]; then
command="./run-coverity.sh"
fi
if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi
if [[ -f $CI_FILE_SKIP_BUILD_PKG_CHECK ]]; then BUILD_PACKAGE_CHECK=n; else BUILD_PACKAGE_CHECK=y; fi
if [ -z "$NDCTL_ENABLE" ]; then ndctl_enable=; else ndctl_enable="--env NDCTL_ENABLE=$NDCTL_ENABLE"; fi
if [[ $UBSAN -eq 1 ]]; then for x in C CPP LD; do declare EXTRA_${x}FLAGS=-fsanitize=undefined; done; fi
# Only run doc update on $GITHUB_REPO master or stable branch
if [[ -z "${CI_BRANCH}" || -z "${TARGET_BRANCHES[${CI_BRANCH}]}" || "$CI_EVENT_TYPE" == "pull_request" || "$CI_REPO_SLUG" != "${GITHUB_REPO}" ]]; then
AUTO_DOC_UPDATE=0
fi
# Check if we are running on a CI (Travis or GitHub Actions)
[ -n "$GITHUB_ACTIONS" -o -n "$TRAVIS" ] && CI_RUN="YES" || CI_RUN="NO"
# We have a blacklist only for ppc64le arch
if [[ "$CI_CPU_ARCH" == ppc64le ]] ; then BLACKLIST_FILE=../../utils/docker/ppc64le.blacklist; fi
# docker on travis + ppc64le runs inside an LXD container and for security
# limits what can be done inside it, and as such, `docker run` fails with
# > the input device is not a TTY
# when using -t because of limited permissions to /dev imposed by LXD.
if [[ -n "$TRAVIS" && "$CI_CPU_ARCH" == ppc64le ]] || [[ -n "$GITHUB_ACTIONS" ]]; then
TTY=''
else
TTY='-t'
fi
WORKDIR=/pmdk
SCRIPTSDIR=$WORKDIR/utils/docker
# Run a container with
# - environment variables set (--env)
# - host directory containing PMDK source mounted (-v)
# - a tmpfs /tmp with the necessary size and permissions (--tmpfs)*
# - working directory set (-w)
#
# * We need a tmpfs /tmp inside docker but we cannot run it with --privileged
# and do it from inside, so we do using this docker-run option.
# By default --tmpfs add nosuid,nodev,noexec to the mount flags, we don't
# want that and just to make sure we add the usually default rw,relatime just
# in case docker change the defaults.
docker run --rm --name=$containerName -i $TTY \
$DNS_SETTING \
$ci_env \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env AUTO_DOC_UPDATE=$AUTO_DOC_UPDATE \
--env CC=$PMDK_CC \
--env CXX=$PMDK_CXX \
--env VALGRIND=$VALGRIND \
--env EXTRA_CFLAGS=$EXTRA_CFLAGS \
--env EXTRA_CXXFLAGS=$EXTRA_CXXFLAGS \
--env EXTRA_LDFLAGS=$EXTRA_LDFLAGS \
--env REMOTE_TESTS=$REMOTE_TESTS \
--env TEST_BUILD=$TEST_BUILD \
--env WORKDIR=$WORKDIR \
--env EXPERIMENTAL=$EXPERIMENTAL \
--env BUILD_PACKAGE_CHECK=$BUILD_PACKAGE_CHECK \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env TRAVIS=$TRAVIS \
--env CI_COMMIT_RANGE=$CI_COMMIT_RANGE \
--env CI_COMMIT=$CI_COMMIT \
--env CI_REPO_SLUG=$CI_REPO_SLUG \
--env CI_BRANCH=$CI_BRANCH \
--env CI_EVENT_TYPE=$CI_EVENT_TYPE \
--env DOC_UPDATE_GITHUB_TOKEN=$DOC_UPDATE_GITHUB_TOKEN \
--env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \
--env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--env FAULT_INJECTION=$FAULT_INJECTION \
--env GITHUB_ACTION=$GITHUB_ACTION \
--env GITHUB_HEAD_REF=$GITHUB_HEAD_REF \
--env GITHUB_REPO=$GITHUB_REPO \
--env GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
--env GITHUB_REF=$GITHUB_REF \
--env GITHUB_RUN_ID=$GITHUB_RUN_ID \
--env GITHUB_SHA=$GITHUB_SHA \
--env CI_RUN=$CI_RUN \
--env SRC_CHECKERS=$SRC_CHECKERS \
--env BLACKLIST_FILE=$BLACKLIST_FILE \
$ndctl_enable \
--tmpfs /tmp:rw,relatime,suid,dev,exec,size=6G \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
-w $SCRIPTSDIR \
$imageName $command
| 5,193 | 35.069444 | 150 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/run-build-package.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2019, Intel Corporation
#
# run-build-package.sh - is called inside a Docker container; prepares
# the environment and starts a build of PMDK project.
#
set -e
# Prepare build enviromnent
./prepare-for-build.sh
# Create fake tag, so that package has proper 'version' field
git config user.email "[email protected]"
git config user.name "test package"
git tag -a 1.4.99 -m "1.4" HEAD~1 || true
# Build all and run tests
cd $WORKDIR
export PCHECK_OPTS="-j2 BLACKLIST_FILE=${BLACKLIST_FILE}"
make -j$(nproc) $PACKAGE_MANAGER
# Install packages
if [[ "$PACKAGE_MANAGER" == "dpkg" ]]; then
cd $PACKAGE_MANAGER
echo $USERPASS | sudo -S dpkg --install *.deb
else
RPM_ARCH=$(uname -m)
cd $PACKAGE_MANAGER/$RPM_ARCH
echo $USERPASS | sudo -S rpm --install *.rpm
fi
# Compile and run standalone test
cd $WORKDIR/utils/docker/test_package
make -j$(nproc) LIBPMEMOBJ_MIN_VERSION=1.4
./test_package testfile1
# Use pmreorder installed in the system
pmreorder_version="$(pmreorder -v)"
pmreorder_pattern="pmreorder\.py .+$"
(echo "$pmreorder_version" | grep -Ev "$pmreorder_pattern") && echo "pmreorder version failed" && exit 1
touch testfile2
touch logfile1
pmreorder -p testfile2 -l logfile1
| 1,293 | 25.958333 | 104 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/run-doc-update.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2020, Intel Corporation
set -e
source `dirname $0`/valid-branches.sh
BOT_NAME="pmem-bot"
USER_NAME="pmem"
REPO_NAME="pmdk"
ORIGIN="https://${DOC_UPDATE_GITHUB_TOKEN}@github.com/${BOT_NAME}/${REPO_NAME}"
UPSTREAM="https://github.com/${USER_NAME}/${REPO_NAME}"
# master or stable-* branch
TARGET_BRANCH=${CI_BRANCH}
VERSION=${TARGET_BRANCHES[$TARGET_BRANCH]}
if [ -z $VERSION ]; then
echo "Target location for branch $TARGET_BRANCH is not defined."
exit 1
fi
# Clone bot repo
git clone ${ORIGIN}
cd ${REPO_NAME}
git remote add upstream ${UPSTREAM}
git config --local user.name ${BOT_NAME}
git config --local user.email "[email protected]"
git remote update
git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH}
# Copy man & PR web md
cd ./doc
make -j$(nproc) web
cd ..
mv ./doc/web_linux ../
mv ./doc/web_windows ../
mv ./doc/generated/libs_map.yml ../
# Checkout gh-pages and copy docs
GH_PAGES_NAME="gh-pages-for-${TARGET_BRANCH}"
git checkout -B $GH_PAGES_NAME upstream/gh-pages
git clean -dfx
rsync -a ../web_linux/ ./manpages/linux/${VERSION}/
rsync -a ../web_windows/ ./manpages/windows/${VERSION}/ \
--exclude='librpmem' \
--exclude='rpmemd' --exclude='pmreorder' \
--exclude='daxio'
rm -r ../web_linux
rm -r ../web_windows
if [ $TARGET_BRANCH = "master" ]; then
[ ! -d _data ] && mkdir _data
cp ../libs_map.yml _data
fi
# Add and push changes.
# git commit command may fail if there is nothing to commit.
# In that case we want to force push anyway (there might be open pull request
# with changes which were reverted).
git add -A
git commit -m "doc: automatic gh-pages docs update" && true
git push -f ${ORIGIN} $GH_PAGES_NAME
GITHUB_TOKEN=${DOC_UPDATE_GITHUB_TOKEN} hub pull-request -f \
-b ${USER_NAME}:gh-pages \
-h ${BOT_NAME}:${GH_PAGES_NAME} \
-m "doc: automatic gh-pages docs update" && true
exit 0
| 1,924 | 24 | 79 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/pull-or-rebuild-image.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# pull-or-rebuild-image.sh - rebuilds the Docker image used in the
# current Travis build if necessary.
#
# The script rebuilds the Docker image if the Dockerfile for the current
# OS version (Dockerfile.${OS}-${OS_VER}) or any .sh script from the directory
# with Dockerfiles were modified and committed.
#
# If the Travis build is not of the "pull_request" type (i.e. in case of
# merge after pull_request) and it succeed, the Docker image should be pushed
# to the Docker Hub repository. An empty file is created to signal that to
# further scripts.
#
# If the Docker image does not have to be rebuilt, it will be pulled from
# Docker Hub.
#
set -e
source $(dirname $0)/set-ci-vars.sh
source $(dirname $0)/set-vars.sh
if [[ "$CI_EVENT_TYPE" != "cron" && "$CI_BRANCH" != "coverity_scan" \
&& "$COVERITY" -eq 1 ]]; then
echo "INFO: Skip Coverity scan job if build is triggered neither by " \
"'cron' nor by a push to 'coverity_scan' branch"
exit 0
fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -ne 1 ]]; then
echo "INFO: Skip regular jobs if build is triggered either by 'cron'" \
" or by a push to 'coverity_scan' branch"
exit 0
fi
if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set properly " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi
if [[ -z "$HOST_WORKDIR" ]]; then
echo "ERROR: The variable HOST_WORKDIR has to contain a path to " \
"the root of the PMDK project on the host machine"
exit 1
fi
# Find all the commits for the current build
if [ -n "$CI_COMMIT_RANGE" ]; then
commits=$(git rev-list $CI_COMMIT_RANGE)
else
commits=$CI_COMMIT
fi
echo "Commits in the commit range:"
for commit in $commits; do echo $commit; done
# Get the list of files modified by the commits
files=$(for commit in $commits; do git diff-tree --no-commit-id --name-only \
-r $commit; done | sort -u)
echo "Files modified within the commit range:"
for file in $files; do echo $file; done
# Path to directory with Dockerfiles and image building scripts
images_dir_name=images
base_dir=utils/docker/$images_dir_name
# Check if committed file modifications require the Docker image to be rebuilt
for file in $files; do
# Check if modified files are relevant to the current build
if [[ $file =~ ^($base_dir)\/Dockerfile\.($OS)-($OS_VER)$ ]] \
|| [[ $file =~ ^($base_dir)\/.*\.sh$ ]]
then
# Rebuild Docker image for the current OS version
echo "Rebuilding the Docker image for the Dockerfile.$OS-$OS_VER"
pushd $images_dir_name
./build-image.sh ${OS}-${OS_VER} ${CI_CPU_ARCH}
popd
# Check if the image has to be pushed to Docker Hub
# (i.e. the build is triggered by commits to the $GITHUB_REPO
# repository's stable-* or master branch, and the Travis build is not
# of the "pull_request" type). In that case, create the empty
# file.
if [[ "$CI_REPO_SLUG" == "$GITHUB_REPO" \
&& ($CI_BRANCH == stable-* || $CI_BRANCH == devel-* || $CI_BRANCH == master) \
&& $CI_EVENT_TYPE != "pull_request" \
&& $PUSH_IMAGE == "1" ]]
then
echo "The image will be pushed to Docker Hub"
touch $CI_FILE_PUSH_IMAGE_TO_REPO
else
echo "Skip pushing the image to Docker Hub"
fi
if [[ $PUSH_IMAGE == "1" ]]
then
echo "Skip build package check if image has to be pushed"
touch $CI_FILE_SKIP_BUILD_PKG_CHECK
fi
exit 0
fi
done
# Getting here means rebuilding the Docker image is not required.
# Pull the image from Docker Hub.
docker pull ${DOCKERHUB_REPO}:1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}
| 3,681 | 31.584071 | 81 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/valid-branches.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2020, Intel Corporation
declare -A TARGET_BRANCHES=( \
["master"]="master" \
["stable-1.5"]="v1.5" \
["stable-1.6"]="v1.6" \
["stable-1.7"]="v1.7" \
["stable-1.8"]="v1.8" \
["stable-1.9"]="v1.9" \
)
| 291 | 21.461538 | 40 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/configure-tests.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# configure-tests.sh - is called inside a Docker container; configures tests
# and ssh server for use during build of PMDK project.
#
set -e
# Configure tests
cat << EOF > $WORKDIR/src/test/testconfig.sh
LONGDIR=LoremipsumdolorsitametconsecteturadipiscingelitVivamuslacinianibhattortordictumsollicitudinNullamvariusvestibulumligulaetegestaselitsemperidMaurisultriciesligulaeuipsumtinciduntluctusMorbimaximusvariusdolorid
# this path is ~3000 characters long
DIRSUFFIX="$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR"
NON_PMEM_FS_DIR=/tmp
PMEM_FS_DIR=/tmp
PMEM_FS_DIR_FORCE_PMEM=1
TEST_BUILD="debug nondebug"
ENABLE_SUDO_TESTS=y
TM=1
EOF
# Configure remote tests
if [[ $REMOTE_TESTS -eq 1 ]]; then
echo "Configuring remote tests"
cat << EOF >> $WORKDIR/src/test/testconfig.sh
NODE[0]=127.0.0.1
NODE_WORKING_DIR[0]=/tmp/node0
NODE_ADDR[0]=127.0.0.1
NODE_ENV[0]="PMEM_IS_PMEM_FORCE=1"
NODE[1]=127.0.0.1
NODE_WORKING_DIR[1]=/tmp/node1
NODE_ADDR[1]=127.0.0.1
NODE_ENV[1]="PMEM_IS_PMEM_FORCE=1"
NODE[2]=127.0.0.1
NODE_WORKING_DIR[2]=/tmp/node2
NODE_ADDR[2]=127.0.0.1
NODE_ENV[2]="PMEM_IS_PMEM_FORCE=1"
NODE[3]=127.0.0.1
NODE_WORKING_DIR[3]=/tmp/node3
NODE_ADDR[3]=127.0.0.1
NODE_ENV[3]="PMEM_IS_PMEM_FORCE=1"
TEST_BUILD="debug nondebug"
TEST_PROVIDERS=sockets
EOF
mkdir -p ~/.ssh/cm
cat << EOF >> ~/.ssh/config
Host 127.0.0.1
StrictHostKeyChecking no
ControlPath ~/.ssh/cm/%r@%h:%p
ControlMaster auto
ControlPersist 10m
EOF
if [ ! -f /etc/ssh/ssh_host_rsa_key ]
then
(echo $USERPASS | sudo -S ssh-keygen -t rsa -C $USER@$HOSTNAME -P '' -f /etc/ssh/ssh_host_rsa_key)
fi
echo $USERPASS | sudo -S sh -c 'cat /etc/ssh/ssh_host_rsa_key.pub >> /etc/ssh/authorized_keys'
ssh-keygen -t rsa -C $USER@$HOSTNAME -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod -R 700 ~/.ssh
chmod 640 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/config
# Start ssh service
echo $USERPASS | sudo -S $START_SSH_COMMAND
ssh 127.0.0.1 exit 0
else
echo "Skipping remote tests"
echo
echo "Removing all libfabric.pc files in order to simulate that libfabric is not installed:"
find /usr -name "libfabric.pc" 2>/dev/null || true
echo $USERPASS | sudo -S sh -c 'find /usr -name "libfabric.pc" -exec rm -f {} + 2>/dev/null'
fi
# Configure python tests
cat << EOF >> $WORKDIR/src/test/testconfig.py
config = {
'unittest_log_level': 1,
'cacheline_fs_dir': '/tmp',
'force_cacheline': True,
'page_fs_dir': '/tmp',
'force_page': False,
'byte_fs_dir': '/tmp',
'force_byte': True,
'tm': True,
'test_type': 'check',
'granularity': 'all',
'fs_dir_force_pmem': 0,
'keep_going': False,
'timeout': '3m',
'build': ['debug', 'release'],
'force_enable': None,
'device_dax_path': [],
'fail_on_skip': False,
'enable_admin_tests': True
}
EOF
| 2,886 | 26.235849 | 216 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/set-vars.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019, Intel Corporation
#
# set-vars.sh - set required environment variables
#
set -e
export CI_FILE_PUSH_IMAGE_TO_REPO=/tmp/push_image_to_repo_flag
export CI_FILE_SKIP_BUILD_PKG_CHECK=/tmp/skip_build_package_check
| 290 | 21.384615 | 65 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/run-coverity.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2020, Intel Corporation
#
# run-coverity.sh - runs the Coverity scan build
#
set -e
if [[ "$CI_REPO_SLUG" != "$GITHUB_REPO" \
&& ( "$COVERITY_SCAN_NOTIFICATION_EMAIL" == "" \
|| "$COVERITY_SCAN_TOKEN" == "" ) ]]; then
echo
echo "Skipping Coverity build:"\
"COVERITY_SCAN_TOKEN=\"$COVERITY_SCAN_TOKEN\" or"\
"COVERITY_SCAN_NOTIFICATION_EMAIL="\
"\"$COVERITY_SCAN_NOTIFICATION_EMAIL\" is not set"
exit 0
fi
# Prepare build environment
./prepare-for-build.sh
CERT_FILE=/etc/ssl/certs/ca-certificates.crt
TEMP_CF=$(mktemp)
cp $CERT_FILE $TEMP_CF
# Download Coverity certificate
echo -n | openssl s_client -connect scan.coverity.com:443 | \
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | \
tee -a $TEMP_CF
echo $USERPASS | sudo -S mv $TEMP_CF $CERT_FILE
export COVERITY_SCAN_PROJECT_NAME="$CI_REPO_SLUG"
[[ "$CI_EVENT_TYPE" == "cron" ]] \
&& export COVERITY_SCAN_BRANCH_PATTERN="master" \
|| export COVERITY_SCAN_BRANCH_PATTERN="coverity_scan"
export COVERITY_SCAN_BUILD_COMMAND="make -j$(nproc) all"
cd $WORKDIR
#
# Run the Coverity scan
#
# The 'travisci_build_coverity_scan.sh' script requires the following
# environment variables to be set:
# - TRAVIS_BRANCH - has to contain the name of the current branch
# - TRAVIS_PULL_REQUEST - has to be set to 'true' in case of pull requests
#
export TRAVIS_BRANCH=${CI_BRANCH}
[ "${CI_EVENT_TYPE}" == "pull_request" ] && export TRAVIS_PULL_REQUEST="true"
# XXX: Patch the Coverity script.
# Recently, this script regularly exits with an error, even though
# the build is successfully submitted. Probably because the status code
# is missing in response, or it's not 201.
# Changes:
# 1) change the expected status code to 200 and
# 2) print the full response string.
#
# This change should be reverted when the Coverity script is fixed.
#
# The previous version was:
# curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | bash
wget https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh
patch < utils/docker/0001-travis-fix-travisci_build_coverity_scan.sh.patch
bash ./travisci_build_coverity_scan.sh
| 2,196 | 29.513889 | 82 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/run-coverage.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# run-coverage.sh - is called inside a Docker container; runs the coverage
# test
#
set -e
# Get and prepare PMDK source
./prepare-for-build.sh
# Hush error messages, mainly from Valgrind
export UT_DUMP_LINES=0
# Skip printing mismatched files for tests with Valgrind
export UT_VALGRIND_SKIP_PRINT_MISMATCHED=1
# Build all and run tests
cd $WORKDIR
make -j$(nproc) COVERAGE=1
make -j$(nproc) test COVERAGE=1
# XXX: unfortunately valgrind raports issues in coverage instrumentation
# which we have to ignore (-k flag), also there is dependency between
# local and remote tests (which cannot be easily removed) we have to
# run local and remote tests separately
cd src/test
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -kj2 pcheck-local-quiet TEST_BUILD=debug || true
make check-remote-quiet TEST_BUILD=debug || true
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pycheck TEST_BUILD=debug || true
cd ../..
bash <(curl -s https://codecov.io/bash)
| 1,138 | 28.973684 | 74 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/images/install-valgrind.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# install-valgrind.sh - installs valgrind for persistent memory
#
set -e
OS=$1
install_upstream_from_distro() {
case "$OS" in
fedora) dnf install -y valgrind ;;
ubuntu) apt-get install -y --no-install-recommends valgrind ;;
*) return 1 ;;
esac
}
install_upstream_3_16_1() {
git clone git://sourceware.org/git/valgrind.git
cd valgrind
# valgrind v3.16.1 upstream
git checkout VALGRIND_3_16_BRANCH
./autogen.sh
./configure
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -rf valgrind
}
install_custom-pmem_from_source() {
git clone https://github.com/pmem/valgrind.git
cd valgrind
# valgrind v3.15 with pmemcheck
# 2020.04.01 Merge pull request #78 from marcinslusarz/opt3
git checkout 759686fd66cc0105df8311cfe676b0b2f9e89196
./autogen.sh
./configure
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -rf valgrind
}
ARCH=$(uname -m)
case "$ARCH" in
ppc64le) install_upstream_3_16_1 ;;
*) install_custom-pmem_from_source ;;
esac
| 1,099 | 19.754717 | 66 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/images/build-image.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# build-image.sh <OS-VER> <ARCH> - prepares a Docker image with <OS>-based
# environment intended for the <ARCH> CPU architecture
# designed for building PMDK project, according to
# the Dockerfile.<OS-VER> file located in the same directory.
#
# The script can be run locally.
#
set -e
OS_VER=$1
CPU_ARCH=$2
function usage {
echo "Usage:"
echo " build-image.sh <OS-VER> <ARCH>"
echo "where:"
echo " <OS-VER> - can be for example 'ubuntu-19.10' provided "\
"a Dockerfile named 'Dockerfile.ubuntu-19.10' "\
"exists in the current directory and"
echo " <ARCH> - is a CPU architecture, for example 'x86_64'"
}
# Check if two first arguments are not empty
if [[ -z "$2" ]]; then
usage
exit 1
fi
# Check if the file Dockerfile.OS-VER exists
if [[ ! -f "Dockerfile.$OS_VER" ]]; then
echo "Error: Dockerfile.$OS_VER does not exist."
echo
usage
exit 1
fi
if [[ -z "${DOCKERHUB_REPO}" ]]; then
echo "Error: DOCKERHUB_REPO environment variable is not set"
exit 1
fi
# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER-ARCH
tag=${DOCKERHUB_REPO}:1.9-${OS_VER}-${CPU_ARCH}
docker build -t $tag \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
-f Dockerfile.$OS_VER .
| 1,373 | 24.444444 | 76 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/images/install-libfabric.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# install-libfabric.sh - installs a customized version of libfabric
#
set -e
OS=$1
# Keep in sync with requirements in src/common.inc.
libfabric_ver=1.4.2
libfabric_url=https://github.com/ofiwg/libfabric/archive
libfabric_dir=libfabric-$libfabric_ver
libfabric_tarball=v${libfabric_ver}.zip
wget "${libfabric_url}/${libfabric_tarball}"
unzip $libfabric_tarball
cd $libfabric_dir
# XXX HACK HACK HACK
# Disable use of spin locks in libfabric.
#
# spinlocks do not play well (IOW at all) with cpu-constrained environments,
# like GitHub Actions, and this leads to timeouts of some PMDK's tests.
# This change speeds up pmempool_sync_remote/TEST28-31 by a factor of 20-30.
#
perl -pi -e 's/have_spinlock=1/have_spinlock=0/' configure.ac
# XXX HACK HACK HACK
./autogen.sh
./configure --prefix=/usr --enable-sockets
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -f ${libfabric_tarball}
rm -rf ${libfabric_dir}
| 1,019 | 23.878049 | 76 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/images/install-libndctl.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# install-libndctl.sh - installs libndctl
#
set -e
OS=$2
echo "==== clone ndctl repo ===="
git clone https://github.com/pmem/ndctl.git
cd ndctl
git checkout $1
if [ "$OS" = "fedora" ]; then
echo "==== setup rpmbuild tree ===="
rpmdev-setuptree
RPMDIR=$HOME/rpmbuild/
VERSION=$(./git-version)
SPEC=./rhel/ndctl.spec
echo "==== create source tarball ====="
git archive --format=tar --prefix="ndctl-${VERSION}/" HEAD | gzip > "$RPMDIR/SOURCES/ndctl-${VERSION}.tar.gz"
echo "==== build ndctl ===="
./autogen.sh
./configure --disable-docs
make -j$(nproc)
echo "==== build ndctl packages ===="
rpmbuild -ba $SPEC
echo "==== install ndctl packages ===="
RPM_ARCH=$(uname -m)
rpm -i $RPMDIR/RPMS/$RPM_ARCH/*.rpm
echo "==== cleanup ===="
rm -rf $RPMDIR
else
echo "==== build ndctl ===="
./autogen.sh
./configure --disable-docs
make -j$(nproc)
echo "==== install ndctl ===="
make -j$(nproc) install
echo "==== cleanup ===="
fi
cd ..
rm -rf ndctl
| 1,057 | 16.344262 | 109 | sh |
null | NearPMSW-main/nearpm/shadow/pmdk-sd/utils/docker/images/push-image.sh | #!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# push-image.sh - pushes the Docker image to the Docker Hub.
#
# The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables
# to log in to Docker Hub. The variables can be set in the Travis project's
# configuration for automated builds.
#
set -e
source $(dirname $0)/../set-ci-vars.sh
if [[ -z "$OS" ]]; then
echo "OS environment variable is not set"
exit 1
fi
if [[ -z "$OS_VER" ]]; then
echo "OS_VER environment variable is not set"
exit 1
fi
if [[ -z "$CI_CPU_ARCH" ]]; then
echo "CI_CPU_ARCH environment variable is not set"
exit 1
fi
if [[ -z "${DOCKERHUB_REPO}" ]]; then
echo "DOCKERHUB_REPO environment variable is not set"
exit 1
fi
TAG="1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}"
# Check if the image tagged with pmdk/OS-VER exists locally
if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:${TAG}\$" \
'$1":"$2 ~ pattern') ]]
then
echo "ERROR: Docker image tagged ${DOCKERHUB_REPO}:${TAG} does not exists locally."
exit 1
fi
# Log in to the Docker Hub
docker login -u="$DOCKERHUB_USER" -p="$DOCKERHUB_PASSWORD"
# Push the image to the repository
docker push ${DOCKERHUB_REPO}:${TAG}
| 1,236 | 22.788462 | 84 | sh |
null | NearPMSW-main/nearpm/shadow/include/txopt.cc | #include "txopt.h"
#include <string.h>
// source: http://stackoverflow.com/questions/1919183/how-to-allocate-and-free-aligned-memory-in-c
void *
aligned_malloc(int size) {
void *mem = malloc(size+64+sizeof(void*));
void **ptr = (void**)((uintptr_t)((uint64_t)mem+64+uint64_t(sizeof(void*))) & ~(64-1));
ptr[-1] = mem;
return ptr;
}
// source: http://stackoverflow.com/questions/1640258/need-a-fast-random-generator-for-c
static unsigned long x=123456789, y=362436069, z=521288629;
unsigned long xorshf96() { //period 2^96-1
unsigned long t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
//volatile void s_fence();
// Flush the selected addresses
//volatile void metadata_cache_flush(uint64_t addr, unsigned size);
//volatile void cache_flush(uint64_t addr, unsigned size);
//volatile void flush_caches(uint64_t addr, unsigned size);
// Flush the one cacheline
//volatile inline void metadata_flush(uint64_t addr);
//volatile inline void cache_flush(uint64_t addr);
// Flush the whole caches
//volatile inline void metadata_flush();
//volatile inline void cache_flush();
//volatile void TX_OPT(uint64_t addr, unsigned size);
// Deduplication and Compression are transaparent
/*
class Dedup {
public:
};
class Compress {
public:
}
*/
uint64_t CounterAtomic::currAtomicAddr = COUNTER_ATOMIC_VADDR;
//uint64_t CounterAtomic::currCacheFlushAddr = CACHE_FLUSH_VADDR;
//uint64_t CounterAtomic::currCounterCacheFlushAddr = COUNTER_CACHE_FLUSH_VADDR;
void*
CounterAtomic::counter_atomic_malloc(unsigned _size) {
return (void*)getNextAtomicAddr(_size);
}
volatile void
metadata_cache_flush(void* addr, unsigned size) {
int num_cache_line = size / CACHE_LINE_SIZE;
if ((uint64_t)addr % CACHE_LINE_SIZE)
num_cache_line++;
for (int i = 0; i < num_cache_line; ++i)
*((volatile uint64_t*)METADATA_CACHE_FLUSH_VADDR) = (uint64_t)addr + i * CACHE_LINE_SIZE;
}
volatile void
cache_flush(void* addr, unsigned size) {
int num_cache_line = size / CACHE_LINE_SIZE;
if ((uint64_t)addr % CACHE_LINE_SIZE)
num_cache_line++;
for (int i = 0; i < num_cache_line; ++i)
*((volatile uint64_t*)CACHE_FLUSH_VADDR) = (uint64_t)addr + i * CACHE_LINE_SIZE;
}
volatile void
flush_caches(void* addr, unsigned size) {
cache_flush(addr, size);
metadata_cache_flush(addr, size);
}
// OPT with both data and addr ready
volatile void
OPT(void* opt_obj, bool reg, void* pmemaddr, void* data, unsigned size) {
// fprintf(stderr, "size: %u\n", size);
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
//opt_packet.seg_id = i;
//opt_packet.pmemaddr = (void*)((uint64_t)(pmemaddr) + i * CACHE_LINE_SIZE);
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = (void*)((uint64_t)(data) + i * CACHE_LINE_SIZE);
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT : FLAG_OPT_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
//*((opt_packet_t*)TXOPT_VADDR) = (opt_packet_t){opt_obj, pmemaddr, size, FLAG_OPT_DATA};
}
// OPT with both data (int) and addr ready
volatile void
OPT_VAL(void* opt_obj, bool reg, void* pmemaddr, int data_val) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = data_val;
opt_packet.size = sizeof(int);
opt_packet.type = (!reg ? FLAG_OPT_VAL : FLAG_OPT_VAL_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only data ready
volatile void
OPT_DATA(void* opt_obj, bool reg, void* data, unsigned size) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = 0;
//opt_packet.data_ptr = (void*)((uint64_t)(data) + i * CACHE_LINE_SIZE);
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT_DATA : FLAG_OPT_DATA_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only addr ready
volatile void
OPT_ADDR(void* opt_obj, bool reg, void* pmemaddr, unsigned size) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT_ADDR : FLAG_OPT_ADDR_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only data (int) ready
volatile void
OPT_DATA_VAL(void* opt_obj, bool reg, int data_val) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = 0;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = data_val;
opt_packet.size = sizeof(int);
opt_packet.type = (!reg ? FLAG_OPT_DATA_VAL : FLAG_OPT_DATA_VAL_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
volatile void
OPT_START(void* opt_obj) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.type = FLAG_OPT_START;
}
volatile void
s_fence() {
std::atomic_thread_fence(std::memory_order_acq_rel);
}
CounterAtomic::CounterAtomic() {
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
}
CounterAtomic::CounterAtomic(uint64_t _val) {
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
*((volatile uint64_t*)val_addr) = _val;
}
CounterAtomic::CounterAtomic(bool _val) {
*((volatile uint64_t*)val_addr) = uint64_t(_val);
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
}
uint64_t
CounterAtomic::getValue() {
return *((volatile uint64_t*)val_addr);
}
uint64_t
CounterAtomic::getPtr() {
return val_addr;
}
CounterAtomic&
CounterAtomic::operator=(uint64_t _val) {
*((volatile uint64_t*)val_addr) = _val;
return *this;
}
CounterAtomic&
CounterAtomic::operator+(uint64_t _val) {
*((volatile uint64_t*)val_addr) += _val;
return *this;
}
CounterAtomic&
CounterAtomic::operator++() {
uint64_t val = *((volatile uint64_t*)val_addr);
val++;
*((volatile uint64_t*)val_addr) = val;
return *this;
}
CounterAtomic&
CounterAtomic::operator--() {
uint64_t val = *((volatile uint64_t*)val_addr);
val--;
*((volatile uint64_t*)val_addr) = val;
return *this;
}
CounterAtomic&
CounterAtomic::operator-(uint64_t _val) {
*((volatile uint64_t*)val_addr) -= _val;
return *this;
}
bool
CounterAtomic::operator==(uint64_t _val) {
return *((volatile uint64_t*)val_addr) == _val;
}
bool
CounterAtomic::operator!=(uint64_t _val) {
return *((volatile uint64_t*)val_addr) != _val;
}
uint64_t
CounterAtomic::getNextAtomicAddr(unsigned _size) {
if (currAtomicAddr + _size >= COUNTER_ATOMIC_VADDR + NUM_COUNTER_ATOMIC_PAGE*4*1024) {
printf("@@not enough counter atomic space, current addr=%lu, size=%u\n", currAtomicAddr, _size);
exit(0);
}
currAtomicAddr += _size;
return (currAtomicAddr - _size);
}
volatile void
CounterAtomic::statOutput() {
*((volatile uint64_t*) (STATUS_OUTPUT_VADDR))= 0;
}
volatile void
CounterAtomic::initCounterCache() {
*((volatile uint64_t*) (INIT_METADATA_CACHE_VADDR))= 0;
}
| 6,969 | 24.345455 | 98 | cc |
null | NearPMSW-main/nearpm/shadow/include/txopt.h | // The starting address of the selected counter_atomic writes
#ifndef TXOPT_H
#define TXOPT_H
#define COUNTER_ATOMIC_VADDR (4096UL*1024*1024)
#define NUM_COUNTER_ATOMIC_PAGE 262144
// The starting address of the flush cache instruction
#define CACHE_FLUSH_VADDR (4096UL*1024*1024+4*NUM_COUNTER_ATOMIC_PAGE*1024)
// The starting address of the flush metadata cache instruction
#define METADATA_CACHE_FLUSH_VADDR (4096UL*1024*1024+(4*NUM_COUNTER_ATOMIC_PAGE+4)*1024)
#define STATUS_OUTPUT_VADDR (METADATA_CACHE_FLUSH_VADDR + 1024UL)
#define INIT_METADATA_CACHE_VADDR (STATUS_OUTPUT_VADDR + 1024UL)
#define TXOPT_VADDR (INIT_METADATA_CACHE_VADDR+1024UL)
#define CACHE_LINE_SIZE 64UL
#include <vector>
#include <deque>
#include <cstdlib>
#include <cstdint>
#include <atomic>
#include <stdio.h>
#include <cassert>
enum opt_flag {
FLAG_OPT,
FLAG_OPT_VAL,
FLAG_OPT_ADDR,
FLAG_OPT_DATA,
FLAG_OPT_DATA_VAL,
/* register no execute */
FLAG_OPT_REG,
FLAG_OPT_VAL_REG,
FLAG_OPT_ADDR_REG,
FLAG_OPT_DATA_REG,
FLAG_OPT_DATA_VAL_REG,
/* execute registered OPT */
FLAG_OPT_START
};
struct opt_t {
//int pid;
int obj_id;
};
// Fields in the OPT packet
// Used by both SW and HW
struct opt_packet_t {
void* opt_obj;
void* pmemaddr;
//void* data_ptr;
//int seg_id;
//int data_val;
unsigned size;
opt_flag type;
};
// OPT with both data and addr ready
volatile void OPT(void* opt_obj, bool reg, void* pmemaddr, void* data, unsigned size);
//#define OPT(opt_obj, pmemaddr, data, size) \
// *((opt_packet_t*)TXOPT_VADDR) = (opt_packet_t){opt_obj, pmemaddr, size, FLAG_OPT_DATA};
// OPT with both data (int) and addr ready
volatile void OPT_VAL(void* opt_obj, bool reg, void* pmemaddr, int data_val);
// OPT with only data ready
volatile void OPT_DATA(void* opt_obj, bool reg, void* data, unsigned size);
// OPT with only addr ready
volatile void OPT_ADDR(void* opt_obj, bool reg, void* pmemaddr, unsigned size);
// OPT with only data (int) ready
volatile void OPT_DATA_VAL(void* opt_obj, bool reg, int data_val);
// Begin OPT operation
volatile void OPT_START(void* opt_obj);
// store barrier
volatile void s_fence();
// flush both metadata cache and data cache
volatile void flush_caches(void* addr, unsigned size);
// flush data cache only
volatile void cache_flush(void* addr, unsigned size);
// flush metadata cache only
volatile void metadata_cache_flush(void* addr, unsigned size);
// malloc that is cache-line aligned
void *aligned_malloc(int size);
class CounterAtomic {
public:
static void* counter_atomic_malloc(unsigned _size);
// size is num of bytes
static volatile void statOutput();
static volatile void initCounterCache();
uint64_t getValue();
uint64_t getPtr();
CounterAtomic();
CounterAtomic(uint64_t _val);
CounterAtomic(bool _val);
CounterAtomic& operator=(uint64_t _val);
CounterAtomic& operator+(uint64_t _val);
CounterAtomic& operator++();
CounterAtomic& operator--();
CounterAtomic& operator-(uint64_t _val);
bool operator==(uint64_t _val);
bool operator!=(uint64_t _val);
private:
void init();
static uint64_t getNextAtomicAddr(unsigned _size);
static uint64_t getNextCacheFlushAddr(unsigned _size);
//static uint64_t getNextPersistBarrierAddr(unsigned _size);
static uint64_t getNextCounterCacheFlushAddr(unsigned _size);
static uint64_t currAtomicAddr;
static uint64_t currCacheFlushAddr;
//static uint64_t currPersistentBarrierAddr;
static uint64_t currCounterCacheFlushAddr;
/*
static bool hasAllocateCacheFlush;
static bool hasAllocateCounterCacheFlush;
static bool hasAllocatePersistBarrier;
*/
//uint64_t val;
uint64_t val_addr = 0;
};
#endif
| 3,665 | 26.155556 | 90 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/crc32c.h | #ifndef CRC32C_H
#define CRC32C_H
typedef uint32_t (*crc_func)(uint32_t crc, const void *buf, size_t len);
crc_func crc32c;
void crc32c_init(void);
#endif /* CRC32C_H */
| 179 | 17 | 72 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/slabs.h | /*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/* slabs memory allocation */
#ifndef SLABS_H
#define SLABS_H
/** Init the subsystem. 1st argument is the limit on no. of bytes to allocate,
0 if no limit. 2nd argument is the growth factor; each slab will use a chunk
size equal to the previous slab's chunk size times this factor.
3rd argument specifies if the slab allocator should allocate all memory
up front (if true), or allocate memory in chunks as it is needed (if false)
*/
void slabs_init(const size_t limit, const double factor, const bool prealloc, const uint32_t *slab_sizes);
/** Call only during init. Pre-allocates all available memory */
void slabs_prefill_global(void);
#ifdef PSLAB
int slabs_dump_sizes(uint32_t *slab_sizes, int max);
void slabs_prefill_global_from_pmem(void);
void slabs_update_policy(void);
int do_slabs_renewslab(const unsigned int id, char *ptr);
void do_slab_realloc(item *it, unsigned int id);
void do_slabs_free(void *ptr, const size_t size, unsigned int id);
#endif
/**
* Given object size, return id to use when allocating/freeing memory for object
* 0 means error: can't store such a large object
*/
unsigned int slabs_clsid(const size_t size);
/** Allocate object of given length. 0 on error */ /*@null@*/
#define SLABS_ALLOC_NO_NEWPAGE 1
void *slabs_alloc(const size_t size, unsigned int id, uint64_t *total_bytes, unsigned int flags);
/** Free previously allocated object */
void slabs_free(void *ptr, size_t size, unsigned int id);
/** Adjust the stats for memory requested */
void slabs_adjust_mem_requested(unsigned int id, size_t old, size_t ntotal);
/** Adjust global memory limit up or down */
bool slabs_adjust_mem_limit(size_t new_mem_limit);
/** Return a datum for stats in binary protocol */
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
typedef struct {
unsigned int chunks_per_page;
unsigned int chunk_size;
long int free_chunks;
long int total_pages;
} slab_stats_automove;
void fill_slab_stats_automove(slab_stats_automove *am);
unsigned int global_page_pool_size(bool *mem_flag);
/** Fill buffer with stats */ /*@null@*/
void slabs_stats(ADD_STAT add_stats, void *c);
/* Hints as to freespace in slab class */
unsigned int slabs_available_chunks(unsigned int id, bool *mem_flag, uint64_t *total_bytes, unsigned int *chunks_perslab);
void slabs_mlock(void);
void slabs_munlock(void);
int start_slab_maintenance_thread(void);
void stop_slab_maintenance_thread(void);
enum reassign_result_type {
REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE,
REASSIGN_SRC_DST_SAME
};
enum reassign_result_type slabs_reassign(int src, int dst);
void slabs_rebalancer_pause(void);
void slabs_rebalancer_resume(void);
#ifdef EXTSTORE
void slabs_set_storage(void *arg);
#endif
#endif
| 3,024 | 31.180851 | 122 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/pslab.h | /*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
#ifndef PSLAB_H
#define PSLAB_H
#include <libpmem.h>
#define PSLAB_POLICY_DRAM 0
#define PSLAB_POLICY_PMEM 1
#define PSLAB_POLICY_BALANCED 2
#define pmem_member_persist(p, m) \
pmem_persist(&(p)->m, sizeof ((p)->m))
#define pmem_member_flush(p, m) \
pmem_flush(&(p)->m, sizeof ((p)->m))
#define pmem_flush_from(p, t, m) \
pmem_flush(&(p)->m, sizeof (t) - offsetof(t, m));
#define pslab_item_data_persist(it) pmem_persist((it)->data, ITEM_dtotal(it)
#define pslab_item_data_flush(it) pmem_flush((it)->data, ITEM_dtotal(it))
int pslab_create(char *pool_name, uint32_t pool_size, uint32_t slab_size,
uint32_t *slabclass_sizes, int slabclass_num);
int pslab_pre_recover(char *name, uint32_t *slab_sizes, int slab_max, int slab_page_size);
int pslab_do_recover(void);
time_t pslab_process_started(time_t process_started);
void pslab_update_flushtime(uint32_t time);
void pslab_use_slab(void *p, int id, unsigned int size);
void *pslab_get_free_slab(void *slab);
int pslab_contains(char *p);
uint64_t pslab_addr2off(void *addr);
extern bool pslab_force;
#endif
| 1,186 | 30.236842 | 90 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/config.h | /* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Set to nonzero if you want to include DTRACE */
/* #undef ENABLE_DTRACE */
/* Set to nonzero if you want to include SASL */
/* #undef ENABLE_SASL */
/* Set to nonzero if you want to enable a SASL pwdb */
/* #undef ENABLE_SASL_PWDB */
/* machine is bigendian */
/* #undef ENDIAN_BIG */
/* machine is littleendian */
#define ENDIAN_LITTLE 1
/* Set to nonzero if you want to enable extstorextstore */
/* #undef EXTSTORE */
/* Define to 1 if support accept4 */
#define HAVE_ACCEPT4 1
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
/* Define this if you have an implementation of drop_privileges() */
/* #undef HAVE_DROP_PRIVILEGES */
/* Define this if you have an implementation of drop_worker_privileges() */
/* #undef HAVE_DROP_WORKER_PRIVILEGES */
/* GCC 64bit Atomics available */
/* #undef HAVE_GCC_64ATOMICS */
/* GCC Atomics available */
#define HAVE_GCC_ATOMICS 1
/* Define to 1 if support getopt_long */
#define HAVE_GETOPT_LONG 1
/* Define to 1 if you have the `getpagesizes' function. */
/* #undef HAVE_GETPAGESIZES */
/* Have ntohll */
/* #undef HAVE_HTONLL */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `memcntl' function. */
/* #undef HAVE_MEMCNTL */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mlockall' function. */
#define HAVE_MLOCKALL 1
/* Define to 1 if you have the `pledge' function. */
/* #undef HAVE_PLEDGE */
/* we have sasl_callback_ft */
/* #undef HAVE_SASL_CALLBACK_FT */
/* Set to nonzero if your SASL implementation supports SASL_CB_GETCONF */
/* #undef HAVE_SASL_CB_GETCONF */
/* Define to 1 if you have the <sasl/sasl.h> header file. */
/* #undef HAVE_SASL_SASL_H */
/* Define to 1 if you have the `setppriv' function. */
/* #undef HAVE_SETPPRIV */
/* Define to 1 if you have the `sigignore' function. */
#define HAVE_SIGIGNORE 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define this if you have umem.h */
/* #undef HAVE_UMEM_H */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Machine need alignment */
/* #undef NEED_ALIGN */
/* Name of package */
#define PACKAGE "memcached"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"
/* Define to the full name of this package. */
#define PACKAGE_NAME "memcached"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "memcached 1.5.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "memcached"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.5.4"
/* Set to nonzero if you want to enable pslab */
#define PSLAB 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.5.4"
/* find sigignore on Linux */
#define _GNU_SOURCE 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* define to int if socklen_t not available */
/* #undef socklen_t */
#if HAVE_STDBOOL_H
#include <stdbool.h>
#else
#define bool char
#define false 0
#define true 1
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
| 4,134 | 24.368098 | 78 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/sasl_defs.h | #ifndef SASL_DEFS_H
#define SASL_DEFS_H 1
// Longest one I could find was ``9798-U-RSA-SHA1-ENC''
#define MAX_SASL_MECH_LEN 32
#if defined(HAVE_SASL_SASL_H) && defined(ENABLE_SASL)
#include <sasl/sasl.h>
void init_sasl(void);
extern char my_sasl_hostname[1025];
#else /* End of SASL support */
typedef void* sasl_conn_t;
#define init_sasl() {}
#define sasl_dispose(x) {}
#define sasl_server_new(a, b, c, d, e, f, g, h) 1
#define sasl_listmech(a, b, c, d, e, f, g, h) 1
#define sasl_server_start(a, b, c, d, e, f) 1
#define sasl_server_step(a, b, c, d, e) 1
#define sasl_getprop(a, b, c) {}
#define SASL_OK 0
#define SASL_CONTINUE -1
#endif /* sasl compat */
#endif /* SASL_DEFS_H */
| 693 | 20.6875 | 55 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/logger.h | /* logging functions */
#ifndef LOGGER_H
#define LOGGER_H
#include "bipbuffer.h"
/* TODO: starttime tunable */
#define LOGGER_BUF_SIZE 1024 * 64
#define LOGGER_WATCHER_BUF_SIZE 1024 * 256
#define LOGGER_ENTRY_MAX_SIZE 2048
#define GET_LOGGER() ((logger *) pthread_getspecific(logger_key));
/* Inlined from memcached.h - should go into sub header */
typedef unsigned int rel_time_t;
enum log_entry_type {
LOGGER_ASCII_CMD = 0,
LOGGER_EVICTION,
LOGGER_ITEM_GET,
LOGGER_ITEM_STORE,
LOGGER_CRAWLER_STATUS,
LOGGER_SLAB_MOVE,
#ifdef EXTSTORE
LOGGER_EXTSTORE_WRITE,
LOGGER_COMPACT_START,
LOGGER_COMPACT_ABORT,
LOGGER_COMPACT_READ_START,
LOGGER_COMPACT_READ_END,
LOGGER_COMPACT_END,
LOGGER_COMPACT_FRAGINFO,
#endif
};
enum log_entry_subtype {
LOGGER_TEXT_ENTRY = 0,
LOGGER_EVICTION_ENTRY,
LOGGER_ITEM_GET_ENTRY,
LOGGER_ITEM_STORE_ENTRY,
#ifdef EXTSTORE
LOGGER_EXT_WRITE_ENTRY,
#endif
};
enum logger_ret_type {
LOGGER_RET_OK = 0,
LOGGER_RET_NOSPACE,
LOGGER_RET_ERR
};
enum logger_parse_entry_ret {
LOGGER_PARSE_ENTRY_OK = 0,
LOGGER_PARSE_ENTRY_FULLBUF,
LOGGER_PARSE_ENTRY_FAILED
};
typedef const struct {
enum log_entry_subtype subtype;
int reqlen;
uint16_t eflags;
char *format;
} entry_details;
/* log entry intermediary structures */
struct logentry_eviction {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
char key[];
};
#ifdef EXTSTORE
struct logentry_ext_write {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
uint8_t bucket;
char key[];
};
#endif
struct logentry_item_get {
uint8_t was_found;
uint8_t nkey;
uint8_t clsid;
char key[];
};
struct logentry_item_store {
int status;
int cmd;
rel_time_t ttl;
uint8_t nkey;
uint8_t clsid;
char key[];
};
/* end intermediary structures */
typedef struct _logentry {
enum log_entry_subtype event;
uint16_t eflags;
uint64_t gid;
struct timeval tv; /* not monotonic! */
int size;
union {
void *entry; /* probably an item */
char end;
} data[];
} logentry;
#define LOG_SYSEVENTS (1<<1) /* threads start/stop/working */
#define LOG_FETCHERS (1<<2) /* get/gets/etc */
#define LOG_MUTATIONS (1<<3) /* set/append/incr/etc */
#define LOG_SYSERRORS (1<<4) /* malloc/etc errors */
#define LOG_CONNEVENTS (1<<5) /* new client, closed, etc */
#define LOG_EVICTIONS (1<<6) /* details of evicted items */
#define LOG_STRICT (1<<7) /* block worker instead of drop */
#define LOG_RAWCMDS (1<<9) /* raw ascii commands */
typedef struct _logger {
struct _logger *prev;
struct _logger *next;
pthread_mutex_t mutex; /* guard for this + *buf */
uint64_t written; /* entries written to the buffer */
uint64_t dropped; /* entries dropped */
uint64_t blocked; /* times blocked instead of dropped */
uint16_t fetcher_ratio; /* log one out of every N fetches */
uint16_t mutation_ratio; /* log one out of every N mutations */
uint16_t eflags; /* flags this logger should log */
bipbuf_t *buf;
const entry_details *entry_map;
} logger;
enum logger_watcher_type {
LOGGER_WATCHER_STDERR = 0,
LOGGER_WATCHER_CLIENT = 1
};
typedef struct {
void *c; /* original connection structure. still with source thread attached */
int sfd; /* client fd */
int id; /* id number for watcher list */
uint64_t skipped; /* lines skipped since last successful print */
bool failed_flush; /* recently failed to write out (EAGAIN), wait before retry */
enum logger_watcher_type t; /* stderr, client, syslog, etc */
uint16_t eflags; /* flags we are interested in */
bipbuf_t *buf; /* per-watcher output buffer */
} logger_watcher;
struct logger_stats {
uint64_t worker_dropped;
uint64_t worker_written;
uint64_t watcher_skipped;
uint64_t watcher_sent;
};
extern pthread_key_t logger_key;
/* public functions */
void logger_init(void);
logger *logger_create(void);
#define LOGGER_LOG(l, flag, type, ...) \
do { \
logger *myl = l; \
if (l == NULL) \
myl = GET_LOGGER(); \
if (myl->eflags & flag) \
logger_log(myl, type, __VA_ARGS__); \
} while (0)
enum logger_ret_type logger_log(logger *l, const enum log_entry_type event, const void *entry, ...);
enum logger_add_watcher_ret {
LOGGER_ADD_WATCHER_TOO_MANY = 0,
LOGGER_ADD_WATCHER_OK,
LOGGER_ADD_WATCHER_FAILED
};
enum logger_add_watcher_ret logger_add_watcher(void *c, const int sfd, uint16_t f);
#endif
| 4,680 | 24.032086 | 100 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/getresult.sh | awk -F ' ' '$1 ~ /time/ {sum += $3} END {print sum}' out
awk -F ' ' '$1 ~ /pagecnt/ {sum += $2} END {print sum}' out
awk -F ' ' '$1 ~ /timecp/ {sum += $3} END {print sum}' out
| 176 | 43.25 | 59 | sh |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/extstore.h | #ifndef EXTSTORE_H
#define EXTSTORE_H
/* A safe-to-read dataset for determining compaction.
* id is the array index.
*/
struct extstore_page_data {
uint64_t version;
uint64_t bytes_used;
unsigned int bucket;
};
/* Pages can have objects deleted from them at any time. This creates holes
* that can't be reused until the page is either evicted or all objects are
* deleted.
* bytes_fragmented is the total bytes for all of these holes.
* It is the size of all used pages minus each page's bytes_used value.
*/
struct extstore_stats {
uint64_t page_allocs;
uint64_t page_count; /* total page count */
uint64_t page_evictions;
uint64_t page_reclaims;
uint64_t page_size; /* size in bytes per page (supplied by caller) */
uint64_t pages_free; /* currently unallocated/unused pages */
uint64_t pages_used;
uint64_t objects_evicted;
uint64_t objects_read;
uint64_t objects_written;
uint64_t objects_used; /* total number of objects stored */
uint64_t bytes_evicted;
uint64_t bytes_written;
uint64_t bytes_read; /* wbuf - read -> bytes read from storage */
uint64_t bytes_used; /* total number of bytes stored */
uint64_t bytes_fragmented; /* see above comment */
struct extstore_page_data *page_data;
};
// TODO: Temporary configuration structure. A "real" library should have an
// extstore_set(enum, void *ptr) which hides the implementation.
// this is plenty for quick development.
struct extstore_conf {
unsigned int page_size; // ideally 64-256M in size
unsigned int page_count;
unsigned int page_buckets; // number of different writeable pages
unsigned int wbuf_size; // must divide cleanly into page_size
unsigned int wbuf_count; // this might get locked to "2 per active page"
unsigned int io_threadcount;
unsigned int io_depth; // with normal I/O, hits locks less. req'd for AIO
};
enum obj_io_mode {
OBJ_IO_READ = 0,
OBJ_IO_WRITE,
};
typedef struct _obj_io obj_io;
typedef void (*obj_io_cb)(void *e, obj_io *io, int ret);
/* An object for both reads and writes to the storage engine.
* Once an IO is submitted, ->next may be changed by the IO thread. It is not
* safe to further modify the IO stack until the entire request is completed.
*/
struct _obj_io {
void *data; /* user supplied data pointer */
struct _obj_io *next;
char *buf; /* buffer of data to read or write to */
struct iovec *iov; /* alternatively, use this iovec */
unsigned int iovcnt; /* number of IOV's */
unsigned int page_version; /* page version for read mode */
unsigned int len; /* for both modes */
unsigned int offset; /* for read mode */
unsigned short page_id; /* for read mode */
enum obj_io_mode mode;
/* callback pointers? */
obj_io_cb cb;
};
enum extstore_res {
EXTSTORE_INIT_BAD_WBUF_SIZE = 1,
EXTSTORE_INIT_NEED_MORE_WBUF,
EXTSTORE_INIT_NEED_MORE_BUCKETS,
EXTSTORE_INIT_PAGE_WBUF_ALIGNMENT,
EXTSTORE_INIT_OOM,
EXTSTORE_INIT_OPEN_FAIL,
EXTSTORE_INIT_THREAD_FAIL
};
const char *extstore_err(enum extstore_res res);
void *extstore_init(char *fn, struct extstore_conf *cf, enum extstore_res *res);
int extstore_write_request(void *ptr, unsigned int bucket, obj_io *io);
void extstore_write(void *ptr, obj_io *io);
int extstore_submit(void *ptr, obj_io *io);
/* count are the number of objects being removed, bytes are the original
* length of those objects. Bytes is optional but you can't track
* fragmentation without it.
*/
int extstore_check(void *ptr, unsigned int page_id, uint64_t page_version);
int extstore_delete(void *ptr, unsigned int page_id, uint64_t page_version, unsigned int count, unsigned int bytes);
void extstore_get_stats(void *ptr, struct extstore_stats *st);
/* add page data array to a stats structure.
* caller must allocate its stats.page_data memory first.
*/
void extstore_get_page_data(void *ptr, struct extstore_stats *st);
void extstore_run_maint(void *ptr);
void extstore_close_page(void *ptr, unsigned int page_id, uint64_t page_version);
#endif
| 4,091 | 36.541284 | 116 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/assoc.h | /* associative array */
void assoc_init(const int hashpower_init);
item *assoc_find(const char *key, const size_t nkey, const uint32_t hv);
int assoc_insert(item *item, const uint32_t hv);
void assoc_delete(const char *key, const size_t nkey, const uint32_t hv);
void do_assoc_move_next_bucket(void);
int start_assoc_maintenance_thread(void);
void stop_assoc_maintenance_thread(void);
extern unsigned int hashpower;
extern unsigned int item_lock_hashpower;
| 457 | 40.636364 | 73 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/run.sh | #!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
sed -i "s/Werror/Wno-error/g" Makefile
make -j USE_PMDK=yes STD=-std=gnu99
sudo ./memcached -u root -m 0 -t 1 -o pslab_policy=pmem,pslab_file=/mnt/mem/pool,pslab_force > out
grep "cp" out > time
log=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1'cp' $log
| 301 | 32.555556 | 98 | sh |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/slab_automove_extstore.h | #ifndef SLAB_AUTOMOVE_EXTSTORE_H
#define SLAB_AUTOMOVE_EXTSTORE_H
void *slab_automove_extstore_init(struct settings *settings);
void slab_automove_extstore_free(void *arg);
void slab_automove_extstore_run(void *arg, int *src, int *dst);
#endif
| 246 | 26.444444 | 63 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/memcached.h | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/** \file
* The main memcached header holding commonly used data
* structures and function prototypes.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <event.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include "itoa_ljust.h"
#include "protocol_binary.h"
#include "cache.h"
#include "logger.h"
#ifdef EXTSTORE
#include "extstore.h"
#include "crc32c.h"
#endif
#ifdef PSLAB
#include "pslab.h"
#endif
#include "sasl_defs.h"
/** Maximum length of a key. */
#define KEY_MAX_LENGTH 250
/** Size of an incr buf. */
#define INCR_MAX_STORAGE_LEN 24
#define DATA_BUFFER_SIZE 2048
#define UDP_READ_BUFFER_SIZE 65536
#define UDP_MAX_PAYLOAD_SIZE 1400
#define UDP_HEADER_SIZE 8
#define MAX_SENDBUF_SIZE (256 * 1024 * 1024)
/* Up to 3 numbers (2 32bit, 1 64bit), spaces, newlines, null 0 */
#define SUFFIX_SIZE 50
/** Initial size of list of items being returned by "get". */
#define ITEM_LIST_INITIAL 200
/** Initial size of list of CAS suffixes appended to "gets" lines. */
#define SUFFIX_LIST_INITIAL 100
/** Initial size of the sendmsg() scatter/gather array. */
#define IOV_LIST_INITIAL 400
/** Initial number of sendmsg() argument structures to allocate. */
#define MSG_LIST_INITIAL 10
/** High water marks for buffer shrinking */
#define READ_BUFFER_HIGHWAT 8192
#define ITEM_LIST_HIGHWAT 400
#define IOV_LIST_HIGHWAT 600
#define MSG_LIST_HIGHWAT 100
/* Binary protocol stuff */
#define MIN_BIN_PKT_LENGTH 16
#define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t))
/* Initial power multiplier for the hash table */
#define HASHPOWER_DEFAULT 16
#define HASHPOWER_MAX 32
/*
* We only reposition items in the LRU queue if they haven't been repositioned
* in this many seconds. That saves us from churning on frequently-accessed
* items.
*/
#define ITEM_UPDATE_INTERVAL 60
/* unistd.h is here */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Slab sizing definitions. */
#ifdef PSLAB
#define POWER_SMALLEST 2
#else
#define POWER_SMALLEST 1
#endif
#define POWER_LARGEST 256 /* actual cap is 255 */
#define SLAB_GLOBAL_PAGE_POOL 0 /* magic slab class for storing pages for reassignment */
#ifdef PSLAB
#define SLAB_GLOBAL_PAGE_POOL_PMEM 1 /* magic slab class for storing pmem pages for reassignment */
#endif
#define CHUNK_ALIGN_BYTES 8
/* slab class max is a 6-bit number, -1. */
#define MAX_NUMBER_OF_SLAB_CLASSES (63 + 1)
/** How long an object can reasonably be assumed to be locked before
harvesting it on a low memory condition. Default: disabled. */
#define TAIL_REPAIR_TIME_DEFAULT 0
/* warning: don't use these macros with a function, as it evals its arg twice */
#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
(i)->data->cas : (uint64_t)0)
#define ITEM_set_cas(i,v) { \
if ((i)->it_flags & ITEM_CAS) { \
(i)->data->cas = v; \
} \
}
#define ITEM_key(item) (((char*)&((item)->data)) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (item)->nsuffix \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \
+ (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#ifdef PSLAB
#define ITEM_dtotal(item) (item)->nkey + 1 + (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)
#endif
#define ITEM_clsid(item) ((item)->slabs_clsid & ~(3<<6))
#define ITEM_lruid(item) ((item)->slabs_clsid & (3<<6))
#define STAT_KEY_LEN 128
#define STAT_VAL_LEN 128
/** Append a simple stat with a stat name, value format and value */
#define APPEND_STAT(name, fmt, val) \
append_stat(name, add_stats, c, fmt, val);
/** Append an indexed stat with a stat name (with format), value format
and value */
#define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \
klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \
vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \
add_stats(key_str, klen, val_str, vlen, c);
/** Common APPEND_NUM_FMT_STAT format. */
#define APPEND_NUM_STAT(num, name, fmt, val) \
APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val)
/**
* Callback for any function producing stats.
*
* @param key the stat's key
* @param klen length of the key
* @param val the stat's value in an ascii form (e.g. text form of a number)
* @param vlen length of the value
* @parm cookie magic callback cookie
*/
typedef void (*ADD_STAT)(const char *key, const uint16_t klen,
const char *val, const uint32_t vlen,
const void *cookie);
/*
* NOTE: If you modify this table you _MUST_ update the function state_text
*/
/**
* Possible states of a connection.
*/
enum conn_states {
conn_listening, /**< the socket which listens for connections */
conn_new_cmd, /**< Prepare connection for next command */
conn_waiting, /**< waiting for a readable socket */
conn_read, /**< reading in a command line */
conn_parse_cmd, /**< try to parse a command from the input buffer */
conn_write, /**< writing out a simple response */
conn_nread, /**< reading in a fixed number of bytes */
conn_swallow, /**< swallowing unnecessary bytes w/o storing */
conn_closing, /**< closing this connection */
conn_mwrite, /**< writing out many items sequentially */
conn_closed, /**< connection is closed */
conn_watch, /**< held by the logger thread as a watcher */
conn_max_state /**< Max state value (used for assertion) */
};
enum bin_substates {
bin_no_state,
bin_reading_set_header,
bin_reading_cas_header,
bin_read_set_value,
bin_reading_get_key,
bin_reading_stat,
bin_reading_del_header,
bin_reading_incr_header,
bin_read_flush_exptime,
bin_reading_sasl_auth,
bin_reading_sasl_auth_data,
bin_reading_touch_key,
};
enum protocol {
ascii_prot = 3, /* arbitrary value. */
binary_prot,
negotiating_prot /* Discovering the protocol */
};
enum network_transport {
local_transport, /* Unix sockets*/
tcp_transport,
udp_transport
};
enum pause_thread_types {
PAUSE_WORKER_THREADS = 0,
PAUSE_ALL_THREADS,
RESUME_ALL_THREADS,
RESUME_WORKER_THREADS
};
#define IS_TCP(x) (x == tcp_transport)
#define IS_UDP(x) (x == udp_transport)
#define NREAD_ADD 1
#define NREAD_SET 2
#define NREAD_REPLACE 3
#define NREAD_APPEND 4
#define NREAD_PREPEND 5
#define NREAD_CAS 6
enum store_item_type {
NOT_STORED=0, STORED, EXISTS, NOT_FOUND, TOO_LARGE, NO_MEMORY
};
enum delta_result_type {
OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH
};
/** Time relative to server start. Smaller than time_t on 64-bit systems. */
// TODO: Move to sub-header. needed in logger.h
//typedef unsigned int rel_time_t;
/** Use X macros to avoid iterating over the stats fields during reset and
* aggregation. No longer have to add new stats in 3+ places.
*/
#define SLAB_STATS_FIELDS \
X(set_cmds) \
X(get_hits) \
X(touch_hits) \
X(delete_hits) \
X(cas_hits) \
X(cas_badval) \
X(incr_hits) \
X(decr_hits)
/** Stats stored per slab (and per thread). */
struct slab_stats {
#define X(name) uint64_t name;
SLAB_STATS_FIELDS
#undef X
};
#define THREAD_STATS_FIELDS \
X(get_cmds) \
X(get_misses) \
X(get_expired) \
X(get_flushed) \
X(touch_cmds) \
X(touch_misses) \
X(delete_misses) \
X(incr_misses) \
X(decr_misses) \
X(cas_misses) \
X(bytes_read) \
X(bytes_written) \
X(flush_cmds) \
X(conn_yields) /* # of yields for connections (-R option)*/ \
X(auth_cmds) \
X(auth_errors) \
X(idle_kicks) /* idle connections killed */
#ifdef EXTSTORE
#define EXTSTORE_THREAD_STATS_FIELDS \
X(get_extstore) \
X(recache_from_extstore) \
X(miss_from_extstore) \
X(badcrc_from_extstore)
#endif
/**
* Stats stored per-thread.
*/
struct thread_stats {
pthread_mutex_t mutex;
#define X(name) uint64_t name;
THREAD_STATS_FIELDS
#ifdef EXTSTORE
EXTSTORE_THREAD_STATS_FIELDS
#endif
#undef X
struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES];
uint64_t lru_hits[POWER_LARGEST];
};
/**
* Global stats. Only resettable stats should go into this structure.
*/
struct stats {
uint64_t total_items;
uint64_t total_conns;
uint64_t rejected_conns;
uint64_t malloc_fails;
uint64_t listen_disabled_num;
uint64_t slabs_moved; /* times slabs were moved around */
uint64_t slab_reassign_rescues; /* items rescued during slab move */
uint64_t slab_reassign_evictions_nomem; /* valid items lost during slab move */
uint64_t slab_reassign_inline_reclaim; /* valid items lost during slab move */
uint64_t slab_reassign_chunk_rescues; /* chunked-item chunks recovered */
uint64_t slab_reassign_busy_items; /* valid temporarily unmovable */
uint64_t slab_reassign_busy_deletes; /* refcounted items killed */
uint64_t lru_crawler_starts; /* Number of item crawlers kicked off */
uint64_t lru_maintainer_juggles; /* number of LRU bg pokes */
uint64_t time_in_listen_disabled_us; /* elapsed time in microseconds while server unable to process new connections */
uint64_t log_worker_dropped; /* logs dropped by worker threads */
uint64_t log_worker_written; /* logs written by worker threads */
uint64_t log_watcher_skipped; /* logs watchers missed */
uint64_t log_watcher_sent; /* logs sent to watcher buffers */
#ifdef EXTSTORE
uint64_t extstore_compact_lost; /* items lost because they were locked */
uint64_t extstore_compact_rescues; /* items re-written during compaction */
uint64_t extstore_compact_skipped; /* unhit items skipped during compaction */
#endif
struct timeval maxconns_entered; /* last time maxconns entered */
};
/**
* Global "state" stats. Reflects state that shouldn't be wiped ever.
* Ordered for some cache line locality for commonly updated counters.
*/
struct stats_state {
uint64_t curr_items;
uint64_t curr_bytes;
uint64_t curr_conns;
uint64_t hash_bytes; /* size used for hash tables */
unsigned int conn_structs;
unsigned int reserved_fds;
unsigned int hash_power_level; /* Better hope it's not over 9000 */
bool hash_is_expanding; /* If the hash table is being expanded */
bool accepting_conns; /* whether we are currently accepting */
bool slab_reassign_running; /* slab reassign in progress */
bool lru_crawler_running; /* crawl in progress */
};
#define MAX_VERBOSITY_LEVEL 2
/* When adding a setting, be sure to update process_stat_settings */
/**
* Globally accessible settings as derived from the commandline.
*/
struct settings {
size_t maxbytes;
int maxconns;
int port;
int udpport;
char *inter;
int verbose;
rel_time_t oldest_live; /* ignore existing items older than this */
uint64_t oldest_cas; /* ignore existing items with CAS values lower than this */
int evict_to_free;
char *socketpath; /* path to unix socket if using local socket */
int access; /* access mask (a la chmod) for unix domain socket */
double factor; /* chunk size growth factor */
int chunk_size;
int num_threads; /* number of worker (without dispatcher) libevent threads to run */
int num_threads_per_udp; /* number of worker threads serving each udp socket */
char prefix_delimiter; /* character that marks a key prefix (for stats) */
int detail_enabled; /* nonzero if we're collecting detailed stats */
int reqs_per_event; /* Maximum number of io to process on each
io-event. */
bool use_cas;
enum protocol binding_protocol;
int backlog;
int item_size_max; /* Maximum item size */
int slab_chunk_size_max; /* Upper end for chunks within slab pages. */
int slab_page_size; /* Slab's page units. */
bool sasl; /* SASL on/off */
bool maxconns_fast; /* Whether or not to early close connections */
bool lru_crawler; /* Whether or not to enable the autocrawler thread */
bool lru_maintainer_thread; /* LRU maintainer background thread */
bool lru_segmented; /* Use split or flat LRU's */
bool slab_reassign; /* Whether or not slab reassignment is allowed */
int slab_automove; /* Whether or not to automatically move slabs */
double slab_automove_ratio; /* youngest must be within pct of oldest */
unsigned int slab_automove_window; /* window mover for algorithm */
int hashpower_init; /* Starting hash power level */
bool shutdown_command; /* allow shutdown command */
int tail_repair_time; /* LRU tail refcount leak repair time */
bool flush_enabled; /* flush_all enabled */
bool dump_enabled; /* whether cachedump/metadump commands work */
char *hash_algorithm; /* Hash algorithm in use */
int lru_crawler_sleep; /* Microsecond sleep between items */
uint32_t lru_crawler_tocrawl; /* Number of items to crawl per run */
int hot_lru_pct; /* percentage of slab space for HOT_LRU */
int warm_lru_pct; /* percentage of slab space for WARM_LRU */
double hot_max_factor; /* HOT tail age relative to COLD tail */
double warm_max_factor; /* WARM tail age relative to COLD tail */
int crawls_persleep; /* Number of LRU crawls to run before sleeping */
bool inline_ascii_response; /* pre-format the VALUE line for ASCII responses */
bool temp_lru; /* TTL < temporary_ttl uses TEMP_LRU */
uint32_t temporary_ttl; /* temporary LRU threshold */
int idle_timeout; /* Number of seconds to let connections idle */
unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */
unsigned int logger_buf_size; /* size of per-thread logger buffer */
bool drop_privileges; /* Whether or not to drop unnecessary process privileges */
bool relaxed_privileges; /* Relax process restrictions when running testapp */
#ifdef EXTSTORE
unsigned int ext_item_size; /* minimum size of items to store externally */
unsigned int ext_item_age; /* max age of tail item before storing ext. */
unsigned int ext_low_ttl; /* remaining TTL below this uses own pages */
unsigned int ext_recache_rate; /* counter++ % recache_rate == 0 > recache */
unsigned int ext_wbuf_size; /* read only note for the engine */
unsigned int ext_compact_under; /* when fewer than this many pages, compact */
unsigned int ext_drop_under; /* when fewer than this many pages, drop COLD items */
double ext_max_frag; /* ideal maximum page fragmentation */
double slab_automove_freeratio; /* % of memory to hold free as buffer */
bool ext_drop_unread; /* skip unread items during compaction */
/* per-slab-class free chunk limit */
unsigned int ext_free_memchunks[MAX_NUMBER_OF_SLAB_CLASSES];
#endif
#ifdef PSLAB
size_t pslab_size; /* pmem slab pool size */
unsigned int pslab_policy; /* pmem slab allocation policy */
bool pslab_recover; /* do recovery from pmem slab pool */
#endif
};
extern struct stats stats;
extern struct stats_state stats_state;
extern time_t process_started;
extern struct settings settings;
#define ITEM_LINKED 1
#define ITEM_CAS 2
/* temp */
#define ITEM_SLABBED 4
/* Item was fetched at least once in its lifetime */
#define ITEM_FETCHED 8
/* Appended on fetch, removed on LRU shuffling */
#define ITEM_ACTIVE 16
/* If an item's storage are chained chunks. */
#define ITEM_CHUNKED 32
#define ITEM_CHUNK 64
#ifdef PSLAB
/* If an item is stored in pmem */
#define ITEM_PSLAB 64
#endif
#ifdef EXTSTORE
/* ITEM_data bulk is external to item */
#define ITEM_HDR 128
#endif
/**
* Structure for storing items within memcached.
*/
typedef struct _stritem {
/* Protected by LRU locks */
struct _stritem *next;
struct _stritem *prev;
/* Rest are protected by an item lock */
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
/* this odd type prevents type-punning issues when we do
* the little shuffle to save space when not using CAS. */
union {
uint64_t cas;
char end;
} data[];
/* if it_flags & ITEM_CAS we have 8 bytes CAS */
/* then null-terminated key */
/* then " flags length\r\n" (no terminating null) */
/* then data with terminating \r\n (no terminating null; it's binary!) */
} item;
// TODO: If we eventually want user loaded modules, we can't use an enum :(
enum crawler_run_type {
CRAWLER_AUTOEXPIRE=0, CRAWLER_EXPIRED, CRAWLER_METADUMP
};
typedef struct {
struct _stritem *next;
struct _stritem *prev;
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
uint32_t remaining; /* Max keys to crawl per slab per invocation */
uint64_t reclaimed; /* items reclaimed during this crawl. */
uint64_t unfetched; /* items reclaimed unfetched during this crawl. */
uint64_t checked; /* items examined during this crawl. */
} crawler;
/* Header when an item is actually a chunk of another item. */
typedef struct _strchunk {
struct _strchunk *next; /* points within its own chain. */
struct _strchunk *prev; /* can potentially point to the head. */
struct _stritem *head; /* always points to the owner chunk */
int size; /* available chunk space in bytes */
int used; /* chunk space used */
int nbytes; /* used. */
unsigned short refcount; /* used? */
uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */
uint8_t it_flags; /* ITEM_* above. */
uint8_t slabs_clsid; /* Same as above. */
#ifdef PSLAB
_Bool pslab : 1;
uint64_t next_poff; /* offset of next chunk in pmem */
#endif
char data[];
} item_chunk;
#ifdef EXTSTORE
typedef struct {
unsigned int page_version; /* from IO header */
unsigned int offset; /* from IO header */
unsigned short page_id; /* from IO header */
} item_hdr;
#endif
typedef struct {
pthread_t thread_id; /* unique ID of this thread */
struct event_base *base; /* libevent handle this thread uses */
struct event notify_event; /* listen event for notify pipe */
int notify_receive_fd; /* receiving end of notify pipe */
int notify_send_fd; /* sending end of notify pipe */
struct thread_stats stats; /* Stats generated by this thread */
struct conn_queue *new_conn_queue; /* queue of new connections to handle */
cache_t *suffix_cache; /* suffix cache */
#ifdef EXTSTORE
cache_t *io_cache; /* IO objects */
void *storage; /* data object for storage system */
#endif
logger *l; /* logger buffer */
void *lru_bump_buf; /* async LRU bump buffer */
} LIBEVENT_THREAD;
typedef struct conn conn;
#ifdef EXTSTORE
typedef struct _io_wrap {
obj_io io;
struct _io_wrap *next;
conn *c;
item *hdr_it; /* original header item. */
unsigned int iovec_start; /* start of the iovecs for this IO */
unsigned int iovec_count; /* total number of iovecs */
unsigned int iovec_data; /* specific index of data iovec */
bool miss; /* signal a miss to unlink hdr_it */
bool badcrc; /* signal a crc failure */
bool active; // FIXME: canary for test. remove
} io_wrap;
#endif
/**
* The structure representing a connection into memcached.
*/
struct conn {
int sfd;
sasl_conn_t *sasl_conn;
bool authenticated;
enum conn_states state;
enum bin_substates substate;
rel_time_t last_cmd_time;
struct event event;
short ev_flags;
short which; /** which events were just triggered */
char *rbuf; /** buffer to read commands into */
char *rcurr; /** but if we parsed some already, this is where we stopped */
int rsize; /** total allocated size of rbuf */
int rbytes; /** how much data, starting from rcur, do we have unparsed */
char *wbuf;
char *wcurr;
int wsize;
int wbytes;
/** which state to go into after finishing current write */
enum conn_states write_and_go;
void *write_and_free; /** free this memory after finishing writing */
char *ritem; /** when we read in an item's value, it goes here */
int rlbytes;
/* data for the nread state */
/**
* item is used to hold an item structure created after reading the command
* line of set/add/replace commands, but before we finished reading the actual
* data. The data is read into ITEM_data(item) to avoid extra copying.
*/
void *item; /* for commands set/add/replace */
/* data for the swallow state */
int sbytes; /* how many bytes to swallow */
/* data for the mwrite state */
struct iovec *iov;
int iovsize; /* number of elements allocated in iov[] */
int iovused; /* number of elements used in iov[] */
struct msghdr *msglist;
int msgsize; /* number of elements allocated in msglist[] */
int msgused; /* number of elements used in msglist[] */
int msgcurr; /* element in msglist[] being transmitted now */
int msgbytes; /* number of bytes in current msg */
item **ilist; /* list of items to write out */
int isize;
item **icurr;
int ileft;
char **suffixlist;
int suffixsize;
char **suffixcurr;
int suffixleft;
#ifdef EXTSTORE
int io_wrapleft;
unsigned int recache_counter;
io_wrap *io_wraplist; /* linked list of io_wraps */
bool io_queued; /* FIXME: debugging flag */
#endif
enum protocol protocol; /* which protocol this connection speaks */
enum network_transport transport; /* what transport is used by this connection */
/* data for UDP clients */
int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */
struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */
socklen_t request_addr_size;
unsigned char *hdrbuf; /* udp packet headers */
int hdrsize; /* number of headers' worth of space is allocated */
bool noreply; /* True if the reply should not be sent. */
/* current stats command */
struct {
char *buffer;
size_t size;
size_t offset;
} stats;
/* Binary protocol stuff */
/* This is where the binary header goes */
protocol_binary_request_header binary_header;
uint64_t cas; /* the cas to return */
short cmd; /* current command being processed */
int opaque;
int keylen;
conn *next; /* Used for generating a list of conn structures */
LIBEVENT_THREAD *thread; /* Pointer to the thread object serving this connection */
uint32_t objid;
};
/* array of conn structures, indexed by file descriptor */
extern conn **conns;
/* current time of day (updated periodically) */
extern volatile rel_time_t current_time;
/* TODO: Move to slabs.h? */
extern volatile int slab_rebalance_signal;
struct slab_rebalance {
void *slab_start;
void *slab_end;
void *slab_pos;
int s_clsid;
int d_clsid;
uint32_t busy_items;
uint32_t rescues;
uint32_t evictions_nomem;
uint32_t inline_reclaim;
uint32_t chunk_rescues;
uint32_t busy_deletes;
uint32_t busy_loops;
uint8_t done;
};
extern struct slab_rebalance slab_rebal;
#ifdef EXTSTORE
extern void *ext_storage;
#endif
/*
* Functions
*/
void do_accept_new_conns(const bool do_accept);
enum delta_result_type do_add_delta(conn *c, const char *key,
const size_t nkey, const bool incr,
const int64_t delta, char *buf,
uint64_t *cas, const uint32_t hv);
enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv);
conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base);
void conn_worker_readd(conn *c);
extern int daemonize(int nochdir, int noclose);
#define mutex_lock(x) pthread_mutex_lock(x)
#define mutex_unlock(x) pthread_mutex_unlock(x)
#include "stats.h"
#include "slabs.h"
#include "assoc.h"
#include "items.h"
#include "crawler.h"
#include "trace.h"
#include "hash.h"
#include "util.h"
/*
* Functions such as the libevent-related calls that need to do cross-thread
* communication in multithreaded mode (rather than actually doing the work
* in the current thread) are called via "dispatch_" frontends, which are
* also #define-d to directly call the underlying code in singlethreaded mode.
*/
void memcached_thread_init(int nthreads, void *arg);
void redispatch_conn(conn *c);
void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport);
void sidethread_conn_close(conn *c);
/* Lock wrappers for cache functions that are called from main loop. */
enum delta_result_type add_delta(conn *c, const char *key,
const size_t nkey, const int incr,
const int64_t delta, char *buf,
uint64_t *cas);
void accept_new_conns(const bool do_accept);
conn *conn_from_freelist(void);
bool conn_add_to_freelist(conn *c);
void conn_close_idle(conn *c);
item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes);
#define DO_UPDATE true
#define DONT_UPDATE false
item *item_get(const char *key, const size_t nkey, conn *c, const bool do_update);
item *item_touch(const char *key, const size_t nkey, uint32_t exptime, conn *c);
int item_link(item *it);
void item_remove(item *it);
int item_replace(item *it, item *new_it, const uint32_t hv);
void item_unlink(item *it);
void item_lock(uint32_t hv);
void *item_trylock(uint32_t hv);
void item_trylock_unlock(void *arg);
void item_unlock(uint32_t hv);
void pause_threads(enum pause_thread_types type);
#define refcount_incr(it) ++(it->refcount)
#define refcount_decr(it) --(it->refcount)
void STATS_LOCK(void);
void STATS_UNLOCK(void);
void threadlocal_stats_reset(void);
void threadlocal_stats_aggregate(struct thread_stats *stats);
void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out);
/* Stat processing functions */
void append_stat(const char *name, ADD_STAT add_stats, conn *c,
const char *fmt, ...);
enum store_item_type store_item(item *item, int comm, conn *c);
#if HAVE_DROP_PRIVILEGES
extern void drop_privileges(void);
#else
#define drop_privileges()
#endif
#if HAVE_DROP_WORKER_PRIVILEGES
extern void drop_worker_privileges(void);
#else
#define drop_worker_privileges()
#endif
/* If supported, give compiler hints for branch prediction. */
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define __builtin_expect(x, expected_value) (x)
#endif
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
| 28,992 | 34.749692 | 175 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/crawler.h | #ifndef CRAWLER_H
#define CRAWLER_H
typedef struct {
uint64_t histo[61];
uint64_t ttl_hourplus;
uint64_t noexp;
uint64_t reclaimed;
uint64_t seen;
rel_time_t start_time;
rel_time_t end_time;
bool run_complete;
} crawlerstats_t;
struct crawler_expired_data {
pthread_mutex_t lock;
crawlerstats_t crawlerstats[POWER_LARGEST];
/* redundant with crawlerstats_t so we can get overall start/stop/done */
rel_time_t start_time;
rel_time_t end_time;
bool crawl_complete;
bool is_external; /* whether this was an alloc local or remote to the module. */
};
enum crawler_result_type {
CRAWLER_OK=0, CRAWLER_RUNNING, CRAWLER_BADCLASS, CRAWLER_NOTSTARTED, CRAWLER_ERROR
};
int start_item_crawler_thread(void);
int stop_item_crawler_thread(void);
int init_lru_crawler(void *arg);
enum crawler_result_type lru_crawler_crawl(char *slabs, enum crawler_run_type, void *c, const int sfd);
int lru_crawler_start(uint8_t *ids, uint32_t remaining,
const enum crawler_run_type type, void *data,
void *c, const int sfd);
void lru_crawler_pause(void);
void lru_crawler_resume(void);
#endif
| 1,191 | 29.564103 | 103 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/slab_automove.h | #ifndef SLAB_AUTOMOVE_H
#define SLAB_AUTOMOVE_H
/* default automove functions */
void *slab_automove_init(struct settings *settings);
void slab_automove_free(void *arg);
void slab_automove_run(void *arg, int *src, int *dst);
typedef void *(*slab_automove_init_func)(struct settings *settings);
typedef void (*slab_automove_free_func)(void *arg);
typedef void (*slab_automove_run_func)(void *arg, int *src, int *dst);
typedef struct {
slab_automove_init_func init;
slab_automove_free_func free;
slab_automove_run_func run;
} slab_automove_reg_t;
#endif
| 568 | 27.45 | 70 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/storage.h | #ifndef STORAGE_H
#define STORAGE_H
int lru_maintainer_store(void *storage, const int clsid);
int start_storage_compact_thread(void *arg);
void storage_compact_pause(void);
void storage_compact_resume(void);
#endif
| 217 | 20.8 | 57 | h |
null | NearPMSW-main/nearpm/shadow/memcached-pmem-sd/stats.h | /* stats */
void stats_prefix_init(void);
void stats_prefix_clear(void);
void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit);
void stats_prefix_record_delete(const char *key, const size_t nkey);
void stats_prefix_record_set(const char *key, const size_t nkey);
/*@null@*/
char *stats_prefix_dump(int *length);
| 342 | 37.111111 | 84 | h |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.