Search is not available for this dataset
repo
stringlengths
2
152
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_avx.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #ifndef PMEM2_MEMSET_AVX_H #define PMEM2_MEMSET_AVX_H #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include "avx.h" #include "out.h" static force_inline void memset_small_avx_noflush(char *dest, __m256i ymm, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; /* 33..64 */ _mm256_storeu_si256((__m256i *)dest, ymm); _mm256_storeu_si256((__m256i *)(dest + len - 32), ymm); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm = m256_get16b(ymm); _mm_storeu_si128((__m128i *)dest, xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 9..16 */ uint64_t d8 = m256_get8b(ymm); *(ua_uint64_t *)dest = d8; *(ua_uint64_t *)(dest + len - 8) = d8; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d = m256_get4b(ymm); *(ua_uint32_t *)dest = d; *(ua_uint32_t *)(dest + len - 4) = d; return; } /* 3..4 */ uint16_t d2 = m256_get2b(ymm); *(ua_uint16_t *)dest = d2; *(ua_uint16_t *)(dest + len - 2) = d2; return; le2: if (len == 2) { uint16_t d2 = m256_get2b(ymm); *(ua_uint16_t *)dest = d2; return; } *(uint8_t *)dest = (uint8_t)m256_get2b(ymm); } static force_inline void memset_small_avx(char *dest, __m256i ymm, size_t len, flush_fn flush) { /* * pmemcheck complains about "overwritten stores before they were made * persistent" for overlapping stores (last instruction in each code * path) in the optimized version. * libc's memset also does that, so we can't use it here. */ if (On_pmemcheck) { memset_nodrain_generic(dest, (uint8_t)m256_get2b(ymm), len, PMEM2_F_MEM_NOFLUSH, NULL); } else { memset_small_avx_noflush(dest, ymm, len); } flush(dest, len); } #endif
1,856
17.94898
71
h
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_t_avx512f.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memset_avx512f.h" static force_inline void mm512_store_si512(char *dest, unsigned idx, __m512i src) { _mm512_store_si512((__m512i *)dest + idx, src); } static force_inline void memset_mov32x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); mm512_store_si512(dest, 1, zmm); mm512_store_si512(dest, 2, zmm); mm512_store_si512(dest, 3, zmm); mm512_store_si512(dest, 4, zmm); mm512_store_si512(dest, 5, zmm); mm512_store_si512(dest, 6, zmm); mm512_store_si512(dest, 7, zmm); mm512_store_si512(dest, 8, zmm); mm512_store_si512(dest, 9, zmm); mm512_store_si512(dest, 10, zmm); mm512_store_si512(dest, 11, zmm); mm512_store_si512(dest, 12, zmm); mm512_store_si512(dest, 13, zmm); mm512_store_si512(dest, 14, zmm); mm512_store_si512(dest, 15, zmm); mm512_store_si512(dest, 16, zmm); mm512_store_si512(dest, 17, zmm); mm512_store_si512(dest, 18, zmm); mm512_store_si512(dest, 19, zmm); mm512_store_si512(dest, 20, zmm); mm512_store_si512(dest, 21, zmm); mm512_store_si512(dest, 22, zmm); mm512_store_si512(dest, 23, zmm); mm512_store_si512(dest, 24, zmm); mm512_store_si512(dest, 25, zmm); mm512_store_si512(dest, 26, zmm); mm512_store_si512(dest, 27, zmm); mm512_store_si512(dest, 28, zmm); mm512_store_si512(dest, 29, zmm); mm512_store_si512(dest, 30, zmm); mm512_store_si512(dest, 31, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); flush64b(dest + 16 * 64); flush64b(dest + 17 * 64); flush64b(dest + 18 * 64); flush64b(dest + 19 * 64); flush64b(dest + 20 * 64); flush64b(dest + 21 * 64); flush64b(dest + 22 * 64); flush64b(dest + 23 * 64); flush64b(dest + 24 * 64); flush64b(dest + 25 * 64); flush64b(dest + 26 * 64); flush64b(dest + 27 * 64); flush64b(dest + 28 * 64); flush64b(dest + 29 * 64); flush64b(dest + 30 * 64); flush64b(dest + 31 * 64); } static force_inline void memset_mov16x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); mm512_store_si512(dest, 1, zmm); mm512_store_si512(dest, 2, zmm); mm512_store_si512(dest, 3, zmm); mm512_store_si512(dest, 4, zmm); mm512_store_si512(dest, 5, zmm); mm512_store_si512(dest, 6, zmm); mm512_store_si512(dest, 7, zmm); mm512_store_si512(dest, 8, zmm); mm512_store_si512(dest, 9, zmm); mm512_store_si512(dest, 10, zmm); mm512_store_si512(dest, 11, zmm); mm512_store_si512(dest, 12, zmm); mm512_store_si512(dest, 13, zmm); mm512_store_si512(dest, 14, zmm); mm512_store_si512(dest, 15, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); } static force_inline void memset_mov8x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); mm512_store_si512(dest, 1, zmm); mm512_store_si512(dest, 2, zmm); mm512_store_si512(dest, 3, zmm); mm512_store_si512(dest, 4, zmm); mm512_store_si512(dest, 5, zmm); mm512_store_si512(dest, 6, zmm); mm512_store_si512(dest, 7, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memset_mov4x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); mm512_store_si512(dest, 1, zmm); mm512_store_si512(dest, 2, zmm); mm512_store_si512(dest, 3, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); mm512_store_si512(dest, 1, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m512i zmm, flush64b_fn flush64b) { mm512_store_si512(dest, 0, zmm); flush64b(dest + 0 * 64); } static force_inline void memset_mov_avx512f(char *dest, int c, size_t len, flush_fn flush, flush64b_fn flush64b) { __m512i zmm = _mm512_set1_epi8((char)c); /* See comment in memset_movnt_avx512f */ __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx512f(dest, ymm, cnt, flush); dest += cnt; len -= cnt; } while (len >= 32 * 64) { memset_mov32x64b(dest, zmm, flush64b); dest += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memset_mov16x64b(dest, zmm, flush64b); dest += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memset_mov8x64b(dest, zmm, flush64b); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_mov4x64b(dest, zmm, flush64b); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, zmm, flush64b); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, zmm, flush64b); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_avx512f(dest, ymm, len, flush); avx_zeroupper(); } void memset_mov_avx512f_noflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx512f(dest, c, len, noflush, noflush64b); } void memset_mov_avx512f_empty(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx512f(dest, c, len, flush_empty_nolog, flush64b_empty); } void memset_mov_avx512f_clflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx512f(dest, c, len, flush_clflush_nolog, pmem_clflush); } void memset_mov_avx512f_clflushopt(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx512f(dest, c, len, flush_clflushopt_nolog, pmem_clflushopt); } void memset_mov_avx512f_clwb(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx512f(dest, c, len, flush_clwb_nolog, pmem_clwb); }
6,851
22.958042
69
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_nt_avx512f.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memset_avx512f.h" #include "out.h" #include "util.h" #include "valgrind_internal.h" static force_inline void mm512_stream_si512(char *dest, unsigned idx, __m512i src) { _mm512_stream_si512((__m512i *)dest + idx, src); barrier(); } static force_inline void memset_movnt32x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); mm512_stream_si512(dest, 1, zmm); mm512_stream_si512(dest, 2, zmm); mm512_stream_si512(dest, 3, zmm); mm512_stream_si512(dest, 4, zmm); mm512_stream_si512(dest, 5, zmm); mm512_stream_si512(dest, 6, zmm); mm512_stream_si512(dest, 7, zmm); mm512_stream_si512(dest, 8, zmm); mm512_stream_si512(dest, 9, zmm); mm512_stream_si512(dest, 10, zmm); mm512_stream_si512(dest, 11, zmm); mm512_stream_si512(dest, 12, zmm); mm512_stream_si512(dest, 13, zmm); mm512_stream_si512(dest, 14, zmm); mm512_stream_si512(dest, 15, zmm); mm512_stream_si512(dest, 16, zmm); mm512_stream_si512(dest, 17, zmm); mm512_stream_si512(dest, 18, zmm); mm512_stream_si512(dest, 19, zmm); mm512_stream_si512(dest, 20, zmm); mm512_stream_si512(dest, 21, zmm); mm512_stream_si512(dest, 22, zmm); mm512_stream_si512(dest, 23, zmm); mm512_stream_si512(dest, 24, zmm); mm512_stream_si512(dest, 25, zmm); mm512_stream_si512(dest, 26, zmm); mm512_stream_si512(dest, 27, zmm); mm512_stream_si512(dest, 28, zmm); mm512_stream_si512(dest, 29, zmm); mm512_stream_si512(dest, 30, zmm); mm512_stream_si512(dest, 31, zmm); } static force_inline void memset_movnt16x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); mm512_stream_si512(dest, 1, zmm); mm512_stream_si512(dest, 2, zmm); mm512_stream_si512(dest, 3, zmm); mm512_stream_si512(dest, 4, zmm); mm512_stream_si512(dest, 5, zmm); mm512_stream_si512(dest, 6, zmm); mm512_stream_si512(dest, 7, zmm); mm512_stream_si512(dest, 8, zmm); mm512_stream_si512(dest, 9, zmm); mm512_stream_si512(dest, 10, zmm); mm512_stream_si512(dest, 11, zmm); mm512_stream_si512(dest, 12, zmm); mm512_stream_si512(dest, 13, zmm); mm512_stream_si512(dest, 14, zmm); mm512_stream_si512(dest, 15, zmm); } static force_inline void memset_movnt8x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); mm512_stream_si512(dest, 1, zmm); mm512_stream_si512(dest, 2, zmm); mm512_stream_si512(dest, 3, zmm); mm512_stream_si512(dest, 4, zmm); mm512_stream_si512(dest, 5, zmm); mm512_stream_si512(dest, 6, zmm); mm512_stream_si512(dest, 7, zmm); } static force_inline void memset_movnt4x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); mm512_stream_si512(dest, 1, zmm); mm512_stream_si512(dest, 2, zmm); mm512_stream_si512(dest, 3, zmm); } static force_inline void memset_movnt2x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); mm512_stream_si512(dest, 1, zmm); } static force_inline void memset_movnt1x64b(char *dest, __m512i zmm) { mm512_stream_si512(dest, 0, zmm); } static force_inline void memset_movnt1x32b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest, ymm); } static force_inline void memset_movnt1x16b(char *dest, __m256i ymm) { __m128i xmm = _mm256_extracti128_si256(ymm, 0); _mm_stream_si128((__m128i *)dest, xmm); } static force_inline void memset_movnt1x8b(char *dest, __m256i ymm) { uint64_t x = m256_get8b(ymm); _mm_stream_si64((long long *)dest, (long long)x); } static force_inline void memset_movnt1x4b(char *dest, __m256i ymm) { uint32_t x = m256_get4b(ymm); _mm_stream_si32((int *)dest, (int)x); } static force_inline void memset_movnt_avx512f(char *dest, int c, size_t len, flush_fn flush, barrier_fn barrier) { char *orig_dest = dest; size_t orig_len = len; __m512i zmm = _mm512_set1_epi8((char)c); /* * Can't use _mm512_extracti64x4_epi64, because some versions of gcc * crash. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887 */ __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx512f(dest, ymm, cnt, flush); dest += cnt; len -= cnt; } while (len >= 32 * 64) { memset_movnt32x64b(dest, zmm); dest += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memset_movnt16x64b(dest, zmm); dest += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memset_movnt8x64b(dest, zmm); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_movnt4x64b(dest, zmm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_movnt2x64b(dest, zmm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_movnt1x64b(dest, zmm); dest += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memset_movnt1x32b(dest, ymm); else if (len == 16) memset_movnt1x16b(dest, ymm); else if (len == 8) memset_movnt1x8b(dest, ymm); else if (len == 4) memset_movnt1x4b(dest, ymm); else goto nonnt; goto end; } nonnt: memset_small_avx512f(dest, ymm, len, flush); end: avx_zeroupper(); barrier(); VALGRIND_DO_FLUSH(orig_dest, orig_len); } void memset_movnt_avx512f_noflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_movnt_avx512f(dest, c, len, noflush, barrier_after_ntstores); } void memset_movnt_avx512f_empty(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_movnt_avx512f(dest, c, len, flush_empty_nolog, barrier_after_ntstores); } void memset_movnt_avx512f_clflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_movnt_avx512f(dest, c, len, flush_clflush_nolog, barrier_after_ntstores); } void memset_movnt_avx512f_clflushopt(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_movnt_avx512f(dest, c, len, flush_clflushopt_nolog, no_barrier_after_ntstores); } void memset_movnt_avx512f_clwb(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_movnt_avx512f(dest, c, len, flush_clwb_nolog, no_barrier_after_ntstores); }
6,397
21.607774
71
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_t_sse2.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "flush.h" #include "memcpy_memset.h" #include "memset_sse2.h" static force_inline void mm_store_si128(char *dest, unsigned idx, __m128i src) { _mm_store_si128((__m128i *)dest + idx, src); } static force_inline void memset_mov4x64b(char *dest, __m128i xmm, flush64b_fn flush64b) { mm_store_si128(dest, 0, xmm); mm_store_si128(dest, 1, xmm); mm_store_si128(dest, 2, xmm); mm_store_si128(dest, 3, xmm); mm_store_si128(dest, 4, xmm); mm_store_si128(dest, 5, xmm); mm_store_si128(dest, 6, xmm); mm_store_si128(dest, 7, xmm); mm_store_si128(dest, 8, xmm); mm_store_si128(dest, 9, xmm); mm_store_si128(dest, 10, xmm); mm_store_si128(dest, 11, xmm); mm_store_si128(dest, 12, xmm); mm_store_si128(dest, 13, xmm); mm_store_si128(dest, 14, xmm); mm_store_si128(dest, 15, xmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m128i xmm, flush64b_fn flush64b) { mm_store_si128(dest, 0, xmm); mm_store_si128(dest, 1, xmm); mm_store_si128(dest, 2, xmm); mm_store_si128(dest, 3, xmm); mm_store_si128(dest, 4, xmm); mm_store_si128(dest, 5, xmm); mm_store_si128(dest, 6, xmm); mm_store_si128(dest, 7, xmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m128i xmm, flush64b_fn flush64b) { mm_store_si128(dest, 0, xmm); mm_store_si128(dest, 1, xmm); mm_store_si128(dest, 2, xmm); mm_store_si128(dest, 3, xmm); flush64b(dest + 0 * 64); } static force_inline void memset_mov_sse2(char *dest, int c, size_t len, flush_fn flush, flush64b_fn flush64b) { __m128i xmm = _mm_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_sse2(dest, xmm, cnt, flush); dest += cnt; len -= cnt; } while (len >= 4 * 64) { memset_mov4x64b(dest, xmm, flush64b); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, xmm, flush64b); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, xmm, flush64b); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_sse2(dest, xmm, len, flush); } void memset_mov_sse2_noflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_sse2(dest, c, len, noflush, noflush64b); } void memset_mov_sse2_empty(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_sse2(dest, c, len, flush_empty_nolog, flush64b_empty); } void memset_mov_sse2_clflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_sse2(dest, c, len, flush_clflush_nolog, pmem_clflush); } void memset_mov_sse2_clflushopt(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_sse2(dest, c, len, flush_clflushopt_nolog, pmem_clflushopt); } void memset_mov_sse2_clwb(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_sse2(dest, c, len, flush_clwb_nolog, pmem_clwb); }
3,304
20.461039
66
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_sse2.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #ifndef PMEM2_MEMSET_SSE2_H #define PMEM2_MEMSET_SSE2_H #include <xmmintrin.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include "out.h" static force_inline void memset_small_sse2_noflush(char *dest, __m128i xmm, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; if (len > 48) { /* 49..64 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + 16), xmm); _mm_storeu_si128((__m128i *)(dest + 32), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 33..48 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + 16), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; le32: if (len > 16) { /* 17..32 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 9..16 */ uint64_t d8 = (uint64_t)_mm_cvtsi128_si64(xmm); *(ua_uint64_t *)dest = d8; *(ua_uint64_t *)(dest + len - 8) = d8; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d4 = (uint32_t)_mm_cvtsi128_si32(xmm); *(ua_uint32_t *)dest = d4; *(ua_uint32_t *)(dest + len - 4) = d4; return; } /* 3..4 */ uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm); *(ua_uint16_t *)dest = d2; *(ua_uint16_t *)(dest + len - 2) = d2; return; le2: if (len == 2) { uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm); *(ua_uint16_t *)dest = d2; return; } *(uint8_t *)dest = (uint8_t)_mm_cvtsi128_si32(xmm); } static force_inline void memset_small_sse2(char *dest, __m128i xmm, size_t len, flush_fn flush) { /* * pmemcheck complains about "overwritten stores before they were made * persistent" for overlapping stores (last instruction in each code * path) in the optimized version. * libc's memset also does that, so we can't use it here. */ if (On_pmemcheck) { memset_nodrain_generic(dest, (uint8_t)_mm_cvtsi128_si32(xmm), len, PMEM2_F_MEM_NOFLUSH, NULL); } else { memset_small_sse2_noflush(dest, xmm, len); } flush(dest, len); } #endif
2,213
20.085714
71
h
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memset/memset_t_avx.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memset_avx.h" static force_inline void mm256_store_si256(char *dest, unsigned idx, __m256i src) { _mm256_store_si256((__m256i *)dest + idx, src); } static force_inline void memset_mov8x64b(char *dest, __m256i ymm, flush64b_fn flush64b) { mm256_store_si256(dest, 0, ymm); mm256_store_si256(dest, 1, ymm); mm256_store_si256(dest, 2, ymm); mm256_store_si256(dest, 3, ymm); mm256_store_si256(dest, 4, ymm); mm256_store_si256(dest, 5, ymm); mm256_store_si256(dest, 6, ymm); mm256_store_si256(dest, 7, ymm); mm256_store_si256(dest, 8, ymm); mm256_store_si256(dest, 9, ymm); mm256_store_si256(dest, 10, ymm); mm256_store_si256(dest, 11, ymm); mm256_store_si256(dest, 12, ymm); mm256_store_si256(dest, 13, ymm); mm256_store_si256(dest, 14, ymm); mm256_store_si256(dest, 15, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memset_mov4x64b(char *dest, __m256i ymm, flush64b_fn flush64b) { mm256_store_si256(dest, 0, ymm); mm256_store_si256(dest, 1, ymm); mm256_store_si256(dest, 2, ymm); mm256_store_si256(dest, 3, ymm); mm256_store_si256(dest, 4, ymm); mm256_store_si256(dest, 5, ymm); mm256_store_si256(dest, 6, ymm); mm256_store_si256(dest, 7, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m256i ymm, flush64b_fn flush64b) { mm256_store_si256(dest, 0, ymm); mm256_store_si256(dest, 1, ymm); mm256_store_si256(dest, 2, ymm); mm256_store_si256(dest, 3, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m256i ymm, flush64b_fn flush64b) { mm256_store_si256(dest, 0, ymm); mm256_store_si256(dest, 1, ymm); flush64b(dest + 0 * 64); } static force_inline void memset_mov_avx(char *dest, int c, size_t len, flush_fn flush, flush64b_fn flush64b) { __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx(dest, ymm, cnt, flush); dest += cnt; len -= cnt; } while (len >= 8 * 64) { memset_mov8x64b(dest, ymm, flush64b); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_mov4x64b(dest, ymm, flush64b); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, ymm, flush64b); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, ymm, flush64b); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_avx(dest, ymm, len, flush); avx_zeroupper(); } void memset_mov_avx_noflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx(dest, c, len, noflush, noflush64b); } void memset_mov_avx_empty(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx(dest, c, len, flush_empty_nolog, flush64b_empty); } void memset_mov_avx_clflush(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx(dest, c, len, flush_clflush_nolog, pmem_clflush); } void memset_mov_avx_clflushopt(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx(dest, c, len, flush_clflushopt_nolog, pmem_clflushopt); } void memset_mov_avx_clwb(char *dest, int c, size_t len) { LOG(15, "dest %p c %d len %zu", dest, c, len); memset_mov_avx(dest, c, len, flush_clwb_nolog, pmem_clwb); }
3,890
20.73743
65
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_t_sse2.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_sse2.h" #include "out.h" static force_inline __m128i mm_loadu_si128(const char *src, unsigned idx) { return _mm_loadu_si128((const __m128i *)src + idx); } static force_inline void mm_store_si128(char *dest, unsigned idx, __m128i src) { _mm_store_si128((__m128i *)dest + idx, src); } static force_inline void memmove_mov4x64b(char *dest, const char *src, flush64b_fn flush64b) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); __m128i xmm4 = mm_loadu_si128(src, 4); __m128i xmm5 = mm_loadu_si128(src, 5); __m128i xmm6 = mm_loadu_si128(src, 6); __m128i xmm7 = mm_loadu_si128(src, 7); __m128i xmm8 = mm_loadu_si128(src, 8); __m128i xmm9 = mm_loadu_si128(src, 9); __m128i xmm10 = mm_loadu_si128(src, 10); __m128i xmm11 = mm_loadu_si128(src, 11); __m128i xmm12 = mm_loadu_si128(src, 12); __m128i xmm13 = mm_loadu_si128(src, 13); __m128i xmm14 = mm_loadu_si128(src, 14); __m128i xmm15 = mm_loadu_si128(src, 15); mm_store_si128(dest, 0, xmm0); mm_store_si128(dest, 1, xmm1); mm_store_si128(dest, 2, xmm2); mm_store_si128(dest, 3, xmm3); mm_store_si128(dest, 4, xmm4); mm_store_si128(dest, 5, xmm5); mm_store_si128(dest, 6, xmm6); mm_store_si128(dest, 7, xmm7); mm_store_si128(dest, 8, xmm8); mm_store_si128(dest, 9, xmm9); mm_store_si128(dest, 10, xmm10); mm_store_si128(dest, 11, xmm11); mm_store_si128(dest, 12, xmm12); mm_store_si128(dest, 13, xmm13); mm_store_si128(dest, 14, xmm14); mm_store_si128(dest, 15, xmm15); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memmove_mov2x64b(char *dest, const char *src, flush64b_fn flush64b) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); __m128i xmm4 = mm_loadu_si128(src, 4); __m128i xmm5 = mm_loadu_si128(src, 5); __m128i xmm6 = mm_loadu_si128(src, 6); __m128i xmm7 = mm_loadu_si128(src, 7); mm_store_si128(dest, 0, xmm0); mm_store_si128(dest, 1, xmm1); mm_store_si128(dest, 2, xmm2); mm_store_si128(dest, 3, xmm3); mm_store_si128(dest, 4, xmm4); mm_store_si128(dest, 5, xmm5); mm_store_si128(dest, 6, xmm6); mm_store_si128(dest, 7, xmm7); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memmove_mov1x64b(char *dest, const char *src, flush64b_fn flush64b) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); mm_store_si128(dest, 0, xmm0); mm_store_si128(dest, 1, xmm1); mm_store_si128(dest, 2, xmm2); mm_store_si128(dest, 3, xmm3); flush64b(dest + 0 * 64); } static force_inline void memmove_mov_sse_fw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_sse2(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } while (len >= 4 * 64) { memmove_mov4x64b(dest, src, flush64b); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_mov2x64b(dest, src, flush64b); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_mov1x64b(dest, src, flush64b); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len) memmove_small_sse2(dest, src, len, flush); } static force_inline void memmove_mov_sse_bw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_sse2(dest, src, cnt, flush); } while (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_mov4x64b(dest, src, flush64b); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_mov2x64b(dest, src, flush64b); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_mov1x64b(dest, src, flush64b); } if (len) memmove_small_sse2(dest - len, src - len, len, flush); } static force_inline void memmove_mov_sse2(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_mov_sse_fw(dest, src, len, flush, flush64b); else memmove_mov_sse_bw(dest, src, len, flush, flush64b); } void memmove_mov_sse2_noflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_sse2(dest, src, len, noflush, noflush64b); } void memmove_mov_sse2_empty(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_sse2(dest, src, len, flush_empty_nolog, flush64b_empty); } void memmove_mov_sse2_clflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_sse2(dest, src, len, flush_clflush_nolog, pmem_clflush); } void memmove_mov_sse2_clflushopt(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_sse2(dest, src, len, flush_clflushopt_nolog, pmem_clflushopt); } void memmove_mov_sse2_clwb(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_sse2(dest, src, len, flush_clwb_nolog, pmem_clwb); }
5,820
22.566802
69
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_avx.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #ifndef PMEM2_MEMCPY_AVX_H #define PMEM2_MEMCPY_AVX_H #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "out.h" static force_inline void memmove_small_avx_noflush(char *dest, const char *src, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; /* 33..64 */ __m256i ymm0 = _mm256_loadu_si256((__m256i *)src); __m256i ymm1 = _mm256_loadu_si256((__m256i *)(src + len - 32)); _mm256_storeu_si256((__m256i *)dest, ymm0); _mm256_storeu_si256((__m256i *)(dest + len - 32), ymm1); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm1); return; } /* 9..16 */ ua_uint64_t d80 = *(ua_uint64_t *)src; ua_uint64_t d81 = *(ua_uint64_t *)(src + len - 8); *(ua_uint64_t *)dest = d80; *(ua_uint64_t *)(dest + len - 8) = d81; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ ua_uint32_t d40 = *(ua_uint32_t *)src; ua_uint32_t d41 = *(ua_uint32_t *)(src + len - 4); *(ua_uint32_t *)dest = d40; *(ua_uint32_t *)(dest + len - 4) = d41; return; } /* 3..4 */ ua_uint16_t d20 = *(ua_uint16_t *)src; ua_uint16_t d21 = *(ua_uint16_t *)(src + len - 2); *(ua_uint16_t *)dest = d20; *(ua_uint16_t *)(dest + len - 2) = d21; return; le2: if (len == 2) { *(ua_uint16_t *)dest = *(ua_uint16_t *)src; return; } *(uint8_t *)dest = *(uint8_t *)src; } static force_inline void memmove_small_avx(char *dest, const char *src, size_t len, flush_fn flush) { /* * pmemcheck complains about "overwritten stores before they were made * persistent" for overlapping stores (last instruction in each code * path) in the optimized version. * libc's memcpy also does that, so we can't use it here. */ if (On_pmemcheck) { memmove_nodrain_generic(dest, src, len, PMEM2_F_MEM_NOFLUSH, NULL); } else { memmove_small_avx_noflush(dest, src, len); } flush(dest, len); } #endif
2,173
20.524752
74
h
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_t_avx.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_avx.h" static force_inline __m256i mm256_loadu_si256(const char *src, unsigned idx) { return _mm256_loadu_si256((const __m256i *)src + idx); } static force_inline void mm256_store_si256(char *dest, unsigned idx, __m256i src) { _mm256_store_si256((__m256i *)dest + idx, src); } static force_inline void memmove_mov8x64b(char *dest, const char *src, flush64b_fn flush64b) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); __m256i ymm4 = mm256_loadu_si256(src, 4); __m256i ymm5 = mm256_loadu_si256(src, 5); __m256i ymm6 = mm256_loadu_si256(src, 6); __m256i ymm7 = mm256_loadu_si256(src, 7); __m256i ymm8 = mm256_loadu_si256(src, 8); __m256i ymm9 = mm256_loadu_si256(src, 9); __m256i ymm10 = mm256_loadu_si256(src, 10); __m256i ymm11 = mm256_loadu_si256(src, 11); __m256i ymm12 = mm256_loadu_si256(src, 12); __m256i ymm13 = mm256_loadu_si256(src, 13); __m256i ymm14 = mm256_loadu_si256(src, 14); __m256i ymm15 = mm256_loadu_si256(src, 15); mm256_store_si256(dest, 0, ymm0); mm256_store_si256(dest, 1, ymm1); mm256_store_si256(dest, 2, ymm2); mm256_store_si256(dest, 3, ymm3); mm256_store_si256(dest, 4, ymm4); mm256_store_si256(dest, 5, ymm5); mm256_store_si256(dest, 6, ymm6); mm256_store_si256(dest, 7, ymm7); mm256_store_si256(dest, 8, ymm8); mm256_store_si256(dest, 9, ymm9); mm256_store_si256(dest, 10, ymm10); mm256_store_si256(dest, 11, ymm11); mm256_store_si256(dest, 12, ymm12); mm256_store_si256(dest, 13, ymm13); mm256_store_si256(dest, 14, ymm14); mm256_store_si256(dest, 15, ymm15); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memmove_mov4x64b(char *dest, const char *src, flush64b_fn flush64b) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); __m256i ymm4 = mm256_loadu_si256(src, 4); __m256i ymm5 = mm256_loadu_si256(src, 5); __m256i ymm6 = mm256_loadu_si256(src, 6); __m256i ymm7 = mm256_loadu_si256(src, 7); mm256_store_si256(dest, 0, ymm0); mm256_store_si256(dest, 1, ymm1); mm256_store_si256(dest, 2, ymm2); mm256_store_si256(dest, 3, ymm3); mm256_store_si256(dest, 4, ymm4); mm256_store_si256(dest, 5, ymm5); mm256_store_si256(dest, 6, ymm6); mm256_store_si256(dest, 7, ymm7); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memmove_mov2x64b(char *dest, const char *src, flush64b_fn flush64b) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); mm256_store_si256(dest, 0, ymm0); mm256_store_si256(dest, 1, ymm1); mm256_store_si256(dest, 2, ymm2); mm256_store_si256(dest, 3, ymm3); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memmove_mov1x64b(char *dest, const char *src, flush64b_fn flush64b) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); mm256_store_si256(dest, 0, ymm0); mm256_store_si256(dest, 1, ymm1); flush64b(dest + 0 * 64); } static force_inline void memmove_mov_avx_fw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_avx(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } while (len >= 8 * 64) { memmove_mov8x64b(dest, src, flush64b); dest += 8 * 64; src += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memmove_mov4x64b(dest, src, flush64b); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_mov2x64b(dest, src, flush64b); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_mov1x64b(dest, src, flush64b); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len) memmove_small_avx(dest, src, len, flush); } static force_inline void memmove_mov_avx_bw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_avx(dest, src, cnt, flush); } while (len >= 8 * 64) { dest -= 8 * 64; src -= 8 * 64; len -= 8 * 64; memmove_mov8x64b(dest, src, flush64b); } if (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_mov4x64b(dest, src, flush64b); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_mov2x64b(dest, src, flush64b); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_mov1x64b(dest, src, flush64b); } if (len) memmove_small_avx(dest - len, src - len, len, flush); } static force_inline void memmove_mov_avx(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_mov_avx_fw(dest, src, len, flush, flush64b); else memmove_mov_avx_bw(dest, src, len, flush, flush64b); avx_zeroupper(); } void memmove_mov_avx_noflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx(dest, src, len, noflush, noflush64b); } void memmove_mov_avx_empty(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx(dest, src, len, flush_empty_nolog, flush64b_empty); } void memmove_mov_avx_clflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx(dest, src, len, flush_clflush_nolog, pmem_clflush); } void memmove_mov_avx_clflushopt(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx(dest, src, len, flush_clflushopt_nolog, pmem_clflushopt); } void memmove_mov_avx_clwb(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx(dest, src, len, flush_clwb_nolog, pmem_clwb); }
6,705
22.780142
68
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_t_avx512f.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_avx512f.h" static force_inline __m512i mm512_loadu_si512(const char *src, unsigned idx) { return _mm512_loadu_si512((const __m512i *)src + idx); } static force_inline void mm512_store_si512(char *dest, unsigned idx, __m512i src) { _mm512_store_si512((__m512i *)dest + idx, src); } static force_inline void memmove_mov32x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); __m512i zmm8 = mm512_loadu_si512(src, 8); __m512i zmm9 = mm512_loadu_si512(src, 9); __m512i zmm10 = mm512_loadu_si512(src, 10); __m512i zmm11 = mm512_loadu_si512(src, 11); __m512i zmm12 = mm512_loadu_si512(src, 12); __m512i zmm13 = mm512_loadu_si512(src, 13); __m512i zmm14 = mm512_loadu_si512(src, 14); __m512i zmm15 = mm512_loadu_si512(src, 15); __m512i zmm16 = mm512_loadu_si512(src, 16); __m512i zmm17 = mm512_loadu_si512(src, 17); __m512i zmm18 = mm512_loadu_si512(src, 18); __m512i zmm19 = mm512_loadu_si512(src, 19); __m512i zmm20 = mm512_loadu_si512(src, 20); __m512i zmm21 = mm512_loadu_si512(src, 21); __m512i zmm22 = mm512_loadu_si512(src, 22); __m512i zmm23 = mm512_loadu_si512(src, 23); __m512i zmm24 = mm512_loadu_si512(src, 24); __m512i zmm25 = mm512_loadu_si512(src, 25); __m512i zmm26 = mm512_loadu_si512(src, 26); __m512i zmm27 = mm512_loadu_si512(src, 27); __m512i zmm28 = mm512_loadu_si512(src, 28); __m512i zmm29 = mm512_loadu_si512(src, 29); __m512i zmm30 = mm512_loadu_si512(src, 30); __m512i zmm31 = mm512_loadu_si512(src, 31); mm512_store_si512(dest, 0, zmm0); mm512_store_si512(dest, 1, zmm1); mm512_store_si512(dest, 2, zmm2); mm512_store_si512(dest, 3, zmm3); mm512_store_si512(dest, 4, zmm4); mm512_store_si512(dest, 5, zmm5); mm512_store_si512(dest, 6, zmm6); mm512_store_si512(dest, 7, zmm7); mm512_store_si512(dest, 8, zmm8); mm512_store_si512(dest, 9, zmm9); mm512_store_si512(dest, 10, zmm10); mm512_store_si512(dest, 11, zmm11); mm512_store_si512(dest, 12, zmm12); mm512_store_si512(dest, 13, zmm13); mm512_store_si512(dest, 14, zmm14); mm512_store_si512(dest, 15, zmm15); mm512_store_si512(dest, 16, zmm16); mm512_store_si512(dest, 17, zmm17); mm512_store_si512(dest, 18, zmm18); mm512_store_si512(dest, 19, zmm19); mm512_store_si512(dest, 20, zmm20); mm512_store_si512(dest, 21, zmm21); mm512_store_si512(dest, 22, zmm22); mm512_store_si512(dest, 23, zmm23); mm512_store_si512(dest, 24, zmm24); mm512_store_si512(dest, 25, zmm25); mm512_store_si512(dest, 26, zmm26); mm512_store_si512(dest, 27, zmm27); mm512_store_si512(dest, 28, zmm28); mm512_store_si512(dest, 29, zmm29); mm512_store_si512(dest, 30, zmm30); mm512_store_si512(dest, 31, zmm31); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); flush64b(dest + 16 * 64); flush64b(dest + 17 * 64); flush64b(dest + 18 * 64); flush64b(dest + 19 * 64); flush64b(dest + 20 * 64); flush64b(dest + 21 * 64); flush64b(dest + 22 * 64); flush64b(dest + 23 * 64); flush64b(dest + 24 * 64); flush64b(dest + 25 * 64); flush64b(dest + 26 * 64); flush64b(dest + 27 * 64); flush64b(dest + 28 * 64); flush64b(dest + 29 * 64); flush64b(dest + 30 * 64); flush64b(dest + 31 * 64); } static force_inline void memmove_mov16x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); __m512i zmm8 = mm512_loadu_si512(src, 8); __m512i zmm9 = mm512_loadu_si512(src, 9); __m512i zmm10 = mm512_loadu_si512(src, 10); __m512i zmm11 = mm512_loadu_si512(src, 11); __m512i zmm12 = mm512_loadu_si512(src, 12); __m512i zmm13 = mm512_loadu_si512(src, 13); __m512i zmm14 = mm512_loadu_si512(src, 14); __m512i zmm15 = mm512_loadu_si512(src, 15); mm512_store_si512(dest, 0, zmm0); mm512_store_si512(dest, 1, zmm1); mm512_store_si512(dest, 2, zmm2); mm512_store_si512(dest, 3, zmm3); mm512_store_si512(dest, 4, zmm4); mm512_store_si512(dest, 5, zmm5); mm512_store_si512(dest, 6, zmm6); mm512_store_si512(dest, 7, zmm7); mm512_store_si512(dest, 8, zmm8); mm512_store_si512(dest, 9, zmm9); mm512_store_si512(dest, 10, zmm10); mm512_store_si512(dest, 11, zmm11); mm512_store_si512(dest, 12, zmm12); mm512_store_si512(dest, 13, zmm13); mm512_store_si512(dest, 14, zmm14); mm512_store_si512(dest, 15, zmm15); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); } static force_inline void memmove_mov8x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); mm512_store_si512(dest, 0, zmm0); mm512_store_si512(dest, 1, zmm1); mm512_store_si512(dest, 2, zmm2); mm512_store_si512(dest, 3, zmm3); mm512_store_si512(dest, 4, zmm4); mm512_store_si512(dest, 5, zmm5); mm512_store_si512(dest, 6, zmm6); mm512_store_si512(dest, 7, zmm7); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memmove_mov4x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); mm512_store_si512(dest, 0, zmm0); mm512_store_si512(dest, 1, zmm1); mm512_store_si512(dest, 2, zmm2); mm512_store_si512(dest, 3, zmm3); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memmove_mov2x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); mm512_store_si512(dest, 0, zmm0); mm512_store_si512(dest, 1, zmm1); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memmove_mov1x64b(char *dest, const char *src, flush64b_fn flush64b) { __m512i zmm0 = mm512_loadu_si512(src, 0); mm512_store_si512(dest, 0, zmm0); flush64b(dest + 0 * 64); } static force_inline void memmove_mov_avx512f_fw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_avx512f(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } while (len >= 32 * 64) { memmove_mov32x64b(dest, src, flush64b); dest += 32 * 64; src += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memmove_mov16x64b(dest, src, flush64b); dest += 16 * 64; src += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memmove_mov8x64b(dest, src, flush64b); dest += 8 * 64; src += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memmove_mov4x64b(dest, src, flush64b); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_mov2x64b(dest, src, flush64b); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_mov1x64b(dest, src, flush64b); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len) memmove_small_avx512f(dest, src, len, flush); } static force_inline void memmove_mov_avx512f_bw(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_avx512f(dest, src, cnt, flush); } while (len >= 32 * 64) { dest -= 32 * 64; src -= 32 * 64; len -= 32 * 64; memmove_mov32x64b(dest, src, flush64b); } if (len >= 16 * 64) { dest -= 16 * 64; src -= 16 * 64; len -= 16 * 64; memmove_mov16x64b(dest, src, flush64b); } if (len >= 8 * 64) { dest -= 8 * 64; src -= 8 * 64; len -= 8 * 64; memmove_mov8x64b(dest, src, flush64b); } if (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_mov4x64b(dest, src, flush64b); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_mov2x64b(dest, src, flush64b); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_mov1x64b(dest, src, flush64b); } if (len) memmove_small_avx512f(dest - len, src - len, len, flush); } static force_inline void memmove_mov_avx512f(char *dest, const char *src, size_t len, flush_fn flush, flush64b_fn flush64b) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_mov_avx512f_fw(dest, src, len, flush, flush64b); else memmove_mov_avx512f_bw(dest, src, len, flush, flush64b); avx_zeroupper(); } void memmove_mov_avx512f_noflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx512f(dest, src, len, noflush, noflush64b); } void memmove_mov_avx512f_empty(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx512f(dest, src, len, flush_empty_nolog, flush64b_empty); } void memmove_mov_avx512f_clflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx512f(dest, src, len, flush_clflush_nolog, pmem_clflush); } void memmove_mov_avx512f_clflushopt(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx512f(dest, src, len, flush_clflushopt_nolog, pmem_clflushopt); } void memmove_mov_avx512f_clwb(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_mov_avx512f(dest, src, len, flush_clwb_nolog, pmem_clwb); }
11,422
25.020501
72
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_sse2.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #ifndef PMEM2_MEMCPY_SSE2_H #define PMEM2_MEMCPY_SSE2_H #include <xmmintrin.h> #include <stddef.h> #include <stdint.h> #include "out.h" static force_inline void memmove_small_sse2_noflush(char *dest, const char *src, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; if (len > 48) { /* 49..64 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16)); __m128i xmm2 = _mm_loadu_si128((__m128i *)(src + 32)); __m128i xmm3 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + 16), xmm1); _mm_storeu_si128((__m128i *)(dest + 32), xmm2); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm3); return; } /* 33..48 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16)); __m128i xmm2 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + 16), xmm1); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm2); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm1); return; } /* 9..16 */ uint64_t d80 = *(ua_uint64_t *)src; uint64_t d81 = *(ua_uint64_t *)(src + len - 8); *(ua_uint64_t *)dest = d80; *(ua_uint64_t *)(dest + len - 8) = d81; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d40 = *(ua_uint32_t *)src; uint32_t d41 = *(ua_uint32_t *)(src + len - 4); *(ua_uint32_t *)dest = d40; *(ua_uint32_t *)(dest + len - 4) = d41; return; } /* 3..4 */ uint16_t d20 = *(ua_uint16_t *)src; uint16_t d21 = *(ua_uint16_t *)(src + len - 2); *(ua_uint16_t *)dest = d20; *(ua_uint16_t *)(dest + len - 2) = d21; return; le2: if (len == 2) { *(ua_uint16_t *)dest = *(ua_uint16_t *)src; return; } *(uint8_t *)dest = *(uint8_t *)src; } static force_inline void memmove_small_sse2(char *dest, const char *src, size_t len, flush_fn flush) { /* * pmemcheck complains about "overwritten stores before they were made * persistent" for overlapping stores (last instruction in each code * path) in the optimized version. * libc's memcpy also does that, so we can't use it here. */ if (On_pmemcheck) { memmove_nodrain_generic(dest, src, len, PMEM2_F_MEM_NOFLUSH, NULL); } else { memmove_small_sse2_noflush(dest, src, len); } flush(dest, len); } #endif
2,726
22.307692
75
h
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_nt_avx.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_avx.h" #include "valgrind_internal.h" static force_inline __m256i mm256_loadu_si256(const char *src, unsigned idx) { return _mm256_loadu_si256((const __m256i *)src + idx); } static force_inline void mm256_stream_si256(char *dest, unsigned idx, __m256i src) { _mm256_stream_si256((__m256i *)dest + idx, src); barrier(); } static force_inline void memmove_movnt8x64b(char *dest, const char *src) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); __m256i ymm4 = mm256_loadu_si256(src, 4); __m256i ymm5 = mm256_loadu_si256(src, 5); __m256i ymm6 = mm256_loadu_si256(src, 6); __m256i ymm7 = mm256_loadu_si256(src, 7); __m256i ymm8 = mm256_loadu_si256(src, 8); __m256i ymm9 = mm256_loadu_si256(src, 9); __m256i ymm10 = mm256_loadu_si256(src, 10); __m256i ymm11 = mm256_loadu_si256(src, 11); __m256i ymm12 = mm256_loadu_si256(src, 12); __m256i ymm13 = mm256_loadu_si256(src, 13); __m256i ymm14 = mm256_loadu_si256(src, 14); __m256i ymm15 = mm256_loadu_si256(src, 15); mm256_stream_si256(dest, 0, ymm0); mm256_stream_si256(dest, 1, ymm1); mm256_stream_si256(dest, 2, ymm2); mm256_stream_si256(dest, 3, ymm3); mm256_stream_si256(dest, 4, ymm4); mm256_stream_si256(dest, 5, ymm5); mm256_stream_si256(dest, 6, ymm6); mm256_stream_si256(dest, 7, ymm7); mm256_stream_si256(dest, 8, ymm8); mm256_stream_si256(dest, 9, ymm9); mm256_stream_si256(dest, 10, ymm10); mm256_stream_si256(dest, 11, ymm11); mm256_stream_si256(dest, 12, ymm12); mm256_stream_si256(dest, 13, ymm13); mm256_stream_si256(dest, 14, ymm14); mm256_stream_si256(dest, 15, ymm15); } static force_inline void memmove_movnt4x64b(char *dest, const char *src) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); __m256i ymm4 = mm256_loadu_si256(src, 4); __m256i ymm5 = mm256_loadu_si256(src, 5); __m256i ymm6 = mm256_loadu_si256(src, 6); __m256i ymm7 = mm256_loadu_si256(src, 7); mm256_stream_si256(dest, 0, ymm0); mm256_stream_si256(dest, 1, ymm1); mm256_stream_si256(dest, 2, ymm2); mm256_stream_si256(dest, 3, ymm3); mm256_stream_si256(dest, 4, ymm4); mm256_stream_si256(dest, 5, ymm5); mm256_stream_si256(dest, 6, ymm6); mm256_stream_si256(dest, 7, ymm7); } static force_inline void memmove_movnt2x64b(char *dest, const char *src) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); __m256i ymm2 = mm256_loadu_si256(src, 2); __m256i ymm3 = mm256_loadu_si256(src, 3); mm256_stream_si256(dest, 0, ymm0); mm256_stream_si256(dest, 1, ymm1); mm256_stream_si256(dest, 2, ymm2); mm256_stream_si256(dest, 3, ymm3); } static force_inline void memmove_movnt1x64b(char *dest, const char *src) { __m256i ymm0 = mm256_loadu_si256(src, 0); __m256i ymm1 = mm256_loadu_si256(src, 1); mm256_stream_si256(dest, 0, ymm0); mm256_stream_si256(dest, 1, ymm1); } static force_inline void memmove_movnt1x32b(char *dest, const char *src) { __m256i ymm0 = _mm256_loadu_si256((__m256i *)src); mm256_stream_si256(dest, 0, ymm0); } static force_inline void memmove_movnt1x16b(char *dest, const char *src) { __m128i xmm0 = _mm_loadu_si128((__m128i *)src); _mm_stream_si128((__m128i *)dest, xmm0); } static force_inline void memmove_movnt1x8b(char *dest, const char *src) { _mm_stream_si64((long long *)dest, *(long long *)src); } static force_inline void memmove_movnt1x4b(char *dest, const char *src) { _mm_stream_si32((int *)dest, *(int *)src); } static force_inline void memmove_movnt_avx_fw(char *dest, const char *src, size_t len, flush_fn flush, perf_barrier_fn perf_barrier) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_avx(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } const char *srcend = src + len; prefetch_ini_fw(src, len); while (len >= PERF_BARRIER_SIZE) { prefetch_next_fw(src, srcend); memmove_movnt8x64b(dest, src); dest += 8 * 64; src += 8 * 64; len -= 8 * 64; memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; COMPILE_ERROR_ON(PERF_BARRIER_SIZE != (8 + 4) * 64); if (len) perf_barrier(); } if (len >= 8 * 64) { memmove_movnt8x64b(dest, src); dest += 8 * 64; src += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_movnt2x64b(dest, src); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_movnt1x64b(dest, src); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memmove_movnt1x32b(dest, src); else if (len == 16) memmove_movnt1x16b(dest, src); else if (len == 8) memmove_movnt1x8b(dest, src); else if (len == 4) memmove_movnt1x4b(dest, src); else goto nonnt; goto end; } nonnt: memmove_small_avx(dest, src, len, flush); end: avx_zeroupper(); } static force_inline void memmove_movnt_avx_bw(char *dest, const char *src, size_t len, flush_fn flush, perf_barrier_fn perf_barrier) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_avx(dest, src, cnt, flush); } const char *srcbegin = src - len; prefetch_ini_bw(src, len); while (len >= PERF_BARRIER_SIZE) { prefetch_next_bw(src, srcbegin); dest -= 8 * 64; src -= 8 * 64; len -= 8 * 64; memmove_movnt8x64b(dest, src); dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); COMPILE_ERROR_ON(PERF_BARRIER_SIZE != (8 + 4) * 64); if (len) perf_barrier(); } if (len >= 8 * 64) { dest -= 8 * 64; src -= 8 * 64; len -= 8 * 64; memmove_movnt8x64b(dest, src); } if (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_movnt2x64b(dest, src); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_movnt1x64b(dest, src); } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) { dest -= 32; src -= 32; memmove_movnt1x32b(dest, src); } else if (len == 16) { dest -= 16; src -= 16; memmove_movnt1x16b(dest, src); } else if (len == 8) { dest -= 8; src -= 8; memmove_movnt1x8b(dest, src); } else if (len == 4) { dest -= 4; src -= 4; memmove_movnt1x4b(dest, src); } else { goto nonnt; } goto end; } nonnt: dest -= len; src -= len; memmove_small_avx(dest, src, len, flush); end: avx_zeroupper(); } static force_inline void memmove_movnt_avx(char *dest, const char *src, size_t len, flush_fn flush, barrier_fn barrier, perf_barrier_fn perf_barrier) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_movnt_avx_fw(dest, src, len, flush, perf_barrier); else memmove_movnt_avx_bw(dest, src, len, flush, perf_barrier); barrier(); VALGRIND_DO_FLUSH(dest, len); } /* variants without perf_barrier */ void memmove_movnt_avx_noflush_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, noflush, barrier_after_ntstores, no_barrier); } void memmove_movnt_avx_empty_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_empty_nolog, barrier_after_ntstores, no_barrier); } void memmove_movnt_avx_clflush_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clflush_nolog, barrier_after_ntstores, no_barrier); } void memmove_movnt_avx_clflushopt_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clflushopt_nolog, no_barrier_after_ntstores, no_barrier); } void memmove_movnt_avx_clwb_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clwb_nolog, no_barrier_after_ntstores, no_barrier); } /* variants with perf_barrier */ void memmove_movnt_avx_noflush_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, noflush, barrier_after_ntstores, wc_barrier); } void memmove_movnt_avx_empty_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_empty_nolog, barrier_after_ntstores, wc_barrier); } void memmove_movnt_avx_clflush_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clflush_nolog, barrier_after_ntstores, wc_barrier); } void memmove_movnt_avx_clflushopt_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clflushopt_nolog, no_barrier_after_ntstores, wc_barrier); } void memmove_movnt_avx_clwb_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx(dest, src, len, flush_clwb_nolog, no_barrier_after_ntstores, wc_barrier); }
10,092
21.731982
79
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_avx512f.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #ifndef PMEM2_MEMCPY_AVX512F_H #define PMEM2_MEMCPY_AVX512F_H #include <stddef.h> #include "memcpy_avx.h" static force_inline void memmove_small_avx512f(char *dest, const char *src, size_t len, flush_fn flush) { /* We can't do better than AVX here. */ memmove_small_avx(dest, src, len, flush); } #endif
396
19.894737
78
h
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_nt_sse2.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_sse2.h" #include "valgrind_internal.h" static force_inline __m128i mm_loadu_si128(const char *src, unsigned idx) { return _mm_loadu_si128((const __m128i *)src + idx); } static force_inline void mm_stream_si128(char *dest, unsigned idx, __m128i src) { _mm_stream_si128((__m128i *)dest + idx, src); barrier(); } static force_inline void memmove_movnt4x64b(char *dest, const char *src) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); __m128i xmm4 = mm_loadu_si128(src, 4); __m128i xmm5 = mm_loadu_si128(src, 5); __m128i xmm6 = mm_loadu_si128(src, 6); __m128i xmm7 = mm_loadu_si128(src, 7); __m128i xmm8 = mm_loadu_si128(src, 8); __m128i xmm9 = mm_loadu_si128(src, 9); __m128i xmm10 = mm_loadu_si128(src, 10); __m128i xmm11 = mm_loadu_si128(src, 11); __m128i xmm12 = mm_loadu_si128(src, 12); __m128i xmm13 = mm_loadu_si128(src, 13); __m128i xmm14 = mm_loadu_si128(src, 14); __m128i xmm15 = mm_loadu_si128(src, 15); mm_stream_si128(dest, 0, xmm0); mm_stream_si128(dest, 1, xmm1); mm_stream_si128(dest, 2, xmm2); mm_stream_si128(dest, 3, xmm3); mm_stream_si128(dest, 4, xmm4); mm_stream_si128(dest, 5, xmm5); mm_stream_si128(dest, 6, xmm6); mm_stream_si128(dest, 7, xmm7); mm_stream_si128(dest, 8, xmm8); mm_stream_si128(dest, 9, xmm9); mm_stream_si128(dest, 10, xmm10); mm_stream_si128(dest, 11, xmm11); mm_stream_si128(dest, 12, xmm12); mm_stream_si128(dest, 13, xmm13); mm_stream_si128(dest, 14, xmm14); mm_stream_si128(dest, 15, xmm15); } static force_inline void memmove_movnt2x64b(char *dest, const char *src) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); __m128i xmm4 = mm_loadu_si128(src, 4); __m128i xmm5 = mm_loadu_si128(src, 5); __m128i xmm6 = mm_loadu_si128(src, 6); __m128i xmm7 = mm_loadu_si128(src, 7); mm_stream_si128(dest, 0, xmm0); mm_stream_si128(dest, 1, xmm1); mm_stream_si128(dest, 2, xmm2); mm_stream_si128(dest, 3, xmm3); mm_stream_si128(dest, 4, xmm4); mm_stream_si128(dest, 5, xmm5); mm_stream_si128(dest, 6, xmm6); mm_stream_si128(dest, 7, xmm7); } static force_inline void memmove_movnt1x64b(char *dest, const char *src) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); __m128i xmm2 = mm_loadu_si128(src, 2); __m128i xmm3 = mm_loadu_si128(src, 3); mm_stream_si128(dest, 0, xmm0); mm_stream_si128(dest, 1, xmm1); mm_stream_si128(dest, 2, xmm2); mm_stream_si128(dest, 3, xmm3); } static force_inline void memmove_movnt1x32b(char *dest, const char *src) { __m128i xmm0 = mm_loadu_si128(src, 0); __m128i xmm1 = mm_loadu_si128(src, 1); mm_stream_si128(dest, 0, xmm0); mm_stream_si128(dest, 1, xmm1); } static force_inline void memmove_movnt1x16b(char *dest, const char *src) { __m128i xmm0 = mm_loadu_si128(src, 0); mm_stream_si128(dest, 0, xmm0); } static force_inline void memmove_movnt1x8b(char *dest, const char *src) { _mm_stream_si64((long long *)dest, *(long long *)src); } static force_inline void memmove_movnt1x4b(char *dest, const char *src) { _mm_stream_si32((int *)dest, *(int *)src); } static force_inline void memmove_movnt_sse_fw(char *dest, const char *src, size_t len, flush_fn flush, perf_barrier_fn perf_barrier) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_sse2(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } const char *srcend = src + len; prefetch_ini_fw(src, len); while (len >= PERF_BARRIER_SIZE) { prefetch_next_fw(src, srcend); memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; COMPILE_ERROR_ON(PERF_BARRIER_SIZE != (4 + 4 + 4) * 64); if (len) perf_barrier(); } while (len >= 4 * 64) { memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_movnt2x64b(dest, src); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_movnt1x64b(dest, src); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len == 0) return; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memmove_movnt1x32b(dest, src); else if (len == 16) memmove_movnt1x16b(dest, src); else if (len == 8) memmove_movnt1x8b(dest, src); else if (len == 4) memmove_movnt1x4b(dest, src); else goto nonnt; return; } nonnt: memmove_small_sse2(dest, src, len, flush); } static force_inline void memmove_movnt_sse_bw(char *dest, const char *src, size_t len, flush_fn flush, perf_barrier_fn perf_barrier) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_sse2(dest, src, cnt, flush); } const char *srcbegin = src - len; prefetch_ini_bw(src, len); while (len >= PERF_BARRIER_SIZE) { prefetch_next_bw(src, srcbegin); dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); COMPILE_ERROR_ON(PERF_BARRIER_SIZE != (4 + 4 + 4) * 64); if (len) perf_barrier(); } while (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_movnt2x64b(dest, src); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_movnt1x64b(dest, src); } if (len == 0) return; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) { dest -= 32; src -= 32; memmove_movnt1x32b(dest, src); } else if (len == 16) { dest -= 16; src -= 16; memmove_movnt1x16b(dest, src); } else if (len == 8) { dest -= 8; src -= 8; memmove_movnt1x8b(dest, src); } else if (len == 4) { dest -= 4; src -= 4; memmove_movnt1x4b(dest, src); } else { goto nonnt; } return; } nonnt: dest -= len; src -= len; memmove_small_sse2(dest, src, len, flush); } static force_inline void memmove_movnt_sse2(char *dest, const char *src, size_t len, flush_fn flush, barrier_fn barrier, perf_barrier_fn perf_barrier) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_movnt_sse_fw(dest, src, len, flush, perf_barrier); else memmove_movnt_sse_bw(dest, src, len, flush, perf_barrier); barrier(); VALGRIND_DO_FLUSH(dest, len); } /* variants without perf_barrier */ void memmove_movnt_sse2_noflush_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, noflush, barrier_after_ntstores, no_barrier); } void memmove_movnt_sse2_empty_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_empty_nolog, barrier_after_ntstores, no_barrier); } void memmove_movnt_sse2_clflush_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clflush_nolog, barrier_after_ntstores, no_barrier); } void memmove_movnt_sse2_clflushopt_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clflushopt_nolog, no_barrier_after_ntstores, no_barrier); } void memmove_movnt_sse2_clwb_nobarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clwb_nolog, no_barrier_after_ntstores, no_barrier); } /* variants with perf_barrier */ void memmove_movnt_sse2_noflush_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, noflush, barrier_after_ntstores, wc_barrier); } void memmove_movnt_sse2_empty_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_empty_nolog, barrier_after_ntstores, wc_barrier); } void memmove_movnt_sse2_clflush_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clflush_nolog, barrier_after_ntstores, wc_barrier); } void memmove_movnt_sse2_clflushopt_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clflushopt_nolog, no_barrier_after_ntstores, wc_barrier); } void memmove_movnt_sse2_clwb_wcbarrier(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_sse2(dest, src, len, flush_clwb_nolog, no_barrier_after_ntstores, wc_barrier); }
9,636
21.463869
80
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/x86_64/memcpy/memcpy_nt_avx512f.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2020, Intel Corporation */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem2_arch.h" #include "avx.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_avx512f.h" #include "valgrind_internal.h" static force_inline __m512i mm512_loadu_si512(const char *src, unsigned idx) { return _mm512_loadu_si512((const __m512i *)src + idx); } static force_inline void mm512_stream_si512(char *dest, unsigned idx, __m512i src) { _mm512_stream_si512((__m512i *)dest + idx, src); barrier(); } static force_inline void memmove_movnt32x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); __m512i zmm8 = mm512_loadu_si512(src, 8); __m512i zmm9 = mm512_loadu_si512(src, 9); __m512i zmm10 = mm512_loadu_si512(src, 10); __m512i zmm11 = mm512_loadu_si512(src, 11); __m512i zmm12 = mm512_loadu_si512(src, 12); __m512i zmm13 = mm512_loadu_si512(src, 13); __m512i zmm14 = mm512_loadu_si512(src, 14); __m512i zmm15 = mm512_loadu_si512(src, 15); __m512i zmm16 = mm512_loadu_si512(src, 16); __m512i zmm17 = mm512_loadu_si512(src, 17); __m512i zmm18 = mm512_loadu_si512(src, 18); __m512i zmm19 = mm512_loadu_si512(src, 19); __m512i zmm20 = mm512_loadu_si512(src, 20); __m512i zmm21 = mm512_loadu_si512(src, 21); __m512i zmm22 = mm512_loadu_si512(src, 22); __m512i zmm23 = mm512_loadu_si512(src, 23); __m512i zmm24 = mm512_loadu_si512(src, 24); __m512i zmm25 = mm512_loadu_si512(src, 25); __m512i zmm26 = mm512_loadu_si512(src, 26); __m512i zmm27 = mm512_loadu_si512(src, 27); __m512i zmm28 = mm512_loadu_si512(src, 28); __m512i zmm29 = mm512_loadu_si512(src, 29); __m512i zmm30 = mm512_loadu_si512(src, 30); __m512i zmm31 = mm512_loadu_si512(src, 31); mm512_stream_si512(dest, 0, zmm0); mm512_stream_si512(dest, 1, zmm1); mm512_stream_si512(dest, 2, zmm2); mm512_stream_si512(dest, 3, zmm3); mm512_stream_si512(dest, 4, zmm4); mm512_stream_si512(dest, 5, zmm5); mm512_stream_si512(dest, 6, zmm6); mm512_stream_si512(dest, 7, zmm7); mm512_stream_si512(dest, 8, zmm8); mm512_stream_si512(dest, 9, zmm9); mm512_stream_si512(dest, 10, zmm10); mm512_stream_si512(dest, 11, zmm11); mm512_stream_si512(dest, 12, zmm12); mm512_stream_si512(dest, 13, zmm13); mm512_stream_si512(dest, 14, zmm14); mm512_stream_si512(dest, 15, zmm15); mm512_stream_si512(dest, 16, zmm16); mm512_stream_si512(dest, 17, zmm17); mm512_stream_si512(dest, 18, zmm18); mm512_stream_si512(dest, 19, zmm19); mm512_stream_si512(dest, 20, zmm20); mm512_stream_si512(dest, 21, zmm21); mm512_stream_si512(dest, 22, zmm22); mm512_stream_si512(dest, 23, zmm23); mm512_stream_si512(dest, 24, zmm24); mm512_stream_si512(dest, 25, zmm25); mm512_stream_si512(dest, 26, zmm26); mm512_stream_si512(dest, 27, zmm27); mm512_stream_si512(dest, 28, zmm28); mm512_stream_si512(dest, 29, zmm29); mm512_stream_si512(dest, 30, zmm30); mm512_stream_si512(dest, 31, zmm31); } static force_inline void memmove_movnt16x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); __m512i zmm8 = mm512_loadu_si512(src, 8); __m512i zmm9 = mm512_loadu_si512(src, 9); __m512i zmm10 = mm512_loadu_si512(src, 10); __m512i zmm11 = mm512_loadu_si512(src, 11); __m512i zmm12 = mm512_loadu_si512(src, 12); __m512i zmm13 = mm512_loadu_si512(src, 13); __m512i zmm14 = mm512_loadu_si512(src, 14); __m512i zmm15 = mm512_loadu_si512(src, 15); mm512_stream_si512(dest, 0, zmm0); mm512_stream_si512(dest, 1, zmm1); mm512_stream_si512(dest, 2, zmm2); mm512_stream_si512(dest, 3, zmm3); mm512_stream_si512(dest, 4, zmm4); mm512_stream_si512(dest, 5, zmm5); mm512_stream_si512(dest, 6, zmm6); mm512_stream_si512(dest, 7, zmm7); mm512_stream_si512(dest, 8, zmm8); mm512_stream_si512(dest, 9, zmm9); mm512_stream_si512(dest, 10, zmm10); mm512_stream_si512(dest, 11, zmm11); mm512_stream_si512(dest, 12, zmm12); mm512_stream_si512(dest, 13, zmm13); mm512_stream_si512(dest, 14, zmm14); mm512_stream_si512(dest, 15, zmm15); } static force_inline void memmove_movnt8x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); __m512i zmm4 = mm512_loadu_si512(src, 4); __m512i zmm5 = mm512_loadu_si512(src, 5); __m512i zmm6 = mm512_loadu_si512(src, 6); __m512i zmm7 = mm512_loadu_si512(src, 7); mm512_stream_si512(dest, 0, zmm0); mm512_stream_si512(dest, 1, zmm1); mm512_stream_si512(dest, 2, zmm2); mm512_stream_si512(dest, 3, zmm3); mm512_stream_si512(dest, 4, zmm4); mm512_stream_si512(dest, 5, zmm5); mm512_stream_si512(dest, 6, zmm6); mm512_stream_si512(dest, 7, zmm7); } static force_inline void memmove_movnt4x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); __m512i zmm2 = mm512_loadu_si512(src, 2); __m512i zmm3 = mm512_loadu_si512(src, 3); mm512_stream_si512(dest, 0, zmm0); mm512_stream_si512(dest, 1, zmm1); mm512_stream_si512(dest, 2, zmm2); mm512_stream_si512(dest, 3, zmm3); } static force_inline void memmove_movnt2x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); __m512i zmm1 = mm512_loadu_si512(src, 1); mm512_stream_si512(dest, 0, zmm0); mm512_stream_si512(dest, 1, zmm1); } static force_inline void memmove_movnt1x64b(char *dest, const char *src) { __m512i zmm0 = mm512_loadu_si512(src, 0); mm512_stream_si512(dest, 0, zmm0); } static force_inline void memmove_movnt1x32b(char *dest, const char *src) { __m256i zmm0 = _mm256_loadu_si256((__m256i *)src); _mm256_stream_si256((__m256i *)dest, zmm0); } static force_inline void memmove_movnt1x16b(char *dest, const char *src) { __m128i ymm0 = _mm_loadu_si128((__m128i *)src); _mm_stream_si128((__m128i *)dest, ymm0); } static force_inline void memmove_movnt1x8b(char *dest, const char *src) { _mm_stream_si64((long long *)dest, *(long long *)src); } static force_inline void memmove_movnt1x4b(char *dest, const char *src) { _mm_stream_si32((int *)dest, *(int *)src); } static force_inline void memmove_movnt_avx512f_fw(char *dest, const char *src, size_t len, flush_fn flush) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_avx512f(dest, src, cnt, flush); dest += cnt; src += cnt; len -= cnt; } while (len >= 32 * 64) { memmove_movnt32x64b(dest, src); dest += 32 * 64; src += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memmove_movnt16x64b(dest, src); dest += 16 * 64; src += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memmove_movnt8x64b(dest, src); dest += 8 * 64; src += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memmove_movnt4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_movnt2x64b(dest, src); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_movnt1x64b(dest, src); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memmove_movnt1x32b(dest, src); else if (len == 16) memmove_movnt1x16b(dest, src); else if (len == 8) memmove_movnt1x8b(dest, src); else if (len == 4) memmove_movnt1x4b(dest, src); else goto nonnt; goto end; } nonnt: memmove_small_avx512f(dest, src, len, flush); end: avx_zeroupper(); } static force_inline void memmove_movnt_avx512f_bw(char *dest, const char *src, size_t len, flush_fn flush) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_avx512f(dest, src, cnt, flush); } while (len >= 32 * 64) { dest -= 32 * 64; src -= 32 * 64; len -= 32 * 64; memmove_movnt32x64b(dest, src); } if (len >= 16 * 64) { dest -= 16 * 64; src -= 16 * 64; len -= 16 * 64; memmove_movnt16x64b(dest, src); } if (len >= 8 * 64) { dest -= 8 * 64; src -= 8 * 64; len -= 8 * 64; memmove_movnt8x64b(dest, src); } if (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_movnt4x64b(dest, src); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_movnt2x64b(dest, src); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_movnt1x64b(dest, src); } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) { dest -= 32; src -= 32; memmove_movnt1x32b(dest, src); } else if (len == 16) { dest -= 16; src -= 16; memmove_movnt1x16b(dest, src); } else if (len == 8) { dest -= 8; src -= 8; memmove_movnt1x8b(dest, src); } else if (len == 4) { dest -= 4; src -= 4; memmove_movnt1x4b(dest, src); } else { goto nonnt; } goto end; } nonnt: dest -= len; src -= len; memmove_small_avx512f(dest, src, len, flush); end: avx_zeroupper(); } static force_inline void memmove_movnt_avx512f(char *dest, const char *src, size_t len, flush_fn flush, barrier_fn barrier) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_movnt_avx512f_fw(dest, src, len, flush); else memmove_movnt_avx512f_bw(dest, src, len, flush); barrier(); VALGRIND_DO_FLUSH(dest, len); } void memmove_movnt_avx512f_noflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx512f(dest, src, len, noflush, barrier_after_ntstores); } void memmove_movnt_avx512f_empty(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx512f(dest, src, len, flush_empty_nolog, barrier_after_ntstores); } void memmove_movnt_avx512f_clflush(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx512f(dest, src, len, flush_clflush_nolog, barrier_after_ntstores); } void memmove_movnt_avx512f_clflushopt(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx512f(dest, src, len, flush_clflushopt_nolog, no_barrier_after_ntstores); } void memmove_movnt_avx512f_clwb(char *dest, const char *src, size_t len) { LOG(15, "dest %p src %p len %zu", dest, src, len); memmove_movnt_avx512f(dest, src, len, flush_clwb_nolog, no_barrier_after_ntstores); }
11,246
23.45
78
c
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/libpmem2/aarch64/init.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2019, Intel Corporation */ #include <string.h> #include "auto_flush.h" #include "flush.h" #include "out.h" #include "pmem2_arch.h" /* * memory_barrier -- (internal) issue the fence instruction */ static void memory_barrier(void) { LOG(15, NULL); arm_store_memory_barrier(); } /* * flush_dcache -- (internal) flush the CPU cache */ static void flush_dcache(const void *addr, size_t len) { LOG(15, "addr %p len %zu", addr, len); flush_dcache_nolog(addr, len); } /* * pmem2_arch_init -- initialize architecture-specific list of pmem operations */ void pmem2_arch_init(struct pmem2_arch_info *info) { LOG(3, NULL); info->fence = memory_barrier; info->flush = flush_dcache; if (info->flush == flush_dcache) LOG(3, "Synchronize VA to poc for ARM"); else FATAL("invalid deep flush function address"); }
882
17.395833
78
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/libpmem2/ppc64/init.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019, IBM Corporation */ /* Copyright 2019-2020, Intel Corporation */ #include <errno.h> #include <sys/mman.h> #include "out.h" #include "pmem2_arch.h" #include "util.h" /* * Older assemblers versions do not support the latest versions of L, e.g. * Binutils 2.34. * Workaround this by using longs. */ #define __SYNC(l) ".long (0x7c0004AC | ((" #l ") << 21))" #define __DCBF(ra, rb, l) ".long (0x7c0000AC | ((" #l ") << 21)" \ " | ((" #ra ") << 16) | ((" #rb ") << 11))" static void ppc_fence(void) { LOG(15, NULL); /* * Force a memory barrier to flush out all cache lines. * Uses a heavyweight sync in order to guarantee the memory ordering * even with a data cache flush. * According to the POWER ISA 3.1, phwsync (aka. sync (L=4)) is treated * as a hwsync by processors compatible with previous versions of the * POWER ISA. */ asm volatile(__SYNC(4) : : : "memory"); } static void ppc_flush(const void *addr, size_t size) { LOG(15, "addr %p size %zu", addr, size); uintptr_t uptr = (uintptr_t)addr; uintptr_t end = uptr + size; /* round down the address */ uptr &= ~(CACHELINE_SIZE - 1); while (uptr < end) { /* * Flush the data cache block. * According to the POWER ISA 3.1, dcbstps (aka. dcbf (L=6)) * behaves as dcbf (L=0) on previous processors. */ asm volatile(__DCBF(0, %0, 6) : :"r"(uptr) : "memory"); uptr += CACHELINE_SIZE; } } void pmem2_arch_init(struct pmem2_arch_info *info) { LOG(3, "libpmem*: PPC64 support"); info->fence = ppc_fence; info->flush = ppc_flush; }
1,594
22.80597
74
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/windows/win_mmap.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * Copyright (c) 2015-2017, Microsoft Corporation. All rights reserved. * Copyright (c) 2016, Hewlett Packard Enterprise Development LP * * 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.c -- memory-mapped files for Windows */ /* * XXX - The initial approach to PMDK for Windows port was to minimize the * amount of changes required in the core part of the library, and to avoid * preprocessor conditionals, if possible. For that reason, some of the * Linux system calls that have no equivalents on Windows have been emulated * using Windows API. * Note that it was not a goal to fully emulate POSIX-compliant behavior * of mentioned functions. They are used only internally, so current * implementation is just good enough to satisfy PMDK needs and to make it * work on Windows. * * This is a subject for change in the future. Likely, all these functions * will be replaced with "util_xxx" wrappers with OS-specific implementation * for Linux and Windows. * * Known issues: * - on Windows, mapping granularity/alignment is 64KB, not 4KB; * - mprotect() behavior and protection flag handling in mmap() is slightly * different than on Linux (see comments below). */ #include <sys/mman.h> #include "mmap.h" #include "util.h" #include "out.h" #include "win_mmap.h" /* uncomment for more debug information on mmap trackers */ /* #define MMAP_DEBUG_INFO */ NTSTATUS NtFreeVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T RegionSize, _In_ ULONG FreeType); /* * XXX Unify the Linux and Windows code and replace this structure with * the map tracking list defined in mmap.h. */ SRWLOCK FileMappingQLock = SRWLOCK_INIT; struct FMLHead FileMappingQHead = PMDK_SORTEDQ_HEAD_INITIALIZER(FileMappingQHead); /* * mmap_file_mapping_comparer -- (internal) compares the two file mapping * trackers */ static LONG_PTR mmap_file_mapping_comparer(PFILE_MAPPING_TRACKER a, PFILE_MAPPING_TRACKER b) { return ((LONG_PTR)a->BaseAddress - (LONG_PTR)b->BaseAddress); } #ifdef MMAP_DEBUG_INFO /* * mmap_info -- (internal) dump info about all the mapping trackers */ static void mmap_info(void) { LOG(4, NULL); AcquireSRWLockShared(&FileMappingQLock); PFILE_MAPPING_TRACKER mt; for (mt = PMDK_SORTEDQ_FIRST(&FileMappingQHead); mt != (void *)&FileMappingQHead; mt = PMDK_SORTEDQ_NEXT(mt, ListEntry)) { LOG(4, "FH %08x FMH %08x AD %p-%p (%zu) " "OF %08x FL %zu AC %d F %d", mt->FileHandle, mt->FileMappingHandle, mt->BaseAddress, mt->EndAddress, (char *)mt->EndAddress - (char *)mt->BaseAddress, mt->Offset, mt->FileLen, mt->Access, mt->Flags); } ReleaseSRWLockShared(&FileMappingQLock); } #endif /* * mmap_reserve -- (internal) reserve virtual address range */ static void * mmap_reserve(void *addr, size_t len) { LOG(4, "addr %p len %zu", addr, len); ASSERTeq((uintptr_t)addr % Mmap_align, 0); ASSERTeq(len % Mmap_align, 0); void *reserved_addr = VirtualAlloc(addr, len, MEM_RESERVE, PAGE_NOACCESS); if (reserved_addr == NULL) { ERR("cannot find a contiguous region - " "addr: %p, len: %lx, gle: 0x%08x", addr, len, GetLastError()); errno = ENOMEM; return MAP_FAILED; } return reserved_addr; } /* * mmap_unreserve -- (internal) frees the range that's previously reserved */ static int mmap_unreserve(void *addr, size_t len) { LOG(4, "addr %p len %zu", addr, len); ASSERTeq((uintptr_t)addr % Mmap_align, 0); ASSERTeq(len % Mmap_align, 0); size_t bytes_returned; MEMORY_BASIC_INFORMATION basic_info; bytes_returned = VirtualQuery(addr, &basic_info, sizeof(basic_info)); if (bytes_returned != sizeof(basic_info)) { ERR("cannot query the virtual address properties of the range " "- addr: %p, len: %d", addr, len); errno = EINVAL; return -1; } if (basic_info.State == MEM_RESERVE) { DWORD nt_status; void *release_addr = addr; size_t release_size = len; nt_status = NtFreeVirtualMemory(GetCurrentProcess(), &release_addr, &release_size, MEM_RELEASE); if (nt_status != 0) { ERR("cannot release the reserved virtual space - " "addr: %p, len: %d, nt_status: 0x%08x", addr, len, nt_status); errno = EINVAL; return -1; } ASSERTeq(release_addr, addr); ASSERTeq(release_size, len); LOG(4, "freed reservation - addr: %p, size: %d", release_addr, release_size); } else { LOG(4, "range not reserved - addr: %p, size: %d", addr, len); } return 0; } /* * win_mmap_init -- initialization of file mapping tracker */ void win_mmap_init(void) { AcquireSRWLockExclusive(&FileMappingQLock); PMDK_SORTEDQ_INIT(&FileMappingQHead); ReleaseSRWLockExclusive(&FileMappingQLock); } /* * win_mmap_fini -- file mapping tracker cleanup routine */ void win_mmap_fini(void) { /* * Let's make sure that no one is in the middle of updating the * list by grabbing the lock. */ AcquireSRWLockExclusive(&FileMappingQLock); while (!PMDK_SORTEDQ_EMPTY(&FileMappingQHead)) { PFILE_MAPPING_TRACKER mt; mt = (PFILE_MAPPING_TRACKER)PMDK_SORTEDQ_FIRST( &FileMappingQHead); PMDK_SORTEDQ_REMOVE(&FileMappingQHead, mt, ListEntry); if (mt->BaseAddress != NULL) UnmapViewOfFile(mt->BaseAddress); size_t release_size = (char *)mt->EndAddress - (char *)mt->BaseAddress; /* * Free reservation after file mapping (if reservation was * bigger than length of mapped file) */ void *release_addr = (char *)mt->BaseAddress + mt->FileLen; mmap_unreserve(release_addr, release_size - mt->FileLen); if (mt->FileMappingHandle != NULL) CloseHandle(mt->FileMappingHandle); if (mt->FileHandle != NULL) CloseHandle(mt->FileHandle); free(mt); } ReleaseSRWLockExclusive(&FileMappingQLock); } #define PROT_ALL (PROT_READ|PROT_WRITE|PROT_EXEC) /* * mmap -- map file into memory * * XXX - If read-only mapping was created initially, it is not possible * to change protection to R/W, even if the file itself was open in R/W mode. * To workaround that, we could modify mmap() to create R/W mapping first, * then change the protection to R/O. This way, it should be possible * to elevate permissions later. */ void * mmap(void *addr, size_t len, int prot, int flags, int fd, os_off_t offset) { LOG(4, "addr %p len %zu prot %d flags %d fd %d offset %ju", addr, len, prot, flags, fd, offset); if (len == 0) { ERR("invalid length: %zu", len); errno = EINVAL; return MAP_FAILED; } if ((prot & ~PROT_ALL) != 0) { ERR("invalid flags: 0x%08x", flags); /* invalid protection flags */ errno = EINVAL; return MAP_FAILED; } if (((flags & MAP_PRIVATE) && (flags & MAP_SHARED)) || ((flags & (MAP_PRIVATE | MAP_SHARED)) == 0)) { ERR("neither MAP_PRIVATE or MAP_SHARED is set, or both: 0x%08x", flags); errno = EINVAL; return MAP_FAILED; } /* XXX shall we use SEC_LARGE_PAGES flag? */ DWORD protect = 0; DWORD access = 0; /* on x86, PROT_WRITE implies PROT_READ */ if (prot & PROT_WRITE) { if (flags & MAP_PRIVATE) { access = FILE_MAP_COPY; if (prot & PROT_EXEC) protect = PAGE_EXECUTE_WRITECOPY; else protect = PAGE_WRITECOPY; } else { /* FILE_MAP_ALL_ACCESS == FILE_MAP_WRITE */ access = FILE_MAP_ALL_ACCESS; if (prot & PROT_EXEC) protect = PAGE_EXECUTE_READWRITE; else protect = PAGE_READWRITE; } } else if (prot & PROT_READ) { access = FILE_MAP_READ; if (prot & PROT_EXEC) protect = PAGE_EXECUTE_READ; else protect = PAGE_READONLY; } else { /* XXX - PAGE_NOACCESS is not supported by CreateFileMapping */ ERR("PAGE_NOACCESS is not supported"); errno = ENOTSUP; return MAP_FAILED; } if (((uintptr_t)addr % Mmap_align) != 0) { if ((flags & MAP_FIXED) == 0) { /* ignore invalid hint if no MAP_FIXED flag is set */ addr = NULL; } else { ERR("hint address is not well-aligned: %p", addr); errno = EINVAL; return MAP_FAILED; } } if ((offset % Mmap_align) != 0) { ERR("offset is not well-aligned: %ju", offset); errno = EINVAL; return MAP_FAILED; } if ((flags & MAP_FIXED) != 0) { /* * Free any reservations that the caller might have, also we * have to unmap any existing mappings in this region as per * mmap's manual. * XXX - Ideally we should unmap only if the prot and flags * are similar, we are deferring it as we don't rely on it * yet. */ int ret = munmap(addr, len); if (ret != 0) { ERR("!munmap: addr %p len %zu", addr, len); return MAP_FAILED; } } size_t len_align = roundup(len, Mmap_align); size_t filelen; size_t filelen_align; HANDLE fh; if (flags & MAP_ANON) { /* * In our implementation we are choosing to ignore fd when * MAP_ANON is set, instead of failing. */ fh = INVALID_HANDLE_VALUE; /* ignore/override offset */ offset = 0; filelen = len; filelen_align = len_align; if ((flags & MAP_NORESERVE) != 0) { /* * For anonymous mappings the meaning of MAP_NORESERVE * flag is pretty much the same as SEC_RESERVE. */ protect |= SEC_RESERVE; } } else { LARGE_INTEGER filesize; if (fd == -1) { ERR("invalid file descriptor: %d", fd); errno = EBADF; return MAP_FAILED; } /* * We need to keep file handle open for proper * implementation of msync() and to hold the file lock. */ if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)_get_osfhandle(fd), GetCurrentProcess(), &fh, 0, FALSE, DUPLICATE_SAME_ACCESS)) { ERR("cannot duplicate handle - fd: %d, gle: 0x%08x", fd, GetLastError()); errno = ENOMEM; return MAP_FAILED; } /* * If we are asked to map more than the file size, map till the * file size and reserve the following. */ if (!GetFileSizeEx(fh, &filesize)) { ERR("cannot query the file size - fh: %d, gle: 0x%08x", fd, GetLastError()); CloseHandle(fh); return MAP_FAILED; } if (offset >= (os_off_t)filesize.QuadPart) { errno = EINVAL; ERR("offset is beyond the file size"); CloseHandle(fh); return MAP_FAILED; } /* calculate length of the mapped portion of the file */ filelen = filesize.QuadPart - offset; if (filelen > len) filelen = len; filelen_align = roundup(filelen, Mmap_align); if ((offset + len) > (size_t)filesize.QuadPart) { /* * Reserve virtual address for the rest of range we need * to map, and free a portion in the beginning for this * allocation. */ void *reserved_addr = mmap_reserve(addr, len_align); if (reserved_addr == MAP_FAILED) { ERR("cannot reserve region"); CloseHandle(fh); return MAP_FAILED; } if (addr != reserved_addr && (flags & MAP_FIXED) != 0) { ERR("cannot find a contiguous region - " "addr: %p, len: %lx, gle: 0x%08x", addr, len, GetLastError()); if (mmap_unreserve(reserved_addr, len_align) != 0) { ASSERT(FALSE); ERR("cannot free reserved region"); } errno = ENOMEM; CloseHandle(fh); return MAP_FAILED; } addr = reserved_addr; if (mmap_unreserve(reserved_addr, filelen_align) != 0) { ASSERT(FALSE); ERR("cannot free reserved region"); CloseHandle(fh); return MAP_FAILED; } } } HANDLE fmh = CreateFileMapping(fh, NULL, /* security attributes */ protect, (DWORD) ((filelen + offset) >> 32), (DWORD) ((filelen + offset) & 0xFFFFFFFF), NULL); if (fmh == NULL) { DWORD gle = GetLastError(); ERR("CreateFileMapping, gle: 0x%08x", gle); if (gle == ERROR_ACCESS_DENIED) errno = EACCES; else errno = EINVAL; /* XXX */ CloseHandle(fh); return MAP_FAILED; } void *base = MapViewOfFileEx(fmh, access, (DWORD) (offset >> 32), (DWORD) (offset & 0xFFFFFFFF), filelen, addr); /* hint address */ if (base == NULL) { if (addr == NULL || (flags & MAP_FIXED) != 0) { ERR("MapViewOfFileEx, gle: 0x%08x", GetLastError()); errno = EINVAL; CloseHandle(fh); CloseHandle(fmh); return MAP_FAILED; } /* try again w/o hint */ base = MapViewOfFileEx(fmh, access, (DWORD) (offset >> 32), (DWORD) (offset & 0xFFFFFFFF), filelen, NULL); /* no hint address */ } if (base == NULL) { ERR("MapViewOfFileEx, gle: 0x%08x", GetLastError()); errno = ENOMEM; CloseHandle(fh); CloseHandle(fmh); return MAP_FAILED; } /* * We will track the file mapping handle on a lookaside list so that * we don't have to modify the fact that we only return back the base * address rather than a more elaborate structure. */ PFILE_MAPPING_TRACKER mt = malloc(sizeof(struct FILE_MAPPING_TRACKER)); if (mt == NULL) { ERR("!malloc"); CloseHandle(fh); CloseHandle(fmh); return MAP_FAILED; } mt->Flags = 0; mt->FileHandle = fh; mt->FileMappingHandle = fmh; mt->BaseAddress = base; mt->EndAddress = (void *)((char *)base + len_align); mt->Access = access; mt->Offset = offset; mt->FileLen = filelen_align; /* * XXX: Use the QueryVirtualMemoryInformation when available in the new * SDK. If the file is DAX mapped say so in the FILE_MAPPING_TRACKER * Flags. */ DWORD filesystemFlags; if (fh == INVALID_HANDLE_VALUE) { LOG(4, "anonymous mapping - not DAX mapped - handle: %p", fh); } else if (GetVolumeInformationByHandleW(fh, NULL, 0, NULL, NULL, &filesystemFlags, NULL, 0)) { if (filesystemFlags & FILE_DAX_VOLUME) { mt->Flags |= FILE_MAPPING_TRACKER_FLAG_DIRECT_MAPPED; } else { LOG(4, "file is not DAX mapped - handle: %p", fh); } } else { ERR("failed to query volume information : %08x", GetLastError()); } AcquireSRWLockExclusive(&FileMappingQLock); PMDK_SORTEDQ_INSERT(&FileMappingQHead, mt, ListEntry, FILE_MAPPING_TRACKER, mmap_file_mapping_comparer); ReleaseSRWLockExclusive(&FileMappingQLock); #ifdef MMAP_DEBUG_INFO mmap_info(); #endif return base; } /* * mmap_split -- (internal) replace existing mapping with another one(s) * * Unmaps the region between [begin,end]. If it's in a middle of the existing * mapping, it results in two new mappings and duplicated file/mapping handles. */ static int mmap_split(PFILE_MAPPING_TRACKER mt, void *begin, void *end) { LOG(4, "begin %p end %p", begin, end); ASSERTeq((uintptr_t)begin % Mmap_align, 0); ASSERTeq((uintptr_t)end % Mmap_align, 0); PFILE_MAPPING_TRACKER mtb = NULL; PFILE_MAPPING_TRACKER mte = NULL; HANDLE fh = mt->FileHandle; HANDLE fmh = mt->FileMappingHandle; size_t len; /* * In this routine we copy flags from mt to the two subsets that we * create. All flags may not be appropriate to propagate so let's * assert about the flags we know, if some one adds a new flag in the * future they would know about this copy and take appropricate action. */ C_ASSERT(FILE_MAPPING_TRACKER_FLAGS_MASK == 1); /* * 1) b e b e * xxxxxxxxxxxxx => xxx.......xxxx - mtb+mte * 2) b e b e * xxxxxxxxxxxxx => xxxxxxx....... - mtb * 3) b e b e * xxxxxxxxxxxxx => ........xxxxxx - mte * 4) b e b e * xxxxxxxxxxxxx => .............. - <none> */ if (begin > mt->BaseAddress) { /* case #1/2 */ /* new mapping at the beginning */ mtb = malloc(sizeof(struct FILE_MAPPING_TRACKER)); if (mtb == NULL) { ERR("!malloc"); goto err; } mtb->Flags = mt->Flags; mtb->FileHandle = fh; mtb->FileMappingHandle = fmh; mtb->BaseAddress = mt->BaseAddress; mtb->EndAddress = begin; mtb->Access = mt->Access; mtb->Offset = mt->Offset; len = (char *)begin - (char *)mt->BaseAddress; mtb->FileLen = len >= mt->FileLen ? mt->FileLen : len; } if (end < mt->EndAddress) { /* case #1/3 */ /* new mapping at the end */ mte = malloc(sizeof(struct FILE_MAPPING_TRACKER)); if (mte == NULL) { ERR("!malloc"); goto err; } if (!mtb) { /* case #3 */ mte->FileHandle = fh; mte->FileMappingHandle = fmh; } else { /* case #1 - need to duplicate handles */ mte->FileHandle = NULL; mte->FileMappingHandle = NULL; if (!DuplicateHandle(GetCurrentProcess(), fh, GetCurrentProcess(), &mte->FileHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { ERR("DuplicateHandle, gle: 0x%08x", GetLastError()); goto err; } if (!DuplicateHandle(GetCurrentProcess(), fmh, GetCurrentProcess(), &mte->FileMappingHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { ERR("DuplicateHandle, gle: 0x%08x", GetLastError()); goto err; } } mte->Flags = mt->Flags; mte->BaseAddress = end; mte->EndAddress = mt->EndAddress; mte->Access = mt->Access; mte->Offset = mt->Offset + ((char *)mte->BaseAddress - (char *)mt->BaseAddress); len = (char *)end - (char *)mt->BaseAddress; mte->FileLen = len >= mt->FileLen ? 0 : mt->FileLen - len; } if (mt->FileLen > 0 && UnmapViewOfFile(mt->BaseAddress) == FALSE) { ERR("UnmapViewOfFile, gle: 0x%08x", GetLastError()); goto err; } len = (char *)mt->EndAddress - (char *)mt->BaseAddress; if (len > mt->FileLen) { void *addr = (char *)mt->BaseAddress + mt->FileLen; mmap_unreserve(addr, len - mt->FileLen); } if (!mtb && !mte) { /* case #4 */ CloseHandle(fmh); CloseHandle(fh); } /* * free entry for the original mapping */ PMDK_SORTEDQ_REMOVE(&FileMappingQHead, mt, ListEntry); free(mt); if (mtb) { len = (char *)mtb->EndAddress - (char *)mtb->BaseAddress; if (len > mtb->FileLen) { void *addr = (char *)mtb->BaseAddress + mtb->FileLen; void *raddr = mmap_reserve(addr, len - mtb->FileLen); if (raddr == MAP_FAILED) { ERR("cannot find a contiguous region - " "addr: %p, len: %lx, gle: 0x%08x", addr, len, GetLastError()); goto err; } } if (mtb->FileLen > 0) { void *base = MapViewOfFileEx(mtb->FileMappingHandle, mtb->Access, (DWORD) (mtb->Offset >> 32), (DWORD) (mtb->Offset & 0xFFFFFFFF), mtb->FileLen, mtb->BaseAddress); /* hint address */ if (base == NULL) { ERR("MapViewOfFileEx, gle: 0x%08x", GetLastError()); goto err; } } PMDK_SORTEDQ_INSERT(&FileMappingQHead, mtb, ListEntry, FILE_MAPPING_TRACKER, mmap_file_mapping_comparer); } if (mte) { len = (char *)mte->EndAddress - (char *)mte->BaseAddress; if (len > mte->FileLen) { void *addr = (char *)mte->BaseAddress + mte->FileLen; void *raddr = mmap_reserve(addr, len - mte->FileLen); if (raddr == MAP_FAILED) { ERR("cannot find a contiguous region - " "addr: %p, len: %lx, gle: 0x%08x", addr, len, GetLastError()); goto err; } } if (mte->FileLen > 0) { void *base = MapViewOfFileEx(mte->FileMappingHandle, mte->Access, (DWORD) (mte->Offset >> 32), (DWORD) (mte->Offset & 0xFFFFFFFF), mte->FileLen, mte->BaseAddress); /* hint address */ if (base == NULL) { ERR("MapViewOfFileEx, gle: 0x%08x", GetLastError()); goto err_mte; } } PMDK_SORTEDQ_INSERT(&FileMappingQHead, mte, ListEntry, FILE_MAPPING_TRACKER, mmap_file_mapping_comparer); } return 0; err: if (mtb) { ASSERTeq(mtb->FileMappingHandle, fmh); ASSERTeq(mtb->FileHandle, fh); CloseHandle(mtb->FileMappingHandle); CloseHandle(mtb->FileHandle); len = (char *)mtb->EndAddress - (char *)mtb->BaseAddress; if (len > mtb->FileLen) { void *addr = (char *)mtb->BaseAddress + mtb->FileLen; mmap_unreserve(addr, len - mtb->FileLen); } } err_mte: if (mte) { if (mte->FileMappingHandle) CloseHandle(mte->FileMappingHandle); if (mte->FileHandle) CloseHandle(mte->FileHandle); len = (char *)mte->EndAddress - (char *)mte->BaseAddress; if (len > mte->FileLen) { void *addr = (char *)mte->BaseAddress + mte->FileLen; mmap_unreserve(addr, len - mte->FileLen); } } free(mtb); free(mte); return -1; } /* * munmap -- delete mapping */ int munmap(void *addr, size_t len) { LOG(4, "addr %p len %zu", addr, len); if (((uintptr_t)addr % Mmap_align) != 0) { ERR("address is not well-aligned: %p", addr); errno = EINVAL; return -1; } if (len == 0) { ERR("invalid length: %zu", len); errno = EINVAL; return -1; } int retval = -1; if (len > UINTPTR_MAX - (uintptr_t)addr) { /* limit len to not get beyond address space */ len = UINTPTR_MAX - (uintptr_t)addr; } void *begin = addr; void *end = (void *)((char *)addr + len); AcquireSRWLockExclusive(&FileMappingQLock); PFILE_MAPPING_TRACKER mt; PFILE_MAPPING_TRACKER next; for (mt = PMDK_SORTEDQ_FIRST(&FileMappingQHead); mt != (void *)&FileMappingQHead; mt = next) { /* * Pick the next entry before we split there by delete the * this one (NOTE: mmap_spilt could delete this entry). */ next = PMDK_SORTEDQ_NEXT(mt, ListEntry); if (mt->BaseAddress >= end) { LOG(4, "ignoring all mapped ranges beyond given range"); break; } if (mt->EndAddress <= begin) { LOG(4, "skipping a mapped range before given range"); continue; } void *begin2 = begin > mt->BaseAddress ? begin : mt->BaseAddress; void *end2 = end < mt->EndAddress ? end : mt->EndAddress; size_t len2 = (char *)end2 - (char *)begin2; void *align_end = (void *)roundup((uintptr_t)end2, Mmap_align); if (mmap_split(mt, begin2, align_end) != 0) { LOG(2, "mapping split failed"); goto err; } if (len > len2) { len -= len2; } else { len = 0; break; } } /* * If we didn't find any mapped regions in our list attempt to free * as if the entire range is reserved. * * XXX: We don't handle a range having few mapped regions and few * reserved regions. */ if (len > 0) mmap_unreserve(addr, roundup(len, Mmap_align)); retval = 0; err: ReleaseSRWLockExclusive(&FileMappingQLock); if (retval == -1) errno = EINVAL; #ifdef MMAP_DEBUG_INFO mmap_info(); #endif return retval; } #define MS_ALL (MS_SYNC|MS_ASYNC|MS_INVALIDATE) /* * msync -- synchronize a file with a memory map */ int msync(void *addr, size_t len, int flags) { LOG(4, "addr %p len %zu flags %d", addr, len, flags); if ((flags & ~MS_ALL) != 0) { ERR("invalid flags: 0x%08x", flags); errno = EINVAL; return -1; } /* * XXX - On Linux it is allowed to call msync() without MS_SYNC * nor MS_ASYNC. */ if (((flags & MS_SYNC) && (flags & MS_ASYNC)) || ((flags & (MS_SYNC | MS_ASYNC)) == 0)) { ERR("neither MS_SYNC or MS_ASYNC is set, or both: 0x%08x", flags); errno = EINVAL; return -1; } if (((uintptr_t)addr % Pagesize) != 0) { ERR("address is not page-aligned: %p", addr); errno = EINVAL; return -1; } if (len == 0) { LOG(4, "zero-length region - do nothing"); return 0; /* do nothing */ } if (len > UINTPTR_MAX - (uintptr_t)addr) { /* limit len to not get beyond address space */ len = UINTPTR_MAX - (uintptr_t)addr; } int retval = -1; void *begin = addr; void *end = (void *)((char *)addr + len); AcquireSRWLockShared(&FileMappingQLock); PFILE_MAPPING_TRACKER mt; PMDK_SORTEDQ_FOREACH(mt, &FileMappingQHead, ListEntry) { if (mt->BaseAddress >= end) { LOG(4, "ignoring all mapped ranges beyond given range"); break; } if (mt->EndAddress <= begin) { LOG(4, "skipping a mapped range before given range"); continue; } void *begin2 = begin > mt->BaseAddress ? begin : mt->BaseAddress; void *end2 = end < mt->EndAddress ? end : mt->EndAddress; size_t len2 = (char *)end2 - (char *)begin2; /* do nothing for anonymous mappings */ if (mt->FileHandle != INVALID_HANDLE_VALUE) { if (FlushViewOfFile(begin2, len2) == FALSE) { ERR("FlushViewOfFile, gle: 0x%08x", GetLastError()); errno = ENOMEM; goto err; } if (FlushFileBuffers(mt->FileHandle) == FALSE) { ERR("FlushFileBuffers, gle: 0x%08x", GetLastError()); errno = EINVAL; goto err; } } if (len > len2) { len -= len2; } else { len = 0; break; } } if (len > 0) { ERR("indicated memory (or part of it) was not mapped"); errno = ENOMEM; } else { retval = 0; } err: ReleaseSRWLockShared(&FileMappingQLock); return retval; } #define PROT_ALL (PROT_READ|PROT_WRITE|PROT_EXEC) /* * mprotect -- set protection on a region of memory * * XXX - If the memory range passed to mprotect() includes invalid pages, * returned status will indicate error, and errno is set to ENOMEM. * However, the protection change is actually applied to all the valid pages, * ignoring the rest. * This is different than on Linux, where it stops on the first invalid page. */ int mprotect(void *addr, size_t len, int prot) { LOG(4, "addr %p len %zu prot %d", addr, len, prot); if (((uintptr_t)addr % Pagesize) != 0) { ERR("address is not page-aligned: %p", addr); errno = EINVAL; return -1; } if (len == 0) { LOG(4, "zero-length region - do nothing"); return 0; /* do nothing */ } if (len > UINTPTR_MAX - (uintptr_t)addr) { len = UINTPTR_MAX - (uintptr_t)addr; LOG(4, "limit len to %zu to not get beyond address space", len); } DWORD protect = 0; if ((prot & PROT_READ) && (prot & PROT_WRITE)) { protect |= PAGE_READWRITE; if (prot & PROT_EXEC) protect |= PAGE_EXECUTE_READWRITE; } else if (prot & PROT_READ) { protect |= PAGE_READONLY; if (prot & PROT_EXEC) protect |= PAGE_EXECUTE_READ; } else { protect |= PAGE_NOACCESS; } int retval = -1; void *begin = addr; void *end = (void *)((char *)addr + len); AcquireSRWLockShared(&FileMappingQLock); PFILE_MAPPING_TRACKER mt; PMDK_SORTEDQ_FOREACH(mt, &FileMappingQHead, ListEntry) { if (mt->BaseAddress >= end) { LOG(4, "ignoring all mapped ranges beyond given range"); break; } if (mt->EndAddress <= begin) { LOG(4, "skipping a mapped range before given range"); continue; } void *begin2 = begin > mt->BaseAddress ? begin : mt->BaseAddress; void *end2 = end < mt->EndAddress ? end : mt->EndAddress; /* * protect of region to VirtualProtection must be compatible * with the access protection specified for this region * when the view was mapped using MapViewOfFileEx */ if (mt->Access == FILE_MAP_COPY) { if (protect & PAGE_READWRITE) { protect &= ~PAGE_READWRITE; protect |= PAGE_WRITECOPY; } else if (protect & PAGE_EXECUTE_READWRITE) { protect &= ~PAGE_EXECUTE_READWRITE; protect |= PAGE_EXECUTE_WRITECOPY; } } size_t len2 = (char *)end2 - (char *)begin2; DWORD oldprot = 0; BOOL ret; ret = VirtualProtect(begin2, len2, protect, &oldprot); if (ret == FALSE) { DWORD gle = GetLastError(); ERR("VirtualProtect, gle: 0x%08x", gle); /* translate error code */ switch (gle) { case ERROR_INVALID_PARAMETER: errno = EACCES; break; case ERROR_INVALID_ADDRESS: errno = ENOMEM; break; default: errno = EINVAL; break; } goto err; } if (len > len2) { len -= len2; } else { len = 0; break; } } if (len > 0) { ERR("indicated memory (or part of it) was not mapped"); errno = ENOMEM; } else { retval = 0; } err: ReleaseSRWLockShared(&FileMappingQLock); return retval; }
28,523
24.17564
79
c
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/windows/getopt/getopt.c
/* * *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. */ #include "getopt.h" #include <stddef.h> #include <string.h> #include <stdio.h> char* optarg; int optopt; /* The variable optind [...] shall be initialized to 1 by the system. */ int optind = 1; int opterr; static char* optcursor = NULL; static char *first = NULL; /* rotates argv array */ static void rotate(char **argv, int argc) { if (argc <= 1) return; char *tmp = argv[0]; memmove(argv, argv + 1, (argc - 1) * sizeof(char *)); argv[argc - 1] = tmp; } /* Implemented based on [1] and [2] for optional arguments. optopt is handled FreeBSD-style, per [3]. Other GNU and FreeBSD extensions are purely accidental. [1] https://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html [2] https://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html [3] https://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE */ int getopt(int argc, char* const argv[], const char* optstring) { int optchar = -1; const char* optdecl = NULL; optarg = NULL; opterr = 0; optopt = 0; /* Unspecified, but we need it to avoid overrunning the argv bounds. */ if (optind >= argc) goto no_more_optchars; /* If, when getopt() is called argv[optind] is a null pointer, getopt() shall return -1 without changing optind. */ if (argv[optind] == NULL) goto no_more_optchars; /* If, when getopt() is called *argv[optind] is not the character '-', permute argv to move non options to the end */ if (*argv[optind] != '-') { if (argc - optind <= 1) goto no_more_optchars; if (!first) first = argv[optind]; do { rotate((char **)(argv + optind), argc - optind); } while (*argv[optind] != '-' && argv[optind] != first); if (argv[optind] == first) goto no_more_optchars; } /* If, when getopt() is called argv[optind] points to the string "-", getopt() shall return -1 without changing optind. */ if (strcmp(argv[optind], "-") == 0) goto no_more_optchars; /* If, when getopt() is called argv[optind] points to the string "--", getopt() shall return -1 after incrementing optind. */ if (strcmp(argv[optind], "--") == 0) { ++optind; if (first) { do { rotate((char **)(argv + optind), argc - optind); } while (argv[optind] != first); } goto no_more_optchars; } if (optcursor == NULL || *optcursor == '\0') optcursor = argv[optind] + 1; optchar = *optcursor; /* FreeBSD: The variable optopt saves the last known option character returned by getopt(). */ optopt = optchar; /* The getopt() function shall return the next option character (if one is found) from argv that matches a character in optstring, if there is one that matches. */ optdecl = strchr(optstring, optchar); if (optdecl) { /* [I]f a character is followed by a colon, the option takes an argument. */ if (optdecl[1] == ':') { optarg = ++optcursor; if (*optarg == '\0') { /* GNU extension: Two colons mean an option takes an optional arg; if there is text in the current argv-element (i.e., in the same word as the option name itself, for example, "-oarg"), then it is returned in optarg, otherwise optarg is set to zero. */ if (optdecl[2] != ':') { /* If the option was the last character in the string pointed to by an element of argv, then optarg shall contain the next element of argv, and optind shall be incremented by 2. If the resulting value of optind is greater than argc, this indicates a missing option-argument, and getopt() shall return an error indication. Otherwise, optarg shall point to the string following the option character in that element of argv, and optind shall be incremented by 1. */ if (++optind < argc) { optarg = argv[optind]; } else { /* If it detects a missing option-argument, it shall return the colon character ( ':' ) if the first character of optstring was a colon, or a question-mark character ( '?' ) otherwise. */ optarg = NULL; fprintf(stderr, "%s: option requires an argument -- '%c'\n", argv[0], optchar); optchar = (optstring[0] == ':') ? ':' : '?'; } } else { optarg = NULL; } } optcursor = NULL; } } else { fprintf(stderr,"%s: invalid option -- '%c'\n", argv[0], optchar); /* If getopt() encounters an option character that is not contained in optstring, it shall return the question-mark ( '?' ) character. */ optchar = '?'; } if (optcursor == NULL || *++optcursor == '\0') ++optind; return optchar; no_more_optchars: optcursor = NULL; first = NULL; return -1; } /* Implementation based on [1]. [1] https://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html */ int getopt_long(int argc, char* const argv[], const char* optstring, const struct option* longopts, int* longindex) { const struct option* o = longopts; const struct option* match = NULL; int num_matches = 0; size_t argument_name_length = 0; const char* current_argument = NULL; int retval = -1; optarg = NULL; optopt = 0; if (optind >= argc) return -1; /* If, when getopt() is called argv[optind] is a null pointer, getopt_long() shall return -1 without changing optind. */ if (argv[optind] == NULL) goto no_more_optchars; /* If, when getopt_long() is called *argv[optind] is not the character '-', permute argv to move non options to the end */ if (*argv[optind] != '-') { if (argc - optind <= 1) goto no_more_optchars; if (!first) first = argv[optind]; do { rotate((char **)(argv + optind), argc - optind); } while (*argv[optind] != '-' && argv[optind] != first); if (argv[optind] == first) goto no_more_optchars; } if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0) return getopt(argc, argv, optstring); /* It's an option; starts with -- and is longer than two chars. */ current_argument = argv[optind] + 2; argument_name_length = strcspn(current_argument, "="); for (; o->name; ++o) { if (strncmp(o->name, current_argument, argument_name_length) == 0) { match = o; ++num_matches; if (strlen(o->name) == argument_name_length) { /* found match is exactly the one which we are looking for */ num_matches = 1; break; } } } if (num_matches == 1) { /* If longindex is not NULL, it points to a variable which is set to the index of the long option relative to longopts. */ if (longindex) *longindex = (int)(match - longopts); /* If flag is NULL, then getopt_long() shall return val. Otherwise, getopt_long() returns 0, and flag shall point to a variable which shall be set to val if the option is found, but left unchanged if the option is not found. */ if (match->flag) *(match->flag) = match->val; retval = match->flag ? 0 : match->val; if (match->has_arg != no_argument) { optarg = strchr(argv[optind], '='); if (optarg != NULL) ++optarg; if (match->has_arg == required_argument) { /* Only scan the next argv for required arguments. Behavior is not specified, but has been observed with Ubuntu and Mac OSX. */ if (optarg == NULL && ++optind < argc) { optarg = argv[optind]; } if (optarg == NULL) retval = ':'; } } else if (strchr(argv[optind], '=')) { /* An argument was provided to a non-argument option. I haven't seen this specified explicitly, but both GNU and BSD-based implementations show this behavior. */ retval = '?'; } } else { /* Unknown option or ambiguous match. */ retval = '?'; if (num_matches == 0) { fprintf(stderr, "%s: unrecognized option -- '%s'\n", argv[0], argv[optind]); } else { fprintf(stderr, "%s: option '%s' is ambiguous\n", argv[0], argv[optind]); } } ++optind; return retval; no_more_optchars: first = NULL; return -1; }
9,866
32.561224
91
c
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/src/include/libpmemobj++/README.md
This folder contained libpmemobj C++ bindings. They have been moved to https://github.com/pmem/libpmemobj-cpp
110
36
62
md
null
NearPMSW-main/nearpm/shadow/pmdk-sd/src/include/libpmemobj++/detail/README.md
This folder contained libpmemobj C++ bindings. They have been moved to https://github.com/pmem/libpmemobj-cpp/tree/master/include/libpmemobj++/detail
150
49.333333
102
md
null
NearPMSW-main/nearpm/shadow/pmdk-sd/utils/check_sdk_version.py
#!/usr/bin/env python3 # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019-2020, Intel Corporation import argparse import os from subprocess import check_output, CalledProcessError import sys import shlex from xml.dom import minidom from xml.parsers.expat import ExpatError VALID_SDK_VERSION = '10.0.17134.0' def get_vcxproj_files(root_dir, ignored): """Get a list ".vcxproj" files under PMDK directory.""" to_format = [] command = 'git ls-files *.vcxproj' try: output = check_output(shlex.split(command), cwd=root_dir).decode("UTF-8") except CalledProcessError as e: sys.exit('Error: "' + command + '" failed with returncode: ' + str(e.returncode)) for line in output.splitlines(): if not line: continue file_path = os.path.join(root_dir, line) if os.path.isfile(file_path): to_format.append(file_path) return to_format def get_sdk_version(file): """ Get Windows SDK version from modified/new files from the current pull request. """ tag = 'WindowsTargetPlatformVersion' try: xml_file = minidom.parse(file) except ExpatError as e: sys.exit('Error: "' + file + '" is incorrect.\n' + str(e)) version_list = xml_file.getElementsByTagName(tag) if len(version_list) != 1: sys.exit('Error: the amount of tags "' + tag + '" is other than 1.') version = version_list[0].firstChild.data return version def main(): parser = argparse.ArgumentParser(prog='check_sdk_version.py', description='The script checks Windows SDK version in .vcxproj files.') parser.add_argument('-d', '--directory', help='Directory of PMDK tree.', required=True) args = parser.parse_args() current_directory = args.directory if not os.path.isdir(current_directory): sys.exit('"' + current_directory + '" is not a directory.') files = get_vcxproj_files(current_directory, '') if not files: sys.exit(0) for file in files: sdk_version = get_sdk_version(file) if sdk_version != VALID_SDK_VERSION: sys.exit('Wrong Windows SDK version: ' + sdk_version + ' in file: "' + file + '". Please use: ' + VALID_SDK_VERSION) if __name__ == '__main__': main()
2,368
29.766234
82
py
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 <piotr.balcer@intel.com>" # 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/check_license/check-ms-license.pl
#!/usr/bin/perl -w # SPDX-License-Identifier: BSD-3-Clause # Copyright 2020, Intel Corporation use Digest::MD5 "md5_hex"; my $BSD3 = <<EndText; 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. EndText # a runaway sed job may alter this file too md5_hex($BSD3) eq "066df8826723b6db407a931e5d6084f4" or die "Text of BSD3 license has been corrupted.\n"; my $err = 0; $BSD3 =~ s/^/ /mg; # indent the text $BSD3 =~ s/\n \n/\n\n/sg; # except for empty lines undef $/; for my $f (@ARGV) { next unless -f $f; open F, '<', $f or die "Can't read 「$f」\n"; $_ = <F>; close F; next unless /Copyright.*(Microsoft Corporation|FUJITSU)/; s/^ \*//mg; s/^#//mg; if (index($_, $BSD3) == -1) { $err = 1; print STDERR "Outside copyright but no/wrong license text in $f\n"; } } exit $err
2,212
34.126984
71
pl
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 "test@package.com" 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 "pmem-bot@intel.com" 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