Ticket #1560: 0002-score-use-new-alignment-routine-in-object-extend-inf.patch

File 0002-score-use-new-alignment-routine-in-object-extend-inf.patch, 2.8 KB (added by Gedare Bloom, on 02/12/13 at 14:28:08)

Use alignment routines

  • cpukit/score/src/objectextendinformation.c

    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( 
    117117    Objects_Control **local_table;
    118118    void             *old_tables;
    119119    size_t            block_size;
     120    uintptr_t         object_blocks_size;
     121    uintptr_t         inactive_per_block_size;
    120122
    121123    /*
    122124     *  Growing the tables means allocating a new area, doing a copy and
    void _Objects_Extend_information( 
    142144
    143145    /*
    144146     *  Allocate the tables and break it up. The tables are:
    145      *      1. object_locks        : void*
     147     *      1. object_blocks        : void*
    146148     *      2. inactive_per_blocks : uint32_t
    147149     *      3. local_table         : Objects_Name*
    148150     */
    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 *));
    154162    if ( information->auto_extend ) {
    155163      object_blocks = _Workspace_Allocate( block_size );
    156164      if ( !object_blocks ) {
    void _Objects_Extend_information( 
    166174     */
    167175    inactive_per_block = (uint32_t *) _Addresses_Add_offset(
    168176        object_blocks,
    169         ALIGN_BLOCK_SIZE( block_count * sizeof(void*) )
     177        object_blocks_size
    170178    );
    171179    local_table = (Objects_Control **) _Addresses_Add_offset(
    172180        inactive_per_block,
    173         ALIGN_BLOCK_SIZE( block_count * sizeof(uint32_t) )
     181        inactive_per_block_size
    174182    );
    175     if ( !_Addresses_Is_aligned( local_table ) ) {
    176       local_table = (Objects_Control **)
    177         (((uintptr_t)local_table + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT - 1));
    178     }
    179183
    180184    /*
    181185     *  Take the block count down. Saves all the (block_count - 1)