[FFmpeg-devel] parse_date using localtime etc.

Michael Niedermayer michaelni
Fri Feb 6 14:47:05 CET 2009

On Fri, Feb 06, 2009 at 12:49:20PM +0100, Reimar D?ffinger wrote:
> On Fri, Feb 06, 2009 at 11:53:51AM +0100, Michael Niedermayer wrote:
> > On Fri, Feb 06, 2009 at 11:11:05AM +0100, Reimar D?ffinger wrote:
> > > as it came out during a recent discussion, parse_date uses the
> > > non-thread-safe functions localtime and gmtime.
> > > This is not much of an issue currently, since libav* does not use that
> > > code path.
> > > However I still have a bad feeling about it, since libav* functions are
> > > expected to not have global side-effects and to be thread safe.
> > > The question is what to do about it.
> > 
> > use localtime_r()
> Not available on MinGW. Though you could use localtime_s, while MinGW
> does not declare it in their headers it should work...
> So how should this be solved,
> #ifdef __MINGW32__
> #define localtime_r(time, tm) localtime_s(tm, time)
> #endif
> (this is not 100% since localtime_s returns errno_t, not tm), this can
> be fixed by making it a function but will cause clashes if localtime_r
> is implemented in MINGW.

> Or make an av_localtime_r?

yes, write a clean, short (max 1 page of code) implementation of localtime()

> > besides it has to be mentiond that some libcs like microsofts according
> > to google provide a thread safe localtime() with thread local storeage.
> That does not solve anything (actually it creates even _more_ issues)
> since you could pass the pointer to a different thread.

and why would this be a problem?
I definitly meant a non broken implementation of thread
local storage, that is each thread stores its copy at a distinct address
and thus a pointer to it would be valid in any thread.

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090206/16668e40/attachment.pgp>

More information about the ffmpeg-devel mailing list