diff options
author | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2020-03-26 12:44:27 +0200 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2020-03-26 12:46:50 +0200 |
commit | 87d308708712ff6075c4dd54b0519b47fdad8816 (patch) | |
tree | 2fb6458b1db7dd21be2648f42412dd2485846c76 /backport-include/linux/time64.h |
Backports v5.4.27
Backports generated by toradex backports f6e8852f1ef28e6d3c9bae8400eb6a87a6b0c3e7
against mainline kernel tag v5.4.27
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Diffstat (limited to 'backport-include/linux/time64.h')
-rw-r--r-- | backport-include/linux/time64.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/backport-include/linux/time64.h b/backport-include/linux/time64.h new file mode 100644 index 0000000..49805da --- /dev/null +++ b/backport-include/linux/time64.h @@ -0,0 +1,46 @@ +#ifndef __BACKPORT_LINUX_TIME64_H +#define __BACKPORT_LINUX_TIME64_H +#if LINUX_VERSION_IS_GEQ(3,17,0) +#include_next <linux/time64.h> +#else +#include <linux/time.h> +#endif + +#if LINUX_VERSION_IS_LESS(3,17,0) +#define timespec64_equal timespec_equal +#define timespec64_compare timespec_compare +#define set_normalized_timespec64 set_normalized_timespec +#define timespec64_add_safe timespec_add_safe +#define timespec64_add timespec_add +#define timespec64_sub timespec_sub +#define timespec64_valid timespec_valid +#define timespec64_valid_strict timespec_valid_strict +#define timespec64_to_ns timespec_to_ns +#define ns_to_timespec64 ns_to_timespec +#define timespec64_add_ns timespec_add_ns +#define timespec64 timespec +#endif /* LINUX_VERSION_IS_LESS(3,17,0) */ + +#if LINUX_VERSION_IS_LESS(3,19,0) +static inline time64_t mktime64(const unsigned int year0, const unsigned int mon0, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec) +{ + unsigned int mon = mon0, year = year0; + + /* 1..12 -> 11,12,1..10 */ + if (0 >= (int) (mon -= 2)) { + mon += 12; /* Puts Feb last since it has leap day */ + year -= 1; + } + + return ((((time64_t) + (year/4 - year/100 + year/400 + 367*mon/12 + day) + + year*365 - 719499 + )*24 + hour /* now have hours - midnight tomorrow handled here */ + )*60 + min /* now have minutes */ + )*60 + sec; /* finally seconds */ +} +#endif + +#endif /* __BACKPORT_LINUX_TIME64_H */ |