On Tue, 17 Dec 2013, Diego Biurrun wrote:

Also unify the related ifdeffery in the atomics implementation.
---

This fixes compilation on systems w/o any atomics implementation available,
e.g. MinGW32 < 4.0.

.. by disabling threading silently in those configurations - right? E.g., configurations where w32threads would be enabled implicitly (but isn't due to the lack of proper support for atomics), you will silently get a slightly crippled build, with no threading?

In general this might work smoother (no failed builds), but is it better? What do others think? I'm a bit undecided.

configure          | 15 ++++++++-------
libavutil/atomic.c |  9 +++------
libavutil/atomic.h |  7 ++++++-
3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/configure b/configure
index 6b23c85..4e927a2 100755
--- a/configure
+++ b/configure
@@ -1583,6 +1583,14 @@ log2_deps="!libc_msvcrt"

symver_if_any="symver_asm_label symver_gnu_asm"

+# threading support
+atomics_gcc_if="sync_val_compare_and_swap"
+atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
+atomics_win32_if="MemoryBarrier"
+atomics_native_if_any="$ATOMICS_LIST"
+threads_deps="atomics_native"
+threads_if_any="$THREADS_LIST"
+

Most of this except for the threads_deps part is a plain refactoring, right? This change would be much easier to review if it would be split into refactorings separately and the actual functional changes in a separate patch.

# subsystems
dct_select="rdft"
error_resilience_select="dsputil"
@@ -3872,10 +3880,6 @@ done
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib

-enabled sync_val_compare_and_swap && enable atomics_gcc
-enabled_all atomic_cas_ptr machine_rw_barrier && enable atomics_suncc
-enabled MemoryBarrier && enable atomics_win32
-
check_lib math.h sin -lm && LIBM="-lm"
enabled vaapi && require vaapi va/va.h vaInitialize -lva

@@ -4177,9 +4181,6 @@ case $target_os in
    ;;
esac

-enabled_any $THREADS_LIST      && enable threads
-enabled_any $ATOMICS_LIST      && enable atomics_native
-
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }

check_deps $CONFIG_LIST       \
diff --git a/libavutil/atomic.c b/libavutil/atomic.c
index add489a..38e998e 100644
--- a/libavutil/atomic.c
+++ b/libavutil/atomic.c
@@ -18,6 +18,7 @@
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

+#include "config.h"
#include "atomic.h"


This is a plain extra change, right? Separate patch please.

#if !HAVE_ATOMICS_NATIVE
@@ -69,7 +70,7 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void 
*oldval, void *newval)
    return ret;
}

-#elif !HAVE_THREADS
+#else

int avpriv_atomic_int_get(volatile int *ptr)
{
@@ -96,13 +97,9 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void 
*oldval, void *newval)
    return *ptr;
}

-#else
-
-#error "Threading is enabled, but there is no implementation of atomic operations 
available"
-
#endif /* HAVE_PTHREADS */

-#endif /* !HAVE_MEMORYBARRIER && !HAVE_SYNC_VAL_COMPARE_AND_SWAP && 
!HAVE_MACHINE_RW_BARRIER */
+#endif /* !HAVE_ATOMICS_NATIVE */

#ifdef TEST
#include <assert.h>
diff --git a/libavutil/atomic.h b/libavutil/atomic.h
index a5c5fe8..57a0c19 100644
--- a/libavutil/atomic.h
+++ b/libavutil/atomic.h
@@ -23,12 +23,16 @@

#include "config.h"

+#if HAVE_ATOMICS_NATIVE
+
#if HAVE_ATOMICS_GCC
#include "atomic_gcc.h"
#elif HAVE_ATOMICS_WIN32
#include "atomic_win32.h"
#elif HAVE_ATOMICS_SUNCC
#include "atomic_suncc.h"
+#endif
+
#else

/**
@@ -70,5 +74,6 @@ int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int 
inc);
 */
void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval);

-#endif /* HAVE_MEMORYBARRIER */
+#endif /* HAVE_ATOMICS_NATIVE */
+
#endif /* AVUTIL_ATOMIC_H */
--
1.8.3.2

This also is a separate cleanup.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to