代码拉取完成,页面将自动刷新
同步操作将从 pengrui_2009/tdcmsg 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* msg.h
*
* the header file of msg
*
* Copyright (C) 2002-2003 Stephen Rothwell, IBM Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _MSG_H_
#define _MSG_H_
#include <stdint.h>
#include <semaphore.h> //sem_t
#include <pthread.h> //pthread_mutex
#include <time.h>
#include <sys/times.h>
#include "config.h"
#include "typedef.h"
/*************************************************
macros define
*************************************************/
//msg prio
#define MSG_PRIO_MIN 0 //lowest prio
#define MSG_PRIO_MAX 99 //highest prio
//msg block flag
#define MSG_RECV_BLOCK 0 //block recv
#define MSG_RECV_NONBLOCK 0xffff //noblock recv
#define CFG_MSG_REALSIZE (CFG_MSG_SIZE + 1)
/*************************************************
structs define
*************************************************/
class msg_t
{
public:
uint16_t type; //msg type
uint16_t wpara; //msg param
uint32_t lpara; //msg extend data
struct timespec time_spec;
uint32_t priv;
} ;
class msg_prio_t
{
msg_t msg;
uint8_t prio;
} ;
class msg_info_st
{
sem_t sem;
pthread_mutex_t mutex;
uint32_t head;
uint32_t tail;
msg_prio_t message[CFG_MSG_REALSIZE];
} ;
/*************************************************
global static variable
*************************************************/
class msg
{
public:
static int msg_inited;
static msg_info_st msg_info[CFG_MSG_MAX];
/******************************************************************************
* Function: msg_init
* Description: init msg
* Param: no
* Return: 0 - success
-ERR_SYS - system error
-ERR_BUSY - module opend
* Comment:
******************************************************************************/
static int msg_init(void);
/******************************************************************************
* Function: msg_send
* Description: send msg
* Param: id - msg id
msg - msg info
prio - msg prio(0 is lowest,99 is highest)
* Return: 0 - success
-ERR_SYS - system error
-ERR_NOINIT - no init
-ERR_NODEV - no device
-ERR_INVAL - invalid pram
-ERR_NOMEM - msg is full
* Comment:
******************************************************************************/
static int msg_send(uint8_t id, msg_t *msg, uint8_t prio);
/******************************************************************************
* Function: msg_recv
* Description: recv msg
* Param: id - msg id
msg - msg recv
timeout - timeout time(0:block, 0xffff:noblock, other:wait times second£©
* Return: 0 - success
-ERR_SYS - system error
-ERR_NODEV - no such msg queue
-ERR_NOINIT - no init
-ERR_TIMEOUT - timeout
* Comment:
******************************************************************************/
static int msg_recv(uint8_t id, msg_t *msg, uint16_t timeout);
/******************************************************************************
* Function: msg_recv_prio
* Description: recv msg with high prio
* Param: id - msg id
msg - msg info recv
timeout - timeout time (0:block,0xffff:noblock,other:wait second time)
* Return: 0 - success
-ERR_SYS - system error
-ERR_NODEV - no msg queue
-ERR_NOINIT - no init
-ERR_TIMEOUT - recv timeout
* Comment:
******************************************************************************/
static int msg_recv_prio(uint8_t id, msg_t *msg, uint16_t timeout);
/******************************************************************************
* Function: msg_clear
* Description: clear msg
* Param: id - msg id
* Return: 0 - success
-ERR_SYS - system error
-ERR_NODEV - no msg queue
-ERR_NOINIT - no init
* Comment:
******************************************************************************/
static int msg_clear(uint8_t id);
/******************************************************************************
* Function: msg_getsize
* Description: get msg count
* Param: id - msg id
* Return: >0 - msg size
-ERR_SYS - system error
-ERR_NODEV - no msg queue
-ERR_NOINIT - no init
* Comment:
******************************************************************************/
static int msg_getsize(uint8_t id);
} ;
#endif /* _MSG_H_ */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。