Changeset 436a0a5 in mainline for kernel/generic/src/mm
- Timestamp:
- 2018-11-09T22:04:01Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 95d45482
- Parents:
- 88e43bc (diff), abf6c01 (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. - Location:
- kernel/generic/src/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
r88e43bc r436a0a5 151 151 as_t *as_create(unsigned int flags) 152 152 { 153 as_t *as = (as_t *) slab_alloc(as_cache, 0); 153 as_t *as = (as_t *) slab_alloc(as_cache, FRAME_ATOMIC); 154 if (!as) 155 return NULL; 156 154 157 (void) as_create_arch(as, 0); 155 158 … … 2237 2240 * 2238 2241 */ 2239 void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize)2242 as_area_info_t *as_get_area_info(as_t *as, size_t *osize) 2240 2243 { 2241 2244 mutex_lock(&as->lock); … … 2245 2248 2246 2249 size_t isize = area_cnt * sizeof(as_area_info_t); 2247 as_area_info_t *info = nfmalloc(isize); 2250 as_area_info_t *info = malloc(isize); 2251 if (!info) { 2252 mutex_unlock(&as->lock); 2253 return NULL; 2254 } 2248 2255 2249 2256 /* Record area data. */ … … 2267 2274 mutex_unlock(&as->lock); 2268 2275 2269 *obuf = info;2270 2276 *osize = isize; 2277 return info; 2271 2278 } 2272 2279 -
kernel/generic/src/mm/slab.c
r88e43bc r436a0a5 667 667 size_t (*destructor)(void *obj), unsigned int flags) 668 668 { 669 slab_cache_t *cache = slab_alloc(&slab_cache_cache, 0); 669 slab_cache_t *cache = slab_alloc(&slab_cache_cache, FRAME_ATOMIC); 670 if (!cache) 671 panic("Not enough memory to allocate slab cache %s.", name); 672 670 673 _slab_cache_create(cache, name, size, align, constructor, destructor, 671 674 flags); … … 730 733 NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab) 731 734 { 735 if (!obj) 736 return; 737 732 738 ipl_t ipl = interrupts_disable(); 733 739 … … 954 960 } 955 961 956 static void *_malloc(size_t size, unsigned int flags)962 void *malloc(size_t size) 957 963 { 958 964 assert(_slab_initialized); … … 964 970 uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; 965 971 966 return slab_alloc(malloc_caches[idx], flags); 967 } 968 969 void *malloc(size_t size) 970 { 971 return _malloc(size, FRAME_ATOMIC); 972 } 973 974 /** Non-failing malloc. 975 * Never returns NULL, but may block forever if no memory is available. 976 */ 977 void *nfmalloc(size_t size) 978 { 979 return _malloc(size, 0); 980 } 981 982 static void *_realloc(void *ptr, size_t size, unsigned int flags) 972 return slab_alloc(malloc_caches[idx], FRAME_ATOMIC); 973 } 974 975 void *realloc(void *ptr, size_t size) 983 976 { 984 977 assert(_slab_initialized); … … 992 985 uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; 993 986 994 new_ptr = slab_alloc(malloc_caches[idx], flags);987 new_ptr = slab_alloc(malloc_caches[idx], FRAME_ATOMIC); 995 988 } else 996 989 new_ptr = NULL; … … 1007 1000 } 1008 1001 1009 void *realloc(void *ptr, size_t size)1010 {1011 return _realloc(ptr, size, FRAME_ATOMIC);1012 }1013 1014 1002 void free(void *ptr) 1015 1003 {
Note:
See TracChangeset
for help on using the changeset viewer.
