summaryrefslogtreecommitdiff
path: root/components/libc/compilers
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2022-01-05 16:43:44 -0500
committerBernard Xiong <[email protected]>2022-01-08 15:46:52 +0800
commit8565fe2448ae086d270687eba3855214b649ebc5 (patch)
tree756c6994c781f9139a2b40a0c73cd52c40fbdc4a /components/libc/compilers
parent495e209f379338b2bbc4ba086e457d0fb6d22a8d (diff)
[simulator] 消除vs下的警告
Diffstat (limited to 'components/libc/compilers')
-rw-r--r--components/libc/compilers/common/sys/time.h18
-rw-r--r--components/libc/compilers/common/time.c6
2 files changed, 14 insertions, 10 deletions
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 55c60d716e..ce3f3a3c08 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -42,20 +42,14 @@ struct timezone
int tz_dsttime; /* type of dst correction */
};
-/*
- * Structure returned by gettimeofday(2) system call,
- * and used in other calls.
- */
-#ifndef _TIMEVAL_DEFINED
+#if !defined(_TIMEVAL_DEFINED) && !defined(_WIN32)
#define _TIMEVAL_DEFINED
-#if !defined(_WIN32)
struct timeval
{
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* and microseconds */
};
#endif
-#endif /* _TIMEVAL_DEFINED */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && \
!(defined(__ICCARM__) && (__VER__ >= 8010001)) && \
@@ -73,6 +67,16 @@ int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv, const struct timezone *tz);
#if defined(__ARMCC_VERSION) || defined (__ICCARM__)
struct tm *gmtime_r(const time_t *timep, struct tm *r);
+#elif defined(_WIN32)
+struct tm* gmtime_r(const time_t* timep, struct tm* r);
+struct tm* gmtime(const time_t* t);
+struct tm* localtime_r(const time_t* t, struct tm* r);
+struct tm* localtime(const time_t* t);
+time_t mktime(struct tm* const t);
+char* asctime_r(const struct tm* t, char* buf);
+char* ctime_r(const time_t* tim_p, char* result);
+char* ctime(const time_t* tim_p);
+time_t time(time_t* t);
#endif
#ifdef RT_USING_POSIX_CLOCK
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 256268a3fc..d5442738a8 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -217,7 +217,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
{
time_t local_tz;
- local_tz = *t + tz_get() * 3600;
+ local_tz = *t + (time_t)tz_get() * 3600;
return gmtime_r(&local_tz, r);
}
RTM_EXPORT(localtime_r);
@@ -234,7 +234,7 @@ time_t mktime(struct tm * const t)
time_t timestamp;
timestamp = timegm(t);
- timestamp = timestamp - 3600 * tz_get();
+ timestamp = timestamp - 3600 * (time_t)tz_get();
return timestamp;
}
RTM_EXPORT(mktime);
@@ -367,7 +367,7 @@ time_t timegm(struct tm * const t)
{
register time_t day;
register time_t i;
- register time_t years = t->tm_year - 70;
+ register time_t years = (time_t)t->tm_year - 70;
if (t->tm_sec > 60)
{