source: rtems/cpukit/rtems/src/msgqgetnumberpending.c @ d78d529

5
Last change on this file since d78d529 was 0e1d11f3, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 11:26:53

score: Add _Thread_queue_Context_set_MP_callout()

Add _Thread_queue_Context_set_MP_callout() to simplify
_Thread_queue_Context_initialize(). This makes it possible to more
easily add additional fields to Thread_queue_Context.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Message Queue Get Number Pending
5 * @ingroup ClassicMessageQueue Message Queues
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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/rtems/messageimpl.h>
22
23rtems_status_code rtems_message_queue_get_number_pending(
24  rtems_id  id,
25  uint32_t *count
26)
27{
28  Message_queue_Control *the_message_queue;
29  Thread_queue_Context   queue_context;
30
31  if ( count == NULL ) {
32    return RTEMS_INVALID_ADDRESS;
33  }
34
35  the_message_queue = _Message_queue_Get( id, &queue_context );
36
37  if ( the_message_queue == NULL ) {
38#if defined(RTEMS_MULTIPROCESSING)
39    return _Message_queue_MP_Get_number_pending( id, count );
40#else
41    return RTEMS_INVALID_ID;
42#endif
43  }
44
45  _CORE_message_queue_Acquire_critical(
46    &the_message_queue->message_queue,
47    &queue_context
48  );
49  *count = the_message_queue->message_queue.number_of_pending_messages;
50  _CORE_message_queue_Release(
51    &the_message_queue->message_queue,
52    &queue_context
53  );
54  return RTEMS_SUCCESSFUL;
55}
Note: See TracBrowser for help on using the repository browser.