[vlc-devel] [vlc-commits] compat: fix localtime_r() replacement
Steve Lhomme
robux4 at videolabs.io
Tue Mar 17 09:19:25 CET 2015
After this change I get the following compilation error on mingw-w64
run on Windows. Reverting the commit fixes the issue.
libtool: link: i686-w64-mingw32-gcc -std=gnu99 -shared
.libs/libvdr_plugin.dll.def ../modules/.libs/module.rc.o
access/.libs/vdr.o ../compat/.libs/libcompat.a
-L/c/Users/robUx4/Documents/Program/Videolabs/work/contrib/i686-w64-mingw32/lib
../src/.libs/libvlccore.dll.a
/c/Users/robUx4/Documents/Program/Videolabs/work/contrib/i686-w64-mingw32/lib/libgpg-error.a
-lwinmm -lws2_32 -g -mms-bitfields --static -static-libgcc
-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -o
.libs/libvdr_plugin.dll -Wl,--enable-auto-image-base -Xlinker
--out-implib -Xlinker .libs/libvdr_plugin.dll.a
../compat/.libs/libcompat.a(localtime_r.o): In function `localtime_r':
C:\Users\robUx4\Documents\Program\Videolabs\build\win32\compat/../../../work/extras/package/win32/../../../compat/localtime_r.c:38:
undefined reference to `localtime_s'
collect2.exe: error: ld returned 1 exit status
On Mon, Mar 16, 2015 at 6:30 PM, Rémi Denis-Courmont <git at videolan.org> wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 16 19:20:44 2015 +0200| [d60d5102b861525edf1ba22f9e6c6b3747a4ed3e] | committer: Rémi Denis-Courmont
>
> compat: fix localtime_r() replacement
>
> - Do not clobber thread-specific state on Windows
> - Be thread-safe on non-Windows
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d60d5102b861525edf1ba22f9e6c6b3747a4ed3e
> ---
>
> compat/localtime_r.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/compat/localtime_r.c b/compat/localtime_r.c
> index b19f68d..67da422 100644
> --- a/compat/localtime_r.c
> +++ b/compat/localtime_r.c
> @@ -1,7 +1,7 @@
> /*****************************************************************************
> * localtime_r.c: POSIX localtime_r() replacement
> *****************************************************************************
> - * Copyright © 1998-2008 VLC authors and VideoLAN
> + * Copyright © 1998-2015 VLC authors and VideoLAN
> *
> * This program is free software; you can redistribute it and/or modify it
> * under the terms of the GNU Lesser General Public License as published by
> @@ -18,20 +18,26 @@
> * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> *****************************************************************************/
>
> +#if (__STDC_VERSION__ >= 201112L)
> +# define __STDC_WANT_LIB_EXT1__ 1
> +#endif
> #ifdef HAVE_CONFIG_H
> # include <config.h>
> #endif
>
> +#include <errno.h>
> #include <time.h>
>
> /* If localtime_r() is not provided, we assume localtime() uses
> * thread-specific storage. */
> struct tm *localtime_r (const time_t *timep, struct tm *result)
> {
> - struct tm *s = localtime (timep);
> - if (s == NULL)
> - return NULL;
> -
> - *result = *s;
> - return result;
> +#if (__STDC_VERSION__ >= 201112L)
> + return localtime_s(timep, result);
> +#elif defined (_WIN32)
> + return ((errno = localtime_s(result, timep)) == 0) ? result : NULL;
> +#else
> +# warning localtime_r() not implemented!
> + return gmtime_r(timep, result);
> +#endif
> }
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list