mbce.c

来自「nucleus 2006 source code」· C语言 代码 · 共 325 行 · 第 1/2 页

C
325
字号
/*************************************************************************/
/*                                                                       */
/*               Copyright Mentor Graphics Corporation 2004              */
/*                         All Rights Reserved.                          */
/*                                                                       */
/* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS  */
/* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS   */
/* SUBJECT TO LICENSE TERMS.                                             */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                               VERSION       */
/*                                                                       */
/*      mbce.c                                         Nucleus PLUS 1.15 */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      MB - Mailbox Management                                          */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the error checking routines for the core      */
/*      functions in the Mailbox component.  This permits easy removal   */
/*      of error checking logic when it is not needed.                   */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      MBCE_Create_Mailbox                 Create a mailbox             */
/*      MBCE_Delete_Mailbox                 Delete a mailbox             */
/*      MBCE_Send_To_Mailbox                Send a mailbox message       */
/*      MBCE_Receive_From_Mailbox           Receive a mailbox message    */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      cs_extr.h                           Common Service functions     */
/*      tc_extr.h                           Thread Control functions     */
/*      mb_extr.h                           Mailbox functions            */
/*                                                                       */
/*************************************************************************/
#define         NU_SOURCE_FILE


#include        "plus/inc/cs_extr.h"        /* Common service functions  */
#include        "plus/inc/tc_extr.h"        /* Thread control functions  */
#include        "plus/inc/mb_extr.h"        /* Mailbox functions         */


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      MBCE_Create_Mailbox                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the mailbox create function.                                  */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      MBC_Create_Mailbox                  Actual create mailbox funct. */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      mailbox_ptr                         Mailbox control block pointer*/
/*      name                                Mailbox name                 */
/*      suspend_type                        Suspension type              */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_INVALID_MAILBOX                  Mailbox pointer is NULL      */
/*      NU_INVALID_SUSPEND                  Suspension type is invalid   */
/*                                                                       */
/*************************************************************************/
STATUS  MBCE_Create_Mailbox(NU_MAILBOX *mailbox_ptr, CHAR *name, 
                                                OPTION suspend_type)
{

MB_MCB         *mailbox;                    /* Mailbox control block ptr */
STATUS          status;                     /* Completion status         */


    /* Move input mailbox pointer into internal pointer.  */
    mailbox =  (MB_MCB *) mailbox_ptr;

    /* Check for a NULL mailbox pointer or an already created mailbox.  */
    if ((mailbox == NU_NULL) || (mailbox -> mb_id == MB_MAILBOX_ID))
    
        /* Invalid mailbox control block pointer.  */
        status =  NU_INVALID_MAILBOX;
        
    else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
    
        /* Invalid suspension type.  */
        status =  NU_INVALID_SUSPEND;
        
    else
    
        /* Call the actual service to create the mailbox.  */
        status =  MBC_Create_Mailbox(mailbox_ptr, name, suspend_type);
        
    /* Return completion status.  */
    return(status);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      MBCE_Delete_Mailbox                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the actual delete mailbox function.                           */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      MBC_Delete_Mailbox                  Actual delete mailbox funct. */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      mailbox_ptr                         Mailbox control block pointer*/
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_INVALID_MAILBOX                  Invalid mailbox supplied     */
/*                                                                       */
/*************************************************************************/
STATUS  MBCE_Delete_Mailbox(NU_MAILBOX *mailbox_ptr)
{

MB_MCB         *mailbox;                    /* Mailbox control block ptr */
STATUS          status;                     /* Completion status         */

    
    /* Move input mailbox pointer into internal pointer.  */
    mailbox =  (MB_MCB *) mailbox_ptr;

    /* Determine if the mailbox pointer is valid.  */
    if ((mailbox) && (mailbox -> mb_id == MB_MAILBOX_ID))
    
        /* Mailbox pointer is valid, call function to delete it.  */
        status =  MBC_Delete_Mailbox(mailbox_ptr);
        
    else
    
        /* Mailbox pointer is invalid, indicate in completion status.  */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?