diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 99dab71eb4168ce3a0d859ea95a9d04642c30a0d..f6f35acb5f5be763b09865f6f8d8054bf2da58c8 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -81,25 +81,25 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) return r; } -struct tm* gmtime(const time_t* t) +struct tm *gmtime(const time_t *t) { static struct tm tmp; return gmtime_r(t, &tmp); } /*TODO timezone is not supprt now */ -struct tm* localtime_r(const time_t* t, struct tm* r) +struct tm *localtime_r(const time_t *t, struct tm *r) { return gmtime_r(t, r); } -struct tm* localtime(const time_t* t) +struct tm *localtime(const time_t *t) { static struct tm tmp; return localtime_r(t, &tmp); } -time_t mktime(struct tm * const t) +time_t mktime(struct tm *const t) { register time_t day; register time_t i; @@ -179,11 +179,12 @@ static void num2str(char *c, int i) c[1] = i % 10 + '0'; } -char* asctime_r(const struct tm *t, char *buf) +char *asctime_r(const struct tm *t, char *buf) { /* "Wed Jun 30 21:49:08 1993\n" */ - *(int*) buf = *(int*) (days + (t->tm_wday << 2)); - *(int*) (buf + 4) = *(int*) (months + (t->tm_mon << 2)); + rt_memcpy(buf, (days + (t->tm_wday << 2)), 4); + rt_memcpy((buf + 4), (months + (t->tm_mon << 2)), 4); + num2str(buf + 8, t->tm_mday); if (buf[8] == '0') buf[8] = ' '; @@ -200,13 +201,13 @@ char* asctime_r(const struct tm *t, char *buf) return buf; } -char* asctime(const struct tm *timeptr) +char *asctime(const struct tm *timeptr) { static char buf[25]; return asctime_r(timeptr, buf); } -char* ctime(const time_t *timep) +char *ctime(const time_t *timep) { return asctime(localtime(timep)); } @@ -245,14 +246,14 @@ int gettimeofday(struct timeval *tp, void *ignore) */ /* for IAR 6.2 later Compiler */ #if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 -#pragma module_name = "?time" -#if _DLIB_TIME_USES_64 -time_t __time64(time_t *t) -#else -time_t __time32(time_t *t) -#endif + #pragma module_name = "?time" + #if _DLIB_TIME_USES_64 + time_t __time64(time_t *t) + #else + time_t __time32(time_t *t) + #endif #else -time_t time(time_t *t) + time_t time(time_t *t) #endif { time_t time_now = 0;