[PATCH v23 03/15] windows: add os shim for localtime_r

Stephen Hemminger stephen at networkplumber.org
Wed Sep 18 17:25:17 CEST 2024


On Wed, 18 Sep 2024 15:09:25 +0800
fengchengwen <fengchengwen at huawei.com> wrote:

> > diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h
> > index eda8113662..e9741a9df2 100644
> > --- a/lib/eal/windows/include/rte_os_shim.h
> > +++ b/lib/eal/windows/include/rte_os_shim.h
> > @@ -110,4 +110,14 @@ rte_clock_gettime(clockid_t clock_id, struct timespec *tp)
> >  }
> >  #define clock_gettime(clock_id, tp) rte_clock_gettime(clock_id, tp)
> >  
> > +static inline struct tm *
> > +rte_localtime_r(const time_t *timer, struct tm *buf)  
> 
> buf always means char *, but this function return struct tm *,
> suggest:
> struct tm *localtime_r(const time_t *timep, struct tm *result)
> 
> > +{
> > +	if (localtime_s(buf, timer) == 0)
> > +		return buf;
> > +	else
> > +		return NULL;
> > +}
> > +#define localtime_r(timer, buf) rte_localtime_r(timer, buf)

This is a windows wrapper around the GNU extension localtime_r()
so the signature needs to be the same, will change the name of
the args to match man page.

   struct tm *localtime_r(const time_t *restrict timep,
                           struct tm *restrict result);



More information about the dev mailing list