| 1 |
Fix cl_times on x32 |
| 2 |
|
| 3 |
On x32, sizeof(long) is 4, and sizeof(clock_t) is 8. cl_times as logic to |
| 4 |
reject that case. We fix this by setting the return type of the function to |
| 5 |
long long instead on x32. |
| 6 |
|
| 7 |
--- a/include/clplumbing/longclock.h |
| 8 |
+++ b/include/clplumbing/longclock.h |
| 9 |
@@ -79,7 +79,11 @@ |
| 10 |
* |
| 11 |
* extern const longclock_t zero_longclock; |
| 12 |
*/ |
| 13 |
+#if __ILP32__ && __x86_64__ |
| 14 |
+extern unsigned long long cl_times(void); |
| 15 |
+#else |
| 16 |
extern unsigned long cl_times(void); |
| 17 |
+#endif |
| 18 |
|
| 19 |
#ifdef CLOCK_T_IS_LONG_ENOUGH |
| 20 |
# ifndef HAVE_LONGCLOCK_ARITHMETIC |
| 21 |
--- a/lib/clplumbing/longclock.c |
| 22 |
+++ b/lib/clplumbing/longclock.c |
| 23 |
@@ -68,7 +68,11 @@ hz_longclock(void) |
| 24 |
# define TIMES_PARAM &dummy_longclock_tms_struct |
| 25 |
#endif |
| 26 |
|
| 27 |
+#if __ILP32__ && __x86_64__ |
| 28 |
+unsigned long long |
| 29 |
+#else |
| 30 |
unsigned long |
| 31 |
+#endif |
| 32 |
cl_times(void) /* Make times(2) behave rationally on Linux */ |
| 33 |
{ |
| 34 |
clock_t ret; |
| 35 |
@@ -114,9 +118,13 @@ cl_times(void) /* Make times(2) behave r |
| 36 |
* because of sign extension. |
| 37 |
* We do expect sizeof(clock_t) <= sizeof(long), however. |
| 38 |
*/ |
| 39 |
+#if __ILP32__ && __x86_64__ |
| 40 |
+ return ret; |
| 41 |
+#else |
| 42 |
BUILD_BUG_ON(sizeof(clock_t) > sizeof(unsigned long)); |
| 43 |
#define CLOCK_T_MAX (~0UL >> (8*(sizeof(unsigned long) - sizeof(clock_t)))) |
| 44 |
return (unsigned long)ret & CLOCK_T_MAX; |
| 45 |
+#endif |
| 46 |
} |
| 47 |
|
| 48 |
#ifdef CLOCK_T_IS_LONG_ENOUGH |