From 7ae409af65daa96761c3a0d84878b0b736a6eef6 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 4 Jun 2020 01:06:58 -0700 Subject: [PATCH] [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). --- src/posix/platform/hdlc_interface.cpp | 2 +- src/posix/platform/hdlc_interface.hpp | 2 +- src/posix/platform/platform-posix.h | 6 +++--- src/posix/platform/radio.cpp | 4 ++-- src/posix/platform/virtual_time.cpp | 16 ++++++++-------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 07da129b0..c497a3746 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -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(aTimeoutUs / US_PER_S); timeout.tv_usec = static_cast(aTimeoutUs % US_PER_S); diff --git a/src/posix/platform/hdlc_interface.hpp b/src/posix/platform/hdlc_interface.hpp index 09e01137b..5b9c7965a 100644 --- a/src/posix/platform/hdlc_interface.hpp +++ b/src/posix/platform/hdlc_interface.hpp @@ -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: diff --git a/src/posix/platform/platform-posix.h b/src/posix/platform/platform-posix.h index 63494de3e..3b11ebe3a 100644 --- a/src/posix/platform/platform-posix.h +++ b/src/posix/platform/platform-posix.h @@ -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. diff --git a/src/posix/platform/radio.cpp b/src/posix/platform/radio.cpp index 819315827..9174a892e 100644 --- a/src/posix/platform/radio.cpp +++ b/src/posix/platform/radio.cpp @@ -39,7 +39,7 @@ #include "hdlc_interface.hpp" #if OPENTHREAD_POSIX_VIRTUAL_TIME -static ot::Spinel::RadioSpinel sRadioSpinel; +static ot::Spinel::RadioSpinel sRadioSpinel; #else static ot::Spinel::RadioSpinel 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); diff --git a/src/posix/platform/virtual_time.cpp b/src/posix/platform/virtual_time.cpp index 1de9e7d8d..9a0fe7bb8 100644 --- a/src/posix/platform/virtual_time.cpp +++ b/src/posix/platform/virtual_time.cpp @@ -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));