Changeset 156b6406 in mainline for uspace/lib/c/generic/malloc.c


Ignore:
Timestamp:
2012-12-04T16:42:06Z (11 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b188002
Parents:
b7acf38
Message:

Differentiated futexes when used with mutex semantics from those with semaphore semantics.

File:
1 edited

Legend:

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

    rb7acf38 r156b6406  
    200200        do { \
    201201                if (!(expr)) {\
    202                         _futex_up(&malloc_futex); \
     202                        futex_up(&malloc_futex); \
    203203                        assert_abort(#expr, __FILE__, __LINE__); \
    204204                } \
     
    785785void *malloc(const size_t size)
    786786{
    787         _futex_down(&malloc_futex);
     787        futex_down(&malloc_futex);
    788788        void *block = malloc_internal(size, BASE_ALIGN);
    789         _futex_up(&malloc_futex);
     789        futex_up(&malloc_futex);
    790790
    791791        return block;
     
    808808            1 << (fnzb(max(sizeof(void *), align) - 1) + 1);
    809809
    810         _futex_down(&malloc_futex);
     810        futex_down(&malloc_futex);
    811811        void *block = malloc_internal(size, palign);
    812         _futex_up(&malloc_futex);
     812        futex_up(&malloc_futex);
    813813
    814814        return block;
     
    828828                return malloc(size);
    829829       
    830         _futex_down(&malloc_futex);
     830        futex_down(&malloc_futex);
    831831       
    832832        /* Calculate the position of the header. */
     
    885885        }
    886886       
    887         _futex_up(&malloc_futex);
     887        futex_up(&malloc_futex);
    888888       
    889889        if (reloc) {
     
    908908                return;
    909909       
    910         _futex_down(&malloc_futex);
     910        futex_down(&malloc_futex);
    911911       
    912912        /* Calculate the position of the header. */
     
    953953        heap_shrink(area);
    954954       
    955         _futex_up(&malloc_futex);
     955        futex_up(&malloc_futex);
    956956}
    957957
    958958void *heap_check(void)
    959959{
    960         _futex_down(&malloc_futex);
     960        futex_down(&malloc_futex);
    961961       
    962962        if (first_heap_area == NULL) {
    963                 _futex_up(&malloc_futex);
     963                futex_up(&malloc_futex);
    964964                return (void *) -1;
    965965        }
     
    975975                    (((uintptr_t) area->start % PAGE_SIZE) != 0) ||
    976976                    (((uintptr_t) area->end % PAGE_SIZE) != 0)) {
    977                         _futex_up(&malloc_futex);
     977                        futex_up(&malloc_futex);
    978978                        return (void *) area;
    979979                }
     
    986986                        /* Check heap block consistency */
    987987                        if (head->magic != HEAP_BLOCK_HEAD_MAGIC) {
    988                                 _futex_up(&malloc_futex);
     988                                futex_up(&malloc_futex);
    989989                                return (void *) head;
    990990                        }
     
    994994                        if ((foot->magic != HEAP_BLOCK_FOOT_MAGIC) ||
    995995                            (head->size != foot->size)) {
    996                                 _futex_up(&malloc_futex);
     996                                futex_up(&malloc_futex);
    997997                                return (void *) foot;
    998998                        }
     
    10001000        }
    10011001       
    1002         _futex_up(&malloc_futex);
     1002        futex_up(&malloc_futex);
    10031003       
    10041004        return NULL;
Note: See TracChangeset for help on using the changeset viewer.