* [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file
@ 2020-02-14 9:17 Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-14 9:17 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta,
Lukasz Majewski
The struct __timespec64's definition has been moved from ./include/time.h to
./include/bits/types/struct___timespec64.h.
This change would prevent from polluting other glibc namespaces (when
headers are modified to support 64 bit time on architectures with
__WORDSIZE==32).
Now it is possible to just include definition of this particular structure
when needed.
---
Changes for v2:
- New patch - as suggested by Andreas Schwab
---
include/bits/types/struct___timespec64.h | 26 ++++++++++++++++++++++++
include/time.h | 24 +---------------------
2 files changed, 27 insertions(+), 23 deletions(-)
create mode 100644 include/bits/types/struct___timespec64.h
diff --git a/include/bits/types/struct___timespec64.h b/include/bits/types/struct___timespec64.h
new file mode 100644
index 0000000000..0c60f144c8
--- /dev/null
+++ b/include/bits/types/struct___timespec64.h
@@ -0,0 +1,26 @@
+#ifndef _TIMESPEC64_H
+#define _TIMESPEC64_H 1
+# if __TIMESIZE == 64
+# define __timespec64 timespec
+# else
+# include <endian.h>
+/* The glibc Y2038-proof struct __timespec64 structure for a time value.
+ To keep things Posix-ish, we keep the nanoseconds field a 32-bit
+ signed long, but since the Linux field is a 64-bit signed int, we
+ pad our tv_nsec with a 32-bit unnamed bit-field padding.
+
+ As a general rule the Linux kernel is ignoring upper 32 bits of
+ tv_nsec field. */
+struct __timespec64
+{
+ __time64_t tv_sec; /* Seconds */
+# if BYTE_ORDER == BIG_ENDIAN
+ __int32_t :32; /* Padding */
+ __int32_t tv_nsec; /* Nanoseconds */
+# else
+ __int32_t tv_nsec; /* Nanoseconds */
+ __int32_t :32; /* Padding */
+# endif
+};
+# endif
+#endif
diff --git a/include/time.h b/include/time.h
index bd0b74dbcc..5931f4854c 100644
--- a/include/time.h
+++ b/include/time.h
@@ -3,11 +3,11 @@
#ifndef _ISOMAC
# include <bits/types/struct_timeval.h>
+# include <bits/types/struct___timespec64.h>
# include <bits/types/locale_t.h>
# include <stdbool.h>
# include <time/mktime-internal.h>
# include <sys/time.h>
-# include <endian.h>
# include <time-clockid.h>
# include <sys/time.h>
@@ -61,28 +61,6 @@ extern void __tzset_parse_tz (const char *tz) attribute_hidden;
extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
__THROW attribute_hidden;
-#if __TIMESIZE == 64
-# define __timespec64 timespec
-#else
-/* The glibc Y2038-proof struct __timespec64 structure for a time value.
- To keep things Posix-ish, we keep the nanoseconds field a 32-bit
- signed long, but since the Linux field is a 64-bit signed int, we
- pad our tv_nsec with a 32-bit unnamed bit-field padding.
-
- As a general rule the Linux kernel is ignoring upper 32 bits of
- tv_nsec field. */
-struct __timespec64
-{
- __time64_t tv_sec; /* Seconds */
-# if BYTE_ORDER == BIG_ENDIAN
- __int32_t :32; /* Padding */
- __int32_t tv_nsec; /* Nanoseconds */
-# else
- __int32_t tv_nsec; /* Nanoseconds */
- __int32_t :32; /* Padding */
-# endif
-};
-#endif
#if __TIMESIZE == 64
# define __itimerspec64 itimerspec
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation
2020-02-14 9:17 [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
@ 2020-02-14 9:17 ` Lukasz Majewski
2020-02-24 9:15 ` Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation Lukasz Majewski
2020-02-24 9:17 ` [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2 siblings, 1 reply; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-14 9:17 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta,
Lukasz Majewski
This patch provides new __mq_timedsend_time64 explicit 64 bit function for
sending messages with absolute timeout.
Moreover, a 32 bit version - __mq_timedsend has been refactored to internally
use __mq_timedsend_time64.
The __mq_timedsend is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct
__timespec64 from struct timespec.
The new __mq_timedsend_time64 syscall available from Linux 5.1+ has been used,
when applicable.
As this wrapper function is also used internally in the glibc, to e.g. provide
mq_send implementation, an explicit check for abs_timeout being NULL has been
added due to conversions between struct timespec and struct __timespec64.
Before this change the Linux kernel handled this NULL pointer.
Build tests:
- ./src/scripts/build-many-glibcs.py glibcs
Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
https://github.com/lmajewski/meta-y2038 and run tests:
https://github.com/lmajewski/y2038-tests/commits/master
Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with mq_timedsend_time64) and glibc built with v5.1 as a
minimal kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
mq_timedsend_time64 syscall.
- Linux v4.19 (no mq_timedsend_time64 support) with default minimal kernel
version for contemporary glibc (3.2.0)
This kernel doesn't support mq_timedsend_time64 syscall, so the fallback to
mq_timedsend is tested.
Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).
---
Changes for v2:
- Fix indentation for __mq_timedsend
- #include <bits/types/struct___timespec64.h> instead of <include/time.h>
---
include/mqueue.h | 9 +++++
sysdeps/unix/sysv/linux/mq_timedsend.c | 49 ++++++++++++++++++++++++--
2 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/include/mqueue.h b/include/mqueue.h
index 3c66f1711e..81d30dbdf7 100644
--- a/include/mqueue.h
+++ b/include/mqueue.h
@@ -10,4 +10,13 @@ extern __typeof (mq_timedreceive) __mq_timedreceive __nonnull ((2, 5));
hidden_proto (__mq_timedreceive)
hidden_proto (mq_setattr)
# endif
+#if __TIMESIZE == 64
+# define __mq_timedsend_time64 __mq_timedsend
+#else
+# include <bits/types/struct___timespec64.h>
+extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
+ size_t msg_len, unsigned int msg_prio,
+ const struct __timespec64 *abs_timeout);
+librt_hidden_proto (__mq_timedsend_time64)
+#endif
#endif
diff --git a/sysdeps/unix/sysv/linux/mq_timedsend.c b/sysdeps/unix/sysv/linux/mq_timedsend.c
index 888ec6744a..0d5a860c48 100644
--- a/sysdeps/unix/sysv/linux/mq_timedsend.c
+++ b/sysdeps/unix/sysv/linux/mq_timedsend.c
@@ -22,12 +22,55 @@
/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
on full message queue if ABS_TIMEOUT expires. */
int
-__mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
- unsigned int msg_prio, const struct timespec *abs_timeout)
+__mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+ unsigned int msg_prio,
+ const struct __timespec64 *abs_timeout)
{
+#ifdef __ASSUME_TIME64_SYSCALLS
+# ifndef __NR_mq_timedsend_time64
+# define __NR_mq_timedsend_time64 __NR_mq_timedsend
+# endif
+ return SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr, msg_len, msg_prio,
+ abs_timeout);
+#else
+ int ret = SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr, msg_len,
+ msg_prio, abs_timeout);
+ if (ret == 0 || errno != ENOSYS)
+ return ret;
+
+ struct timespec ts32;
+ if (abs_timeout)
+ {
+ if (! in_time_t_range (abs_timeout->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ ts32 = valid_timespec64_to_timespec (*abs_timeout);
+ }
+
return SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len, msg_prio,
- abs_timeout);
+ abs_timeout ? &ts32 : NULL);
+#endif
+}
+
+#if __TIMESIZE != 64
+librt_hidden_def (__mq_timedsend_time64)
+
+int
+__mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+ unsigned int msg_prio, const struct timespec *abs_timeout)
+{
+ struct __timespec64 ts64;
+ if (abs_timeout)
+ ts64 = valid_timespec_to_timespec64 (*abs_timeout);
+
+ return __mq_timedsend_time64 (mqdes, msg_ptr, msg_len, msg_prio,
+ abs_timeout ? &ts64 : NULL);
}
+#endif
+
hidden_def (__mq_timedsend)
weak_alias (__mq_timedsend, mq_timedsend)
hidden_weak (mq_timedsend)
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation
2020-02-14 9:17 [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
@ 2020-02-14 9:17 ` Lukasz Majewski
2020-02-24 9:16 ` Lukasz Majewski
2020-02-24 9:17 ` [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2 siblings, 1 reply; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-14 9:17 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta,
Lukasz Majewski
This patch provides new __mq_timedreceive_time64 explicit 64 bit function for
receiving messages with absolute timeout.
Moreover, a 32 bit version - __mq_timedreceive has been refactored to
internally use __mq_timedreceive_time64.
The __mq_timedreceive is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct
__timespec64 from struct timespec.
The new mq_timedsend_time64 syscall available from Linux 5.1+ has been used,
when applicable.
As this wrapper function is also used internally in the glibc, to e.g. provide
mq_receive implementation, an explicit check for abs_timeout being NULL has been
added due to conversions between struct timespec and struct __timespec64.
Before this change the Linux kernel handled this NULL pointer.
Build tests:
- ./src/scripts/build-many-glibcs.py glibcs
Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
https://github.com/lmajewski/meta-y2038 and run tests:
https://github.com/lmajewski/y2038-tests/commits/master
Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with mq_timedreceive_time64) and glibc built with v5.1 as
minimal kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
mq_timedreceive_time64 syscall.
- Linux v4.19 (no mq_timedreceive_time64 support) with default minimal kernel
version for contemporary glibc (3.2.0)
This kernel doesn't support mq_timedreceive_time64 syscall, so the fallback to
mq_timedreceive is tested.
Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).
---
Changes for v2:
- Fix indentation in __mq_timedreceive function
---
include/mqueue.h | 6 +++
sysdeps/unix/sysv/linux/mq_timedreceive.c | 51 +++++++++++++++++++++--
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/include/mqueue.h b/include/mqueue.h
index 81d30dbdf7..1ef5d3e3af 100644
--- a/include/mqueue.h
+++ b/include/mqueue.h
@@ -12,11 +12,17 @@ hidden_proto (mq_setattr)
# endif
#if __TIMESIZE == 64
# define __mq_timedsend_time64 __mq_timedsend
+# define __mq_timedreceive_time64 __mq_timedreceive
#else
# include <bits/types/struct___timespec64.h>
extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
size_t msg_len, unsigned int msg_prio,
const struct __timespec64 *abs_timeout);
librt_hidden_proto (__mq_timedsend_time64)
+extern ssize_t __mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr,
+ size_t msg_len,
+ unsigned int *__restrict msg_prio,
+ const struct __timespec64 *__restrict abs_timeout);
+librt_hidden_proto (__mq_timedreceive_time64)
#endif
#endif
diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c b/sysdeps/unix/sysv/linux/mq_timedreceive.c
index 73a1d63e41..6eb10595ac 100644
--- a/sysdeps/unix/sysv/linux/mq_timedreceive.c
+++ b/sysdeps/unix/sysv/linux/mq_timedreceive.c
@@ -22,13 +22,56 @@
/* Receive the oldest from highest priority messages in message queue
MQDES, stop waiting if ABS_TIMEOUT expires. */
ssize_t
-__mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len,
- unsigned int *__restrict msg_prio,
- const struct timespec *__restrict abs_timeout)
+__mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len,
+ unsigned int *__restrict msg_prio,
+ const struct __timespec64 *__restrict abs_timeout)
{
+#ifdef __ASSUME_TIME64_SYSCALLS
+# ifndef __NR_mq_timedreceive_time64
+# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
+# endif
+ return SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr, msg_len,
+ msg_prio, abs_timeout);
+#else
+ int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr, msg_len,
+ msg_prio, abs_timeout);
+ if (ret == 0 || errno != ENOSYS)
+ return ret;
+
+ struct timespec ts32;
+ if (abs_timeout)
+ {
+ if (! in_time_t_range (abs_timeout->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ ts32 = valid_timespec64_to_timespec (*abs_timeout);
+ }
+
return SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len, msg_prio,
- abs_timeout);
+ abs_timeout ? &ts32 : NULL);
+#endif
+}
+
+#if __TIMESIZE != 64
+librt_hidden_def (__mq_timedreceive_time64)
+
+ssize_t
+__mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len,
+ unsigned int *__restrict msg_prio,
+ const struct timespec *__restrict abs_timeout)
+{
+ struct __timespec64 ts64;
+ if (abs_timeout)
+ ts64 = valid_timespec_to_timespec64 (*abs_timeout);
+
+ return __mq_timedreceive_time64 (mqdes, msg_ptr, msg_len, msg_prio,
+ abs_timeout ? &ts64 : NULL);
}
+#endif
+
hidden_def (__mq_timedreceive)
weak_alias (__mq_timedreceive, mq_timedreceive)
hidden_weak (mq_timedreceive)
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation
2020-02-14 9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
@ 2020-02-24 9:15 ` Lukasz Majewski
0 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-24 9:15 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta
[-- Attachment #1: Type: text/plain, Size: 5639 bytes --]
Dear All,
> This patch provides new __mq_timedsend_time64 explicit 64 bit
> function for sending messages with absolute timeout.
> Moreover, a 32 bit version - __mq_timedsend has been refactored to
> internally use __mq_timedsend_time64.
>
> The __mq_timedsend is now supposed to be used on systems still
> supporting 32 bit time (__TIMESIZE != 64) - hence the necessary
> conversion to 64 bit struct __timespec64 from struct timespec.
>
> The new __mq_timedsend_time64 syscall available from Linux 5.1+ has
> been used, when applicable.
>
> As this wrapper function is also used internally in the glibc, to
> e.g. provide mq_send implementation, an explicit check for
> abs_timeout being NULL has been added due to conversions between
> struct timespec and struct __timespec64. Before this change the Linux
> kernel handled this NULL pointer.
>
> Build tests:
> - ./src/scripts/build-many-glibcs.py glibcs
>
> Run-time tests:
> - Run specific tests on ARM/x86 32bit systems (qemu):
> https://github.com/lmajewski/meta-y2038 and run tests:
> https://github.com/lmajewski/y2038-tests/commits/master
>
> Linux kernel, headers and minimal kernel version for glibc build test
> matrix:
> - Linux v5.1 (with mq_timedsend_time64) and glibc built with v5.1 as a
> minimal kernel version (--enable-kernel="5.1.0")
> The __ASSUME_TIME64_SYSCALLS flag defined.
>
> - Linux v5.1 and default minimal kernel version
> The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
> mq_timedsend_time64 syscall.
>
> - Linux v4.19 (no mq_timedsend_time64 support) with default minimal
> kernel version for contemporary glibc (3.2.0)
> This kernel doesn't support mq_timedsend_time64 syscall, so the
> fallback to mq_timedsend is tested.
>
> Above tests were performed with Y2038 redirection applied as well as
> without (so the __TIMESIZE != 64 execution path is checked as well).
>
> ---
> Changes for v2:
> - Fix indentation for __mq_timedsend
> - #include <bits/types/struct___timespec64.h> instead of
> <include/time.h>
Gentle ping on this patch.
---
> include/mqueue.h | 9 +++++
> sysdeps/unix/sysv/linux/mq_timedsend.c | 49
> ++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 3
> deletions(-)
>
> diff --git a/include/mqueue.h b/include/mqueue.h
> index 3c66f1711e..81d30dbdf7 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -10,4 +10,13 @@ extern __typeof (mq_timedreceive)
> __mq_timedreceive __nonnull ((2, 5)); hidden_proto (__mq_timedreceive)
> hidden_proto (mq_setattr)
> # endif
> +#if __TIMESIZE == 64
> +# define __mq_timedsend_time64 __mq_timedsend
> +#else
> +# include <bits/types/struct___timespec64.h>
> +extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
> + size_t msg_len, unsigned int
> msg_prio,
> + const struct __timespec64
> *abs_timeout); +librt_hidden_proto (__mq_timedsend_time64)
> +#endif
> #endif
> diff --git a/sysdeps/unix/sysv/linux/mq_timedsend.c
> b/sysdeps/unix/sysv/linux/mq_timedsend.c index 888ec6744a..0d5a860c48
> 100644 --- a/sysdeps/unix/sysv/linux/mq_timedsend.c
> +++ b/sysdeps/unix/sysv/linux/mq_timedsend.c
> @@ -22,12 +22,55 @@
> /* Add message pointed by MSG_PTR to message queue MQDES, stop
> blocking on full message queue if ABS_TIMEOUT expires. */
> int
> -__mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> - unsigned int msg_prio, const struct timespec
> *abs_timeout) +__mq_timedsend_time64 (mqd_t mqdes, const char
> *msg_ptr, size_t msg_len,
> + unsigned int msg_prio,
> + const struct __timespec64 *abs_timeout)
> {
> +#ifdef __ASSUME_TIME64_SYSCALLS
> +# ifndef __NR_mq_timedsend_time64
> +# define __NR_mq_timedsend_time64 __NR_mq_timedsend
> +# endif
> + return SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr,
> msg_len, msg_prio,
> + abs_timeout);
> +#else
> + int ret = SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr,
> msg_len,
> + msg_prio, abs_timeout);
> + if (ret == 0 || errno != ENOSYS)
> + return ret;
> +
> + struct timespec ts32;
> + if (abs_timeout)
> + {
> + if (! in_time_t_range (abs_timeout->tv_sec))
> + {
> + __set_errno (EOVERFLOW);
> + return -1;
> + }
> +
> + ts32 = valid_timespec64_to_timespec (*abs_timeout);
> + }
> +
> return SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len,
> msg_prio,
> - abs_timeout);
> + abs_timeout ? &ts32 : NULL);
> +#endif
> +}
> +
> +#if __TIMESIZE != 64
> +librt_hidden_def (__mq_timedsend_time64)
> +
> +int
> +__mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> + unsigned int msg_prio, const struct timespec
> *abs_timeout) +{
> + struct __timespec64 ts64;
> + if (abs_timeout)
> + ts64 = valid_timespec_to_timespec64 (*abs_timeout);
> +
> + return __mq_timedsend_time64 (mqdes, msg_ptr, msg_len, msg_prio,
> + abs_timeout ? &ts64 : NULL);
> }
> +#endif
> +
> hidden_def (__mq_timedsend)
> weak_alias (__mq_timedsend, mq_timedsend)
> hidden_weak (mq_timedsend)
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation
2020-02-14 9:17 ` [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation Lukasz Majewski
@ 2020-02-24 9:16 ` Lukasz Majewski
0 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-24 9:16 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta
[-- Attachment #1: Type: text/plain, Size: 6065 bytes --]
Dear All,
> This patch provides new __mq_timedreceive_time64 explicit 64 bit
> function for receiving messages with absolute timeout.
> Moreover, a 32 bit version - __mq_timedreceive has been refactored to
> internally use __mq_timedreceive_time64.
>
> The __mq_timedreceive is now supposed to be used on systems still
> supporting 32 bit time (__TIMESIZE != 64) - hence the necessary
> conversion to 64 bit struct __timespec64 from struct timespec.
>
> The new mq_timedsend_time64 syscall available from Linux 5.1+ has
> been used, when applicable.
>
> As this wrapper function is also used internally in the glibc, to
> e.g. provide mq_receive implementation, an explicit check for
> abs_timeout being NULL has been added due to conversions between
> struct timespec and struct __timespec64. Before this change the Linux
> kernel handled this NULL pointer.
>
> Build tests:
> - ./src/scripts/build-many-glibcs.py glibcs
>
> Run-time tests:
> - Run specific tests on ARM/x86 32bit systems (qemu):
> https://github.com/lmajewski/meta-y2038 and run tests:
> https://github.com/lmajewski/y2038-tests/commits/master
>
> Linux kernel, headers and minimal kernel version for glibc build test
> matrix:
> - Linux v5.1 (with mq_timedreceive_time64) and glibc built with v5.1
> as minimal kernel version (--enable-kernel="5.1.0")
> The __ASSUME_TIME64_SYSCALLS flag defined.
>
> - Linux v5.1 and default minimal kernel version
> The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
> mq_timedreceive_time64 syscall.
>
> - Linux v4.19 (no mq_timedreceive_time64 support) with default
> minimal kernel version for contemporary glibc (3.2.0)
> This kernel doesn't support mq_timedreceive_time64 syscall, so the
> fallback to mq_timedreceive is tested.
>
> Above tests were performed with Y2038 redirection applied as well as
> without (so the __TIMESIZE != 64 execution path is checked as well).
>
> ---
> Changes for v2:
> - Fix indentation in __mq_timedreceive function
Gentle ping on this patch. Are there any more comments?
> ---
> include/mqueue.h | 6 +++
> sysdeps/unix/sysv/linux/mq_timedreceive.c | 51
> +++++++++++++++++++++-- 2 files changed, 53 insertions(+), 4
> deletions(-)
>
> diff --git a/include/mqueue.h b/include/mqueue.h
> index 81d30dbdf7..1ef5d3e3af 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -12,11 +12,17 @@ hidden_proto (mq_setattr)
> # endif
> #if __TIMESIZE == 64
> # define __mq_timedsend_time64 __mq_timedsend
> +# define __mq_timedreceive_time64 __mq_timedreceive
> #else
> # include <bits/types/struct___timespec64.h>
> extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr,
> size_t msg_len, unsigned int
> msg_prio, const struct __timespec64 *abs_timeout);
> librt_hidden_proto (__mq_timedsend_time64)
> +extern ssize_t __mq_timedreceive_time64 (mqd_t mqdes, char
> *__restrict msg_ptr,
> + size_t msg_len,
> + unsigned int *__restrict msg_prio,
> + const struct __timespec64 *__restrict
> abs_timeout); +librt_hidden_proto (__mq_timedreceive_time64)
> #endif
> #endif
> diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c
> b/sysdeps/unix/sysv/linux/mq_timedreceive.c index
> 73a1d63e41..6eb10595ac 100644 ---
> a/sysdeps/unix/sysv/linux/mq_timedreceive.c +++
> b/sysdeps/unix/sysv/linux/mq_timedreceive.c @@ -22,13 +22,56 @@
> /* Receive the oldest from highest priority messages in message queue
> MQDES, stop waiting if ABS_TIMEOUT expires. */
> ssize_t
> -__mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t
> msg_len,
> - unsigned int *__restrict msg_prio,
> - const struct timespec *__restrict abs_timeout)
> +__mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr,
> size_t msg_len,
> + unsigned int *__restrict msg_prio,
> + const struct __timespec64 *__restrict
> abs_timeout) {
> +#ifdef __ASSUME_TIME64_SYSCALLS
> +# ifndef __NR_mq_timedreceive_time64
> +# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive
> +# endif
> + return SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
> msg_len,
> + msg_prio, abs_timeout);
> +#else
> + int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr,
> msg_len,
> + msg_prio, abs_timeout);
> + if (ret == 0 || errno != ENOSYS)
> + return ret;
> +
> + struct timespec ts32;
> + if (abs_timeout)
> + {
> + if (! in_time_t_range (abs_timeout->tv_sec))
> + {
> + __set_errno (EOVERFLOW);
> + return -1;
> + }
> +
> + ts32 = valid_timespec64_to_timespec (*abs_timeout);
> + }
> +
> return SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len,
> msg_prio,
> - abs_timeout);
> + abs_timeout ? &ts32 : NULL);
> +#endif
> +}
> +
> +#if __TIMESIZE != 64
> +librt_hidden_def (__mq_timedreceive_time64)
> +
> +ssize_t
> +__mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t
> msg_len,
> + unsigned int *__restrict msg_prio,
> + const struct timespec *__restrict abs_timeout)
> +{
> + struct __timespec64 ts64;
> + if (abs_timeout)
> + ts64 = valid_timespec_to_timespec64 (*abs_timeout);
> +
> + return __mq_timedreceive_time64 (mqdes, msg_ptr, msg_len, msg_prio,
> + abs_timeout ? &ts64 : NULL);
> }
> +#endif
> +
> hidden_def (__mq_timedreceive)
> weak_alias (__mq_timedreceive, mq_timedreceive)
> hidden_weak (mq_timedreceive)
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file
2020-02-14 9:17 [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation Lukasz Majewski
@ 2020-02-24 9:17 ` Lukasz Majewski
2020-03-04 10:12 ` Andreas Schwab
2 siblings, 1 reply; 8+ messages in thread
From: Lukasz Majewski @ 2020-02-24 9:17 UTC (permalink / raw)
To: Joseph Myers, Paul Eggert, Adhemerval Zanella
Cc: Alistair Francis, Alistair Francis, GNU C Library,
Siddhesh Poyarekar, Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Andreas Schwab, Vineet Gupta
[-- Attachment #1: Type: text/plain, Size: 3807 bytes --]
Dear All,
> The struct __timespec64's definition has been moved from
> ./include/time.h to ./include/bits/types/struct___timespec64.h.
>
> This change would prevent from polluting other glibc namespaces (when
> headers are modified to support 64 bit time on architectures with
> __WORDSIZE==32).
>
> Now it is possible to just include definition of this particular
> structure when needed.
>
> ---
> Changes for v2:
> - New patch - as suggested by Andreas Schwab
Gentle ping on this patch. Are there any more comments?
> ---
> include/bits/types/struct___timespec64.h | 26
> ++++++++++++++++++++++++ include/time.h |
> 24 +--------------------- 2 files changed, 27 insertions(+), 23
> deletions(-) create mode 100644
> include/bits/types/struct___timespec64.h
>
> diff --git a/include/bits/types/struct___timespec64.h
> b/include/bits/types/struct___timespec64.h new file mode 100644
> index 0000000000..0c60f144c8
> --- /dev/null
> +++ b/include/bits/types/struct___timespec64.h
> @@ -0,0 +1,26 @@
> +#ifndef _TIMESPEC64_H
> +#define _TIMESPEC64_H 1
> +# if __TIMESIZE == 64
> +# define __timespec64 timespec
> +# else
> +# include <endian.h>
> +/* The glibc Y2038-proof struct __timespec64 structure for a time
> value.
> + To keep things Posix-ish, we keep the nanoseconds field a 32-bit
> + signed long, but since the Linux field is a 64-bit signed int, we
> + pad our tv_nsec with a 32-bit unnamed bit-field padding.
> +
> + As a general rule the Linux kernel is ignoring upper 32 bits of
> + tv_nsec field. */
> +struct __timespec64
> +{
> + __time64_t tv_sec; /* Seconds */
> +# if BYTE_ORDER == BIG_ENDIAN
> + __int32_t :32; /* Padding */
> + __int32_t tv_nsec; /* Nanoseconds */
> +# else
> + __int32_t tv_nsec; /* Nanoseconds */
> + __int32_t :32; /* Padding */
> +# endif
> +};
> +# endif
> +#endif
> diff --git a/include/time.h b/include/time.h
> index bd0b74dbcc..5931f4854c 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -3,11 +3,11 @@
>
> #ifndef _ISOMAC
> # include <bits/types/struct_timeval.h>
> +# include <bits/types/struct___timespec64.h>
> # include <bits/types/locale_t.h>
> # include <stdbool.h>
> # include <time/mktime-internal.h>
> # include <sys/time.h>
> -# include <endian.h>
> # include <time-clockid.h>
> # include <sys/time.h>
>
> @@ -61,28 +61,6 @@ extern void __tzset_parse_tz (const char *tz)
> attribute_hidden; extern void __tz_compute (__time64_t timer, struct
> tm *tm, int use_localtime) __THROW attribute_hidden;
>
> -#if __TIMESIZE == 64
> -# define __timespec64 timespec
> -#else
> -/* The glibc Y2038-proof struct __timespec64 structure for a time
> value.
> - To keep things Posix-ish, we keep the nanoseconds field a 32-bit
> - signed long, but since the Linux field is a 64-bit signed int, we
> - pad our tv_nsec with a 32-bit unnamed bit-field padding.
> -
> - As a general rule the Linux kernel is ignoring upper 32 bits of
> - tv_nsec field. */
> -struct __timespec64
> -{
> - __time64_t tv_sec; /* Seconds */
> -# if BYTE_ORDER == BIG_ENDIAN
> - __int32_t :32; /* Padding */
> - __int32_t tv_nsec; /* Nanoseconds */
> -# else
> - __int32_t tv_nsec; /* Nanoseconds */
> - __int32_t :32; /* Padding */
> -# endif
> -};
> -#endif
>
> #if __TIMESIZE == 64
> # define __itimerspec64 itimerspec
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file
2020-02-24 9:17 ` [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
@ 2020-03-04 10:12 ` Andreas Schwab
2020-03-04 11:07 ` Lukasz Majewski
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2020-03-04 10:12 UTC (permalink / raw)
To: Lukasz Majewski
Cc: Joseph Myers, Paul Eggert, Adhemerval Zanella, Alistair Francis,
Alistair Francis, GNU C Library, Siddhesh Poyarekar,
Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Vineet Gupta
Could you please rebase? The patch doesn't apply.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file
2020-03-04 10:12 ` Andreas Schwab
@ 2020-03-04 11:07 ` Lukasz Majewski
0 siblings, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2020-03-04 11:07 UTC (permalink / raw)
To: Andreas Schwab
Cc: Joseph Myers, Paul Eggert, Adhemerval Zanella, Alistair Francis,
Alistair Francis, GNU C Library, Siddhesh Poyarekar,
Florian Weimer, Florian Weimer, Zack Weinberg,
Carlos O'Donell, Vineet Gupta
[-- Attachment #1: Type: text/plain, Size: 453 bytes --]
Hi Andreas,
> Could you please rebase? The patch doesn't apply.
>
No problem. I'm just now running build-many-glibcs script and post
patches after it finish.
> Andreas.
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-04 11:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 9:17 [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 2/3] y2038: linux: Provide __mq_timedsend_time64 implementation Lukasz Majewski
2020-02-24 9:15 ` Lukasz Majewski
2020-02-14 9:17 ` [PATCH v2 3/3] y2038: linux: Provide __mq_timedreceive_time64 implementation Lukasz Majewski
2020-02-24 9:16 ` Lukasz Majewski
2020-02-24 9:17 ` [PATCH v2 1/3] y2038: include: Move struct __timespec64 definition to a separate file Lukasz Majewski
2020-03-04 10:12 ` Andreas Schwab
2020-03-04 11:07 ` Lukasz Majewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).