source: rtems/cpukit/itron/src/ref_mbf.c @ f42b726

4.104.114.84.95
Last change on this file since f42b726 was f42b726, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/01 at 14:17:28

2001-01-24 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/config.h
  • src/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/.cvsignore: Add config.h and stamp-h
  • src/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  ITRON Message Buffer Manager
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <itron.h>
19
20#include <rtems/itron/msgbuffer.h>
21#include <rtems/itron/task.h>
22
23/*
24 *  ref_mbf - Reference Message Buffer Status
25 */
26
27ER ref_mbf(
28  T_RMBF *pk_rmbf,
29  ID      mbfid
30)
31{
32  ITRON_Message_buffer_Control      *the_message_buffer;
33  Objects_Locations                  location;
34  CORE_message_queue_Control        *the_core_msgq;
35       
36  if ( !pk_rmbf )
37    return E_PAR;   /* XXX check this error code */
38
39  the_message_buffer = _ITRON_Message_buffer_Get( mbfid, &location );
40  switch ( location ) {   
41  case OBJECTS_REMOTE:               /* Multiprocessing not supported */
42  case OBJECTS_ERROR:
43    return _ITRON_Message_buffer_Clarify_get_id_error( mbfid );
44 
45  case OBJECTS_LOCAL:
46    the_core_msgq = &the_message_buffer->message_queue;
47
48    /*
49     *  Fill in the size of message to be sent
50     */
51
52    if (the_core_msgq->number_of_pending_messages == 0) {
53      pk_rmbf->msgsz = 0;
54    } else {
55      pk_rmbf->msgsz = ((CORE_message_queue_Buffer_control *)
56        the_core_msgq->Pending_messages.first)->Contents.size;
57    }
58       
59    /*
60     *  Fill in the size of free buffer
61     */
62
63    pk_rmbf->frbufsz =
64      (the_core_msgq->maximum_pending_messages -
65       the_core_msgq->number_of_pending_messages) *
66       the_core_msgq->maximum_message_size;
67
68
69    /*
70     *  Fill in whether or not there is a waiting task
71     */
72
73    if ( !_Thread_queue_First(&the_core_msgq->Wait_queue ) )
74       pk_rmbf->wtsk = FALSE;
75    else
76       pk_rmbf->wtsk =  TRUE;
77
78    pk_rmbf->stsk = FALSE;
79    _Thread_Enable_dispatch();
80    return E_OK;
81  }   
82  return E_OK;
83}
Note: See TracBrowser for help on using the repository browser.