git: 34670aeab4f5 - stable/13 - linux(4): add struct timespec64 definition and conversion routine for future use.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Jun 2022 19:28:51 UTC
The branch stable/13 has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=34670aeab4f5a4a1b2d0b7c3a759c0caf9e6e0b2
commit 34670aeab4f5a4a1b2d0b7c3a759c0caf9e6e0b2
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-06-07 01:47:12 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:27:55 +0000
linux(4): add struct timespec64 definition and conversion routine for
future use.
MFC after: 2 weeks
(cherry picked from commit bfcce1a9f6e3c9defde10bb1f83d4ba9752c23f6)
---
sys/amd64/linux32/linux.h | 7 +++++++
sys/compat/linux/linux_time.c | 24 ++++++++++++++++++++++++
sys/compat/linux/linux_timer.h | 6 ++++++
sys/i386/linux/linux.h | 7 +++++++
4 files changed, 44 insertions(+)
diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
index 6f26974a75a1..50a4efed1709 100644
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -81,6 +81,7 @@ typedef l_int l_pid_t;
typedef l_uint l_size_t;
typedef l_long l_suseconds_t;
typedef l_long l_time_t;
+typedef l_longlong l_time64_t;
typedef l_uint l_uid_t;
typedef l_ushort l_uid16_t;
typedef l_int l_timer_t;
@@ -171,6 +172,12 @@ struct l_timespec {
l_long tv_nsec;
};
+/* __kernel_timespec */
+struct l_timespec64 {
+ l_time64_t tv_sec;
+ l_longlong tv_nsec;
+};
+
struct l_newstat {
l_ushort st_dev;
l_ushort __pad1;
diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c
index 1d7dcc869159..2f1430faf702 100644
--- a/sys/compat/linux/linux_time.c
+++ b/sys/compat/linux/linux_time.c
@@ -124,6 +124,30 @@ linux_to_native_timespec(struct timespec *ntp, struct l_timespec *ltp)
return (0);
}
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+int
+native_to_linux_timespec64(struct l_timespec64 *ltp64, struct timespec *ntp)
+{
+
+ ltp64->tv_sec = ntp->tv_sec;
+ ltp64->tv_nsec = ntp->tv_nsec;
+
+ return (0);
+}
+
+int
+linux_to_native_timespec64(struct timespec *ntp, struct l_timespec64 *ltp64)
+{
+
+ if (ltp64->tv_sec < 0 || ltp64->tv_nsec < 0 || ltp64->tv_nsec > 999999999)
+ return (EINVAL);
+ ntp->tv_sec = ltp64->tv_sec;
+ ntp->tv_nsec = ltp64->tv_nsec;
+
+ return (0);
+}
+#endif
+
int
native_to_linux_itimerspec(struct l_itimerspec *ltp, struct itimerspec *ntp)
{
diff --git a/sys/compat/linux/linux_timer.h b/sys/compat/linux/linux_timer.h
index 5344191742bb..6b5cf346049e 100644
--- a/sys/compat/linux/linux_timer.h
+++ b/sys/compat/linux/linux_timer.h
@@ -108,6 +108,12 @@ int native_to_linux_timespec(struct l_timespec *,
struct timespec *);
int linux_to_native_timespec(struct timespec *,
struct l_timespec *);
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+int native_to_linux_timespec64(struct l_timespec64 *,
+ struct timespec *);
+int linux_to_native_timespec64(struct timespec *,
+ struct l_timespec64 *);
+#endif
int linux_to_native_clockid(clockid_t *, clockid_t);
int native_to_linux_itimerspec(struct l_itimerspec *,
struct itimerspec *);
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 7a8de667e176..1bb76d8e41d0 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -71,6 +71,7 @@ typedef l_int l_pid_t;
typedef l_uint l_size_t;
typedef l_long l_suseconds_t;
typedef l_long l_time_t;
+typedef l_longlong l_time64_t;
typedef l_uint l_uid_t;
typedef l_ushort l_uid16_t;
typedef l_int l_timer_t;
@@ -142,6 +143,12 @@ struct l_timespec {
l_long tv_nsec;
};
+/* __kernel_timespec */
+struct l_timespec64 {
+ l_time64_t tv_sec;
+ l_longlong tv_nsec;
+};
+
struct l_newstat {
l_ushort st_dev;
l_ushort __pad1;