~jakub/helenos/ia64-revival

« back to all changes in this revision

Viewing changes to uspace/lib/c/generic/as.c

  • Committer: Jakub Jermar
  • Date: 2011-04-13 14:45:41 UTC
  • mfrom: (527.1.397 main-clone)
  • Revision ID: jakub@jermar.eu-20110413144541-x0j3r1zxqhsljx1o
MergeĀ mainlineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <sys/types.h>
40
40
#include <bitops.h>
41
41
#include <malloc.h>
42
 
 
43
 
/** Last position allocated by as_get_mappable_page */
44
 
static uintptr_t last_allocated = 0;
 
42
#include "private/libc.h"
45
43
 
46
44
/** Create address space area.
47
45
 *
102
100
            (sysarg_t) flags);
103
101
}
104
102
 
105
 
/** Return pointer to some unmapped area, where fits new as_area
 
103
/** Return pointer to unmapped address space area
106
104
 *
107
105
 * @param size Requested size of the allocation.
108
106
 *
109
 
 * @return pointer to the beginning
 
107
 * @return Pointer to the beginning of unmapped address space area.
110
108
 *
111
109
 */
112
110
void *as_get_mappable_page(size_t size)
113
111
{
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);
 
112
        return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA,
 
113
            (sysarg_t) __entry, (sysarg_t) size);
128
114
}
129
115
 
130
116
/** @}