summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt93
-rw-r--r--Makefile.am96
-rw-r--r--configure.ac32
-rw-r--r--mem.c8
-rw-r--r--test/test_mem_cache.c2
-rw-r--r--test/test_phys.c1
6 files changed, 134 insertions, 98 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index dc4bba1..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-project(LIBBRAUNR)
-cmake_minimum_required(VERSION 2.6)
-
-include(TestBigEndian)
-
-set(CMAKE_VERBOSE_MAKEFILE OFF)
-set(CMAKE_BUILD_TYPE RelWithDebInfo)
-#set(CMAKE_BUILD_TYPE Debug)
-set(BUILD_SHARED_LIBS TRUE)
-test_big_endian(HOST_BIG_ENDIAN)
-
-add_definitions(-Wall -Wextra -Wmissing-prototypes)
-add_definitions(-D_HOST_BIG_ENDIAN=${HOST_BIG_ENDIAN})
-
-set(CONFIG_NR_CPUS 8)
-set(CONFIG_CPU_L1_SHIFT 6)
-set(CONFIG_MEM_MALLOC 0)
-set(CONFIG_MEM_USE_PHYS 0)
-set(CONFIG_MEM_VERIFY 0)
-
-set(BRAUNR_SOURCES
- error.c
- list.c
- avltree.c
- rbtree.c
- rdxtree.c
- mem.c
- phys.c
- xprintf.c
-)
-
-set(LIBS -lpthread -lrt)
-
-add_definitions(-DCONFIG_NR_CPUS=${CONFIG_NR_CPUS})
-add_definitions(-DCONFIG_CPU_L1_SHIFT=${CONFIG_CPU_L1_SHIFT})
-
-if(CONFIG_MEM_MALLOC)
- add_definitions(-DCONFIG_MEM_MALLOC)
- set(BRAUNR_SOURCES ${BRAUNR_SOURCES} mem_malloc.c)
-endif(CONFIG_MEM_MALLOC)
-
-if(CONFIG_MEM_USE_PHYS)
- add_definitions(-DCONFIG_MEM_USE_PHYS)
-endif(CONFIG_MEM_USE_PHYS)
-
-if(CONFIG_MEM_VERIFY)
- add_definitions(-DCONFIG_MEM_VERIFY)
-endif(CONFIG_MEM_VERIFY)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-add_library(rbraun ${BRAUNR_SOURCES})
-target_link_libraries(rbraun ${LIBS})
-set_target_properties(rbraun PROPERTIES VERSION 1)
-
-add_executable(test_avltree test/test_avltree.c)
-target_link_libraries(test_avltree rbraun ${LIBS})
-
-add_executable(test_rbtree test/test_rbtree.c)
-target_link_libraries(test_rbtree rbraun ${LIBS})
-
-add_executable(test_rdxtree test/test_rdxtree.c)
-target_link_libraries(test_rdxtree rbraun ${LIBS})
-
-add_executable(test_mem_cache test/test_mem_cache.c)
-target_link_libraries(test_mem_cache ${LIBS})
-
-add_executable(test_mem test/test_mem.c)
-target_link_libraries(test_mem rbraun ${LIBS})
-
-add_executable(test_mem_offbyone test/test_mem_offbyone.c)
-target_link_libraries(test_mem_offbyone rbraun ${LIBS})
-
-add_executable(test_mem_cache_invalid_free test/test_mem_cache_invalid_free.c)
-target_link_libraries(test_mem_cache_invalid_free rbraun ${LIBS})
-
-add_executable(test_mem_cache_double_free test/test_mem_cache_double_free.c)
-target_link_libraries(test_mem_cache_double_free rbraun ${LIBS})
-
-add_executable(test_mem_cache_write_free test/test_mem_cache_write_free.c)
-target_link_libraries(test_mem_cache_write_free rbraun ${LIBS})
-
-add_executable(test_mem_cache_write_beyond test/test_mem_cache_write_beyond.c)
-target_link_libraries(test_mem_cache_write_beyond rbraun ${LIBS})
-
-add_executable(test_mem_cache_write_buftag test/test_mem_cache_write_buftag.c)
-target_link_libraries(test_mem_cache_write_buftag rbraun ${LIBS})
-
-add_executable(test_phys test/test_phys.c)
-target_link_libraries(test_phys rbraun ${LIBS})
-
-add_executable(test_xprintf test/test_xprintf.c)
-target_link_libraries(test_xprintf rbraun ${LIBS})
-set_target_properties(test_xprintf PROPERTIES COMPILE_FLAGS -Wno-format)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..55da9a2
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,96 @@
+EXTRA_DIST =
+MOSTLYCLEANFILES =
+
+AM_CPPFLAGS = \
+ -pipe \
+ -std=gnu99 \
+ -imacros config.h \
+ -I$(top_srcdir)
+
+AM_CFLAGS = \
+ -Wall \
+ -Wextra \
+ -Wmissing-prototypes
+
+lib_LTLIBRARIES = librbraun.la
+
+librbraun_la_SOURCES = \
+ avltree.c \
+ avltree.h \
+ avltree_i.h \
+ cpu.h \
+ error.c \
+ error.h \
+ hash.h \
+ list.c \
+ list.h \
+ macros.h \
+ mem.c \
+ mem.h \
+ mem_malloc.c \
+ mem_malloc.h \
+ phys.c \
+ phys.h \
+ rbtree.c \
+ rbtree.h \
+ rbtree_i.h \
+ rdxtree.c \
+ rdxtree.h \
+ xprintf.c \
+ xprintf.h
+librbraun_la_LIBADD = -lrt -lpthread
+
+bin_PROGRAMS = \
+ test_avltree \
+ test_mem \
+ test_mem_cache \
+ test_mem_cache_invalid_free \
+ test_mem_cache_double_free \
+ test_mem_cache_write_free \
+ test_mem_cache_write_beyond \
+ test_mem_cache_write_buftag \
+ test_mem_offbyone \
+ test_phys \
+ test_rbtree \
+ test_rdxtree \
+ test_xprintf
+
+test_avltree_SOURCES = test/test_avltree.c
+test_avltree_LDADD = librbraun.la
+
+test_mem_SOURCES = test/test_mem.c
+test_mem_LDADD = librbraun.la
+
+test_mem_cache_SOURCES = test/test_mem_cache.c
+test_mem_cache_LDADD = -lrt -lpthread
+
+test_mem_cache_invalid_free_SOURCES = test/test_mem_cache_invalid_free.c
+test_mem_cache_invalid_free_LDADD = librbraun.la
+
+test_mem_cache_double_free_SOURCES = test/test_mem_cache_double_free.c
+test_mem_cache_double_free_LDADD = librbraun.la
+
+test_mem_cache_write_free_SOURCES = test/test_mem_cache_write_free.c
+test_mem_cache_write_free_LDADD = librbraun.la
+
+test_mem_cache_write_beyond_SOURCES = test/test_mem_cache_write_beyond.c
+test_mem_cache_write_beyond_LDADD = librbraun.la
+
+test_mem_cache_write_buftag_SOURCES = test/test_mem_cache_write_buftag.c
+test_mem_cache_write_buftag_LDADD = librbraun.la
+
+test_mem_offbyone_SOURCES = test/test_mem_offbyone.c
+test_mem_offbyone_LDADD = librbraun.la
+
+test_phys_SOURCES = test/test_phys.c
+test_phys_LDADD = -lrt -lpthread
+
+test_rbtree_SOURCES = test/test_rbtree.c
+test_rbtree_LDADD = librbraun.la
+
+test_rdxtree_SOURCES = test/test_rdxtree.c
+test_rdxtree_LDADD = -lrt -lpthread
+
+test_xprintf_SOURCES = test/test_xprintf.c
+test_xprintf_CFLAGS = $(AM_CFLAGS) -Wno-format
+test_xprintf_LDADD = librbraun.la
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..4bf5219
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,32 @@
+AC_INIT([librbraun], [0.1], [rbraun@sceen.net], [librbraun])
+
+AC_CONFIG_SRCDIR([macros.h])
+AC_CONFIG_AUX_DIR([build-aux])
+
+LT_INIT
+
+AM_INIT_AUTOMAKE([foreign subdir-objects 1.10])
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
+ [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
+
+AC_PREFIX_DEFAULT([])
+AC_CANONICAL_HOST
+AC_PROG_CPP
+AC_PROG_CC
+AM_PROG_AS
+AM_PROG_CC_C_O
+
+AC_DEFINE_UNQUOTED([CONFIG_NR_CPUS], [8],
+ [maximum number of supported processors])
+AC_DEFINE_UNQUOTED([CONFIG_CPU_L1_SHIFT], [6],
+ [Size of the CPU cache line size defined as a base two logarithm])
+AC_DEFINE_UNQUOTED([CONFIG_MEM_MALLOC], [0], [build malloc and friends])
+AC_DEFINE_UNQUOTED([CONFIG_MEM_USE_PHYS], [0],
+ [make the mem module use the phys module as its backend])
+AC_DEFINE_UNQUOTED([CONFIG_MEM_VERIFY], [0],
+ [enforce strong verification on all memory caches])
+
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/mem.c b/mem.c
index 45a4dd9..ce71be5 100644
--- a/mem.c
+++ b/mem.c
@@ -412,7 +412,7 @@ static void mem_cache_error(struct mem_cache *cache, void *buf, int error,
static void * mem_cache_alloc_from_slab(struct mem_cache *cache);
static void mem_cache_free_to_slab(struct mem_cache *cache, void *buf);
-#ifdef CONFIG_MEM_USE_PHYS
+#if CONFIG_MEM_USE_PHYS
#include "phys.h"
static void *
@@ -889,7 +889,7 @@ mem_cache_init(struct mem_cache *cache, const char *name,
struct mem_cpu_pool_type *cpu_pool_type;
size_t i, buf_size;
-#ifdef CONFIG_MEM_VERIFY
+#if CONFIG_MEM_VERIFY
cache->flags = MEM_CF_VERIFY;
#else
cache->flags = 0;
@@ -1577,7 +1577,7 @@ mem_gc(void *arg)
#if 0
mem_info();
-#ifdef CONFIG_MEM_USE_PHYS
+#if CONFIG_MEM_USE_PHYS
phys_info();
#endif /* CONFIG_MEM_USE_PHYS */
#endif
@@ -1616,7 +1616,7 @@ mem_setup(void)
*/
assert(sizeof(union mem_bufctl) <= MEM_ALIGN_MIN);
-#ifdef CONFIG_MEM_USE_PHYS
+#if CONFIG_MEM_USE_PHYS
phys_setup();
#endif /* CONFIG_MEM_USE_PHYS */
diff --git a/test/test_mem_cache.c b/test/test_mem_cache.c
index 518dc09..eaa043a 100644
--- a/test/test_mem_cache.c
+++ b/test/test_mem_cache.c
@@ -34,7 +34,7 @@
#include "../error.c"
#include "../avltree.c"
-#ifdef CONFIG_MEM_USE_PHYS
+#if CONFIG_MEM_USE_PHYS
#include "../phys.c"
#endif /* CONFIG_MEM_USE_PHYS */
diff --git a/test/test_phys.c b/test/test_phys.c
index d9ad154..5ded8d5 100644
--- a/test/test_phys.c
+++ b/test/test_phys.c
@@ -27,6 +27,7 @@
#include <stddef.h>
#include <string.h>
+#include "../error.c"
#include "../phys.c"
int