From 7259d1b512b7caa6f9511b87b913a799773d4eda Mon Sep 17 00:00:00 2001 From: Terry Dontje Date: Wed, 25 Oct 2006 18:22:38 +0000 Subject: [PATCH] Adjust allocation size to be a quantity divisible by sizeof(size_t). This is done to assure alignment so strictly aligned CPUs (like SPARC) do not sigbus. This also may benefit other platforms too. This commit fixes trac:494. This commit was SVN r12312. The following Trac tickets were found above: Ticket 494 --> https://svn.open-mpi.org/trac/ompi/ticket/494 --- ompi/mca/allocator/basic/allocator_basic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ompi/mca/allocator/basic/allocator_basic.c b/ompi/mca/allocator/basic/allocator_basic.c index 008ec06f63..664a0ecd94 100644 --- a/ompi/mca/allocator/basic/allocator_basic.c +++ b/ompi/mca/allocator/basic/allocator_basic.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -172,8 +173,11 @@ void *mca_allocator_basic_alloc( size_t allocated_size; OPAL_THREAD_LOCK(&module->seg_lock); - /* search the list for a segment of the required size */ + /* add the size of the header into the amount we need to request */ size += sizeof(size_t); + /* normalize size so we don't end up with seg_addr on an odd boundary */ + size += sizeof(size_t) - (size & (sizeof(size_t) - 1)); + /* search the list for a segment of the required size */ 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)) {