summaryrefslogtreecommitdiffstats
path: root/compat/atomics.h
Commit message (Collapse)AuthorAgeFilesLines
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-77/+0
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* build: allow compilation without any atomicswm42014-07-051-2/+13
| | | | | | | | | | | | | | | | | | | Not all compilers on all platforms have atomics available (even if they could, technically speaking). We don't use atomics that much, only the following things rely on it: 1. the audio pull code, and all audio outputs using it 2. updating global msg levels 3. reading log messages through the client API Just disable 1. and 3. if atomics are not available. For 2., using fake- atomics isn't too bad; at worst, message levels won't properly update under certain situations (but most likely, it will work just fine). This means if atomics are not available, the client API function mpv_request_log_messages() will do nothing. CC: @mpv-player/stable
* atomics: some corrections to __sync builtins usagewm42014-05-281-3/+3
| | | | | | | | | | | | We don't need to combine __sync_add_and_fetch with a memory barrier, since these intrinsics are documented as using a full barrier already. Use __sync_fetch_and_add instead of __sync_add_and_fetch; this gives atomic_fetch_add() the correct return value (although we don't use it). Use __sync_fetch_and_add to emulate atomic_load(). This should enforce the full barrier semantics better. (This trick is stolen from the FreeBSD based stdatomic.h emulation.)
* atomics: more correct usage of gcc/clang __atomic builtinswm42014-05-211-11/+15
| | | | | | | | | | | This should be more correct. The builtins were made to directly map to C11, and the way we use them is now relatively close to how gcc implements atomics in 4.9. In particular, we make use of the load and store builtins. I'm not entirely sure why gcc didn't support stdatomic.h in 4.8 already. Maybe support for the builtins was incomplete or broken - so there's a lot of room for doubt about the correctness of this.
* atomics: switch to C11 stdatomic.hwm42014-05-211-6/+36
| | | | | | | | | | | | | | | | | | | | | | | | | In my opinion, we shouldn't use atomics at all, but ok. This switches the mpv code to use C11 stdatomic.h, and for compilers that don't support stdatomic.h yet, we emulate the subset used by mpv using the builtins commonly provided by gcc and clang. This supersedes an earlier similar attempt by Kovensky. That attempt unfortunately relied on a big copypasted freebsd header (which also depended on much more highly compiler-specific functionality, defined reserved symbols, etc.), so it had to be NIH'ed. Some issues: - C11 says default initialization of atomics "produces a valid state", but it's not sure whether the stored value is really 0. But we rely on this. - I'm pretty sure our use of the __atomic... builtins is/was incorrect. We don't use atomic load/store intrinsics, and access stuff directly. - Our wrapper actually does stricter typechecking than the stdatomic.h implementation by gcc 4.9. We make the atomic types incompatible with normal types by wrapping them into structs. (The FreeBSD wrapper does the same.) - I couldn't test on MinGW.
* build: make configure fail if both __atomic and __sync are not availableStefano Pigozzi2014-01-011-1/+3
|
* compat: use __atomic operations instead of __sync, when presentAlessandro Ghedini2013-12-311-2/+9
| | | | | Fixes #434 Fixes #437
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-0/+23