blank = True
else:
after = i.lstrip()
- if blank and before[-1:] not in opens and after[:1] not in closes:
+ if blank and len(before) and before[-1:] not in opens and after[:1] not in closes:
sys.stdout.write('\n')
sys.stdout.write(i + '\n')
j = i.find('//')
#!/bin/sh -e
+sed -e 's/^\/\/#define CLASSIC_POOL 1/#define CLASSIC_POOL 1/' -i pool.h
+sed -e 's/^#define MOVEABLE_POOL 1/\/\/#define MOVEABLE_POOL 1/' -i pool.h
+
# we will only use non-moveable swap, so it must be preallocated,
# this is because the swap-move routines are too hard to implement
sed -e 's/^\/\/#define PREALLOCATE_SWAP 1/#define PREALLOCATE_SWAP 1/' -i swap.h
rm indirect_core_inode_swap/swap.[ch]
cp rassert.h fuzix_fs.[ch] util.[ch] indirect_core_inode_swap
+sed -e 's/^\/\/#define MOVEABLE_POOL 1/#define MOVEABLE_POOL 1/' -i pool.h
+
sed -e 's/^#define PREALLOCATE_CORE 1/\/\/#define PREALLOCATE_CORE 1/' -i core.h
sed -e 's/^#define INDIRECT_CORE 1/\/\/#define INDIRECT_CORE 1/' -i core.h
sed -e 's/^\/\/#define MOVEABLE_CORE 1/#define MOVEABLE_CORE 1/' -i core.h
./pp.sh moveable_core_indirect_swap
cp rassert.h moveable_core_indirect_swap
+sed -e 's/^#define CLASSIC_POOL 1/\/\/#define CLASSIC_POOL 1/' -i pool.h
+
sed -e 's/^\/\/#define INODE_SWAP 1/#define INODE_SWAP 1/' -i process.h
./pp.sh moveable_core_inode_swap
rm moveable_core_inode_swap/swap.[ch]
check_invariants(head);
}
+#ifdef CLASSIC_POOL
bool pool_alloc(
struct pool_head *head,
struct pool_item *item,
check_invariants(head);
return true;
}
-
-void pool_free(struct pool_head *head, struct pool_item *item) {
- // item must be already allocated
- assert(item->prev && item->next);
-
- // remove from list
- item->prev->next = item->next;
- item->next->prev = item->prev;
-#ifndef NDEBUG
- item->prev = NULL;
- item->next = NULL;
#endif
- // keep track of total allocation
- head->avail += item->limit - item->base;
- check_invariants(head);
-}
-
+#ifdef MOVEABLE_POOL
bool pool_alloc_moveable(
struct pool_head *head,
struct pool_item *item,
check_invariants(head);
return true;
}
+#endif
-void pool_move_item(struct pool_item *from, struct pool_item *to) {
- // from-item must be already allocated
- assert(from->prev && from->next);
-
- // to-item must not be already allocated
- assert(to->prev == NULL && to->next == NULL);
+void pool_free(struct pool_head *head, struct pool_item *item) {
+ // item must be already allocated
+ assert(item->prev && item->next);
- *to = *from;
+ // remove from list
+ item->prev->next = item->next;
+ item->next->prev = item->prev;
#ifndef NDEBUG
- from->prev = NULL;
- from->next = NULL;
+ item->prev = NULL;
+ item->next = NULL;
#endif
- to->prev->next = to;
- to->next->prev = to;
+
+ // keep track of total allocation
+ head->avail += item->limit - item->base;
+ check_invariants(head);
}
#include <stdbool.h>
+//#define CLASSIC_POOL 1
+#define MOVEABLE_POOL 1
+
struct pool_item {
struct pool_item *prev;
struct pool_item *next;
void (*move)(struct pool_item *item, int new_base),
void (*move_up)(struct pool_item *item, int new_limit)
);
+#ifdef CLASSIC_POOL
bool pool_alloc(
struct pool_head *head,
struct pool_item *item,
struct pool_item *item,
int size
);
-void pool_free(struct pool_head *head, struct pool_item *item);
+#endif
+#ifdef MOVEABLE_POOL
bool pool_alloc_moveable(
struct pool_head *head,
struct pool_item *item,
struct pool_item *item,
int size
);
-void pool_move_item(struct pool_item *from, struct pool_item *to);
+#endif
+void pool_free(struct pool_head *head, struct pool_item *item);
#endif