News for hackers. Stuff that matters.
Re:I've been writing ring buffers wrong all these years by lorenzhs on Wednesday December 14, 2016 @05:36PM (#13180329)
That only works for compile time constants, though. With a power of two sized buffer you can just store the mask and decide how large you want your buffer to be at runtime.
Re:I've been writing ring buffers wrong all these years by _ihaque on Wednesday December 14, 2016 @07:32PM (#13181173)
libdivide (http://libdivide.com) implements similar logic at runtime
Re:I've been writing ring buffers wrong all these years by nullc on Thursday December 15, 2016 @04:42AM (#13183485)
You can also compute the optimization at runtime, same as the compiler does. Libtheora contains code for this, used for quantizing video data.