Commit Graph

37 Commits

Author SHA1 Message Date
phunkyfish 0830e9116f avformat/udp: support w32pthreads compat
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-08 19:08:04 +01:00
Matt Oliver fc6fde22c3 avutil/thread: Add pthread_cond_timedwait function
v2: fix calculating milisecond times and use SleepConditionVariableSRW.

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2020-01-21 22:34:15 +01:00
James Almer 613f789c19 w32pthreads: remove some remaining superfluous checks
Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-25 23:17:56 -03:00
wm4 9b121dfc32 w32pthreads: always use Vista+ API, drop XP support
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.
2017-12-26 02:49:48 +01:00
Aaron Levinson bceb3d0f86 Support building C++ files with MSVC
Made appropriate changes to be able to successfully
build C++ files using a Visual C++ build on Windows.

Based on an earlier patch by Kyle Schwarz.

Comments:

-- compat/w32pthreads.h: Made appropriate changes to w32pthreads.h to
   get it to build when it is being included in a C++ file and built
   with Visual C++.  This is mostly a copy of Kyle Schwarz's patch as
   described above.

-- configure:
a) Now calling set_ccvars CXX to cause the various CXX_ variables to
   be setup properly.  For example, with MSVC (Microsoft Visual C++),
   this causes CXX_O to be set to -Fo$@ instead of using the default
   value.  The default value does not work with Visual C++.  This
   change will also have the impact of correcting CXX_O (and possibly
   CXX_C) for other compilers, although this is really only relevant
   for the Intel compiler, in addition to MSVC.
b) Now using cl for the C++ compiler for the MSVC toolchain.  This is
   currently only relevant for building the
   Blackmagic/Decklink-related files under avdevice.

Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-04-13 23:57:31 +02:00
James Almer b30cd14b57 Merge commit 'bd9cd04626a98a752c5771d057a6b86779359904'
* commit 'bd9cd04626a98a752c5771d057a6b86779359904':
  w32pthreads: Fix function pointer casts

Merged-by: James Almer <jamrial@gmail.com>
2017-04-04 15:59:56 -03:00
Diego Biurrun bd9cd04626 w32pthreads: Fix function pointer casts
This eliminates a handful of warnings at every inclusion of the header.
2016-11-24 16:14:33 +01:00
Timothy Gu 180f9a0958 all: Make header guard names consistent 2016-01-31 15:44:11 -08:00
Hendrik Leppkes c1b712e078 Merge commit '407ac22322e5ce67996ec54ef619cafa4c9ceb78'
* commit '407ac22322e5ce67996ec54ef619cafa4c9ceb78':
  w32pthreads: Map MemoryBarrier to __sync_synchronize on mingw

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-02 11:58:27 +01:00
Martin Storsjö 407ac22322 w32pthreads: Map MemoryBarrier to __sync_synchronize on mingw
This fixes building on older mingw (both mingw.org and mingw64;
mingw64 from before May 2011).

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-10-30 20:15:11 +02:00
Hendrik Leppkes 68e00ad66d w32pthreads: fix mingw build on x86 with -msse2 or higher
When SSE2 or higher compiler optimizations are used, mingw uses
the _mm_mfence intrinsic for MemoryBarrier, however it doesn't include
the appropriate headers automatically.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-16 17:46:41 +02:00
Hendrik Leppkes 97be5d4d20 w32pthreads: fix mingw build on x86 with -msse2 or higher
When SSE2 or higher compiler optimizations are used, mingw uses
the _mm_mfence intrinsic for MemoryBarrier, however it doesn't include
the appropriate headers automatically.
2015-10-16 14:54:48 +02:00
wang-bin 0861862b89 winrt: multithreading support
_beginthreadex is for desktop only. CreateThread is available for windows store apps on windows (and phone) 8.1 and later. http://msdn.microsoft.com/en-us/library/ms682453%28VS.85%29.aspx

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-16 00:54:57 +11:00
Hendrik Leppkes 9d6873a43d Merge commit '2830bce47e2eb29c76202f19017031ddc1f95dd3'
* commit '2830bce47e2eb29c76202f19017031ddc1f95dd3':
  w32pthreads: Load dynamically loaded functions on demand

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-10 09:45:44 +02:00
Hendrik Leppkes 89da893c88 Merge commit 'b22693b06d1e5d73454a65c203b4d31c1ca5b69a'
* commit 'b22693b06d1e5d73454a65c203b4d31c1ca5b69a':
  w32pthreads: Add pthread_once emulation

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-10 09:45:16 +02:00
Hendrik Leppkes 2830bce47e w32pthreads: Load dynamically loaded functions on demand
This removes the requirement of calling w32thread_init before being
able to use the threading primitives.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-07 18:45:50 +02:00
Hendrik Leppkes b22693b06d w32pthreads: Add pthread_once emulation
The emulation uses native InitOnce* APIs on Windows Vista+, and a
lock-free/allocation-free approach using atomics and spinning for
Windows XP.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-07 18:45:50 +02:00
Matt Oliver ae58abeabb compat/w32pthreads: Add return values to match the simulated pthread functions. 2015-09-30 13:41:33 +10:00
James Almer b7c3bfd5eb w32pthreads: use the condition variable API directly when targeting newer versions of Windows
Wrap the function calls in a similar fashion to how it's being done
with the critical section API.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-10 11:27:30 +03:00
James Almer 73ea3ffcd5 w32pthreads: use the CONDITION_VARIABLE typedef if available
This silences warnings about passing arguments from incompatible pointer type
when targeting Windows Vista or newer.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-10 11:27:26 +03:00
James Almer 8c6992bf0c compat/w32pthreads: use the condition variable API directly when targeting newer versions of Windows
Wrap the function calls in a similar fashion to how it's being done
with the critical section API.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-10-09 17:51:46 -03:00
James Almer 0c06949314 compat/w32pthreads: use the CONDITION_VARIABLE typedef if available
This silences warnings about passing arguments from incompatible pointer type
when targeting Windows Vista or newer.

