<div dir="ltr"><div>Hi,<br><br></div><div>In order to compile VLC with MSVC I recently implemented atomic operations in vlc_atomic.h using the Interlocked API <a href="(http://msdn.microsoft.com/en-us/library/sbhbke0y%28v=vs.110%29.aspx">(http://msdn.microsoft.com/en-us/library/windows/desktop/ms686360%28v=vs.85%29.aspx#interlocked_functions</a>).<br>

<br></div><div>However when compiling for WinRT we discovered some operations are not implemented for all types, for instance InterlockedExchange8 is only available for desktop apps. This mean we cannot currently provide an implementation of atomic load/store operations on char/bool types. Since some important files (stream_demux.c, picture_pool.c, variables.h and win32/thread.c) are using the atomic_bool type, we need a way to solve this problem.<br>

<br></div><div>I've found three options and I would like your opinion in order to decide which one is the best.<br><br></div><div>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.<br>

<br></div><div>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).<br>

<br></div><div>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:<br></div><div>#if defined (_MSC_VER)<br>

typedef int atomic_bool;<br></div><div>#else<br>typedef bool atomic_bool;<br></div><div>#endif<br></div><div>This approach could also be used if we encounter the same issue with a different target.<br><br></div><div>Cheers,<br>

</div><div><br>-- <br>Félix Abecassis<div><a href="http://felix.abecassis.me" target="_blank">http://felix.abecassis.me</a></div>
</div></div>