Changeset b1b6f3b0 in rtems


Ignore:
Timestamp:
May 3, 2016, 10:57:16 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
159b637
Parents:
e4fd35d
git-author:
Sebastian Huber <sebastian.huber@…> (05/03/16 10:57:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/04/16 05:24:29)
Message:

confdefs.h: Fix message queue size estimate

Account for maximum message size alignment. Simplify
_CORE_message_queue_Initialize().

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/confdefs.h

    re4fd35d rb1b6f3b0  
    29792979#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(_messages, _size) \
    29802980    _Configure_From_workspace( \
    2981       (_messages) * ((_size) + sizeof(CORE_message_queue_Buffer_control)))
     2981      (_messages) * (_Configure_Align_up(_size, sizeof(uintptr_t)) \
     2982        + sizeof(CORE_message_queue_Buffer_control)))
    29822983
    29832984/**
  • cpukit/score/src/coremsg.c

    re4fd35d rb1b6f3b0  
    5151{
    5252  size_t message_buffering_required = 0;
    53   size_t allocated_message_size;
     53  size_t aligned_message_size;
     54  size_t align_mask;
    5455
    5556  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
     
    5859  _CORE_message_queue_Set_notify( the_message_queue, NULL );
    5960
    60   allocated_message_size = maximum_message_size;
     61  /*
     62   * Align up the maximum message size to be an integral multiple of the
     63   * pointer size.
     64   */
     65  align_mask = sizeof(uintptr_t) - 1;
     66  aligned_message_size = ( maximum_message_size + align_mask ) & ~align_mask;
    6167
    62   /*
    63    * Check if allocated_message_size is aligned to uintptr-size boundary.
    64    * If not, it will increase allocated_message_size to multiplicity of pointer
    65    * size.
     68  /*
     69   * Check for an integer overflow.  It can occur while aligning up the maximum
     70   * message size.
    6671   */
    67   if (allocated_message_size & (sizeof(uintptr_t) - 1)) {
    68     allocated_message_size += sizeof(uintptr_t);
    69     allocated_message_size &= ~(sizeof(uintptr_t) - 1);
    70   }
    71 
    72   /*
    73    * Check for an overflow. It can occur while increasing allocated_message_size
    74    * to multiplicity of uintptr_t above.
    75    */
    76   if (allocated_message_size < maximum_message_size)
     72  if (aligned_message_size < maximum_message_size)
    7773    return false;
    7874
     
    8379  if ( !size_t_mult32_with_overflow(
    8480        (size_t) maximum_pending_messages,
    85         allocated_message_size + sizeof(CORE_message_queue_Buffer_control),
     81        aligned_message_size + sizeof(CORE_message_queue_Buffer_control),
    8682        &message_buffering_required ) )
    8783    return false;
     
    104100    the_message_queue->message_buffers,
    105101    (size_t) maximum_pending_messages,
    106     allocated_message_size + sizeof( CORE_message_queue_Buffer_control )
     102    aligned_message_size + sizeof( CORE_message_queue_Buffer_control )
    107103  );
    108104
Note: See TracChangeset for help on using the changeset viewer.