static void * pmem_memmove_persist_wrapper(void *pmemdest, const void *src, size_t len, unsigned flags) { (void) flags; return pmem_memmove_persist(pmemdest, src, len); }
/* * do_memmove: Worker function for memmove. * * Always work within the boundary of bytes. Fill in 1/2 of the src * memory with the pattern we want to write. This allows us to check * that we did not overwrite anything we were not supposed to in the * dest. Use the non pmem version of the memset/memcpy commands * so as not to introduce any possible side affects. */ static void do_memmove(int fd, void *dest, void *src, char *file_name, off_t dest_off, off_t src_off, off_t off, off_t bytes) { void *ret; void *src1 = malloc(bytes); void *buf = malloc(bytes); char old; memset(buf, 0, bytes); memset(src1, 0, bytes); memset(src, 0x5A, bytes / 4); memset(src + bytes / 4, 0x54, bytes / 4); /* dest == src */ old = *(char *)(dest + dest_off); ret = pmem_memmove_persist(dest + dest_off, dest + dest_off, bytes / 2); ASSERTeq(ret, dest + dest_off); ASSERTeq(*(char *)(dest + dest_off), old); /* len == 0 */ old = *(char *)(dest + dest_off); ret = pmem_memmove_persist(dest + dest_off, src + src_off, 0); ASSERTeq(ret, dest + dest_off); ASSERTeq(*(char *)(dest + dest_off), old); /* * A side affect of the memmove call is that * src contents will be changed in the case of overlapping * addresses. */ memcpy(src1, src, bytes / 2); ret = pmem_memmove_persist(dest + dest_off, src + src_off, bytes / 2); ASSERTeq(ret, dest + dest_off); /* memcmp will validate that what I expect in memory. */ if (memcmp(src1 + src_off, dest + dest_off, bytes / 2)) ERR("%s: %zu bytes do not match with memcmp", file_name, bytes / 2); /* * This is a special case. An overlapping dest means that * src is a pointer to the file, and destination is src + dest_off + * overlap. This is the basis for the comparison. The use of ERR * here is deliberate. This will force a failure of the test but allow * it to continue until its done. The idea is that allowing some * to succeed and others to fail gives more information about what * went wrong. */ if (dest > src && off != 0) { LSEEK(fd, (off_t)dest_off + off, SEEK_SET); if (READ(fd, buf, bytes / 2) == bytes / 2) { if (memcmp(src1 + src_off, buf, bytes / 2)) ERR("%s: first %zu bytes do not match", file_name, bytes / 2); } } else { LSEEK(fd, (off_t)dest_off, SEEK_SET); if (READ(fd, buf, bytes / 2) == bytes / 2) { if (memcmp(src1 + src_off, buf, bytes / 2)) ERR("%s: first %zu bytes do not match", file_name, bytes / 2); } } }