source: rtems/cpukit/rtems/src/msgqgetnumberpending.c @ 7f04cb18

4.115
Last change on this file since 7f04cb18 was 7f04cb18, checked in by Sebastian Huber <sebastian.huber@…>, on 07/25/13 at 07:10:38

score: Create mpci implementation header

Move implementation specific parts of mpci.h into new header file
mpciimpl.h. The mpci.h contains now only the application visible API.

  • Property mode set to 100644
File size: 2.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-2007.
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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/coremsgimpl.h>
25#include <rtems/score/object.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/rtems/status.h>
29#include <rtems/rtems/attrimpl.h>
30#include <rtems/rtems/messageimpl.h>
31#include <rtems/rtems/options.h>
32#include <rtems/rtems/support.h>
33
34/*
35 *  rtems_message_queue_get_number_pending
36 *
37 *  This directive returns the number of messages pending.
38 *
39 *  Input parameters:
40 *    id    - queue id
41 *    count - return area for count
42 *
43 *  Output parameters:
44 *    count             - number of messages removed ( 0 = empty queue )
45 *    RTEMS_SUCCESSFUL - if successful
46 *    error code        - if unsuccessful
47 */
48
49rtems_status_code rtems_message_queue_get_number_pending(
50  rtems_id  id,
51  uint32_t *count
52)
53{
54  register Message_queue_Control *the_message_queue;
55  Objects_Locations               location;
56
57  if ( !count )
58    return RTEMS_INVALID_ADDRESS;
59
60  the_message_queue = _Message_queue_Get( id, &location );
61  switch ( location ) {
62
63    case OBJECTS_LOCAL:
64      *count = the_message_queue->message_queue.number_of_pending_messages;
65      _Objects_Put( &the_message_queue->Object );
66      return RTEMS_SUCCESSFUL;
67
68#if defined(RTEMS_MULTIPROCESSING)
69    case OBJECTS_REMOTE:
70      _Thread_Executing->Wait.return_argument = count;
71
72      return _Message_queue_MP_Send_request_packet(
73          MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
74          id,
75          0,                               /* buffer not used */
76          0,                               /* size */
77          0,                               /* option_set not used */
78          MPCI_DEFAULT_TIMEOUT
79        );
80#endif
81
82    case OBJECTS_ERROR:
83      break;
84  }
85
86  return RTEMS_INVALID_ID;
87}
Note: See TracBrowser for help on using the repository browser.