Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The previous code was "probably fine" in practice, but was both missing some
necessary synchronization, and using unnecessarily heavyweight barriers on
Windows.
Since this code conveniently has a 1:1 relationship between barriers and atomic
accesses anyway, rewrite things to use an "atomic" interface closer to standard
C11 and C++11. Harden things in the process, so that the thread-safety
guarantees are followed, and hopefully clearer to see in the code (1
synchronized read of "their" index, then maybe 1 synchronized write of "your"
index).
Windows/MSVC annoyingly does not provide a suitable C API for this, so just
ignore the existence of Windows on ARM and use x86/x64 Windows intrinsics to
prevent compiler reordering (which is all that's required on those
architectures). Note that MSVC can make some reordering guarantees about
volatile variables, but:
* Only with a certain option, /volatile:ms, which Microsoft "strongly
recommend" against using. It is disabled by default (and painfully slow if
enabled) on ARM.
* This guarantee does not prevent reordering of access to other memory (only
the volatile variables themselves), which is required by a ring buffer.
So, deal with that case by using explicit read and write barriers like before,
but only in the atomic abstractions. In the process, switch to more
lightweight barriers, which should marginally improve performance on Windows.
When MSVC adds stdatomic.h support, most of the platform-specific gunk here can
go away entirely.
|
|
The compiler is surely smart enough to factor out these common expressions, but
I find this easier to read this way anyway.
|
|
|
|
It isn't necessary to branch here to avoid underflow. Essentially, the way
that unsigned binary integers work "automatically" does what this code was
doing.
Note that these expressions only work for a ring buffer that, like this one,
has a power of 2 (real) size and a maximum capacity 1 less than that.
|
|
I give in.
|
|
|
|
I can never decide between these two patterns for polymorphic objects in C, but
this one seems more appropriate here since it's more conducive to inheritance.
|
|
|
|
|
|
|
|
|
|
|
|
Add ZixChunk.
Add SSE 4.2 accelerated digest (with fallback) in zix/digest.h.
Make library optionally header-only (define ZIX_INLINE).
git-svn-id: http://svn.drobilla.net/zix/trunk@76 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
-Wmissing-prototypes.
git-svn-id: http://svn.drobilla.net/zix/trunk@72 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
git-svn-id: http://svn.drobilla.net/zix/trunk@51 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
Update waf.
git-svn-id: http://svn.drobilla.net/zix/trunk@50 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
Use a non-power-of-two message size in ZixRing test to test this.
git-svn-id: http://svn.drobilla.net/zix/trunk@43 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
git-svn-id: http://svn.drobilla.net/zix/trunk@14 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|
|
git-svn-id: http://svn.drobilla.net/zix/trunk@13 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
|