1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
Description: tolerate different sizes for suseconds_t and timeval.tv_usec
Bug-Debian: https://bugs.debian.org/1067223
Forwarded: https://sourceware.org/bugzilla/show_bug.cgi?id=31510
Author: Nicolas Boulenguez <nicolas@debian.org>
--- a/c-posix.c
+++ b/c-posix.c
@@ -940,19 +940,20 @@
GT2A(c_cc, cc_t_array, cc_t, NCCS)
GT3
-#ifdef HAVE_suseconds_t
-#else
+/* The type of the tv_usec field may differ from suseconds_t, */
+/* for example on ARM 32 bits with GNU libc and _TIME_BITS=64. */
#ifdef HAVE_struct_timeval
struct timeval struct_timeval_temp;
+typedef __typeof__ (struct_timeval_temp.tv_usec) timeval_tv_usec_t;
+#ifndef HAVE_suseconds_t
typedef __typeof__ (struct_timeval_temp.tv_usec) suseconds_t;
-#else
-typedef int suseconds_t;
#endif
-#endif
-
-#ifdef HAVE_struct_timeval
GT1(timeval, 1)
#else
+#ifndef HAVE_suseconds_t
+typedef int suseconds_t;
+#endif
+typedef suseconds_t timeval_tv_usec_t
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
@@ -960,12 +961,13 @@
GT1(timeval, 0)
#endif
GT2(tv_sec, time_t)
- GT2(tv_usec, suseconds_t)
+ GT2(tv_usec, timeval_tv_usec_t)
GT3
-struct timeval struct_timeval_dummy;
+void g_timeval_tv_usec_t()
+ {gsitp("timeval_tv_usec_t", sizeof(timeval_tv_usec_t));}
void g_suseconds_t()
- {gsitp("suseconds_t", sizeof(struct_timeval_dummy.tv_usec));}
+ {gsitp("suseconds_t", sizeof(suseconds_t));}
#ifdef HAVE_struct_iovec
GT1(iovec, 1)
@@ -980,19 +982,27 @@
GT2(iov_len, size_t)
GT3
+/* The type of the tv_nsec field may differ from long, */
+/* for example on the x32 architecture. */
#ifdef HAVE_struct_timespec
+struct timespec struct_timespec_temp;
+typedef __typeof__ (struct_timespec_temp.tv_nsec) timespec_tv_nsec_t;
GT1(timespec, 1)
#else
struct timespec {
time_t tv_sec;
long tv_nsec;
};
+typedef long timespec_tv_nsec_t;
GT1(timespec, 0)
#endif
GT2(tv_sec,time_t)
- GT2(tv_nsec,long)
+ GT2(tv_nsec,timespec_tv_nsec_t)
GT3
+void g_timespec_tv_nsec_t()
+ {gsitp("timespec_tv_nsec_t", sizeof(timespec_tv_nsec_t));}
+
#ifdef HAVE_struct_itimerspec
GT1(itimerspec, 1)
#else
@@ -5954,6 +5964,8 @@
g_uid_t();
g_mode_t();
g_suseconds_t();
+ g_timeval_tv_usec_t();
+ g_timespec_tv_nsec_t();
g_ssize_t();
g_DIR();
g_ino_t();
--- a/libsrc/posix-implementation.gpb
+++ b/libsrc/posix-implementation.gpb
@@ -399,7 +399,7 @@
F := F + 1.0;
end if;
return struct_timespec'(tv_sec => S,
- tv_nsec => long (Long_Long_Integer (F * NS_per_S)));
+ tv_nsec => timespec_tv_nsec_t (Long_Long_Integer (F * NS_per_S)));
end To_Struct_Timespec;
function To_Struct_Timespec (T : Timespec) return struct_timespec is
@@ -452,7 +452,7 @@
F := F + 1.0;
end if;
return struct_timeval'(tv_sec => S,
- tv_usec => suseconds_t (Long_Long_Integer (F * MS_per_S)));
+ tv_usec => timeval_tv_usec_t (Long_Long_Integer (F * MS_per_S)));
end To_Struct_Timeval;
end POSIX.Implementation;
--- a/libsrc/threads/posix-signals.adb
+++ b/libsrc/threads/posix-signals.adb
@@ -1057,7 +1057,7 @@
Check_Awaitable (Set);
Split (Timeout, S, NS);
c_timeout.tv_sec := time_t (S);
- c_timeout.tv_nsec := long (NS);
+ c_timeout.tv_nsec := timespec_tv_nsec_t (NS);
Check (sigtimedwait
(Set.C'Unchecked_Access,
Info'Unchecked_Access,
|