Changeset 197ef43 in mainline for uspace/lib/c/generic/malloc.c


Ignore:
Timestamp:
2011-01-29T23:52:07Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
12573db, 40fb017
Parents:
6aef742 (diff), 47b7006 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge various cosmetic run-time support improvements

  • coding style cleanups, comments cleanups, unsigned types for bit flags, indentation, etc.
  • SYS_TASK_EXIT for proper termination of a task (optionally with udebug notification)
    • get rid of exit(), _exit(), core()
    • reimplement robust main(), exit() and abort()
    • call abort() if some part of libc initialization fails
  • add more private libc headers to reduce the namespace pollution
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/malloc.c

    r6aef742 r197ef43  
    4545#include <futex.h>
    4646#include <adt/gcdlcm.h>
     47#include "private/malloc.h"
    4748
    4849/* Magic used in heap headers. */
     
    215216/** Initialize the heap allocator
    216217 *
    217  * Find how much physical memory we have and create
    218  * the heap management structures that mark the whole
    219  * physical memory as a single free block.
    220  *
    221  */
    222 void __heap_init(void)
    223 {
    224         futex_down(&malloc_futex);
    225        
    226         if (as_area_create((void *) &_heap, PAGE_SIZE,
    227             AS_AREA_WRITE | AS_AREA_READ)) {
    228                 heap_pages = 1;
    229                 heap_start = (void *) ALIGN_UP((uintptr_t) &_heap, BASE_ALIGN);
    230                 heap_end =
    231                     (void *) ALIGN_DOWN(((uintptr_t) &_heap) + PAGE_SIZE, BASE_ALIGN);
    232                
    233                 /* Make the entire area one large block. */
    234                 block_init(heap_start, heap_end - heap_start, true);
    235         }
    236        
    237         futex_up(&malloc_futex);
     218 * Create initial heap memory area. This routine is
     219 * only called from libc initialization, thus we do not
     220 * take any locks.
     221 *
     222 */
     223void __malloc_init(void)
     224{
     225        if (!as_area_create((void *) &_heap, PAGE_SIZE,
     226            AS_AREA_WRITE | AS_AREA_READ))
     227                abort();
     228       
     229        heap_pages = 1;
     230        heap_start = (void *) ALIGN_UP((uintptr_t) &_heap, BASE_ALIGN);
     231        heap_end =
     232            (void *) ALIGN_DOWN(((uintptr_t) &_heap) + PAGE_SIZE, BASE_ALIGN);
     233       
     234        /* Make the entire area one large block. */
     235        block_init(heap_start, heap_end - heap_start, true);
    238236}
    239237
Note: See TracChangeset for help on using the changeset viewer.