Commit Graph

46 Commits

Author SHA1 Message Date
Hugo Beauzée-Luyssen 5a6b9d32bd vlc_atomic: Add a vlc_atomic_rc_get function 2020-12-17 16:15:31 +01:00
Quentin Chateau 50d5f881d7 atomic: prevent overflow
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2020-03-02 21:11:57 +02:00
Rémi Denis-Courmont 36a58d83aa Remove useless VLC atomic float helpers 2020-02-27 22:33:22 +02:00
Romain Vimont 618a789958 core: add atomic refcounter helper
Implement an atomic refcounter with a weak but correct (1) memory order,
and expose a simple API.

(1) See for example "Using weakly ordered C++ atomics correctly" by Hans
    Boehm at CppCon 2016 (the refcounting part also applies to C11):
    <https://www.youtube.com/watch?v=M15UKpNlpeM&t=45m15s>

Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
2018-07-09 09:13:01 +02:00
Rémi Denis-Courmont d811804855 include: remove atomic legacy wrappers 2017-12-19 19:34:56 +02:00
Rémi Denis-Courmont a1c3e136c4 Drop broken C99 support 2017-11-14 18:28:02 +02:00
Francois Cartegnie 54bda02c83 vlc_atomic: atomic_compare_exchange_strong_explicit takes 5 parameters 2016-07-22 13:05:44 +02:00
Steve Lhomme ea4edfb6ae vlc_atomic: atomic_compare_exchange_weak_explicit takes 5 parameters
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2016-06-09 20:46:33 +03:00
Jean-Baptiste Kempf 5d26efcad8 Try fixing previous atomic header commit 2015-06-30 23:12:49 +02:00
Jean-Baptiste Kempf 406f697d55 vlc_atomic.h: cosmetics for clang workaround 2015-06-30 11:59:00 +02:00
Felix Paul Kühne 569df08d1b atomics: fix compilation with GCC 2015-06-26 17:04:05 +02:00
Felix Paul Kühne 45495aa458 atomics: fix compilation with clang version < 7 2015-06-26 16:23:00 +02:00
Rémi Denis-Courmont a7a70e8163 include: restore Intel intrinsics replacement for C11 atomics 2015-06-25 23:57:25 +03:00
Rémi Denis-Courmont ada4b4748e include: do not redefine standard C++ symbols 2015-06-25 23:55:36 +03:00
Hugo Beauzée-Luyssen 0bcb7fd256 Revert "Fix warning on all c++ files"
This reverts commit 59678ec0b4.
2015-06-22 16:00:24 +02:00
Hugo Beauzée-Luyssen 59678ec0b4 Fix warning on all c++ files
Since vlc_atomic_float is only used for C files, another option would be
to disable this block when building in C++ mode.
Related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64658
2015-06-22 15:52:37 +02:00
Thomas Guillem e8b683357b vlc_atomic: use std::atomic<> instead of std::atomic_base<>
Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940
2015-06-22 15:52:37 +02:00
Rémi Denis-Courmont ab550d60dd include: stick to a single version (2011) C/C++ atomics
This fixes mismatched binary interface when either:
 - the versions of C and C++ were different within the LibVLC build, or
 - an out-of-tree plugin used a different language versin than LibVLC.

The LibVLC implementation for ISO C atomics with Intel intrinsics was
not generally binary compatible with the native implementation of the
compiler. In other words, only one atomics implementation can be used
in one LibVLC installation. The One Definition Rule from C++ imposes
that native implementation is used, so the LibVLC implementation is
hereby removed.

