diff --git a/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c b/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c index 5ff99949b38..20df0d7a7b4 100644 --- a/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c +++ b/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c @@ -270,7 +270,7 @@ static int cxd56_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -325,7 +325,7 @@ static int cxd56_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert the RTC time to a timespec (1 second accuracy) */ - lowerinfo.as_time.tv_sec = mktime((FAR struct tm *)&alarminfo->time); + lowerinfo.as_time.tv_sec = timegm((FAR struct tm *)&alarminfo->time); lowerinfo.as_time.tv_nsec = 0; /* And set the alarm */ diff --git a/arch/arm/src/imxrt/imxrt_rtc_lowerhalf.c b/arch/arm/src/imxrt/imxrt_rtc_lowerhalf.c index 079ce0cb299..0712e62487b 100644 --- a/arch/arm/src/imxrt/imxrt_rtc_lowerhalf.c +++ b/arch/arm/src/imxrt/imxrt_rtc_lowerhalf.c @@ -238,7 +238,7 @@ static int imxrt_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -312,7 +312,7 @@ static int imxrt_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert the RTC time to a timespec (1 second accuracy) */ - ts.tv_sec = mktime((FAR struct tm *)&alarminfo->time); + ts.tv_sec = timegm((FAR struct tm *)&alarminfo->time); ts.tv_nsec = 0; /* Remember the callback information */ diff --git a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c index dbbad807405..2c9702f94fa 100644 --- a/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c +++ b/arch/arm/src/kinetis/kinetis_rtc_lowerhalf.c @@ -274,7 +274,7 @@ static int kinetis_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Set the time (to one second accuracy) */ @@ -325,7 +325,7 @@ static int kinetis_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert from Julian calendar time to epoch time */ - tp.tv_sec = mktime((FAR struct tm *)&alarminfo->time) ; + tp.tv_sec = timegm((FAR struct tm *)&alarminfo->time) ; /* And set the alarm */ @@ -393,7 +393,7 @@ kinetis_setrelative(FAR struct rtc_lowerhalf_s *lower, return ret; } - ts.tv_sec = mktime(&time); + ts.tv_sec = timegm(&time); ts.tv_nsec = 0; #else /* Get the current time in broken out format */ diff --git a/arch/arm/src/lc823450/lc823450_rtc.c b/arch/arm/src/lc823450/lc823450_rtc.c index 03a0c89f746..b5a4952b3b0 100644 --- a/arch/arm/src/lc823450/lc823450_rtc.c +++ b/arch/arm/src/lc823450/lc823450_rtc.c @@ -170,7 +170,7 @@ volatile bool g_rtc_enabled = false; static void tm_divider(struct tm *tm, int divn, int divm) { time_t tt; - tt = mktime(tm); + tt = timegm(tm); tt = (time_t) ((uint64_t)tt * divn / divm); gmtime_r(&tt, tm); } @@ -690,7 +690,7 @@ int up_rtc_getrawtime(FAR struct timespec *ts) #endif /* CONFIG_RTC_DIV */ ts->tv_nsec = 0; - ts->tv_sec = mktime(&tm); + ts->tv_sec = timegm(&tm); return 0; } diff --git a/arch/arm/src/lpc54xx/lpc54_rtc_lowerhalf.c b/arch/arm/src/lpc54xx/lpc54_rtc_lowerhalf.c index e0779d11d19..3056d82c79b 100644 --- a/arch/arm/src/lpc54xx/lpc54_rtc_lowerhalf.c +++ b/arch/arm/src/lpc54xx/lpc54_rtc_lowerhalf.c @@ -253,7 +253,7 @@ static int lpc54_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -321,7 +321,7 @@ static int lpc54_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert the RTC time to a timespec (1 second accuracy) */ - ts.tv_sec = mktime((FAR struct tm *)&alarminfo->time); + ts.tv_sec = timegm((FAR struct tm *)&alarminfo->time); ts.tv_nsec = 0; /* Remember the callback information */ diff --git a/arch/arm/src/max326xx/common/max326_rtc_lowerhalf.c b/arch/arm/src/max326xx/common/max326_rtc_lowerhalf.c index 7d0152bc859..2489e59da02 100644 --- a/arch/arm/src/max326xx/common/max326_rtc_lowerhalf.c +++ b/arch/arm/src/max326xx/common/max326_rtc_lowerhalf.c @@ -314,7 +314,7 @@ static int max326_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -383,7 +383,7 @@ static int max326_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert the RTC time to a timespec (1 second accuracy) */ - ts.tv_sec = mktime((FAR struct tm *)&alarminfo->time); + ts.tv_sec = timegm((FAR struct tm *)&alarminfo->time); ts.tv_nsec = 0; /* Remember the callback information */ @@ -460,7 +460,7 @@ static int max326_setrelative(FAR struct rtc_lowerhalf_s *lower, return ret; } - ts.tv_sec = mktime(&time); + ts.tv_sec = timegm(&time); ts.tv_nsec = 0; #elif defined(CONFIG_RTC_HIRES) diff --git a/arch/arm/src/sam34/sam_rtc.c b/arch/arm/src/sam34/sam_rtc.c index 858ca90f862..d3a622f62cd 100644 --- a/arch/arm/src/sam34/sam_rtc.c +++ b/arch/arm/src/sam34/sam_rtc.c @@ -788,7 +788,7 @@ int up_rtc_gettime(FAR struct timespec *tp) RTC_CALR_YEAR_SHIFT) - 1900; - tp->tv_sec = mktime(&t); + tp->tv_sec = timegm(&t); tp->tv_nsec = (((rtt_val - g_rtt_offset) & (CONFIG_RTC_FREQUENCY - 1)) * 1000000000ull) / CONFIG_RTC_FREQUENCY; diff --git a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c index ff014468973..9b3ed1cf120 100644 --- a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c @@ -347,7 +347,7 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -470,7 +470,7 @@ static int stm32_setalarm(FAR struct rtc_lowerhalf_s *lower, /* Convert the RTC time to a timespec (1 second accuracy) */ - ts.tv_sec = mktime((FAR struct tm *)&alarminfo->time); + ts.tv_sec = timegm((FAR struct tm *)&alarminfo->time); ts.tv_nsec = 0; /* Remember the callback information */ @@ -542,7 +542,7 @@ static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. @@ -600,7 +600,7 @@ static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, return ret; } - ts.tv_sec = mktime(&time); + ts.tv_sec = timegm(&time); ts.tv_nsec = 0; #elif defined(CONFIG_RTC_HIRES) diff --git a/arch/arm/src/stm32f7/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32f7/stm32_rtc_lowerhalf.c index e1f4ce4076d..f78db23167d 100644 --- a/arch/arm/src/stm32f7/stm32_rtc_lowerhalf.c +++ b/arch/arm/src/stm32f7/stm32_rtc_lowerhalf.c @@ -312,7 +312,7 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -459,7 +459,7 @@ static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. diff --git a/arch/arm/src/stm32h7/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32h7/stm32_rtc_lowerhalf.c index ceb132657f2..4166c958428 100644 --- a/arch/arm/src/stm32h7/stm32_rtc_lowerhalf.c +++ b/arch/arm/src/stm32h7/stm32_rtc_lowerhalf.c @@ -313,7 +313,7 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -460,7 +460,7 @@ static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. diff --git a/arch/arm/src/stm32l4/stm32l4_rtc_lowerhalf.c b/arch/arm/src/stm32l4/stm32l4_rtc_lowerhalf.c index 71f3ee33205..9a934c5570b 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtc_lowerhalf.c +++ b/arch/arm/src/stm32l4/stm32l4_rtc_lowerhalf.c @@ -426,7 +426,7 @@ stm32l4_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. diff --git a/arch/renesas/src/rx65n/rx65n_rtc.c b/arch/renesas/src/rx65n/rx65n_rtc.c index 27360893f23..9a675b7710f 100644 --- a/arch/renesas/src/rx65n/rx65n_rtc.c +++ b/arch/renesas/src/rx65n/rx65n_rtc.c @@ -532,7 +532,7 @@ int up_rtc_gettime(FAR struct timespec *tp) t.tm_year = rtc_bcd2dec((uint8_t) (bcd_years & 0xff)) + 100; - tp->tv_sec = mktime(&t); + tp->tv_sec = timegm(&t); tp->tv_nsec = 0; } diff --git a/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c b/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c index 6cc9e13b4d8..bb5cfa04ce3 100644 --- a/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c +++ b/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c @@ -303,7 +303,7 @@ static int rx65n_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -446,7 +446,7 @@ static int rx65n_setrelative(FAR struct rtc_lowerhalf_s *lower, return ret; } - ts.tv_sec = mktime(&time); + ts.tv_sec = timegm(&time); ts.tv_nsec = 0; #elif defined(CONFIG_RTC_HIRES) @@ -457,7 +457,7 @@ static int rx65n_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. diff --git a/arch/sim/src/sim/up_rtc.c b/arch/sim/src/sim/up_rtc.c index 628ae82b56a..d119253f6ef 100644 --- a/arch/sim/src/sim/up_rtc.c +++ b/arch/sim/src/sim/up_rtc.c @@ -83,7 +83,7 @@ static int sim_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower, static int sim_rtc_settime(FAR struct rtc_lowerhalf_s *lower, FAR const struct rtc_time *rtctime) { - g_sim_delta = mktime((FAR struct tm *)rtctime); + g_sim_delta = timegm((FAR struct tm *)rtctime); g_sim_delta *= NSEC_PER_SEC; g_sim_delta += rtctime->tm_nsec; g_sim_delta -= host_gettime(true); diff --git a/arch/z80/src/ez80/ez80_rtc_lowerhalf.c b/arch/z80/src/ez80/ez80_rtc_lowerhalf.c index cf849eed4fb..f7231b496bc 100644 --- a/arch/z80/src/ez80/ez80_rtc_lowerhalf.c +++ b/arch/z80/src/ez80/ez80_rtc_lowerhalf.c @@ -297,7 +297,7 @@ static int ez80_settime(FAR struct rtc_lowerhalf_s *lower, * rtc_time is cast compatible with struct tm. */ - ts.tv_sec = mktime((FAR struct tm *)rtctime); + ts.tv_sec = timegm((FAR struct tm *)rtctime); ts.tv_nsec = 0; /* Now set the time (to one second accuracy) */ @@ -432,7 +432,7 @@ static int ez80_setrelative(FAR struct rtc_lowerhalf_s *lower, { /* Convert to seconds since the epoch */ - seconds = mktime(&time); + seconds = timegm(&time); /* Add the seconds offset. Add one to the number of seconds * because we are unsure of the phase of the timer. diff --git a/drivers/timers/arch_rtc.c b/drivers/timers/arch_rtc.c index 231f321acc9..6e1b90f3a12 100644 --- a/drivers/timers/arch_rtc.c +++ b/drivers/timers/arch_rtc.c @@ -89,7 +89,7 @@ time_t up_rtc_time(void) if (g_rtc_lower->ops->rdtime(g_rtc_lower, &rtctime) == 0) { - time = mktime((FAR struct tm *)&rtctime); + time = timegm((FAR struct tm *)&rtctime); } } @@ -125,7 +125,7 @@ int up_rtc_gettime(FAR struct timespec *tp) ret = g_rtc_lower->ops->rdtime(g_rtc_lower, &rtctime); if (ret == 0) { - tp->tv_sec = mktime((FAR struct tm *)&rtctime); + tp->tv_sec = timegm((FAR struct tm *)&rtctime); tp->tv_nsec = rtctime.tm_nsec; } } diff --git a/drivers/timers/rpmsg_rtc.c b/drivers/timers/rpmsg_rtc.c index f0b3542399b..78b68d52026 100644 --- a/drivers/timers/rpmsg_rtc.c +++ b/drivers/timers/rpmsg_rtc.c @@ -367,7 +367,7 @@ static int rpmsg_rtc_settime(FAR struct rtc_lowerhalf_s *lower, { struct rpmsg_rtc_set_s msg = { - .sec = mktime((FAR struct tm *)rtctime), + .sec = timegm((FAR struct tm *)rtctime), .nsec = rtctime->tm_nsec, }; @@ -388,7 +388,7 @@ static int rpmsg_rtc_setalarm(FAR struct rtc_lowerhalf_s *lower_, (FAR struct rpmsg_rtc_lowerhalf_s *)lower_; struct rpmsg_rtc_alarm_set_s msg = { - .sec = mktime((FAR struct tm *)&alarminfo->time), + .sec = timegm((FAR struct tm *)&alarminfo->time), .nsec = alarminfo->time.tm_nsec, .id = alarminfo->id, }; @@ -419,7 +419,7 @@ rpmsg_rtc_setrelative(FAR struct rtc_lowerhalf_s *lower, time_t time; rpmsg_rtc_rdtime(lower, &alarminfo.time); - time = mktime((FAR struct tm *)&alarminfo.time); + time = timegm((FAR struct tm *)&alarminfo.time); time = time + relinfo->reltime; gmtime_r(&time, (FAR struct tm *)&alarminfo.time); diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c index e9f5079ea7c..7045068e856 100644 --- a/fs/fat/fs_fat32util.c +++ b/fs/fat/fs_fat32util.c @@ -465,7 +465,7 @@ time_t fat_fattime2systime(uint16_t fattime, uint16_t fatdate) /* Then convert the broken out time into seconds since the epoch */ - return mktime(&tm); + return timegm(&tm); #else return 0; #endif diff --git a/include/time.h b/include/time.h index e2954577abf..6bca5791024 100644 --- a/include/time.h +++ b/include/time.h @@ -91,7 +91,6 @@ #define TIME_UTC 1 - /* Redirect the timelocal */ #define timelocal mktime diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c index 223e81bb954..7edafb7c96b 100644 --- a/sched/clock/clock_initialize.c +++ b/sched/clock/clock_initialize.c @@ -92,7 +92,7 @@ int clock_basetime(FAR struct timespec *tp) { /* And use the broken-out time to initialize the system time */ - tp->tv_sec = mktime(&rtctime); + tp->tv_sec = timegm(&rtctime); tp->tv_nsec = nsecs; }