Move PREALLOCATE_CORE/PREALLOCATE_SWAP defines into the respective header files and...
authorNick Downing <nick@ndcode.org>
Sun, 7 Apr 2019 05:27:35 +0000 (15:27 +1000)
committerNick Downing <nick@ndcode.org>
Sun, 7 Apr 2019 05:27:35 +0000 (15:27 +1000)
core.c
core.h
process.c
process.h
swap.c
swap.h

diff --git a/core.c b/core.c
index 21ac014..43d6a46 100644 (file)
--- a/core.c
+++ b/core.c
@@ -20,6 +20,10 @@ int core_block_next;
 int core_block_avail;
 #endif
 
+#ifdef PREALLOCATE_CORE
+int victim_core_blocks;
+#endif
+
 static void core_move(struct pool_item *item, int new_base) {
   int base = item->base;
   int blocks = item->limit - base;
diff --git a/core.h b/core.h
index 21125a0..2eaf017 100644 (file)
--- a/core.h
+++ b/core.h
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include "pool.h"
 
+//#define PREALLOCATE_CORE 1
 //#define INDIRECT_CORE 1
 #define MOVEABLE_CORE 1
 #define BLOCK_SIZE 0x1000
@@ -43,6 +44,10 @@ extern int core_block_next;
 extern int core_block_avail;
 #endif
 
+#ifdef PREALLOCATE_CORE
+extern int victim_core_blocks;
+#endif
+
 #ifdef INDIRECT_CORE
 void core_init(int n_table, int n_blocks);
 bool core_block_alloc(int *blocks, int size);
index fbc00ac..dc91ef9 100644 (file)
--- a/process.c
+++ b/process.c
@@ -16,12 +16,6 @@ int process_avail, process_spare;
 struct lru_item lru_head;
 
 struct process *victim;
-#ifdef PREALLOCATE_CORE
-int victim_core_blocks;
-#endif
-#ifdef PREALLOCATE_SWAP
-int victim_swap_blocks;
-#endif
 
 #if 1
 // won't work when compiled with NDEBUG
index 1e37161..10b9a33 100644 (file)
--- a/process.h
+++ b/process.h
@@ -3,9 +3,6 @@
 
 #include "pool.h"
 
-//#define PREALLOCATE_CORE 1
-#define PREALLOCATE_SWAP 1
-
 struct lru_item {
   struct lru_item *prev;
   struct lru_item *next;
@@ -24,16 +21,6 @@ extern int process_avail, process_spare;
 extern struct lru_item lru_head;
 
 extern struct process *victim;
-#ifdef PREALLOCATE_CORE
-extern int victim_core_blocks;
-#else
-extern struct pool_item victim_core_item;
-#endif
-#ifdef PREALLOCATE_SWAP
-extern int victim_swap_blocks;
-#else
-extern struct pool_item victim_swap_item;
-#endif
 
 void process_init(int n, int spare);
 bool process_alloc(struct process *process, long size);
diff --git a/swap.c b/swap.c
index 4c7a9db..db6c120 100644 (file)
--- a/swap.c
+++ b/swap.c
@@ -21,6 +21,10 @@ int swap_block_next;
 int swap_block_avail;
 #endif
 
+#ifdef PREALLOCATE_SWAP
+int victim_swap_blocks;
+#endif
+
 static void swap_move(struct pool_item *item, int new_base) {
   int base = item->base;
   int blocks = item->limit - base;
diff --git a/swap.h b/swap.h
index 62e458e..ba77844 100644 (file)
--- a/swap.h
+++ b/swap.h
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include "pool.h"
 
+#define PREALLOCATE_SWAP 1
 #define INDIRECT_SWAP 1
 //#define MOVEABLE_SWAP 1
 
@@ -41,6 +42,10 @@ extern int swap_block_next;
 extern int swap_block_avail;
 #endif
 
+#ifdef PREALLOCATE_SWAP
+extern int victim_swap_blocks;
+#endif
+
 #ifdef INDIRECT_SWAP
 void swap_init(int n_table, int n_blocks);
 bool swap_block_alloc(int *blocks, int size);