git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into signal-dev
[lunaix-os.git]
/
lunaix-os
/
kernel
/
mm
/
dmm.c
diff --git
a/lunaix-os/kernel/mm/dmm.c
b/lunaix-os/kernel/mm/dmm.c
index dee5d28636fa30f5ff1fc3438762b1b5c1644662..d5826253963e09fc2d74adae073d7ff7114b9816 100644
(file)
--- a/
lunaix-os/kernel/mm/dmm.c
+++ b/
lunaix-os/kernel/mm/dmm.c
@@
-20,20
+20,21
@@
#include <lunaix/status.h>
#include <lunaix/spike.h>
#include <lunaix/status.h>
#include <lunaix/spike.h>
+#include <lunaix/syscall.h>
-
int _syscall_sbrk(void* addr
) {
+
__DEFINE_LXSYSCALL1(int, sbrk, size_t, size
) {
heap_context_t* uheap = &__current->mm.u_heap;
mutex_lock(&uheap->lock);
heap_context_t* uheap = &__current->mm.u_heap;
mutex_lock(&uheap->lock);
-
int r = lxsbrk(uheap, addr
);
+
void* r = lxsbrk(uheap, size
);
mutex_unlock(&uheap->lock);
return r;
}
mutex_unlock(&uheap->lock);
return r;
}
-
void* _syscall_brk(size_t size
) {
+
__DEFINE_LXSYSCALL1(void*, brk, void*, addr
) {
heap_context_t* uheap = &__current->mm.u_heap;
mutex_lock(&uheap->lock);
heap_context_t* uheap = &__current->mm.u_heap;
mutex_lock(&uheap->lock);
-
void* r = lxbrk(uheap, size
);
+
int r = lxbrk(uheap, addr
);
mutex_unlock(&uheap->lock);
return r;
}
mutex_unlock(&uheap->lock);
return r;
}
@@
-50,13
+51,13
@@
dmm_init(heap_context_t* heap)
}
int
}
int
-lx
s
brk(heap_context_t* heap, void* addr)
+lxbrk(heap_context_t* heap, void* addr)
{
{
- return
lxbrk(heap, addr - heap->brk) != NULL
;
+ return
-(lxsbrk(heap, addr - heap->brk) == (void*)-1)
;
}
void*
}
void*
-lxbrk(heap_context_t* heap, size_t size)
+lx
s
brk(heap_context_t* heap, size_t size)
{
if (size == 0) {
return heap->brk;
{
if (size == 0) {
return heap->brk;
@@
-71,6
+72,7
@@
lxbrk(heap_context_t* heap, size_t size)
// any invalid situations
if (next >= heap->max_addr || next < current_brk) {
__current->k_status = LXINVLDPTR;
// any invalid situations
if (next >= heap->max_addr || next < current_brk) {
__current->k_status = LXINVLDPTR;
+ return (void*)-1;
}
uintptr_t diff = PG_ALIGN(next) - PG_ALIGN(current_brk);
}
uintptr_t diff = PG_ALIGN(next) - PG_ALIGN(current_brk);