test/nvme: allocate aligned memory in unit tests

Match the expected alignment for nvme_alloc_request() and nvme_malloc()
to allow optimized memory copy code to work even in the unit tests.

Change-Id: I546692a6df9615a12a8209618fb6159a9c9e426b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-06-27 09:35:05 -07:00
parent 88669436f9
commit eb9d77a910

View File

@ -47,7 +47,10 @@ struct spdk_pci_device;
static inline void *
nvme_malloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
{
void *buf = calloc(1, size);
void *buf = NULL;
if (posix_memalign(&buf, align, size)) {
return NULL;
}
*phys_addr = (uint64_t)buf;
return buf;
}
@ -74,7 +77,9 @@ uint64_t nvme_vtophys(void *buf);
#define nvme_alloc_request(bufp) \
do \
{ \
*bufp = malloc(sizeof(struct nvme_request)); \
if (posix_memalign((void **)(bufp), 64, sizeof(struct nvme_request))) { \
*(bufp) = NULL; \
} \
} \
while (0)