aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
index afc50ba6d..13b2cf9b9 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
@@ -125,15 +125,21 @@ static time_t rtc_encode(const RTCDateTime *timespec) {
*
* @notapi
*/
-static void rtc_decode(uint32_t tv_sec, uint32_t tv_msec,
- RTCDateTime *timespec) {
+static void rtc_decode(uint32_t tv_sec,
+ uint32_t tv_msec,
+ RTCDateTime *timespec) {
struct tm tim;
- struct tm *canary;
+ struct tm *t;
/* If the conversion is successful the function returns a pointer
to the object the result was written into.*/
- canary = localtime_r((time_t *)&(tv_sec), &tim);
- osalDbgCheck(&tim == canary);
+#if defined __GNUC__
+ t = localtime_r((time_t *)&(tv_sec), &tim);
+ osalDbgAssert(t != NULL, "conversion failed");
+#else
+ struct tm *t = localtime(&tv_sec);
+ memcpy(&timp, t, sizeof(struct tm));
+#endif
rtcConvertStructTmToDateTime(&tim, tv_msec, timespec);
}