/* * libpmem_memset_nodrain -- perform operation using libpmem * pmem_memset_nodrain(). */ static int libpmem_memset_nodrain(void *dest, int c, size_t len) { pmem_memset_nodrain(dest, c, len); return 0; }
int main(int argc, char *argv[]) { char *dst; char *src; START(argc, argv, "pmem_movnt"); src = MEMALIGN(64, 8192); dst = MEMALIGN(64, 8192); memset(src, 0x88, 8192); memset(dst, 0, 8192); for (size_t size = 1; size <= 4096; size *= 2) { memset(dst, 0, 4096); pmem_memcpy_nodrain(dst, src, size); ASSERTeq(memcmp(src, dst, size), 0); ASSERTeq(dst[size], 0); } for (size_t size = 1; size <= 4096; size *= 2) { memset(dst, 0, 4096); pmem_memmove_nodrain(dst, src, size); ASSERTeq(memcmp(src, dst, size), 0); ASSERTeq(dst[size], 0); } for (size_t size = 1; size <= 4096; size *= 2) { memset(dst, 0, 4096); pmem_memset_nodrain(dst, 0x77, size); ASSERTeq(dst[0], 0x77); ASSERTeq(dst[size - 1], 0x77); ASSERTeq(dst[size], 0); } FREE(dst); FREE(src); DONE(NULL); }
static void * pmem_memset_nodrain_wrapper(void *pmemdest, int c, size_t len, unsigned flags) { (void) flags; return pmem_memset_nodrain(pmemdest, c, len); }