[FFmpeg-devel] [PATCH 1/5] w32pthreads: always use Vista+ API, drop XP support
James Almer
jamrial at gmail.com
Fri Dec 22 03:05:11 EET 2017
On 12/21/2017 9:40 PM, wm4 wrote:
> On Thu, 21 Dec 2017 21:31:37 -0300
> James Almer <jamrial at gmail.com> wrote:
>
>> On 12/21/2017 7:22 PM, wm4 wrote:
>>> This removes the XP compatibility code, and switches entirely to SWR
>>> locks, which are available starting at Windows Vista.
>>>
>>> This removes CRITICAL_SECTION use, which allows us to add
>>> PTHREAD_MUTEX_INITIALIZER, which will be useful later.
>>>
>>> Windows XP is hereby not a supported build target anymore. It was
>>> decided in a project vote that this is OK. (Technically, it could still
>>> be built for Windows XP using an external pthread lib as of this
>>> commit.)
>>>
>>> Windows Vista adds WSAPoll(), and for some reason struct pollfd. Since
>>> we raise the Windows API level globally when enabling w32threads, we
>>> need to move it before configure checks for struct pollfd to avoid that
>>> the compatibility ifdef mess redefines it.
>>> ---
>>> Not sure if there's a better way to do the things configure does.
>>> ---
>>> Changelog | 2 +
>>> compat/w32pthreads.h | 269 ++-------------------------------------------
>>> configure | 93 ++++++++--------
>>> libavcodec/pthread_frame.c | 4 -
>>> libavcodec/pthread_slice.c | 4 -
>>> libavfilter/pthread.c | 4 -
>>> libavutil/slicethread.c | 4 -
>>> 7 files changed, 60 insertions(+), 320 deletions(-)
>>
>> [...]
>>
>>> --- a/configure
>>> +++ b/configure
>>> @@ -2089,7 +2089,6 @@ TOOLCHAIN_FEATURES="
>>> "
>>>
>>> TYPES_LIST="
>>> - CONDITION_VARIABLE_Ptr
>>> kCMVideoCodecType_HEVC
>>> socklen_t
>>> struct_addrinfo
>>> @@ -5163,8 +5162,8 @@ probe_libc(){
>>> add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
>>> check_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
>>> add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
>>> - check_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0502" &&
>>> - add_${pfx}cppflags -D_WIN32_WINNT=0x0502
>>> + check_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600" &&
>>> + add_${pfx}cppflags -D_WIN32_WINNT=0x0600
>>
>> This same check should now also be added to the mingw-w64 part of this
>> function.
>> Until now, this was done this way because mingw32 defaults to Win98,
>> whereas mingw-w64 to WinXP. Now we need Vista in both.
>
> Oh, I didn't even notice that was mingw32 only.
>
>> It would be a good idea for that matter to make sure all the required
>> Vista API is actually supported by Mingw32 3.15, or if we need to bump
>> that (or just drop mingw32 support, which wouldn't really hurt).
>
> The code already checks for CONDITION_VARIABLE. Any other things I
> should check for? Maybe a representative function? (I don't think I'm
> going to add checks for _all_ the symbols.)
Didn't realize that was checked, so no, should be good then.
>
>>> eval test \$${pfx_no_}cc_type = "gcc" &&
>>> add_${pfx}cppflags -D__printf__=__gnu_printf__
>>> elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
>>> @@ -5184,14 +5183,14 @@ probe_libc(){
>>> # 0x601 by default unless something else is set by the user.
>>> # This can easily lead to us detecting functions only present
>>> # in such new versions and producing binaries requiring windows 7.0.
>>> - # Therefore explicitly set the default to XP unless the user has
>>> + # Therefore explicitly set the default to Vista unless the user has
>>> # set something else on the command line.
>>> # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
>>> # family. For these cases, configure is free to use any functions
>>> # found in the SDK headers by default. (Alternatively, we could force
>>> # _WIN32_WINNT to 0x0602 in that case.)
>>> check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
>>> - { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
>>> + { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0600; }
>>> #ifdef WINAPI_FAMILY
>>> #include <winapifamily.h>
>>> #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
>>> @@ -5564,6 +5563,51 @@ check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_
>>> check_ldflags -Wl,--as-needed
>>> check_ldflags -Wl,-z,noexecstack
>>>
>>> +if ! disabled w32threads && ! enabled pthreads; then
>>> + check_func_headers "windows.h process.h" _beginthreadex &&
>>> + check_type "windows.h" CONDITION_VARIABLE &&
>>> + enable w32threads || disable w32threads
>>> + if ! enabled w32threads && enabled winrt; then
>>> + check_func_headers "windows.h" CreateThread &&
>>> + enable w32threads || disable w32threads
>>> + fi
>>> +fi
>>> +
>>> +if enabled w32threads; then
>>> + if check_cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" ; then
>>> + add_cppflags -D_WIN32_WINNT=0x0600
>>
>> Win Vista should be forced regardless of w32threads being enabled or
>> not, so this should be done in probe_libc().
>
> OK, sounds good. So this means we always set _WIN32_WINNT
> unconditionally (unless it's already set to something higher than
> Vista). This will probably simplify the configure changes.
Yes, that's the idea. After this we should also remove the lavf
os_support compat code (things like poll emulation).
More information about the ffmpeg-devel
mailing list