Changes in uspace/lib/c/generic/as.c [56273bb:63f8966] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/as.c
r56273bb r63f8966 40 40 #include <bitops.h> 41 41 #include <malloc.h> 42 #include "private/libc.h" 42 43 /** Last position allocated by as_get_mappable_page */ 44 static uintptr_t last_allocated = 0; 43 45 44 46 /** Create address space area. … … 51 53 * 52 54 */ 53 void *as_area_create(void *address, size_t size, unsignedint flags)55 void *as_area_create(void *address, size_t size, int flags) 54 56 { 55 57 return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address, … … 67 69 * 68 70 */ 69 int as_area_resize(void *address, size_t size, unsignedint flags)71 int as_area_resize(void *address, size_t size, int flags) 70 72 { 71 73 return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t) address, … … 95 97 * 96 98 */ 97 int as_area_change_flags(void *address, unsignedint flags)99 int as_area_change_flags(void *address, int flags) 98 100 { 99 101 return __SYSCALL2(SYS_AS_AREA_CHANGE_FLAGS, (sysarg_t) address, … … 101 103 } 102 104 103 /** Return pointer to unmapped address spacearea105 /** Return pointer to some unmapped area, where fits new as_area 104 106 * 105 107 * @param size Requested size of the allocation. 106 108 * 107 * @return Pointer to the beginning of unmapped address space area.109 * @return pointer to the beginning 108 110 * 109 111 */ 110 112 void *as_get_mappable_page(size_t size) 111 113 { 112 return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA, 113 (sysarg_t) __entry, (sysarg_t) size); 114 if (size == 0) 115 return NULL; 116 117 size_t sz = 1 << (fnzb(size - 1) + 1); 118 if (last_allocated == 0) 119 last_allocated = get_max_heap_addr(); 120 121 /* 122 * Make sure we allocate from naturally aligned address. 123 */ 124 uintptr_t res = ALIGN_UP(last_allocated, sz); 125 last_allocated = res + ALIGN_UP(size, PAGE_SIZE); 126 127 return ((void *) res); 114 128 } 115 129
Note:
See TracChangeset
for help on using the changeset viewer.