Hi наб,
On 11/28/21 19:17, наб wrote:
There are three files that govern userspace struct timespec on glibc:
1. bits/wordsize.h, defining:
(a) __WORDSIZE to 32 on ILP32 and 64 on LP64
(b) on x32: __SYSCALL_WORDSIZE to 64
2. bits/timesize.h, defining
(a) __TIMESIZE to __WORDSIZE, except on x32 where it's 64
3. bits/types/struct_timespec.h, declaring struct timespec as:
struct timespec
{
__time_t tv_sec; /* Seconds. */
#if __WORDSIZE == 64 \
|| (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
|| __TIMESIZE == 32
__syscall_slong_t tv_nsec; /* Nanoseconds. */
#else
# if __BYTE_ORDER == __BIG_ENDIAN
int: 32; /* Padding. */
long int tv_nsec; /* Nanoseconds. */
# else
long int tv_nsec; /* Nanoseconds. */
int: 32; /* Padding. */
# endif
#endif
};
this has two side-effects: struct timespec
(a) is always sizeof==time_t+8, and
(b) has tv_nsec as __syscall_slong_t
*and* !is_same<__syscall_slong_t, long>
if using ILP64 syscalls on an LP32 system, i.e. on x32.
I guess you meant LP64, not ILP64?
AFAIK, glibc doesn't support ILP64.
Other than that, the commit looks good to me.
But this would be a simpler commit if we only had one definition. Do
you agree in changing the whole patch set in that (IMO simpler) way?
Thanks,
Alex
This means, that the simplified
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
};
declaration is *invalid* for x32,
where struct timespec::tv_nsec is an int64_t (long long).
Transformation snippet:
sed -i -e '/Nanoseconds \[0/i#if !(__x86_64__ && __ILP32__ /* == x32 */)' -e '/Nanoseconds \[0/a#else\
long long tv_nsec;\
#endif' man2/clock_getres.2 man2/clock_nanosleep.2 man2/io_getevents.2 man2/nanosleep.2 man2/poll.2 man2/sched_rr_get_interval.2 man2/select.2 man2/sigwaitinfo.2 man2/timer_settime.2 man2/timerfd_create.2 man2/utimensat.2 man3/mq_receive.3 man3/mq_send.3 man3/pthread_tryjoin_np.3 man7/system_data_types.7
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
---
man2/clock_getres.2 | 4 ++++
man2/clock_nanosleep.2 | 4 ++++
man2/io_getevents.2 | 4 ++++
man2/nanosleep.2 | 4 ++++
man2/poll.2 | 4 ++++
man2/sched_rr_get_interval.2 | 4 ++++
man2/select.2 | 4 ++++
man2/sigwaitinfo.2 | 4 ++++
man2/timer_settime.2 | 4 ++++
man2/timerfd_create.2 | 4 ++++
man2/utimensat.2 | 4 ++++
man3/mq_receive.3 | 4 ++++
man3/mq_send.3 | 4 ++++
man3/pthread_tryjoin_np.3 | 4 ++++
man7/system_data_types.7 | 4 ++++
15 files changed, 60 insertions(+)
diff --git a/man2/clock_getres.2 b/man2/clock_getres.2
index f94b69d3c..0d9326b84 100644
--- a/man2/clock_getres.2
+++ b/man2/clock_getres.2
@@ -94,7 +94,11 @@ structures, as specified in
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/clock_nanosleep.2 b/man2/clock_nanosleep.2
index e6386e6a5..06ad6acf3 100644
--- a/man2/clock_nanosleep.2
+++ b/man2/clock_nanosleep.2
@@ -65,7 +65,11 @@ structures, defined as follows:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/io_getevents.2 b/man2/io_getevents.2
index 08738e413..020cb5882 100644
--- a/man2/io_getevents.2
+++ b/man2/io_getevents.2
@@ -47,7 +47,11 @@ and is specified as a relative timeout in a structure of the following form:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/nanosleep.2 b/man2/nanosleep.2
index 993007e92..81f5d93a5 100644
--- a/man2/nanosleep.2
+++ b/man2/nanosleep.2
@@ -85,7 +85,11 @@ It is defined as follows:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/poll.2 b/man2/poll.2
index a278efbcc..1bdd06ded 100644
--- a/man2/poll.2
+++ b/man2/poll.2
@@ -330,7 +330,11 @@ This argument is a pointer to a structure of the following form:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/sched_rr_get_interval.2 b/man2/sched_rr_get_interval.2
index 1f249572b..ee9067c20 100644
--- a/man2/sched_rr_get_interval.2
+++ b/man2/sched_rr_get_interval.2
@@ -55,7 +55,11 @@ structure has the following form:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/select.2 b/man2/select.2
index fd9a994eb..dad9e8937 100644
--- a/man2/select.2
+++ b/man2/select.2
@@ -359,7 +359,11 @@ has the following type:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man2/sigwaitinfo.2 b/man2/sigwaitinfo.2
index 226625e4e..e2dcb5eef 100644
--- a/man2/sigwaitinfo.2
+++ b/man2/sigwaitinfo.2
@@ -94,7 +94,11 @@ This argument is of the following type:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
}
.EE
.in
diff --git a/man2/timer_settime.2 b/man2/timer_settime.2
index 1c8d7fa17..a76fb9b10 100644
--- a/man2/timer_settime.2
+++ b/man2/timer_settime.2
@@ -67,7 +67,11 @@ structure is defined as follows:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
struct itimerspec {
diff --git a/man2/timerfd_create.2 b/man2/timerfd_create.2
index 832ec4b68..4bf8a3a4b 100644
--- a/man2/timerfd_create.2
+++ b/man2/timerfd_create.2
@@ -159,7 +159,11 @@ each of which is in turn a structure of type
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
struct itimerspec {
diff --git a/man2/utimensat.2 b/man2/utimensat.2
index 19fa8c677..c806c51a5 100644
--- a/man2/utimensat.2
+++ b/man2/utimensat.2
@@ -94,7 +94,11 @@ This information is conveyed in a structure of the following form:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man3/mq_receive.3 b/man3/mq_receive.3
index 4dac43643..deda2d452 100644
--- a/man3/mq_receive.3
+++ b/man3/mq_receive.3
@@ -98,7 +98,11 @@ specified in the following structure:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man3/mq_send.3 b/man3/mq_send.3
index 6b3fbe98a..c0e67df34 100644
--- a/man3/mq_send.3
+++ b/man3/mq_send.3
@@ -107,7 +107,11 @@ specified in the following structure:
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man3/pthread_tryjoin_np.3 b/man3/pthread_tryjoin_np.3
index 10b498c80..d68c2bbba 100644
--- a/man3/pthread_tryjoin_np.3
+++ b/man3/pthread_tryjoin_np.3
@@ -80,7 +80,11 @@ specifying an absolute time measured since the Epoch (see
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.in
diff --git a/man7/system_data_types.7 b/man7/system_data_types.7
index 1e6a3f74c..80679b180 100644
--- a/man7/system_data_types.7
+++ b/man7/system_data_types.7
@@ -1544,7 +1544,11 @@ or
.EX
struct timespec {
time_t tv_sec; /* Seconds */
+#if !(__x86_64__ && __ILP32__ /* == x32 */)
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
+#else
+ long long tv_nsec;
+#endif
};
.EE
.PP
--
Alejandro Colomar
Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/