1
1

make ompi_free_list_item_t a class..

This will go to the 1.1 branch but will probably require a few changes as
ompi_free_list_t is different in the branch.. 

This commit was SVN r10306.
Этот коммит содержится в:
Galen Shipman
2006-06-12 16:44:00 +00:00
родитель a31a73cb15
Коммит 18dda70fd0
25 изменённых файлов: 65 добавлений и 58 удалений

Просмотреть файл

@ -54,7 +54,7 @@ mca_allocator_base_component_t mca_allocator_basic_component = {
OBJ_CLASS_INSTANCE(
mca_allocator_basic_segment_t,
opal_list_item_t,
ompi_free_list_item_t,
NULL,
NULL);
@ -123,7 +123,7 @@ static void mca_allocator_basic_combine_prev(
mca_allocator_basic_segment_t *prev = (mca_allocator_basic_segment_t*)item;
if(prev->seg_addr + prev->seg_size == seg->seg_addr) {
prev->seg_size += seg->seg_size;
opal_list_remove_item(&module->seg_list, &seg->seg_item);
opal_list_remove_item(&module->seg_list, &seg->seg_item.super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, &seg->seg_item);
return;
}
@ -140,7 +140,7 @@ static void mca_allocator_basic_combine_next(
if(seg->seg_addr + seg->seg_size == next->seg_addr) {
next->seg_addr = seg->seg_addr;
next->seg_size += seg->seg_size;
opal_list_remove_item(&module->seg_list, &seg->seg_item);
opal_list_remove_item(&module->seg_list, &seg->seg_item.super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, &seg->seg_item);
return;
}
@ -167,16 +167,16 @@ void *mca_allocator_basic_alloc(
{
mca_allocator_basic_module_t* module = (mca_allocator_basic_module_t*)base;
mca_allocator_basic_segment_t* seg;
opal_list_item_t* item;
ompi_free_list_item_t* item;
unsigned char* addr;
size_t allocated_size;
OPAL_THREAD_LOCK(&module->seg_lock);
/* search the list for a segment of the required size */
size += sizeof(size_t);
for(item = opal_list_get_first(&module->seg_list);
item != opal_list_get_end(&module->seg_list);
item = opal_list_get_next(item)) {
for(item = (ompi_free_list_item_t*) opal_list_get_first(&module->seg_list);
item != (ompi_free_list_item_t*) opal_list_get_end(&module->seg_list);
item = (ompi_free_list_item_t*) opal_list_get_next(&item->super)) {
seg = (mca_allocator_basic_segment_t*)item;
/* split the segment */
@ -189,7 +189,7 @@ void *mca_allocator_basic_alloc(
return addr+sizeof(size_t);
} else if (seg->seg_size == size) {
addr = seg->seg_addr;
opal_list_remove_item(&module->seg_list, item);
opal_list_remove_item(&module->seg_list, &item->super);
OMPI_FREE_LIST_RETURN(&module->seg_descriptors, item);
OPAL_THREAD_UNLOCK(&module->seg_lock);
*(size_t*)addr = size;
@ -215,7 +215,7 @@ void *mca_allocator_basic_alloc(
seg = (mca_allocator_basic_segment_t*)item;
seg->seg_addr = addr + size;
seg->seg_size = allocated_size - size;
opal_list_append(&module->seg_list, item);
opal_list_append(&module->seg_list, &item->super);
}
*(size_t*)addr = size;
@ -274,16 +274,16 @@ void mca_allocator_basic_free(
{
mca_allocator_basic_module_t* module = (mca_allocator_basic_module_t*)base;
mca_allocator_basic_segment_t* seg;
opal_list_item_t *item;
ompi_free_list_item_t *item;
unsigned char* addr = (unsigned char*)ptr - sizeof(size_t);
size_t size = *(size_t*)addr;
int rc;
OPAL_THREAD_LOCK(&module->seg_lock);
/* maintain the free list in sorted order by address */
for(item = opal_list_get_first(&module->seg_list);
item != opal_list_get_end(&module->seg_list);
item = opal_list_get_next(item)) {
for(item = (ompi_free_list_item_t*) opal_list_get_first(&module->seg_list);
item != (ompi_free_list_item_t*) opal_list_get_end(&module->seg_list);
item = (ompi_free_list_item_t*) opal_list_get_next((&item->super))) {
seg = (mca_allocator_basic_segment_t*)item;
if (seg->seg_addr < addr) {
@ -315,10 +315,11 @@ void mca_allocator_basic_free(
OPAL_THREAD_UNLOCK(&module->seg_lock);
return;
}
new_seg = (mca_allocator_basic_segment_t*)item;
new_seg = (
mca_allocator_basic_segment_t*)item;
new_seg->seg_addr = addr;
new_seg->seg_size = size;
opal_list_insert_pos(&module->seg_list, &seg->seg_item, item);
opal_list_insert_pos(&module->seg_list, &seg->seg_item.super, &item->super);
OPAL_THREAD_UNLOCK(&module->seg_lock);
return;
}
@ -334,7 +335,7 @@ void mca_allocator_basic_free(
seg = (mca_allocator_basic_segment_t*)item;
seg->seg_addr = addr;
seg->seg_size = size;
opal_list_append(&module->seg_list, item);
opal_list_append(&module->seg_list, &item->super);
OPAL_THREAD_UNLOCK(&module->seg_lock);
}