mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
libc: Don't define localtime[_r] to macro when CONFIG_LIBC_LOCALTIME not define
since libc++ declare these function in ctime by: using ::localtime[_r]; Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: Ic0bb68b44c0cab838ab7cc34baee2aaa3ca8a9b5
This commit is contained in:
committed by
Brennan Ashton
parent
11f8b7c974
commit
e1ecb3e27c
@@ -64,7 +64,6 @@
|
||||
|
||||
FAR char *ctime(FAR const time_t *timep)
|
||||
{
|
||||
#ifdef CONFIG_LIBC_LOCALTIME
|
||||
/* Section 4.12.3.2 of X3.159-1989 requires that
|
||||
* The ctime function converts the calendar time pointed to by timer
|
||||
* to local time in the form of a string. It is equivalent to
|
||||
@@ -72,7 +71,4 @@ FAR char *ctime(FAR const time_t *timep)
|
||||
*/
|
||||
|
||||
return asctime(localtime(timep));
|
||||
#else
|
||||
return asctime(gmtime(timep));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -71,9 +71,5 @@ FAR char *ctime_r(FAR const time_t *timep, FAR char *buf)
|
||||
{
|
||||
struct tm tm;
|
||||
|
||||
#ifdef CONFIG_LIBC_LOCALTIME
|
||||
return asctime_r(localtime_r(timep, &tm), buf);
|
||||
#else
|
||||
return asctime_r(gmtime_r(timep, &tm), buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -57,8 +57,15 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct tm *gmtime(const time_t *timer)
|
||||
FAR struct tm *gmtime(FAR const time_t *timep)
|
||||
{
|
||||
static struct tm tm;
|
||||
return gmtime_r(timer, &tm);
|
||||
return gmtime_r(timep, &tm);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_LIBC_LOCALTIME
|
||||
FAR struct tm *localtime(FAR const time_t *timep)
|
||||
{
|
||||
return gmtime(timep);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -301,7 +301,7 @@ static void clock_utc2calendar(time_t days, FAR int *year, FAR int *month,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result)
|
||||
FAR struct tm *gmtime_r(FAR const time_t *timep, FAR struct tm *result)
|
||||
{
|
||||
time_t epoch;
|
||||
time_t jdn;
|
||||
@@ -314,7 +314,7 @@ FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result)
|
||||
|
||||
/* Get the seconds since the EPOCH */
|
||||
|
||||
epoch = *timer;
|
||||
epoch = *timep;
|
||||
linfo("timer=%d\n", (int)epoch);
|
||||
|
||||
/* Convert to days, hours, minutes, and seconds since the EPOCH */
|
||||
@@ -357,3 +357,10 @@ FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_LIBC_LOCALTIME
|
||||
FAR struct tm *localtime_r(FAR const time_t *timep, FAR struct tm *result)
|
||||
{
|
||||
return gmtime_r(timep, result);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user