summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/objectextendinformation.c
diff options
context:
space:
mode:
authorGedare Bloom <gedare@rtems.org>2013-02-11 14:12:08 -0500
committerGedare Bloom <gedare@rtems.org>2013-02-11 15:24:28 -0500
commitd5ec257356f371f2fef99efdbd32a5d9bd3be339 (patch)
treec4e5daa5aa93d534731c78ab9afb7b20cf796df9 /cpukit/score/src/objectextendinformation.c
parentbsp/lpc24xx: Move UART probes to separate files (diff)
downloadrtems-d5ec257356f371f2fef99efdbd32a5d9bd3be339.tar.bz2
PR1560: _Objects_Extend_information improper alignment
_Objects_Extend_information uses a sizeof(uint32_t) offset that leads to improper alignment in case the CPU (actually, heap) alignment is 8 or higher. The problem is solved by adding enough padding to align the sub-tables.
Diffstat (limited to 'cpukit/score/src/objectextendinformation.c')
-rw-r--r--cpukit/score/src/objectextendinformation.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index a6a5c253a1..07f4997970 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -141,10 +141,15 @@ void _Objects_Extend_information(
block_count++;
/*
- * Allocate the tables and break it up.
+ * 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*
*/
- block_size = block_count *
- (sizeof(void *) + sizeof(uint32_t) + sizeof(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 *));
if ( information->auto_extend ) {
object_blocks = _Workspace_Allocate( block_size );
@@ -160,9 +165,17 @@ void _Objects_Extend_information(
* Break the block into the various sections.
*/
inactive_per_block = (uint32_t *) _Addresses_Add_offset(
- object_blocks, block_count * sizeof(void*) );
+ object_blocks,
+ ALIGN_BLOCK_SIZE( block_count * sizeof(void*) )
+ );
local_table = (Objects_Control **) _Addresses_Add_offset(
- inactive_per_block, block_count * sizeof(uint32_t) );
+ inactive_per_block,
+ ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) )
+ );
+ if ( !_Addresses_Is_aligned( local_table ) ) {
+ local_table = (Objects_Control **)
+ (((uintptr_t)local_table + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT - 1));
+ }
/*
* Take the block count down. Saves all the (block_count - 1)