From 63a083b523ede3d842f62cfb604fd9e153bef043 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Thu, 3 Jul 2025 03:17:55 +0800 Subject: [PATCH] [posix] fix the compile errors of src/posix/platform/alarm.cpp (#11658) The definition of sMicroTimer and sRealTimeSignal are wrapped by the __linux__, OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE and !OPENTHREAD_POSIX_VIRTUAL_TIME. But the code using these two variables is not completely wrapped by these three macros. It causes the compile errors in some conditions. This commit wraps all the code that uses these two variables with these three macros. --- src/posix/platform/alarm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/posix/platform/alarm.cpp b/src/posix/platform/alarm.cpp index f6bd5bf3d..d14312bc8 100644 --- a/src/posix/platform/alarm.cpp +++ b/src/posix/platform/alarm.cpp @@ -173,7 +173,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) sUsAlarm = aT0 + aDt; sIsUsRunning = true; -#ifdef __linux__ +#if defined(__linux__) && !OPENTHREAD_POSIX_VIRTUAL_TIME if (sRealTimeSignal != 0) { struct itimerspec its; @@ -190,7 +190,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) otLogWarnPlat("Failed to update microsecond timer: %s", strerror(errno)); } } -#endif // __linux__ +#endif // defined( __linux__) && !OPENTHREAD_POSIX_VIRTUAL_TIME } void otPlatAlarmMicroStop(otInstance *aInstance) @@ -199,7 +199,7 @@ void otPlatAlarmMicroStop(otInstance *aInstance) sIsUsRunning = false; -#ifdef __linux__ +#if defined(__linux__) && !OPENTHREAD_POSIX_VIRTUAL_TIME if (sRealTimeSignal != 0) { struct itimerspec its = {{0, 0}, {0, 0}}; @@ -209,7 +209,7 @@ void otPlatAlarmMicroStop(otInstance *aInstance) otLogWarnPlat("Failed to stop microsecond timer: %s", strerror(errno)); } } -#endif // __linux__ +#endif // defined( __linux__) && !OPENTHREAD_POSIX_VIRTUAL_TIME } #endif // OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE