History

time: Add time_types.h

sys/time.h is the mandated include for many time related defines. However, linux/time.h overlaps sys/time.h significantly and this makes including both from userspace or one from the other impossible. This also means that userspace can get away with including sys/time.h whenever it needs linux/time.h and this is what's been happening in the user world usually. But, we have new data types that we plan to use in the uapi time interfaces also defined in the linux/time.h. But, we are unable to use these types when sys/time.h is included. Hence, move the new types to a new header, time_types.h. We intend to eventually have all the uapi defines that the kernel uses defined in this header. Note that the plan is to replace uapi interfaces with timeval to use __kernel_old_timeval, timespec to use __kernel_old_timespec etc.

Deepa Dinamani committed 7 years ago

Commit ca5e9ab1 parent a08ef412 files · +41 −35Browse files

Showing the changes to include/uapi/linux (2 of 2 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/time.h +1 −35
  2. include/uapi/linux/time_types.h +40 −0
include/uapi/linux/time.h+1−35
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #define _UAPI_LINUX_TIME_H
44
55 #include <linux/types.h>
6−
6+#include <linux/time_types.h>
77
88 #ifndef _STRUCT_TIMESPEC
99 #define _STRUCT_TIMESPEC
@@ -23,7 +23,6 @@ struct timezone { · 13 unmodified lines
2323 int tz_dsttime; /* type of dst correction */
2424 };
2525
26−
2726 /*
2827 * Names of the interval timers, and structure
2928 * defining a timer setting:
@@ -42,39 +41,6 @@ struct itimerval { · 12 unmodified lines
4241 struct timeval it_value; /* current value */
4342 };
4443
45−#ifndef __kernel_timespec
46−struct __kernel_timespec {
47− __kernel_time64_t tv_sec; /* seconds */
48− long long tv_nsec; /* nanoseconds */
49−};
50−#endif
51−
52−#ifndef __kernel_itimerspec
53−struct __kernel_itimerspec {
54− struct __kernel_timespec it_interval; /* timer period */
55− struct __kernel_timespec it_value; /* timer expiration */
56−};
57−#endif
58−
59−/*
60− * legacy timeval structure, only embedded in structures that
61− * traditionally used 'timeval' to pass time intervals (not absolute
62− * times). Do not add new users. If user space fails to compile
63− * here, this is probably because it is not y2038 safe and needs to
64− * be changed to use another interface.
65− */
66−#ifndef __kernel_old_timeval
67−struct __kernel_old_timeval {
68− __kernel_long_t tv_sec;
69− __kernel_long_t tv_usec;
70−};
71−#endif
72−
73−struct __kernel_sock_timeval {
74− __s64 tv_sec;
75− __s64 tv_usec;
76−};
77−
7844 /*
7945 * The IDs of the various system clocks (for POSIX.1b interval timers):
8046 */
include/uapi/linux/time_types.h+40−0
@@ -0,0 +1,40 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI_LINUX_TIME_TYPES_H
3+#define _UAPI_LINUX_TIME_TYPES_H
4+
5+#include <linux/types.h>
6+
7+#ifndef __kernel_timespec
8+struct __kernel_timespec {
9+ __kernel_time64_t tv_sec; /* seconds */
10+ long long tv_nsec; /* nanoseconds */
11+};
12+#endif
13+
14+#ifndef __kernel_itimerspec
15+struct __kernel_itimerspec {
16+ struct __kernel_timespec it_interval; /* timer period */
17+ struct __kernel_timespec it_value; /* timer expiration */
18+};
19+#endif
20+
21+/*
22+ * legacy timeval structure, only embedded in structures that
23+ * traditionally used 'timeval' to pass time intervals (not absolute
24+ * times). Do not add new users. If user space fails to compile
25+ * here, this is probably because it is not y2038 safe and needs to
26+ * be changed to use another interface.
27+ */
28+#ifndef __kernel_old_timeval
29+struct __kernel_old_timeval {
30+ __kernel_long_t tv_sec;
31+ __kernel_long_t tv_usec;
32+};
33+#endif
34+
35+struct __kernel_sock_timeval {
36+ __s64 tv_sec;
37+ __s64 tv_usec;
38+};
39+
40+#endif /* _UAPI_LINUX_TIME_TYPES_H */