[posix] rename struct Event to VirtualTimeEvent (#5052)

This `struct` is defined in a C header file and therefore it is not
scoped in a `namespae`. The rename is to avoid name conflicts with
OpenThread core definitions (allowing `ot::Event` to be defined).
This commit is contained in:
Abtin Keshavarzian
2020-06-08 10:17:52 -07:00
committed by Jonathan Hui
parent 75e21adcec
commit 7ae409af65
5 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ otError HdlcInterface::WaitForFrame(uint64_t aTimeoutUs)
otError error = OT_ERROR_NONE;
struct timeval timeout;
#if OPENTHREAD_POSIX_VIRTUAL_TIME
struct Event event;
struct VirtualTimeEvent event;
timeout.tv_sec = static_cast<time_t>(aTimeoutUs / US_PER_S);
timeout.tv_usec = static_cast<suseconds_t>(aTimeoutUs % US_PER_S);
+1 -1
View File
@@ -145,7 +145,7 @@ public:
* @param[in] aEvent The data event.
*
*/
void Process(const Event &aEvent) { Decode(aEvent.mData, aEvent.mDataLength); }
void Process(const VirtualTimeEvent &aEvent) { Decode(aEvent.mData, aEvent.mDataLength); }
#endif
private:
+3 -3
View File
@@ -83,7 +83,7 @@ enum
};
OT_TOOL_PACKED_BEGIN
struct Event
struct VirtualTimeEvent
{
uint64_t mDelay;
uint8_t mEvent;
@@ -331,7 +331,7 @@ void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength
* @param[out] aEvent A pointer to the event receiving the event.
*
*/
void virtualTimeReceiveEvent(struct Event *aEvent);
void virtualTimeReceiveEvent(struct VirtualTimeEvent *aEvent);
/**
* This function sends sleep event through virtual time simulation.
@@ -348,7 +348,7 @@ void virtualTimeSendSleepEvent(const struct timeval *aTimeout);
* @param[in] aEvent A pointer to the current event.
*
*/
void virtualTimeRadioSpinelProcess(otInstance *aInstance, const struct Event *aEvent);
void virtualTimeRadioSpinelProcess(otInstance *aInstance, const struct VirtualTimeEvent *aEvent);
/**
* This function initializes platform UDP driver.
+2 -2
View File
@@ -39,7 +39,7 @@
#include "hdlc_interface.hpp"
#if OPENTHREAD_POSIX_VIRTUAL_TIME
static ot::Spinel::RadioSpinel<ot::Posix::HdlcInterface, Event> sRadioSpinel;
static ot::Spinel::RadioSpinel<ot::Posix::HdlcInterface, VirtualTimeEvent> sRadioSpinel;
#else
static ot::Spinel::RadioSpinel<ot::Posix::HdlcInterface, RadioProcessContext> sRadioSpinel;
#endif // OPENTHREAD_POSIX_VIRTUAL_TIME
@@ -246,7 +246,7 @@ void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMax
}
#if OPENTHREAD_POSIX_VIRTUAL_TIME
void virtualTimeRadioSpinelProcess(otInstance *aInstance, const struct Event *aEvent)
void virtualTimeRadioSpinelProcess(otInstance *aInstance, const struct VirtualTimeEvent *aEvent)
{
OT_UNUSED_VARIABLE(aInstance);
sRadioSpinel.Process(*aEvent);
+8 -8
View File
@@ -105,7 +105,7 @@ void virtualTimeDeinit(void)
}
}
static void virtualTimeSendEvent(struct Event *aEvent, size_t aLength)
static void virtualTimeSendEvent(struct VirtualTimeEvent *aEvent, size_t aLength)
{
ssize_t rval;
struct sockaddr_in sockaddr;
@@ -123,11 +123,11 @@ static void virtualTimeSendEvent(struct Event *aEvent, size_t aLength)
}
}
void virtualTimeReceiveEvent(struct Event *aEvent)
void virtualTimeReceiveEvent(struct VirtualTimeEvent *aEvent)
{
ssize_t rval = recvfrom(sSockFd, aEvent, sizeof(*aEvent), 0, NULL, NULL);
if (rval < 0 || (uint16_t)rval < offsetof(struct Event, mData))
if (rval < 0 || (uint16_t)rval < offsetof(struct VirtualTimeEvent, mData))
{
DieNowWithMessage("recvfrom", (rval < 0) ? OT_EXIT_ERROR_ERRNO : OT_EXIT_FAILURE);
}
@@ -137,18 +137,18 @@ void virtualTimeReceiveEvent(struct Event *aEvent)
void virtualTimeSendSleepEvent(const struct timeval *aTimeout)
{
struct Event event;
struct VirtualTimeEvent event;
event.mDelay = (uint64_t)aTimeout->tv_sec * kUsPerSecond + (uint64_t)aTimeout->tv_usec;
event.mEvent = OT_SIM_EVENT_ALARM_FIRED;
event.mDataLength = 0;
virtualTimeSendEvent(&event, offsetof(struct Event, mData));
virtualTimeSendEvent(&event, offsetof(struct VirtualTimeEvent, mData));
}
void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength)
{
struct Event event;
struct VirtualTimeEvent event;
event.mDelay = 0;
event.mEvent = OT_SIM_EVENT_RADIO_SPINEL_WRITE;
@@ -156,7 +156,7 @@ void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength
memcpy(event.mData, aData, aLength);
virtualTimeSendEvent(&event, offsetof(struct Event, mData) + event.mDataLength);
virtualTimeSendEvent(&event, offsetof(struct VirtualTimeEvent, mData) + event.mDataLength);
}
void virtualTimeUpdateFdSet(fd_set * aReadFdSet,
@@ -181,7 +181,7 @@ void virtualTimeProcess(otInstance * aInstance,
const fd_set *aWriteFdSet,
const fd_set *aErrorFdSet)
{
struct Event event;
struct VirtualTimeEvent event;
memset(&event, 0, sizeof(event));