static void check_memmove_variants(size_t doff, size_t soff, size_t len) { check_memmove(doff, soff, len, pmem_memmove_persist_wrapper, 0); if (!Heavy) return; check_memmove(doff, soff, len, pmem_memmove_nodrain_wrapper, 0); for (int i = 0; i < ARRAY_SIZE(Flags); ++i) check_memmove(doff, soff, len, pmem_memmove, Flags[i]); }
int main(int argc, char *argv[]) { START(argc, argv, "pmem_movnt_align"); if (argc != 2) UT_FATAL("usage: %s type", argv[0]); char type = argv[1][0]; char *src, *dst; size_t s; switch (type) { case 'C': /* memcpy */ /* mmap with guard pages */ src = MMAP_ANON_ALIGNED(N_BYTES, 0); dst = MMAP_ANON_ALIGNED(N_BYTES, 0); if (src == NULL || dst == NULL) UT_FATAL("!mmap"); /* check memcpy with 0 size */ check_memcpy(dst, src, 0); /* check memcpy with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst, src, N_BYTES - s); /* check memcpy with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src, N_BYTES - s); /* check memcpy with unaligned begin and end */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src + s, N_BYTES - 2 * s); MUNMAP_ANON_ALIGNED(src, N_BYTES); MUNMAP_ANON_ALIGNED(dst, N_BYTES); break; case 'B': /* memmove backward */ /* mmap with guard pages */ src = MMAP_ANON_ALIGNED(2 * N_BYTES - 4096, 0); dst = src + N_BYTES - 4096; if (src == NULL) UT_FATAL("!mmap"); /* check memmove in backward direction with 0 size */ check_memmove(dst, src, 0); /* check memmove in backward direction with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memmove(dst, src, N_BYTES - s); /* check memmove in backward direction with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src, N_BYTES - s); /* * check memmove in backward direction with unaligned begin * and end */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src + s, N_BYTES - 2 * s); MUNMAP_ANON_ALIGNED(src, 2 * N_BYTES - 4096); break; case 'F': /* memmove forward */ /* mmap with guard pages */ dst = MMAP_ANON_ALIGNED(2 * N_BYTES - 4096, 0); src = dst + N_BYTES - 4096; if (src == NULL) UT_FATAL("!mmap"); /* check memmove in forward direction with 0 size */ check_memmove(dst, src, 0); /* check memmove in forward direction with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memmove(dst, src, N_BYTES - s); /* check memmove in forward direction with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src, N_BYTES - s); /* * check memmove in forward direction with unaligned begin * and end */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src + s, N_BYTES - 2 * s); MUNMAP_ANON_ALIGNED(dst, 2 * N_BYTES - 4096); break; case 'S': /* memset */ /* mmap with guard pages */ dst = MMAP_ANON_ALIGNED(N_BYTES, 0); if (dst == NULL) UT_FATAL("!mmap"); /* check memset with 0 size */ check_memset(dst, 0); /* check memset with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memset(dst, N_BYTES - s); /* check memset with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memset(dst + s, N_BYTES - s); /* check memset with unaligned begin and end */ for (s = 0; s < CACHELINE; s++) check_memset(dst + s, N_BYTES - 2 * s); MUNMAP_ANON_ALIGNED(dst, N_BYTES); break; default: UT_FATAL("!wrong type of test"); break; } DONE(NULL); }
int main(int argc, char *argv[]) { START(argc, argv, "pmem_movnt_align"); if (argc != 2) FATAL("usage: %s type", argv[0]); char type = argv[1][0]; /* * mmap twice the number of bytes to transfer and * separators after each region */ size_t mmap_size = N_BYTES * 2 + SEPARATOR * 2; void *buff = MMAP(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); if (buff == NULL) FATAL("!mmap"); void *src; void *dst; size_t s; switch (type) { case 'C': /* memcpy */ src = buff + N_BYTES + SEPARATOR; dst = buff; /* unmap separators */ MUNMAP(dst + N_BYTES, SEPARATOR); MUNMAP(src + N_BYTES, SEPARATOR); /* check memcpy with 0 size */ check_memcpy(dst, src, 0); /* check memcpy with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst, src, N_BYTES - s); /* check memcpy with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src, N_BYTES - s); /* check memcpy with unaligned begin and end */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src + s, N_BYTES - 2 * s); break; case 'B': /* memmove backward */ MUNMAP(buff, SEPARATOR); MUNMAP(buff + 2 * N_BYTES, 2 * SEPARATOR); src = buff + SEPARATOR; dst = buff + N_BYTES; /* check memmove in backward direction with 0 size */ check_memmove(dst, src, 0); /* check memmove in backward direction with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memmove(dst, src, N_BYTES - s); /* check memmove in backward direction with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src, N_BYTES - s); /* * check memmove in backward direction with unaligned begin * and end */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src + s, N_BYTES - 2 * s); break; case 'F': /* memmove forward */ MUNMAP(buff, SEPARATOR); MUNMAP(buff + 2 * N_BYTES, 2 * SEPARATOR); src = buff + N_BYTES; dst = buff + SEPARATOR; /* check memmove in forward direction with 0 size */ check_memmove(dst, src, 0); /* check memmove in forward direction with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memmove(dst, src, N_BYTES - s); /* check memmove in forward direction with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memcpy(dst + s, src, N_BYTES - s); /* * check memmove in forward direction with unaligned begin * and end */ for (s = 0; s < CACHELINE; s++) check_memmove(dst + s, src + s, N_BYTES - 2 * s); break; case 'S': /* memset */ MUNMAP(buff, SEPARATOR); MUNMAP(buff + N_BYTES + SEPARATOR, N_BYTES + SEPARATOR); dst = buff + SEPARATOR; /* check memset with 0 size */ check_memset(dst, 0); /* check memset with unaligned size */ for (s = 0; s < CACHELINE; s++) check_memset(dst, N_BYTES - s); /* check memset with unaligned begin */ for (s = 0; s < CACHELINE; s++) check_memset(dst + s, N_BYTES - s); /* check memset with unaligned begin and end */ for (s = 0; s < CACHELINE; s++) check_memset(dst + s, N_BYTES - 2 * s); break; default: FATAL("!wrong type of test"); break; } MUNMAP(buff, mmap_size); DONE(NULL); }