[PATCH 1/2] difftime can throw exceptions

DJ Delorie dj@redhat.com
Mon Jun 3 22:01:52 GMT 2024


Paul Eggert <eggert@cs.ucla.edu> writes:
> Although we could do something more complicated, in which difftime is
> plain on modern platforms but const and nothrow on obsolescent
> platforms with 32-bit time_t, it hardly seems worth the trouble.
> difftime is used so rarely that it's not worth taking pains to
> optimize calls to it on obsolescent platforms.

So the rule is "function might throw an exception", ok...

>  /* Return the difference between TIME1 and TIME0.  */
> -extern double difftime (time_t __time1, time_t __time0)
> -     __THROW __attribute_pure__;
> +extern double difftime (time_t __time1, time_t __time0);

So now we (1) assume it can throw by not labelling it __THROW, and (2)
revoking its pure attribute because it might throw.

Ok.

(Who decided __THROW means "doesn't throw" ?)

>  extern double __REDIRECT_NTH (difftime, (time_t __time1, time_t __time0),
> -                              __difftime64) __attribute_pure__;
> +                              __difftime64);

Basically the same here, ok.

Neither of these changes could do anything other than reduce
optimization opportunities anyway, so I can't see how functionality
would be changed.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>



More information about the Libc-alpha mailing list