Changeset 156b6406 in mainline for uspace/lib/c/generic/malloc.c
- Timestamp:
- 2012-12-04T16:42:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b188002
- Parents:
- b7acf38
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
rb7acf38 r156b6406 200 200 do { \ 201 201 if (!(expr)) {\ 202 _futex_up(&malloc_futex); \202 futex_up(&malloc_futex); \ 203 203 assert_abort(#expr, __FILE__, __LINE__); \ 204 204 } \ … … 785 785 void *malloc(const size_t size) 786 786 { 787 _futex_down(&malloc_futex);787 futex_down(&malloc_futex); 788 788 void *block = malloc_internal(size, BASE_ALIGN); 789 _futex_up(&malloc_futex);789 futex_up(&malloc_futex); 790 790 791 791 return block; … … 808 808 1 << (fnzb(max(sizeof(void *), align) - 1) + 1); 809 809 810 _futex_down(&malloc_futex);810 futex_down(&malloc_futex); 811 811 void *block = malloc_internal(size, palign); 812 _futex_up(&malloc_futex);812 futex_up(&malloc_futex); 813 813 814 814 return block; … … 828 828 return malloc(size); 829 829 830 _futex_down(&malloc_futex);830 futex_down(&malloc_futex); 831 831 832 832 /* Calculate the position of the header. */ … … 885 885 } 886 886 887 _futex_up(&malloc_futex);887 futex_up(&malloc_futex); 888 888 889 889 if (reloc) { … … 908 908 return; 909 909 910 _futex_down(&malloc_futex);910 futex_down(&malloc_futex); 911 911 912 912 /* Calculate the position of the header. */ … … 953 953 heap_shrink(area); 954 954 955 _futex_up(&malloc_futex);955 futex_up(&malloc_futex); 956 956 } 957 957 958 958 void *heap_check(void) 959 959 { 960 _futex_down(&malloc_futex);960 futex_down(&malloc_futex); 961 961 962 962 if (first_heap_area == NULL) { 963 _futex_up(&malloc_futex);963 futex_up(&malloc_futex); 964 964 return (void *) -1; 965 965 } … … 975 975 (((uintptr_t) area->start % PAGE_SIZE) != 0) || 976 976 (((uintptr_t) area->end % PAGE_SIZE) != 0)) { 977 _futex_up(&malloc_futex);977 futex_up(&malloc_futex); 978 978 return (void *) area; 979 979 } … … 986 986 /* Check heap block consistency */ 987 987 if (head->magic != HEAP_BLOCK_HEAD_MAGIC) { 988 _futex_up(&malloc_futex);988 futex_up(&malloc_futex); 989 989 return (void *) head; 990 990 } … … 994 994 if ((foot->magic != HEAP_BLOCK_FOOT_MAGIC) || 995 995 (head->size != foot->size)) { 996 _futex_up(&malloc_futex);996 futex_up(&malloc_futex); 997 997 return (void *) foot; 998 998 } … … 1000 1000 } 1001 1001 1002 _futex_up(&malloc_futex);1002 futex_up(&malloc_futex); 1003 1003 1004 1004 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.