[vlc-commits] [Git][videolan/vlc][master] 7 commits: configure: detect asprintf/vasprintf the standard way

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jan 31 09:45:02 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
dddae218 by Steve Lhomme at 2023-01-31T09:11:53+00:00
configure: detect asprintf/vasprintf the standard way

The mingw-w64 variant is equivalent to ours. No need to do a special case.
These are GNU functions, not C11 or POSIX functions.

- - - - -
5643ba03 by Steve Lhomme at 2023-01-31T09:11:53+00:00
meson: remove never set _UNICODE

It's not set in configure.ac either.

- - - - -
a7b55fa7 by Steve Lhomme at 2023-01-31T09:11:53+00:00
configure: don't define _POSIX_SOURCE for mingw-w64

It forces __USE_MINGW_ANSI_STDIO, M_PI and some functions we already have
done better in compat.

- - - - -
42d230be by Steve Lhomme at 2023-01-31T09:11:53+00:00
configure: don't define _POSIX_C_SOURCE for mingw-w64

It forces __USE_MINGW_ANSI_STDIO, M_PI and some functions we already have
done better in compat.

- - - - -
39039374 by Steve Lhomme at 2023-01-31T09:11:53+00:00
configure: remove defines used with __USE_MINGW_ANSI_STDIO

The PRId64, PRIi64, etc. are properly defined since at least mingw-w64 5 which
is the minimum we support.

snprintf, vsnprintf and swprintf officially exists in the Windows SDK and in
mingw-w64 5.

- - - - -
c74f0a8e by Steve Lhomme at 2023-01-31T09:11:53+00:00
vlc_common: remove unused swprintf

It would use the proper call via mingw-w64 anyway.

- - - - -
b2a7a5b3 by Steve Lhomme at 2023-01-31T09:11:53+00:00
vlc_common: remove redirections to mingw printf functions

This is the job of mingw-w64 to pick the proper variant when we set
__USE_MINGW_ANSI_STDIO. In fact when including stdio.h it undefines our defines.

- - - - -


4 changed files:

- config.h.meson
- configure.ac
- include/vlc_common.h
- meson.build


Changes:

=====================================
config.h.meson
=====================================
@@ -37,17 +37,10 @@
 
 /* Define to 1 for Unicode (Wide Chars) APIs. */
 #mesondefine UNICODE
-#mesondefine _UNICODE
 
 /* Define for Windows 7 APIs. */
 #mesondefine _WIN32_WINNT
 
-/* IEEE Std 1003.1. */
-#mesondefine _POSIX_SOURCE
-
-/* IEEE Std 1003.1. */
-#mesondefine _POSIX_C_SOURCE
-
 /* Define to 1 to force use of MinGW provided C99 *printf over msvcrt */
 #mesondefine __USE_MINGW_ANSI_STDIO
 


=====================================
configure.ac
=====================================
@@ -293,8 +293,6 @@ int foo() { return my_array[0]; }
     ])
     AC_DEFINE([WIN32_LEAN_AND_MEAN],, [Define to limit the scope of <windows.h>.])
     AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
-    AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.])
-    AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
 
     AC_ARG_WITH(packagedir,
       AS_HELP_STRING([--with-packagedir=DIR],
@@ -753,7 +751,7 @@ need_libc=false
 
 dnl Check for usual libc functions
 AC_CHECK_FUNCS([accept4 dup3 fcntl flock fstatat fstatvfs fork getmntent_r getenv getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale pipe2 posix_fadvise setlocale stricmp uselocale wordexp])
-AC_REPLACE_FUNCS([aligned_alloc atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lfind lldiv localtime_r memrchr nrand48 poll posix_memalign readv recvmsg rewind sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get strverscmp writev])
+AC_REPLACE_FUNCS([aligned_alloc asprintf atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lfind lldiv localtime_r memrchr nrand48 poll posix_memalign readv recvmsg rewind sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get strverscmp vasprintf writev])
 AC_REPLACE_FUNCS([gettimeofday])
 AC_CHECK_FUNC(fdatasync,,
   [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
@@ -761,10 +759,6 @@ AC_CHECK_FUNC(fdatasync,,
 
 VLC_REPLACE_DECL([realpath], [#include <stdlib.h>])
 
-dnl mingw64 implements those as static inline, not functions with C linkage
-VLC_REPLACE_DECL([asprintf], [#include <stdio.h>])
-VLC_REPLACE_DECL([vasprintf], [#include <stdio.h>])
-
 # Windows CE does not have strcoll()
 AC_FUNC_STRCOLL
 


=====================================
include/vlc_common.h
=====================================
@@ -72,23 +72,6 @@
 # define VLC_GCC_VERSION(maj,min) (0)
 #endif
 
-/* Try to fix format strings for all versions of mingw and mingw64 */
-#if defined( _WIN32 ) && defined( __USE_MINGW_ANSI_STDIO )
- #undef PRId64
- #define PRId64 "lld"
- #undef PRIi64
- #define PRIi64 "lli"
- #undef PRIu64
- #define PRIu64 "llu"
- #undef PRIo64
- #define PRIo64 "llo"
- #undef PRIx64
- #define PRIx64 "llx"
- #define snprintf __mingw_snprintf
- #define vsnprintf __mingw_vsnprintf
- #define swprintf _snwprintf
-#endif
-
 /* Function attributes for compiler warnings */
 #if defined __has_attribute
 # if __has_attribute(warning)


=====================================
meson.build
=====================================
@@ -347,10 +347,7 @@ windows_version_test = '''
 
         # Defines needed for MinGW
 
-        mingw_defines = [
-            ['_POSIX_SOURCE',               1], # IEEE Std 1003.1
-            ['_POSIX_C_SOURCE',             '200809L'], #IEEE Std 1003.1
-        ]
+        mingw_defines = []
 
 ucrt_version_test = '''
 #include <crtdefs.h>
@@ -635,6 +632,8 @@ libcompat_functions = [
     ['localtime_r',      '#include <time.h>'],
     ['strverscmp',       '#include <string.h>'],
     ['writev',           '#include <sys/uio.h>'],
+    ['asprintf',         '#include <stdio.h>'],
+    ['vasprintf',        '#include <stdio.h>'],
 
     ['gettimeofday',     '#include <sys/time.h>'],
 
@@ -669,11 +668,8 @@ foreach f : libcompat_functions
 endforeach
 
 # These functions need to be checked with has_header_symbol as
-# MinGW-w64 implements those as static inline, not functions with C linkage
 libcompat_functions = [
     ['realpath',         'stdlib.h'],
-    ['asprintf',         'stdio.h'],
-    ['vasprintf',        'stdio.h'],
 ]
 
 foreach f : libcompat_functions



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6b1f7dc26554e92351f9513359332664358eb540...b2a7a5b3740b74bf3d124ff77e00b1cd14588e2d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6b1f7dc26554e92351f9513359332664358eb540...b2a7a5b3740b74bf3d124ff77e00b1cd14588e2d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list