summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>2020-01-06 00:01:10 +0900
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>2020-01-06 00:01:19 +0900
commitfd745bf3cacdd51b58619ae48bfeb0358ddda28e (patch)
tree862b90d3e1240c219405f18f058c9e8f19ab9563 /unittests
parentfa6e7f4fb827adb124dbb97a7f72d64e76b2fe6a (diff)
downloadfio-fd745bf3cacdd51b58619ae48bfeb0358ddda28e.tar.gz
fio-fd745bf3cacdd51b58619ae48bfeb0358ddda28e.tar.bz2
lib/memalign: remove smalloc()/sfree() dependency
fio_memalign()/fio_memfree() implementation shouldn't depend on smalloc()/sfree() which has dependency on fio code itself. e.g. This forces unittest code to prepare stab functions for smalloc()/sfree(). This smalloc()/sfree() dependency was added by 3114b675fd ("fio: enable cross-thread overlap checking with processes"). Rename fio_memalign()/fio_memfree() to __fio_memalign()/__fio_memfree() and take a function pointer instead of a boolean flag. Add fio_memalign()/fio_memfree() as an inlined wrapper for __fio_memalign()/__fio_memfree() without API change. The only real change here is lib/memalign functions got renamed. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Diffstat (limited to 'unittests')
-rw-r--r--unittests/lib/memalign.c3
-rw-r--r--unittests/unittest.c11
-rw-r--r--unittests/unittest.h4
3 files changed, 2 insertions, 16 deletions
diff --git a/unittests/lib/memalign.c b/unittests/lib/memalign.c
index 854c2744..42a2e31a 100644
--- a/unittests/lib/memalign.c
+++ b/unittests/lib/memalign.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include "../unittest.h"
#include "../../lib/memalign.h"
@@ -5,7 +6,7 @@
static void test_memalign_1(void)
{
size_t align = 4096;
- void *p = fio_memalign(align, 1234, false);
+ void *p = __fio_memalign(align, 1234, malloc);
if (p)
CU_ASSERT_EQUAL(((int)(uintptr_t)p) & (align - 1), 0);
diff --git a/unittests/unittest.c b/unittests/unittest.c
index 66789e4f..c37e1971 100644
--- a/unittests/unittest.c
+++ b/unittests/unittest.c
@@ -8,17 +8,6 @@
#include "./unittest.h"
-/* XXX workaround lib/memalign.c's dependency on smalloc.c */
-void *smalloc(size_t size)
-{
- return malloc(size);
-}
-
-void sfree(void *ptr)
-{
- free(ptr);
-}
-
CU_ErrorCode fio_unittest_add_suite(const char *name, CU_InitializeFunc initfn,
CU_CleanupFunc cleanfn, struct fio_unittest_entry *tvec)
{
diff --git a/unittests/unittest.h b/unittests/unittest.h
index bbc49613..786c1c97 100644
--- a/unittests/unittest.h
+++ b/unittests/unittest.h
@@ -11,10 +11,6 @@ struct fio_unittest_entry {
CU_TestFunc fn;
};
-/* XXX workaround lib/memalign.c's dependency on smalloc.c */
-void *smalloc(size_t);
-void sfree(void*);
-
CU_ErrorCode fio_unittest_add_suite(const char*, CU_InitializeFunc,
CU_CleanupFunc, struct fio_unittest_entry*);