Tested-by: Matt Oliver <protogonoi@gmail.com>
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-10-09 13:26:44 -03:00
Michael Niedermayer 6afd726b7b Merge commit '6baeadd11083774ebd823dd5e1a744c2150a3bfc'
* commit '6baeadd11083774ebd823dd5e1a744c2150a3bfc':
  w32pthreads: Mark functions in compatibility wrapper as av_unused

Conflicts:
	compat/w32pthreads.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 12:31:29 +02:00
Diego Biurrun 6baeadd110 w32pthreads: Mark functions in compatibility wrapper as av_unused
This avoids annoying warnings about unused functions. The compatibility
wrapper is designed to provide a complete (stub) API, so some functions
being unused by some files is natural and no reason for a warning.
2014-08-15 09:37:38 +02:00
Michael Niedermayer a0f3db8f60 Merge commit '428b0578c64241fc677fed7083cc8fe65e10f32e'
* commit '428b0578c64241fc677fed7083cc8fe65e10f32e':
  w32threads: Use newer thread synchronization functions when targeting Vista

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-13 18:33:06 +02:00
Martin Storsjö 428b0578c6 w32threads: Use newer thread synchronization functions when targeting Vista
When explicitly targeting Vista or newer (which only happens if the
caller explicitly sets _WIN32_WINNT to a high enough value via the
extra cflags option - otherwise configure script sets
-D_WIN32_WINNT=0x0502), we already unconditionally link to the
ConditionVariable functions, since 4622f11f9.

Similarly use the newer -Ex versions of CreateEvent, CreateSemaphore,
InitializeCriticalSection and WaitForSingleObject, that all appeared
in Vista. When building Windows Store applications, the older versions
of these functions aren't available, only the -Ex functions. When
doing such a build, the user can set -D_WIN32_WINNT=0x0600 to
forcibly use the newer functions instead.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-08-13 14:38:18 +03:00
Nicolas George 58a10e0e2c compat/w32pthreads: add return value to pthread_cond_init(). 2014-05-26 11:33:42 +02:00
Michael Niedermayer 983ed20c1c Merge commit 'ef51692a49d58963966adca55c62da9c34c3c7e1'
* commit 'ef51692a49d58963966adca55c62da9c34c3c7e1':
  Revert "w32pthread: help compiler figure out undeeded code"

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-28 12:46:12 +02:00
Michael Niedermayer a8ddafb0f4 Merge commit '4332bf98dc051fd1ffbd9d4ddc1c5e55790c96f1'
* commit '4332bf98dc051fd1ffbd9d4ddc1c5e55790c96f1':
  w32threads: Don't use function pointers when linking directly to newer APIs

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-28 12:41:16 +02:00
Martin Storsjö ef51692a49 Revert "w32pthread: help compiler figure out undeeded code"
This reverts commit 4622f11f9c.

The compiler should be able to do the dead code elimination now
without this when the cond_* names point directly to the real
functions instead of to local function pointers.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-08-27 23:12:49 +03:00
Martin Storsjö 4332bf98dc w32threads: Don't use function pointers when linking directly to newer APIs
This reduces the call overhead slightly. More noticeably, it
restores the earlier (unintended?) feature that condition variable
functions work just fine even if w32thread_init() hasn't been called.
This was broken as a side effect of 4622f11f9, if explicitly targeting
Vista+.

This makes w32threading work in VP8 again, if targeting Vista+.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-08-27 23:12:28 +03:00
Michael Niedermayer 221a99aae7 Merge commit '4622f11f9c83db8a2e08408c71ff901826ca652c'
* commit '4622f11f9c83db8a2e08408c71ff901826ca652c':
  w32pthread: help compiler figure out undeeded code

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-22 13:09:24 +02:00
Rafaël Carré 4622f11f9c w32pthread: help compiler figure out undeeded code
The emulation code is not needed when targetting Vista+
This helps getting rid of CreateSemaphore symbol, which is
forbidden in Windows Store apps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-08-21 14:20:33 +01:00
Michael Niedermayer c88503e3f6 Merge commit '439902e0d68a0f0d800c21b5e6b598d5fa0c51da'
* commit '439902e0d68a0f0d800c21b5e6b598d5fa0c51da':
  Employ consistent LIBAV_COMPAT_ multiple inclusion guards in compat/

Conflicts:
	compat/aix/math.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-19 10:56:10 +02:00
Diego Biurrun 439902e0d6 Employ consistent LIBAV_COMPAT_ multiple inclusion guards in compat/
Also fix a comment and an #endif comment.
2013-07-18 18:12:38 +02:00
Michael Niedermayer a4d3757b29 Merge commit '90f9a5830b5d332de7ebb1ab45589f1870cbd65d'
* commit '90f9a5830b5d332de7ebb1ab45589f1870cbd65d':
  w32pthreads: move from lavc to compat/

Conflicts:
	libavcodec/Makefile
	libavcodec/pthread.c
	libavcodec/vp8.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-24 13:01:41 +02:00
Anton Khirnov 90f9a5830b w32pthreads: move from lavc to compat/
It will be used in other places than lavc.
2013-05-24 09:26:54 +02:00