source: rtems/cpukit/score/src/coremsginsert.c @ fce900b5

5
Last change on this file since fce900b5 was 0c286e3, checked in by Sebastian Huber <sebastian.huber@…>, on 10/25/17 at 14:00:17

score: _Chain_Insert_ordered_unprotected()

Change the chain order relation to use a directly specified left hand
side value. This is similar to _RBTree_Insert_inline() and helps the
compiler to better optimize the code.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Insert a Message into the Message Queue
5 * @ingroup ScoreMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2005.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/coremsgimpl.h>
22
23#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
24static bool _CORE_message_queue_Order(
25  const void       *left,
26  const Chain_Node *right
27)
28{
29   const int                               *left_priority;
30   const CORE_message_queue_Buffer_control *right_message;
31
32   left_priority = (const int *) left;
33   right_message = (const CORE_message_queue_Buffer_control *) right;
34
35   return *left_priority <
36     _CORE_message_queue_Get_message_priority( right_message );
37}
38#endif
39
40void _CORE_message_queue_Insert_message(
41  CORE_message_queue_Control        *the_message_queue,
42  CORE_message_queue_Buffer_control *the_message,
43  const void                        *content_source,
44  size_t                             content_size,
45  CORE_message_queue_Submit_types    submit_type
46)
47{
48  Chain_Control *pending_messages;
49
50  the_message->Contents.size = content_size;
51
52  _CORE_message_queue_Copy_buffer(
53    content_source,
54    the_message->Contents.buffer,
55    content_size
56  );
57
58#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
59  the_message->priority = submit_type;
60#endif
61
62  pending_messages = &the_message_queue->Pending_messages;
63  ++the_message_queue->number_of_pending_messages;
64
65  if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
66    _Chain_Append_unprotected( pending_messages, &the_message->Node );
67#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
68  } else  if ( submit_type != CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
69    int priority;
70
71    priority = _CORE_message_queue_Get_message_priority( the_message );
72    _Chain_Insert_ordered_unprotected(
73      pending_messages,
74      &the_message->Node,
75      &priority,
76      _CORE_message_queue_Order
77    );
78#endif
79  } else {
80    _Chain_Prepend_unprotected( pending_messages, &the_message->Node );
81  }
82}
Note: See TracBrowser for help on using the repository browser.