[FFmpeg-devel] [RFC] avoid non-threadsafe localtime, gmtime

Michael Niedermayer michaelni
Sat Feb 7 16:09:19 CET 2009


On Sat, Feb 07, 2009 at 02:18:09PM +0100, Reimar D?ffinger wrote:
> On Sat, Feb 07, 2009 at 01:24:19PM +0100, Michael Niedermayer wrote:
> > On Sat, Feb 07, 2009 at 12:02:03PM +0100, Reimar D?ffinger wrote:
> > > attached patch would be the first step to get rid of the non-threadsafe
> > > localtime and gmtime functions.
> > > It should work on all POSIX and current Windows versions.
> > > For anything else it would still be a simple hack to add support to
> > > fallback to the non-threadsafe functions, only libavformat then would
> > > not be thread-safe which keeps the probability of issues quite low.
> > 
> > fine, though i must add the ifdefs are ugly
> 
> If you find that ugly, you'll certainly be jumping with joy at the end
> of the email.
> Neither localtime_s nor localtime_r are available in MinGW actually.
> The MinGW developers claimed that they are not necessary because
> localtime is thread-safe (due to use thread-local storage), missing that
> that is not enough.
> An application might do
> > struct tm *now = localtime(time());
> > some_lib_func();
> > use now
> 
> So you have the choice of either forbidding all the applications that
> use your library to use localtime in this way (with no way to forbid it)
> or you can't use localtime in your library.
> I do have a solution (just create a new thread for the sole purpose of
> running localtime()), and I even have a patch to do that (attached) but
> I am sure nobody will like it.
> The other solution is to use localtime_r where available and tell
> everyone else they use a broken platform and they use localtime/gmtime in their
> applications at their own risk (how to do that "telling" is another
> question).

what with my original suggestion of ignoring summer time and just
implementing our own localtime?

or for the less sane, just extract the summer time switches automatically
from localtime() ? (zero maintaince ...)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20090207/a11fe0af/attachment.pgp>



More information about the ffmpeg-devel mailing list