diff options
Diffstat (limited to 'lib/libc/time')
| -rw-r--r-- | lib/libc/time/Kbuild | 15 | ||||
| -rw-r--r-- | lib/libc/time/asctime.c | 9 | ||||
| -rw-r--r-- | lib/libc/time/gmtime_r.c | 2 | ||||
| -rw-r--r-- | lib/libc/time/strftime.c | 24 | ||||
| -rw-r--r-- | lib/libc/time/utimes.c | 4 |
5 files changed, 26 insertions, 28 deletions
diff --git a/lib/libc/time/Kbuild b/lib/libc/time/Kbuild new file mode 100644 index 00000000..6b9e00cc --- /dev/null +++ b/lib/libc/time/Kbuild @@ -0,0 +1,15 @@ +obj-y += asctime.o +obj-y += clock_getcpuclockid.o +obj-y += clock_getres.o +obj-y += clock_nanosleep.o +obj-y += clock.o +obj-y += ctime.o +obj-y += difftime.o +obj-y += gmtime_r.o +obj-y += localtime_r.o +obj-y += localtime.o +obj-y += nanosleep.o +obj-y += strftime.o +obj-y += time.o +obj-y += tzset.o +obj-y += utimes.o diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c index 54729a77..ab5ff096 100644 --- a/lib/libc/time/asctime.c +++ b/lib/libc/time/asctime.c @@ -3,11 +3,10 @@ char *asctime(const struct tm *timeptr) { - static char wday_name[7][3] = { "Sun", "Mon", "Tue", "Wed", - "Thu", "Fri", "Sat" }; - static char mon_name[12][3] = { "Jan", "Feb", "Mar", "Apr", - "May", "Jun", "Jul", "Aug", - "Sep", "Oct", "Nov", "Dec" }; + static char wday_name[][4] = { "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat" }; + static char mon_name[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static char result[26]; snprintf(result, sizeof(result), "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", diff --git a/lib/libc/time/gmtime_r.c b/lib/libc/time/gmtime_r.c index 8d441549..2c741127 100644 --- a/lib/libc/time/gmtime_r.c +++ b/lib/libc/time/gmtime_r.c @@ -4,7 +4,7 @@ struct tm *gmtime_r(const time_t *timer, struct tm *result) { time_t t = *timer; int days, rem; - int year, month; + int year; rem = t % 86400; days = t / 86400; diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index f0881eb1..3f54961b 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -9,7 +9,7 @@ static size_t append_string(char *restrict *s, size_t *remaining, if (len >= *remaining) { return 0; } - strcpy(*s, str); + strlcpy(*s, str, *remaining); *s += len; *remaining -= len; return len; @@ -73,26 +73,10 @@ static const char *month_full[] = { "January", "February", "March", "July", "August", "September", "October", "November", "December" }; -static int day_of_year(const struct tm *tm) -{ - static const int days_to_month[] = { 0, 31, 59, 90, 120, 151, - 181, 212, 243, 273, 304, 334 }; - int days = days_to_month[tm->tm_mon] + tm->tm_mday; - - if (tm->tm_mon > 1) { - int year = tm->tm_year + 1900; - if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { - days++; - } - } - return days; -} - static int iso_week_number(const struct tm *tm, int *week_year) { int year = tm->tm_year + 1900; int yday = tm->tm_yday + 1; - int wday; int jan4_wday = (4 + year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % @@ -554,9 +538,9 @@ size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, } __weak size_t strftime_l(char *restrict s, size_t maxsize, - const char *restrict format, - const struct tm *restrict timeptr, - locale_t __unused locale) + const char *restrict format, + const struct tm *restrict timeptr, + locale_t __unused locale) { return strftime(s, maxsize, format, timeptr); } diff --git a/lib/libc/time/utimes.c b/lib/libc/time/utimes.c index d6448c76..7b928e7a 100644 --- a/lib/libc/time/utimes.c +++ b/lib/libc/time/utimes.c @@ -9,8 +9,8 @@ int utimes(const char *path, const struct timeval times[2]) struct timespec ts[2]; if (times) { - if (times[0].tv_usec >= 1000000ULL || - times[1].tv_usec >= 1000000ULL) { + if (times[0].tv_usec >= 1000000L || + times[1].tv_usec >= 1000000L) { errno = EINVAL; return -1; } |
