2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-20 19:23:57 +08:00

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.

Reported-by: Ran Rozenstein <ranro@mellanox.com>
Fixes: 9718475e69 ("socket: Add SO_TIMESTAMPING_NEW")
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Deepa Dinamani 2019-02-12 19:26:03 -08:00 committed by David S. Miller
parent a08ef41f71
commit ca5e9aba75
2 changed files with 41 additions and 35 deletions

View File

@ -3,7 +3,7 @@
#define _UAPI_LINUX_TIME_H #define _UAPI_LINUX_TIME_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/time_types.h>
#ifndef _STRUCT_TIMESPEC #ifndef _STRUCT_TIMESPEC
#define _STRUCT_TIMESPEC #define _STRUCT_TIMESPEC
@ -23,7 +23,6 @@ struct timezone {
int tz_dsttime; /* type of dst correction */ int tz_dsttime; /* type of dst correction */
}; };
/* /*
* Names of the interval timers, and structure * Names of the interval timers, and structure
* defining a timer setting: * defining a timer setting:
@ -42,39 +41,6 @@ struct itimerval {
struct timeval it_value; /* current value */ struct timeval it_value; /* current value */
}; };
#ifndef __kernel_timespec
struct __kernel_timespec {
__kernel_time64_t tv_sec; /* seconds */
long long tv_nsec; /* nanoseconds */
};
#endif
#ifndef __kernel_itimerspec
struct __kernel_itimerspec {
struct __kernel_timespec it_interval; /* timer period */
struct __kernel_timespec it_value; /* timer expiration */
};
#endif
/*
* legacy timeval structure, only embedded in structures that
* traditionally used 'timeval' to pass time intervals (not absolute
* times). Do not add new users. If user space fails to compile
* here, this is probably because it is not y2038 safe and needs to
* be changed to use another interface.
*/
#ifndef __kernel_old_timeval
struct __kernel_old_timeval {
__kernel_long_t tv_sec;
__kernel_long_t tv_usec;
};
#endif
struct __kernel_sock_timeval {
__s64 tv_sec;
__s64 tv_usec;
};
/* /*
* The IDs of the various system clocks (for POSIX.1b interval timers): * The IDs of the various system clocks (for POSIX.1b interval timers):
*/ */

View File

@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_LINUX_TIME_TYPES_H
#define _UAPI_LINUX_TIME_TYPES_H
#include <linux/types.h>
#ifndef __kernel_timespec
struct __kernel_timespec {
__kernel_time64_t tv_sec; /* seconds */
long long tv_nsec; /* nanoseconds */
};
#endif
#ifndef __kernel_itimerspec
struct __kernel_itimerspec {
struct __kernel_timespec it_interval; /* timer period */
struct __kernel_timespec it_value; /* timer expiration */
};
#endif
/*
* legacy timeval structure, only embedded in structures that
* traditionally used 'timeval' to pass time intervals (not absolute
* times). Do not add new users. If user space fails to compile
* here, this is probably because it is not y2038 safe and needs to
* be changed to use another interface.
*/
#ifndef __kernel_old_timeval
struct __kernel_old_timeval {
__kernel_long_t tv_sec;
__kernel_long_t tv_usec;
};
#endif
struct __kernel_sock_timeval {
__s64 tv_sec;
__s64 tv_usec;
};
#endif /* _UAPI_LINUX_TIME_TYPES_H */