Commit 18723117 authored by AKASHI Takahiro's avatar AKASHI Takahiro Committed by Tom Rini

lib: add mktime64() for linux compatibility

This function will be used  in lib/crypto/x509_cert_parser.c, which
will also be imported from linux code in a later commit.
Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
parent 05429b6c
#ifndef _LINUX_TIME_H
#define _LINUX_TIME_H
#include <rtc.h>
#include <linux/types.h>
#define _DEFUN(a,b,c) a(c)
......@@ -150,4 +151,13 @@ _DEFUN (ctime_r, (tim_p, result),
return asctime_r (localtime_r (tim_p, &tm), result);
}
/* for compatibility with linux code */
typedef __s64 time64_t;
#ifdef CONFIG_LIB_DATE
time64_t mktime64(const unsigned int year, const unsigned int mon,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec);
#endif
#endif
......@@ -8,6 +8,7 @@
#include <command.h>
#include <errno.h>
#include <rtc.h>
#include <linux/time.h>
#if defined(CONFIG_LIB_DATE) || defined(CONFIG_TIMESTAMP)
......@@ -97,3 +98,22 @@ unsigned long rtc_mktime(const struct rtc_time *tm)
}
#endif /* CONFIG_LIB_DATE || CONFIG_TIMESTAMP */
#ifdef CONFIG_LIB_DATE
/* for compatibility with linux code */
time64_t mktime64(const unsigned int year, const unsigned int mon,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec)
{
struct rtc_time time;
time.tm_year = year;
time.tm_mon = mon;
time.tm_mday = day;
time.tm_hour = hour;
time.tm_min = min;
time.tm_sec = sec;
return (time64_t)rtc_mktime((const struct rtc_time *)&time);
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment