summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/time32.h1
-rw-r--r--include/uapi/linux/time.h12
-rw-r--r--kernel/time/time.c12
3 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/time32.h b/include/linux/time32.h
index 65b1de25198d..d2bcd4377b56 100644
--- a/include/linux/time32.h
+++ b/include/linux/time32.h
@@ -217,5 +217,6 @@ static inline s64 timeval_to_ns(const struct timeval *tv)
217 * Returns the timeval representation of the nsec parameter. 217 * Returns the timeval representation of the nsec parameter.
218 */ 218 */
219extern struct timeval ns_to_timeval(const s64 nsec); 219extern struct timeval ns_to_timeval(const s64 nsec);
220extern struct __kernel_old_timeval ns_to_kernel_old_timeval(s64 nsec);
220 221
221#endif 222#endif
diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h
index 61a187df8da2..16a296612ba4 100644
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -43,6 +43,18 @@ struct itimerval {
43}; 43};
44 44
45/* 45/*
46 * legacy timeval structure, only embedded in structures that
47 * traditionally used 'timeval' to pass time intervals (not absolute
48 * times). Do not add new users. If user space fails to compile
49 * here, this is probably because it is not y2038 safe and needs to
50 * be changed to use another interface.
51 */
52struct __kernel_old_timeval {
53 __kernel_long_t tv_sec;
54 __kernel_long_t tv_usec;
55};
56
57/*
46 * The IDs of the various system clocks (for POSIX.1b interval timers): 58 * The IDs of the various system clocks (for POSIX.1b interval timers):
47 */ 59 */
48#define CLOCK_REALTIME 0 60#define CLOCK_REALTIME 0
diff --git a/kernel/time/time.c b/kernel/time/time.c
index bd4e6c7dd689..3044d48ebe56 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -488,6 +488,18 @@ struct timeval ns_to_timeval(const s64 nsec)
488} 488}
489EXPORT_SYMBOL(ns_to_timeval); 489EXPORT_SYMBOL(ns_to_timeval);
490 490
491struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64 nsec)
492{
493 struct timespec64 ts = ns_to_timespec64(nsec);
494 struct __kernel_old_timeval tv;
495
496 tv.tv_sec = ts.tv_sec;
497 tv.tv_usec = (suseconds_t)ts.tv_nsec / 1000;
498
499 return tv;
500}
501EXPORT_SYMBOL(ns_to_kernel_old_timeval);
502
491/** 503/**
492 * set_normalized_timespec - set timespec sec and nsec parts and normalize 504 * set_normalized_timespec - set timespec sec and nsec parts and normalize
493 * 505 *