source: rtems/cpukit/rtems/src/msgqbroadcast.c @ e980b219

4.104.114.84.9
Last change on this file since e980b219 was e980b219, checked in by Joel Sherrill <joel.sherrill@…>, on May 6, 2004 at 7:21:40 PM

2004-05-06 Joel Sherrill <joel@…>

PR 618/rtems

  • rtems/include/rtems/rtems/status.h, rtems/src/clockget.c, rtems/src/clockset.c, rtems/src/dpmemcreate.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmeminternal2external.c, rtems/src/eventmp.c, rtems/src/eventreceive.c, rtems/src/eventsend.c, rtems/src/msgqbroadcast.c, rtems/src/msgqcreate.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqreceive.c, rtems/src/msgqsubmit.c, rtems/src/partcreate.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/ratemoncancel.c, rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c, rtems/src/ratemonperiod.c, rtems/src/regioncreate.c, rtems/src/regiondelete.c, rtems/src/regionextend.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionreturnsegment.c, rtems/src/semcreate.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semident.c, rtems/src/taskcreate.c, rtems/src/taskgetnote.c, rtems/src/taskmode.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasksetnote.c, rtems/src/tasksuspend.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c, rtems/src/taskwakewhen.c, rtems/src/timercreate.c, rtems/src/timerdelete.c, rtems/src/timerfireafter.c, rtems/src/timerfirewhen.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c, score/include/rtems/score/object.h, score/src/coretodvalidate.c, score/src/objectnametoid.c: Add NULL checks.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/sysstate.h>
17#include <rtems/score/chain.h>
18#include <rtems/score/isr.h>
19#include <rtems/score/coremsg.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#if defined(RTEMS_MULTIPROCESSING)
25#include <rtems/score/mpci.h>
26#endif
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attr.h>
29#include <rtems/rtems/message.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33/*PAGE
34 *
35 *  rtems_message_queue_broadcast
36 *
37 *  This directive sends a message for every thread waiting on the queue
38 *  designated by id.
39 *
40 *  Input parameters:
41 *    id     - pointer to message queue
42 *    buffer - pointer to message buffer
43 *    size   - size of message to broadcast
44 *    count  - pointer to area to store number of threads made ready
45 *
46 *  Output parameters:
47 *    count             - number of threads made ready
48 *    RTEMS_SUCCESSFUL  - if successful
49 *    error code        - if unsuccessful
50 */
51
52rtems_status_code rtems_message_queue_broadcast(
53  Objects_Id            id,
54  void                 *buffer,
55  uint32_t              size,
56  uint32_t             *count
57)
58{
59  register Message_queue_Control *the_message_queue;
60  Objects_Locations               location;
61  CORE_message_queue_Status       core_status;
62
63  if ( !buffer )
64    return RTEMS_INVALID_ADDRESS;
65
66  if ( !count )
67    return RTEMS_INVALID_ADDRESS;
68
69  the_message_queue = _Message_queue_Get( id, &location );
70  switch ( location ) {
71    case OBJECTS_REMOTE:
72#if defined(RTEMS_MULTIPROCESSING)
73      _Thread_Executing->Wait.return_argument = count;
74
75      return
76        _Message_queue_MP_Send_request_packet(
77          MESSAGE_QUEUE_MP_BROADCAST_REQUEST,
78          id,
79          buffer,
80          &size,
81          0,                               /* option_set not used */
82          MPCI_DEFAULT_TIMEOUT
83        );
84#endif
85
86    case OBJECTS_ERROR:
87      return RTEMS_INVALID_ID;
88
89    case OBJECTS_LOCAL:
90      core_status = _CORE_message_queue_Broadcast(
91                      &the_message_queue->message_queue,
92                      buffer,
93                      size,
94                      id,
95#if defined(RTEMS_MULTIPROCESSING)
96                      _Message_queue_Core_message_queue_mp_support,
97#else
98                      NULL,
99#endif
100                      count
101                    );
102
103      _Thread_Enable_dispatch();
104      return
105        _Message_queue_Translate_core_message_queue_return_code( core_status );
106
107  }
108  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
109}
Note: See TracBrowser for help on using the repository browser.