git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
IPv6, and I need to learn to compile before commiting
[tpg/acess2.git]
/
Kernel
/
heap.c
diff --git
a/Kernel/heap.c
b/Kernel/heap.c
index
0e3c5f4
..
61f7881
100644
(file)
--- a/
Kernel/heap.c
+++ b/
Kernel/heap.c
@@
-2,7
+2,7
@@
* AcessOS Microkernel Version
* heap.c
*/
* AcessOS Microkernel Version
* heap.c
*/
-#include <
common
.h>
+#include <
acess
.h>
#include <mm_virt.h>
#include <heap.h>
#include <mm_virt.h>
#include <heap.h>
@@
-30,7
+30,7
@@
void free(void *Ptr);
void Heap_Dump();
// === GLOBALS ===
void Heap_Dump();
// === GLOBALS ===
- int g
iHeapSpinlock
;
+ int g
lHeap
;
void *gHeapStart;
void *gHeapEnd;
void *gHeapStart;
void *gHeapEnd;
@@
-140,7
+140,7
@@
void *malloc(size_t Bytes)
Bytes = (Bytes + sizeof(tHeapHead) + sizeof(tHeapFoot) + BLOCK_SIZE-1) & ~(BLOCK_SIZE-1);
// Lock Heap
Bytes = (Bytes + sizeof(tHeapHead) + sizeof(tHeapFoot) + BLOCK_SIZE-1) & ~(BLOCK_SIZE-1);
// Lock Heap
- LOCK(&g
iHeapSpinlock
);
+ LOCK(&g
lHeap
);
// Traverse Heap
for( head = gHeapStart;
// Traverse Heap
for( head = gHeapStart;
@@
-154,6
+154,7
@@
void *malloc(size_t Bytes)
Warning("Size of heap address %p is invalid not aligned (0x%x)", head, head->Size);
Heap_Dump();
#endif
Warning("Size of heap address %p is invalid not aligned (0x%x)", head, head->Size);
Heap_Dump();
#endif
+ RELEASE(&glHeap);
return NULL;
}
return NULL;
}
@@
-165,7
+166,7
@@
void *malloc(size_t Bytes)
Warning("Magic of heap address %p is invalid (0x%x)", head, head->Magic);
Heap_Dump();
#endif
Warning("Magic of heap address %p is invalid (0x%x)", head, head->Magic);
Heap_Dump();
#endif
- RELEASE(&g
iHeapSpinlock
); // Release spinlock
+ RELEASE(&g
lHeap
); // Release spinlock
return NULL;
}
return NULL;
}
@@
-175,7
+176,7
@@
void *malloc(size_t Bytes)
// Perfect fit
if(head->Size == Bytes) {
head->Magic = MAGIC_USED;
// Perfect fit
if(head->Size == Bytes) {
head->Magic = MAGIC_USED;
- RELEASE(&g
iHeapSpinlock
); // Release spinlock
+ RELEASE(&g
lHeap
); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
@@
-202,12
+203,12
@@
void *malloc(size_t Bytes)
best = Heap_Extend( Bytes );
// Check for errors
if(!best) {
best = Heap_Extend( Bytes );
// Check for errors
if(!best) {
- RELEASE(&g
iHeapSpinlock
); // Release spinlock
+ RELEASE(&g
lHeap
); // Release spinlock
return NULL;
}
// Check size
if(best->Size == Bytes) {
return NULL;
}
// Check size
if(best->Size == Bytes) {
- RELEASE(&g
iHeapSpinlock
); // Release spinlock
+ RELEASE(&g
lHeap
); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
@@
-228,7
+229,7
@@
void *malloc(size_t Bytes)
best->Size = Bytes; // Update size in old header
best->Magic = MAGIC_USED; // Mark block as used
best->Size = Bytes; // Update size in old header
best->Magic = MAGIC_USED; // Mark block as used
- RELEASE(&g
iHeapSpinlock
); // Release spinlock
+ RELEASE(&g
lHeap
); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
@@
-285,7
+286,7
@@
void free(void *Ptr)
}
// Lock
}
// Lock
- LOCK( &g
iHeapSpinlock
);
+ LOCK( &g
lHeap
);
// Mark as free
head->Magic = MAGIC_FREE;
// Mark as free
head->Magic = MAGIC_FREE;
@@
-293,7
+294,7
@@
void free(void *Ptr)
Heap_Merge( head );
// Release
Heap_Merge( head );
// Release
- RELEASE( &g
iHeapSpinlock
);
+ RELEASE( &g
lHeap
);
}
/**
}
/**
@@
-444,3
+445,8
@@
void Heap_Dump()
}
}
#endif
}
}
#endif
+
+// === EXPORTS ===
+EXPORT(malloc);
+EXPORT(realloc);
+EXPORT(free);
UCC
git Repository :: git.ucc.asn.au