Move memalign to lib/
authorJens Axboe <axboe@fb.com>
Tue, 1 Dec 2015 02:21:08 +0000 (19:21 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 1 Dec 2015 02:21:08 +0000 (19:21 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile
backend.c
lib/memalign.c [new file with mode: 0644]
lib/memalign.h [new file with mode: 0644]
memalign.c [deleted file]
memalign.h [deleted file]
t/dedupe.c

index e30273c..7686eb8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,13 +41,13 @@ SOURCE :=   gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
                lib/num2str.c lib/ieee754.c lib/strntol.c engines/cpu.c \
                engines/mmap.c engines/sync.c engines/null.c engines/net.c \
-               memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
+               server.c client.c iolog.c backend.c libfio.c flow.c \
                cconv.c lib/prio_tree.c lib/zipf.c lib/axmap.c lib/pattern.c \
                lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c json.c \
                lib/hweight.c lib/getrusage.c idletime.c td_error.c \
                profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
                lib/tp.c lib/bloom.c lib/gauss.c lib/mountcheck.c workqueue.c \
-               lib/output_buffer.c \
+               lib/output_buffer.c lib/memalign.c \
                $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c))
 
 ifdef CONFIG_LIBHDFS
@@ -222,8 +222,8 @@ endif
 
 T_DEDUPE_OBJS = t/dedupe.o
 T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
-               memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \
-               crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
+               lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
+               crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
 T_DEDUPE_PROGS = t/fio-dedupe
 
 T_OBJS = $(T_SMALLOC_OBJS)
index 224736f..9a142e8 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -49,7 +49,7 @@
 #include "cgroup.h"
 #include "profile.h"
 #include "lib/rand.h"
-#include "memalign.h"
+#include "lib/memalign.h"
 #include "server.h"
 #include "lib/getrusage.h"
 #include "idletime.h"
diff --git a/lib/memalign.c b/lib/memalign.c
new file mode 100644 (file)
index 0000000..cfd6e46
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <inttypes.h>
+
+#include "memalign.h"
+
+struct align_footer {
+       unsigned int offset;
+};
+
+#define PTR_ALIGN(ptr, mask)   \
+       (char *) (((uintptr_t) ((ptr) + (mask)) & ~(mask)))
+
+void *fio_memalign(size_t alignment, size_t size)
+{
+       struct align_footer *f;
+       void *ptr, *ret = NULL;
+
+       assert(!(alignment & (alignment - 1)));
+
+       ptr = malloc(size + alignment + size + sizeof(*f) - 1);
+       if (ptr) {
+               ret = PTR_ALIGN(ptr, alignment - 1);
+               f = ret + size;
+               f->offset = (uintptr_t) ret - (uintptr_t) ptr;
+       }
+
+       return ret;
+}
+
+void fio_memfree(void *ptr, size_t size)
+{
+       struct align_footer *f = ptr + size;
+
+       free(ptr - f->offset);
+}
diff --git a/lib/memalign.h b/lib/memalign.h
new file mode 100644 (file)
index 0000000..df412e2
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef FIO_MEMALIGN_H
+#define FIO_MEMALIGN_H
+
+extern void *fio_memalign(size_t alignment, size_t size);
+extern void fio_memfree(void *ptr, size_t size);
+
+#endif
diff --git a/memalign.c b/memalign.c
deleted file mode 100644 (file)
index cfd6e46..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-#include <inttypes.h>
-
-#include "memalign.h"
-
-struct align_footer {
-       unsigned int offset;
-};
-
-#define PTR_ALIGN(ptr, mask)   \
-       (char *) (((uintptr_t) ((ptr) + (mask)) & ~(mask)))
-
-void *fio_memalign(size_t alignment, size_t size)
-{
-       struct align_footer *f;
-       void *ptr, *ret = NULL;
-
-       assert(!(alignment & (alignment - 1)));
-
-       ptr = malloc(size + alignment + size + sizeof(*f) - 1);
-       if (ptr) {
-               ret = PTR_ALIGN(ptr, alignment - 1);
-               f = ret + size;
-               f->offset = (uintptr_t) ret - (uintptr_t) ptr;
-       }
-
-       return ret;
-}
-
-void fio_memfree(void *ptr, size_t size)
-{
-       struct align_footer *f = ptr + size;
-
-       free(ptr - f->offset);
-}
diff --git a/memalign.h b/memalign.h
deleted file mode 100644 (file)
index df412e2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef FIO_MEMALIGN_H
-#define FIO_MEMALIGN_H
-
-extern void *fio_memalign(size_t alignment, size_t size);
-extern void fio_memfree(void *ptr, size_t size);
-
-#endif
index 5b88fcb..e1cea50 100644 (file)
@@ -21,7 +21,7 @@
 #include "../smalloc.h"
 #include "../minmax.h"
 #include "../crc/md5.h"
-#include "../memalign.h"
+#include "../lib/memalign.h"
 #include "../os/os.h"
 #include "../gettime.h"
 #include "../fio_time.h"