static void test_cache_aligned_alloc(void) { void *p0; void *p1; size_t cls; printf("test rtems_cache_aligned_malloc()\n"); p0 = rtems_cache_aligned_malloc(1); p1 = rtems_cache_aligned_malloc(1); rtems_test_assert(p0 != NULL); rtems_test_assert(p1 != NULL); cls = rtems_cache_get_data_line_size(); if (cls > 0) { size_t m = cls - 1; uintptr_t a0 = (uintptr_t) p0; uintptr_t a1 = (uintptr_t) p1; rtems_test_assert(a1 - a0 > cls); rtems_test_assert((a0 & m) == 0); rtems_test_assert((a1 & m) == 0); } free(p0); free(p1); }
void * rtems_bsd_chunk_alloc(rtems_bsd_chunk_control *self, uintptr_t chunk_size) { char *p = rtems_cache_aligned_malloc(chunk_size + self->info_size); if (p != NULL) { rtems_bsd_chunk_info *info = (rtems_bsd_chunk_info *) p; p += self->info_size; info->begin = (uintptr_t) p; info->end = (uintptr_t) p + chunk_size; (*self->info_ctor)(self, info); _RTEMS_Lock_allocator(); rtems_rbtree_insert(&self->chunks, &info->node, chunk_compare, true); _RTEMS_Unlock_allocator(); } return p; }