This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 04/18/2018 01:17 PM, Albert ARIBAUD (3ADEV) wrote:
+/* Return the difference between 64-bit TIME1 and TIME0. */
+double
+__difftime64 (__time64_t time1, __time64_t time0)
+{
+ /* Subtract the smaller integer from the larger, convert the difference to
+ double, and then negate if needed. */
+ return time1 < time0 ? - (time0 - time1) : (time1 - time0);
+}
This does not work correctly if there is an integer overflow in any of the three subtractions. Also, the comment disagrees with the code.
How about if you just #include difftime.c after defining a couple of macros, and then have difftime.c do its thing? That'd avoid problems like this. difftime.c would also need to be generalized a bit.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |