[Bug 1560] sparc64 [1/5]: _Objects_Extend_information improper alignment for 64-bit targets

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Wed Sep 1 15:23:09 UTC 2010


https://www.rtems.org/bugzilla/show_bug.cgi?id=1560

--- Comment #14 from Gedare <giddyup44 at yahoo.com> 2010-09-01 10:23:09 CDT ---
(In reply to comment #13)
> (In reply to comment #11)
> > Created an attachment (id=1044)
 --> (https://www.rtems.org/bugzilla/attachment.cgi?id=1044) [details]
[details]
> > Updated patch.
> > 
> > I realized that the allocation was now too small in case of an alignment
> > adjustment.  So now the alignment adjustment is also made in computing the size
> > of the allocation.
> 
> My understanding is the need for 3 alignments, not 2.
> 
> Part 1, aligned by the allocator.
>  block_size = (block_count * (sizeof(void *) + sizeof(uint32_t)) + 
>        CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT - 1);
> 
> Part 2, aligned by the line above.
>  block_size += block_count * sizeof(Objects_Name *) +
> 
> Part 3, it is not aligned.
>        ((maximum + minimum_index) * sizeof(Objects_Control *));
> 
> How does this look ? Note I have removed the Object_Name*. I cannot see where
> it is used or why it is there so removed it. It seems to have been present from
> the start.
> 
>     /*                       
>      *  Allocate the tables and break it up. The tables are:
>      *      1. object_locks        : void*
>      *      2. inactive_per_blocks : uint32_t
>      *      3. local_table         : Objects_Name*
>      */
> #define ALIGN_BLOCK_SIZE(_s) \
>                    (((_s) + (CPU_ALIGNMENT - 1)) & ~(CPU_ALIGNMENT - 1))
>     block_size =
>       ALIGN_BLOCK_SIZE( block_count * sizeof(void *) ) +
>       ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) ) +
>       ( (maximum + minimum_index) * sizeof(Objects_Control *) );
>     object_blocks = (void**) _Workspace_Allocate( block_size );
> 
>     if ( !object_blocks ) {
>       _Workspace_Free( new_object_block );
>       return;
>     }
> 
>     /*
>      *  Break the block into the various sections.
>      */
>     inactive_per_block = (uint32_t *) _Addresses_Add_offset(
>       object_blocks, ALIGN_BLOCK_SIZE( block_count * sizeof(void*) ));
>     local_table = (Objects_Control **) _Addresses_Add_offset(
>       inactive_per_block, ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) ));

This looks good. I'm not sure if any architectures need the ALIGN_BLOCK_SIZE(
block_count * sizeof(void *) ). (Only if CPU_ALIGNMENT > sizeof(void*) ).  But
it probably doesn't hurt to add it.

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list