|
@@ -59,11 +59,18 @@ void *memalign(size_t alignment, size_t size) {
|
|
|
/* Search the available freelist-organized raw blocks for a block whose size
|
|
|
* is size + alignment - 1 */
|
|
|
SLIST_FOREACH(raw_block, &systemallocator.rb_head, pointers) {
|
|
|
- LOCK_RAW_BLOCK(raw_block);
|
|
|
- encapsulated_rb = (freelist_rb_t *)
|
|
|
- ((uintptr_t) raw_block + sizeof(raw_block_header_t));
|
|
|
- memptr = freelist_memalign(encapsulated_rb, alignment, size);
|
|
|
- UNLOCK_RAW_BLOCK(raw_block);
|
|
|
+#ifdef TRYLOCK_ON_MALLOC
|
|
|
+ if(TRYLOCK_RAW_BLOCK(raw_block) == 0) {
|
|
|
+#else /* TRYLOCK_ON_MALLOC */
|
|
|
+ LOCK_RAW_BLOCK(raw_block);
|
|
|
+#endif /* TRYLOCK_ON_MALLOC */
|
|
|
+ encapsulated_rb = (freelist_rb_t *)
|
|
|
+ ((uintptr_t) raw_block + sizeof(raw_block_header_t));
|
|
|
+ memptr = freelist_memalign(encapsulated_rb, alignment, size);
|
|
|
+ UNLOCK_RAW_BLOCK(raw_block);
|
|
|
+#ifdef TRYLOCK_ON_MALLOC
|
|
|
+ }
|
|
|
+#endif /* TRYLOCK_ON_MALLOC */
|
|
|
}
|
|
|
|
|
|
if(memptr == NULL) {
|