source: rtems/cpukit/rtems/src/msgqflush.c @ a2e3f33

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.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_flush
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/thread.h>
26#include <rtems/score/wkspace.h>
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attrimpl.h>
29#include <rtems/rtems/messageimpl.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33/*
34 *  rtems_message_queue_flush
35 *
36 *  This directive removes all pending messages from a queue and returns
37 *  the number of messages removed.  If no messages were present then
38 *  a count of zero is returned.
39 *
40 *  Input parameters:
41 *    id    - queue id
42 *    count - return area for count
43 *
44 *  Output parameters:
45 *    count             - number of messages removed ( 0 = empty queue )
46 *    RTEMS_SUCCESSFUL - if successful
47 *    error code        - if unsuccessful
48 */
49
50rtems_status_code rtems_message_queue_flush(
51  rtems_id  id,
52  uint32_t *count
53)
54{
55  register Message_queue_Control *the_message_queue;
56  Objects_Locations               location;
57
58  if ( !count )
59    return RTEMS_INVALID_ADDRESS;
60
61  the_message_queue = _Message_queue_Get( id, &location );
62  switch ( location ) {
63
64    case OBJECTS_LOCAL:
65      *count = _CORE_message_queue_Flush( &the_message_queue->message_queue );
66      _Objects_Put( &the_message_queue->Object );
67      return RTEMS_SUCCESSFUL;
68
69#if defined(RTEMS_MULTIPROCESSING)
70    case OBJECTS_REMOTE:
71      _Thread_Executing->Wait.return_argument = count;
72
73      return
74        _Message_queue_MP_Send_request_packet(
75          MESSAGE_QUEUE_MP_FLUSH_REQUEST,
76          id,
77          0,                               /* buffer not used */
78          0,                               /* size */
79          0,                               /* option_set not used */
80          MPCI_DEFAULT_TIMEOUT
81        );
82#endif
83
84    case OBJECTS_ERROR:
85      break;
86  }
87
88  return RTEMS_INVALID_ID;
89}
Note: See TracBrowser for help on using the repository browser.