Browse Source

Added support for static library compilation, fixed indentation in src/CMakeLists.txt, fixed heap.h to include stddef.h for size_t support, added P2012 in cmake to automate some choices required.

Ioannis Koutras 13 years ago
parent
commit
2f06c81a16
3 changed files with 38 additions and 17 deletions
  1. 10 0
      DefineOptions.cmake
  2. 3 2
      include/dmmlib/heap.h
  3. 25 15
      src/CMakeLists.txt

+ 10 - 0
DefineOptions.cmake

@@ -1,3 +1,13 @@
 option(HAVE_LOCKS "Build with POSIX locking mechanisms" ON)
 option(WITH_EXAMPLES "Build with examples" OFF)
 option(WITH_MEMORY_SPACE_AWARENESS "Build with memory space awareness" OFF)
+option(WITH_STATIC_LIB "Build with a static library" OFF)
+
+option(P2012 "Build for P2012 runtime" OFF)
+
+if (P2012)
+  set(HAVE_LOCKS OFF)
+  set(WITH_MEMORY_SPACE_AWARENESS ON)
+  set(WITH_STATIC_LIB ON)
+endif (P2012)
+

+ 3 - 2
include/dmmlib/heap.h

@@ -9,6 +9,7 @@
 #define HEAP_H
 
 #include <stdint.h>
+#include <stddef.h> // For size_t support
 #include <stdbool.h>
 
 #include "dmm_config.h"
@@ -71,12 +72,12 @@ typedef struct dmmknobs_s {
 	float empty_threshold; /**< FIXME Need to find explanation \brief Empty
 				 Threshold */
 	uint32_t percentage; // FIXME to be investigated what it is
-	knob_state_t frag_state;
+	knob_state_t frag_state; /**< \brief The current state of fragmentation. */
 	knob_state_t foot_state;	
 } dmmknobs_t;
 
 /**
- * \brief A structure to store heap information.
+ * A structure to store heap information.
  */
 typedef struct heap_s {
 	maptable_node_t *maptable_head; /**< \brief The head of the maptable list. */

+ 25 - 15
src/CMakeLists.txt

@@ -15,30 +15,40 @@ set(DMMLIB_SHARED_LIBRARY
   CACHE INTERNAL "dmmlib shared library"
 )
 
+if (WITH_STATIC_LIB)
+  set(DMMLIB_STATIC_LIBRARY
+    dmm_static
+    CACHE INTERNAL "dmmlib static library"
+  )
+endif (WITH_STATIC_LIB)
+
 set(dmmlib_SRCS
-	block_header.c
-	coalesce.c
-	custom_free.c
-	custom_malloc.c
-	dmm_adaptor.c
-	other.c
-	initialize_allocator.c
-	sys_alloc.c
+  block_header.c
+  coalesce.c
+  custom_free.c
+  custom_malloc.c
+  dmm_adaptor.c
+  other.c
+  initialize_allocator.c
+  sys_alloc.c
 )
 
 if (HAVE_LOCKS)
-	find_package (Threads)
-	set(dmmlib_SRCS
-		${dmmlib_SRCS}
-		posix_lock.c
-	)
+  find_package (Threads)
+  set(dmmlib_SRCS
+    ${dmmlib_SRCS}
+    posix_lock.c
+  )
 endif (HAVE_LOCKS)
 
 include_directories(
-	${DMMLIB_PUBLIC_INCLUDE_DIRS}
-	${DMMLIB_PRIVATE_INCLUDE_DIRS}
+  ${DMMLIB_PUBLIC_INCLUDE_DIRS}
+  ${DMMLIB_PRIVATE_INCLUDE_DIRS}
 )
 
 add_library(${DMMLIB_SHARED_LIBRARY} SHARED ${dmmlib_SRCS})
 
+if (WITH_STATIC_LIB)
+  add_library(${DMMLIB_STATIC_LIBRARY} STATIC ${dmmlib_SRCS})
+endif (WITH_STATIC_LIB)