[PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
Zack Weinberg
zackw@panix.com
Wed Oct 28 14:12:47 GMT 2020
On Wed, Oct 28, 2020 at 9:54 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> * Adhemerval Zanella:
>
> > On 26/10/2020 13:29, Florian Weimer wrote:
> >> * Adhemerval Zanella:
> >>
> >>> On 26/10/2020 13:19, Florian Weimer wrote:
> >>>> * Adhemerval Zanella:
> >>>>
> >>>>> +struct timeb
> >>>>> + {
> >>>>> + time_t time; /* Seconds since epoch, as from `time'. */
> >>>>> + unsigned short int millitm; /* Additional milliseconds. */
> >>>>> + short int timezone; /* Minutes west of GMT. */
> >>>>> + short int dstflag; /* Nonzero if Daylight Savings Time used. */
> >>>>> + };
> >>>>
> >>>> I think you could add __attribute_deprecated_msg__ on the struct itself.
> >>>
> >>> I tried to add on it, but it would require to add the warning suppression
> >>> on ftime.c build before the header inclusion and also on check-local header
> >>> tests as well (since it includes).
> >>
> >> Ahh, so you get a deprecation warning on the ftime function declaration,
> >> even though itself it is marked deprecated. Oh well. That's not how
> >> things work in Java.
> >
> > On the struct timeb declaration to be more exact, even when then ftime
> > is not issued. I would expect a deprecation warning iff the code
> > actually uses the struct timeb.
>
> The ftime prototype uses it (in the deprecation sense). This use should
> be ignored due to the deprecation attribute on ftime itself, though.
Workaround: move the complete declaration of struct timeb, with
__attribute_deprecated__, below the declaration of ftime:
__BEGIN_DECLS
/* Forward-declare struct timeb so we can use it in the prototype
of ftime without a spurious deprecation warning.
See GCC bug xxxxxx. */
struct timeb;
/* Fill in TIMEBUF with information about the current time. */
extern int ftime (struct timeb *__timebuf)
__nonnull ((1)) __attribute_deprecated__;
/* Structure returned by the `ftime' function. */
struct timeb
{
time_t time; /* Seconds since epoch, as from `time'. */
unsigned short int millitm; /* Additional milliseconds. */
short int timezone; /* Minutes west of GMT. */
short int dstflag; /* Nonzero if Daylight Savings Time used. */
}
__attribute_deprecated__;
__END_DECLS
zw
More information about the Libc-alpha
mailing list