Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git] / lunaix-os / kernel / mm / dmm.c
index 3da8501f34aecdb43aa89a1fcd3270d15e9e6b6a..a76b9de979dd8e93ad68c6e9a24fdc7e7a571664 100644 (file)
@@ -24,17 +24,19 @@ create_heap(struct proc_mm* pvms, ptr_t addr)
                                     .mlen = PG_SIZE };
     int status = 0;
     struct mm_region* heap;
-    if ((status = mem_map(NULL, &heap, addr, NULL, &map_param))) {
+    if ((status = mmap_user(NULL, &heap, addr, NULL, &map_param))) {
         return status;
     }
 
     heap->region_copied = __heap_copied;
     mm_index((void**)&pvms->heap, heap);
+
+    return status;
 }
 
 __DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
 {
-    struct proc_mm* pvms = &__current->mm;
+    struct proc_mm* pvms = vmspace(__current);
     struct mm_region* heap = pvms->heap;
 
     assert(heap);
@@ -47,11 +49,11 @@ __DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
 
 __DEFINE_LXSYSCALL1(int, brk, void*, addr)
 {
-    struct proc_mm* pvms = &__current->mm;
+    struct proc_mm* pvms = vmspace(__current);
     struct mm_region* heap = pvms->heap;
 
     if (!heap) {
-        return DO_STATUS(create_heap(pvms, addr));
+        return DO_STATUS(create_heap(pvms, (ptr_t)addr));
     }
 
     assert(heap);