[vlc-devel] [RFC] Atomic API

Rémi Denis-Courmont remi at remlab.net
Fri Dec 6 14:23:07 CET 2013


Le jeudi 5 décembre 2013, 22:47:23 Felix Abecassis a écrit :
> 1) Fill the holes in the Interlocked API by implementing the missing
> functions. We could use locks similarly to what is currently being
> implemented in vlc_atomic.h when no builtin atomic operations are used.

Locks should only be used on architecture that do not have any atomic 
operations (or lack compare-exchange).

> 2) Replace the aforementioned occurrences of variables of type atomic_bool
> and use the type vlc_atomic_t instead. Some modules take this approach for
> similar variables. For instance android/thread.c has a variable
> "vlc_atomic_t killed;" whereas win32/thread.c uses "atomic_bool killed;".
> vlc_atomic_t uses the type uintptr_t (4 or 8 bytes).

No. vlc_atomic_t is the old deprecated interface just waiting for someone to 
remove it.

> 3) Disable atomic types of size 1 byte for this target. We could force the
> types atomic_bool/atomic_char... to be of a larger size. For instance with
> something like this:

If the target instructions set lacks 1-byte atomic operations (and some 
certainly do), that would be the logical solution. That's the whole point in 
having separate types defined for atomic and non-atomic variables.

But then, how is it that GCC is able to implement 1-byte atomic ops on the 
same architecture?

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list