Changeset 9a3b469 in mainline for uspace/lib/c/generic/malloc.c
- Timestamp:
- 2012-12-04T04:09:08Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d54b303
- Parents:
- 1b7eec9
- File:
-
- 1 edited
-
uspace/lib/c/generic/malloc.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
r1b7eec9 r9a3b469 47 47 #include <adt/gcdlcm.h> 48 48 #include "private/malloc.h" 49 #include "private/thread.h" 49 50 50 51 /** Magic used in heap headers. */ … … 785 786 void *malloc(const size_t size) 786 787 { 787 futex_down(&malloc_futex); 788 void *block = malloc_internal(size, BASE_ALIGN); 789 futex_up(&malloc_futex); 790 791 return block; 788 /* Do not use futexes for allocations during main thread initialization. */ 789 if (0 == atomic_get(&_created_thread_cnt)) { 790 return malloc_internal(size, BASE_ALIGN); 791 } else { 792 futex_down(&malloc_futex); 793 void *block = malloc_internal(size, BASE_ALIGN); 794 futex_up(&malloc_futex); 795 return block; 796 } 792 797 } 793 798 … … 807 812 size_t palign = 808 813 1 << (fnzb(max(sizeof(void *), align) - 1) + 1); 809 810 futex_down(&malloc_futex); 811 void *block = malloc_internal(size, palign); 812 futex_up(&malloc_futex); 813 814 return block; 814 815 /* Do not use futexes for allocations during main thread initialization. */ 816 if (0 == atomic_get(&_created_thread_cnt)) { 817 return malloc_internal(size, palign); 818 } else { 819 futex_down(&malloc_futex); 820 void *block = malloc_internal(size, palign); 821 futex_up(&malloc_futex); 822 823 return block; 824 } 815 825 } 816 826
Note:
See TracChangeset
for help on using the changeset viewer.
