From fcc5d9ccca8451da61fc0abd95fad5ce68eb7646 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare@rtems.org>
Date: Tue, 12 Feb 2013 10:22:52 -0500
Subject: [PATCH 2/2] score: use new alignment routine in object extend information.
---
cpukit/score/src/objectextendinformation.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index 07f4997..e712051 100644
a
|
b
|
void _Objects_Extend_information( |
117 | 117 | Objects_Control **local_table; |
118 | 118 | void *old_tables; |
119 | 119 | size_t block_size; |
| 120 | uintptr_t object_blocks_size; |
| 121 | uintptr_t inactive_per_block_size; |
120 | 122 | |
121 | 123 | /* |
122 | 124 | * Growing the tables means allocating a new area, doing a copy and |
… |
… |
void _Objects_Extend_information( |
142 | 144 | |
143 | 145 | /* |
144 | 146 | * Allocate the tables and break it up. The tables are: |
145 | | * 1. object_locks : void* |
| 147 | * 1. object_blocks : void* |
146 | 148 | * 2. inactive_per_blocks : uint32_t |
147 | 149 | * 3. local_table : Objects_Name* |
148 | 150 | */ |
149 | | #define ALIGN_BLOCK_SIZE(_s) \ |
150 | | (((_s) + (CPU_ALIGNMENT - 1)) & ~(CPU_ALIGNMENT - 1)) |
151 | | block_size = ALIGN_BLOCK_SIZE( block_count * sizeof(void*) ) + |
152 | | ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) ) + |
153 | | ((maximum + minimum_index) * sizeof(Objects_Control *)); |
| 151 | object_blocks_size = (uintptr_t)_Addresses_Align_up( |
| 152 | (void*)(block_count * sizeof(void*)), |
| 153 | CPU_ALIGNMENT |
| 154 | ); |
| 155 | inactive_per_block_size = |
| 156 | (uintptr_t)_Addresses_Align_up( |
| 157 | (void*)(block_count * sizeof(uint32_t)), |
| 158 | CPU_ALIGNMENT |
| 159 | ); |
| 160 | block_size = object_blocks_size + inactive_per_block_size + |
| 161 | ((maximum + minimum_index) * sizeof(Objects_Control *)); |
154 | 162 | if ( information->auto_extend ) { |
155 | 163 | object_blocks = _Workspace_Allocate( block_size ); |
156 | 164 | if ( !object_blocks ) { |
… |
… |
void _Objects_Extend_information( |
166 | 174 | */ |
167 | 175 | inactive_per_block = (uint32_t *) _Addresses_Add_offset( |
168 | 176 | object_blocks, |
169 | | ALIGN_BLOCK_SIZE( block_count * sizeof(void*) ) |
| 177 | object_blocks_size |
170 | 178 | ); |
171 | 179 | local_table = (Objects_Control **) _Addresses_Add_offset( |
172 | 180 | inactive_per_block, |
173 | | ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) ) |
| 181 | inactive_per_block_size |
174 | 182 | ); |
175 | | if ( !_Addresses_Is_aligned( local_table ) ) { |
176 | | local_table = (Objects_Control **) |
177 | | (((uintptr_t)local_table + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT - 1)); |
178 | | } |
179 | 183 | |
180 | 184 | /* |
181 | 185 | * Take the block count down. Saves all the (block_count - 1) |