msgQLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:4k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* msgQLib.h - message queue library header file */
  2. /* Copyright 1984-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 02m,19oct01,bwa  Added MSG_Q_EVENTSEND_ERR_NOTIFY option.
  7. 02l,17apr98,rlp  canceled MSG_Q_INFO modification for backward compatibility.
  8. 02k,04nov97,rlp  modified MSG_Q_INFO structure for tracking messages sent.
  9. 02j,13jul93,wmd  use MEM_ROUND_UP to determine MSG_NODE_SIZE.
  10. 02i,22sep92,rrr  added support for c++
  11. 02h,04jul92,jcf  cleaned up.
  12. 01g,26may92,rrr  the tree shuffle
  13. 01f,04oct91,rrr  passed through the ansification filter
  14.   -changed copyright notice
  15. 01e,05oct90,dnw  changed MSG_Q_INFO structure.
  16. 01d,05oct90,dnw  changed function declarations for new interface.
  17. 01c,05oct90,shl  added ANSI function prototypes.
  18.                  made #endif ANSI style.
  19.                  added copyright notice.
  20. 01b,07aug90,shl  moved function declarations to end of file.
  21. 01a,10may90,dnw  written
  22. */
  23. #ifndef __INCmsgQLibh
  24. #define __INCmsgQLibh
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #include "vxWorks.h"
  29. #include "vwModNum.h"
  30. /* generic status codes */
  31. #define S_msgQLib_INVALID_MSG_LENGTH (M_msgQLib | 1)
  32. #define S_msgQLib_NON_ZERO_TIMEOUT_AT_INT_LEVEL (M_msgQLib | 2)
  33. #define S_msgQLib_INVALID_QUEUE_TYPE (M_msgQLib | 3)
  34. /* message queue options */
  35. #define MSG_Q_TYPE_MASK 0x01 /* mask for pend queue type in options */
  36. #define MSG_Q_FIFO 0x00 /* tasks wait in FIFO order */
  37. #define MSG_Q_PRIORITY 0x01 /* tasks wait in PRIORITY order */
  38. #define MSG_Q_EVENTSEND_ERR_NOTIFY 0x02 /* notify when eventRsrcSend fails */
  39. /* message send priorities */
  40. #define MSG_PRI_NORMAL 0 /* normal priority message */
  41. #define MSG_PRI_URGENT 1 /* urgent priority message */
  42. /* message queue typedefs */
  43. typedef struct msg_q *MSG_Q_ID; /* message queue ID */
  44. typedef struct /* MSG_Q_INFO */
  45.     {
  46.     int     numMsgs; /* OUT: number of messages queued */
  47.     int     numTasks; /* OUT: number of tasks waiting on msg q */
  48.     int     sendTimeouts; /* OUT: count of send timeouts */
  49.     int     recvTimeouts; /* OUT: count of receive timeouts */
  50.     int     options; /* OUT: options with which msg q was created */
  51.     int     maxMsgs; /* OUT: max messages that can be queued */
  52.     int     maxMsgLength; /* OUT: max byte length of each message */
  53.     int     taskIdListMax; /* IN: max tasks to fill in taskIdList */
  54.     int *   taskIdList; /* PTR: array of task ids waiting on msg q */
  55.     int     msgListMax; /* IN: max msgs to fill in msg lists */
  56.     char ** msgPtrList; /* PTR: array of msg ptrs queued to msg q */
  57.     int *   msgLenList; /* PTR: array of lengths of msgs */
  58.     } MSG_Q_INFO;
  59. /* macros */
  60. /* The following macro determines the number of bytes needed to buffer
  61.  * a message of the specified length.  The node size is rounded up for
  62.  * efficiency.  The total buffer space required for a pool for
  63.  * <maxMsgs> messages each of up to <maxMsgLength> bytes is:
  64.  *
  65.  *    maxMsgs * MSG_NODE_SIZE (maxMsgLength)
  66.  */
  67. #define MSG_NODE_SIZE(msgLength) 
  68. (MEM_ROUND_UP((sizeof (MSG_NODE) + msgLength)))
  69. /* function declarations */
  70. #if defined(__STDC__) || defined(__cplusplus)
  71. extern STATUS  msgQLibInit (void);
  72. extern MSG_Q_ID msgQCreate (int maxMsgs, int maxMsgLength, int options);
  73. extern STATUS  msgQDelete (MSG_Q_ID msgQId);
  74. extern STATUS  msgQSend (MSG_Q_ID msgQId, char *buffer, UINT nBytes,
  75.   int timeout, int priority);
  76. extern int  msgQReceive (MSG_Q_ID msgQId, char *buffer, UINT maxNBytes,
  77.      int timeout);
  78. extern STATUS  msgQInfoGet (MSG_Q_ID msgQId, MSG_Q_INFO *pInfo);
  79. extern int  msgQNumMsgs (MSG_Q_ID msgQId);
  80. extern void  msgQShowInit (void);
  81. extern STATUS  msgQShow (MSG_Q_ID msgQId, int level);
  82. #else /* __STDC__ */
  83. extern STATUS  msgQLibInit ();
  84. extern MSG_Q_ID  msgQCreate ();
  85. extern STATUS  msgQDelete ();
  86. extern STATUS  msgQSend ();
  87. extern int  msgQReceive ();
  88. extern STATUS  msgQInfoGet ();
  89. extern int  msgQNumMsgs ();
  90. extern void  msgQShowInit ();
  91. extern STATUS  msgQShow ();
  92. #endif /* __STDC__ */
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif /* __INCmsgQLibh */