lib_localtime: gmtime_r should get right time in OS init process

Enable CONFIG_LIBC_LOCALTIME,CONFIG_RTC and CONFIG_SCHED_TICKLESS
In os clock init process, clock_initialize() --> ... -->
sim_rtc_rdtime() --> gmtime_r() --> gmtsub() --> return NULL
get the error rtctime.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
wangbowen6 2022-09-09 12:00:07 +08:00 committed by Xiang Xiao
parent 0bff62e3e8
commit 8b84d19771

View File

@ -59,6 +59,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <nuttx/init.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/mutex.h> #include <nuttx/mutex.h>
@ -1768,7 +1769,7 @@ static FAR struct tm *gmtsub(FAR const time_t *timep,
if (!g_gmt_isset) if (!g_gmt_isset)
{ {
#ifndef __KERNEL__ #ifndef __KERNEL__
if (up_interrupt_context() || sched_idletask()) if (up_interrupt_context() || (sched_idletask() && OSINIT_IDLELOOP()))
{ {
return NULL; return NULL;
} }
@ -2486,7 +2487,7 @@ void tzset(void)
FAR const char *name; FAR const char *name;
#ifndef __KERNEL__ #ifndef __KERNEL__
if (up_interrupt_context() || sched_idletask()) if (up_interrupt_context() || (sched_idletask() && OSINIT_IDLELOOP()))
{ {
return; return;
} }