vxWorks version of message queue.

This commit is contained in:
W. Eric Norum
2003-02-28 22:22:07 +00:00
parent 36ffa70608
commit 3c02a693c7
2 changed files with 88 additions and 0 deletions
@@ -0,0 +1,54 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* $Id$
*
* Author W. Eric Norum
* norume@aps.anl.gov
* 630 252 4793
*/
#define epicsExportSharedSymbols
#include <limits.h>
#include "epicsMessageQueue.h"
int sysClkRateGet(void);
epicsShareFunc int epicsShareAPI epicsMessageQueueSendWithTimeout(
epicsMessageQueueId id,
void *message,
unsigned int messageSize,
double timeout)
{
int ticks;
if (timeout<=0.0) {
ticks = 0;
} else {
ticks = (int)(timeout*sysClkRateGet());
if(ticks<=0) ticks = 1;
}
return msgQSend((MSG_Q_ID)id, (char *)message, messageSize, ticks, MSG_PRI_NORMAL);
}
epicsShareFunc int epicsShareAPI epicsMessageQueueReceiveWithTimeout(
epicsMessageQueueId id,
void *message,
double timeout)
{
int ticks;
if (timeout<=0.0) {
ticks = 0;
} else {
ticks = (int)(timeout*sysClkRateGet());
if(ticks<=0) ticks = 1;
}
return msgQReceive((MSG_Q_ID)id, (char *)message, UINT_MAX, ticks);
}
@@ -0,0 +1,34 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* $Id$
*
* Author W. Eric Norum
* norume@aps.anl.gov
* 630 252 4793
*/
/*
* Very thin shims around vxWorks routines
*/
#include <msgQLib.h>
#include <limits.h>
#define epicsMessageQueueCreate(c,l) ((epicsMessageQueueId)msgQCreate((c), (l), MSG_Q_FIFO))
#define epicsMessageQueueDestroy(q) (msgQDelete((MSG_Q_ID)(q)))
#define epicsMessageQueueTrySend(q,m,l) (msgQSend((MSG_Q_ID)(q), (char*)(m), (l), NO_WAIT, MSG_PRI_NORMAL))
#define epicsMessageQueueSend(q,m,l) (msgQSend((MSG_Q_ID)(q), (char*)(m), (l), WAIT_FOREVER, MSG_PRI_NORMAL))
#define epicsMessageQueueTryReceive(q,m) (msgQReceive((MSG_Q_ID)(q), (char*)(m), UINT_MAX, NO_WAIT))
#define epicsMessageQueueReceive(q,m) (msgQReceive((MSG_Q_ID)(q), (char*)(m), UINT_MAX, WAIT_FOREVER))
#define epicsMessageQueuePending(q) (msgQNumMsgs((MSG_Q_ID)(q)))
#define epicsMessageQueueShow(q,l) (msgQShow((MSG_Q_ID)(q),(l)))