Regression from edf1c76018.
2015-06-22 00:11:23 +03:00
Felix Paul Kühne f5d5cb7576 fix atomics for non-x86 clang targets 2015-05-27 18:07:02 +02:00
Jean-Baptiste Kempf c5f80f5bc4 Use C++11 atomic only on gcc 5.0+ for now 2015-05-26 15:12:34 +02:00
Jean-Baptiste Kempf 66842e08e1 Fix C++11 compilation of atomic
Close #14569
2015-05-26 14:10:25 +02:00
Jean-Baptiste Kempf da7f0a603e Atomic: fix compilation under MSVC WinRT mode
... no comment...
2014-02-10 16:52:46 +01:00
Felix Abecassis 8ef254bbae vlc_atomic: fix compilation warnings with MSVC.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2014-01-03 12:49:01 +01:00
Felix Abecassis 66572ed7ea vlc_atomic: set the atomic types to be at least 32 bits wide with MSVC.
This change is required since some atomic operations of the
Interlocked API are only available for desktop apps.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2014-01-03 12:49:01 +01:00
Felix Abecassis 5ff29f804f vlc_atomic: add missing include for MSVC.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2014-01-03 12:49:01 +01:00
Felix Abecassis 331299dc7b Remove the deprecated vlc_atomic_t type.
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2014-01-02 13:41:42 +02:00
Felix Abecassis 9c077c0d28 Implement atomic operations for MSVC using the Interlocked API.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2013-11-30 21:16:46 +01:00
Rémi Denis-Courmont 5fb6de10c7 Rewrite atomic float helpers, fix 64-bits big endian support 2012-12-13 18:53:52 +02:00
Rémi Denis-Courmont 8fec577251 Fix mutex-emulated atomic operations on GCC 2012-11-11 18:26:56 +02:00
Felix Paul Kühne 82858095f5 vlc_atomic: work-around clang issue #11174
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_ is neither defined nor is an equivalent macro available. However, the protected features are supported.
2012-11-11 15:25:40 +01:00
Rémi Denis-Courmont fd82bdcba3 vlc_atomic: fix GCC macros return types 2012-11-10 18:58:57 +02:00
Rémi Denis-Courmont ec377ed3c7 Partial atomic replacement for antiquated GCC versions (fixes #6825) 2012-08-23 21:01:52 +03:00
Rémi Denis-Courmont d22cf31fe1 Fix vlc_atomic_compare_swap() return value
(Though in practice, the only call site ignores the return value.)
2012-08-23 21:01:51 +03:00
Rémi Denis-Courmont 2e186c72e0 Remove untenable const qualifiers from vlc_atomic_get() 2012-08-23 21:01:50 +03:00
Rémi Denis-Courmont 5035a0281c Move vlc_atomic_t to <vlc_atomic.h> and correct definition 2012-05-13 20:28:00 +03:00
Rémi Denis-Courmont cbbb1e4917 Add missing atomic types 2012-05-13 20:27:59 +03:00
Rémi Denis-Courmont 535e8b60f1 Rewrite vlc_atomic_* using the new atomic operations
This way, the official atomic functions will be used when available,
rather than VLC's own implementation.

This commit also enables proper atomic operations on some platforms
or with some toolchains. __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is not
defined on some platforms such as ARM Linux, nor by other compilers
than GCC such as LLVM/clang. Then atomic operations wrongly fell
back to the lame mutex-based implementation.

This will break support for some old compilers and old or irrelevant
instruction set architectures. They would need to provide replacement
for the Intel-originated __sync_* builtin functions.
2012-05-11 20:55:38 +03:00
Rémi Denis-Courmont ad3586579f Provide C11-like atomics in <vlc_atomic.h>
Since this constitutes mostly of macros and type definitions, it would
not fit too well in compat/. Most of the code would end up in
<vlc_fixups.h> rather than compat/. Moreover, I doubt that those
functions would be detected properly with AC_CHECK_FUNCS or
AC_REPLACE_FUNCS.

Anyway, VLC already has a separate header, and it will need to keep it
until <stdatomic.h> can be relied upon... many years from now.
2012-05-11 20:54:44 +03:00
Jean-Baptiste Kempf 36ab287e77 LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+

This move was authorized by the developers, either:
 - by e-mail,
 - by vote at the VideoLAN Dev Days 2011,
 - on the license website,
 - in a contract, oral or written.
No objection was raised, so far.

The developers agreeing are:
  Justus Piater
  Alexis Ballier
  Alexander Bethke
  Mohammed Adnène Trojette
  Alex Converse
  Alexey Sokolov
  Alexis de Lattre
  Andre Pang
  Anthony Loiseau
  Cyril Deguet
  André Weber
  Boris Dorès
  Brieuc Jeunhomme
  Benjamin Drung
  Hugo Beauzée-Luyssen
  Benoit Steiner
  Benjamin Pracht
  Bernie Purcell
  Przemyslaw Fiala
  Arnaud de Bossoreille de Ribou
  Brad Smith
  Nick Briggs
  Christopher Rath
  Christophe Courtaut
  Christopher Mueller
  Clement Chesnin
  Andres Krapf
  Damien Fouilleul
  David Flynn
  Sebastien Zwickert
  Antoine Cellerier
  Jérôme Decoodt
  Jérome Decoodt
  Dylan Yudaken
  Eduard Babayan
  Eugenio Jarosiewicz
  Elliot Murphy
  Eric Petit
  Erwan Tulou
  Etienne Membrives
  Ludovic Fauvet
  Fabio Ritrovato
  Tobias Güntner
  Jakub Wieczorek
  Frédéric Crozat
  Francois Cartegnie
  Laurent Aimar
  Florian G. Pflug
  Felix Paul Kühne
  Frank Enderle
  Rafaël Carré
  Simon Latapie
  Gildas Bazin
  Geoffroy Couprie
  Julien / Gellule
  Gildas Bazin
  Arnaud Schauly
  Toralf Niebuhr
  Vicente Jimenez Aguilar
  Derk-Jan Hartman
  Henri Fallon
  Ilkka Ollakka
  Olivier Teulière
  Rémi Duraffort
  Jakob Leben
  Jean-Baptiste Kempf
  Jean-Paul Saman
  Jean-Philippe Grimaldi
  Jean-François Massol
  Gaël Hendryckx
  Jakob Leben
  Jean-Marc Dressler
  Jai Menon
  Johan Bilien
  Johann Ransay
  Joris van Rooij
  JP Dinger
  Jean-Philippe André
  Adrien Grand
  Juha Jeronen
  Juho Vähä-Herttua
  Kaarlo Raiha
  Kaarlo Raiha
  Kamil Baldyga
  Keary Griffin
  Ken Self
  KO Myung-Hun
  Pierre Ynard
  Filippo Carone
  Loïc Minier
  Luca Barbato
  Lucas C. Villa Real
  Lukas Durfina
  Adrien Maglo
  Marc Ariberti
  Mark Lee
  Mark Moriarty
  Martin Storsjö
  Christophe Massiot
  Michel Kaempf
  Marian Ďurkovič
  Mirsal Ennaime
  Carlo Calabrò
  Damien Lucas
  Naohiro Koriyama
  Basos G
  Pierre Baillet
  Vincent Penquerc'h
  Olivier Aubert
  Pankaj Yadav
  Paul Corke
  Pierre d'Herbemont
  Philippe Morin
  Antoine Lejeune
  Michael Ploujnikov
  Jean-Marc Dressler
  Michael Hanselmann
  Rafaël Carré
  Ramiro Polla
  Rémi Denis-Courmont
  Renaud Dartus
  Richard Shepherd
  Faustino Osuna
  Arnaud Vallat
  Rob Jonson
  Robert Jedrzejczyk
  Steve Lhomme
  Rocky Bernstein
  Romain Goyet
  Rov Juvano
  Sam Hocevar
  Martin T. H. Sandsmark
  Sebastian Birk
  Sébastien Escudier
  Vincent Seguin
  Fabio Ritrovato
  Sigmund Augdal Helberg
  Casian Andrei
  Srikanth Raju
  Hannes Domani
  Stéphane Borel
  Stephan Krempel
  Stephan Assmus
  Tony Castley
  Pavlov Konstantin
  Eric Petit
  Tanguy Krotoff
  Dennis van Amerongen
  Michel Lespinasse
  Can Wu
  Xavier Marchesini
  Sébastien Toque
  Christophe Mutricy
  Yoann Peronneau
  Yohann Martineau
  Yuval Tze
  Scott Caudle
  Clément Stenac

It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 22:54:33 +01:00
Rémi Denis-Courmont 1252a5ebff Add helpers to store floats into vlc_atomic_t
(Lets assume that uintptr_t is big enough, i.e. 32-bits).
2011-08-09 18:33:46 +03:00
Rémi Denis-Courmont da9ea07cf7 Add VLC_ATOMIC_INIT, static initializer for vlc_atomic_t 2011-07-10 18:03:55 +03:00
Rémi Denis-Courmont 6f258887aa Replace VLC_EXPORT macro with a simple prefix, VLC_API
This should help Doxygen parse VLC headers, and generally makes headers
easier to read. LibVLC already uses a similar approach.
2011-05-07 18:43:51 +03:00
Rémi Denis-Courmont 59fb10d033 Add atomic swap and compare-and-swap 2010-10-13 19:20:29 +03:00
Rémi Denis-Courmont a9daba19eb Move vlc_atomic_t typedef to <vlc_common.h>
Then we don't always need to include <vlc_atomic.h>
2010-06-29 17:29:01 +03:00
Rémi Denis-Courmont 85a9ea3bac Atom: use volatile keyword 2010-06-29 17:29:01 +03:00
Rémi Denis-Courmont 34f3dfb172 Atomic operations (currently same ones as in garbage collector) 2010-06-28 02:13:33 +03:00