Branch: Tag:


2016-12-29 15:02:29 by Arne Goedeke <>

New byte buffer

This new byte buffer implements a simple dynamic buffer. It aims to

* Provide a clean API.
* Convince the compiler to generate good code. In particular it tries
to avoid unnecessary loads and stores which are otherwise generated
due to the C aliasing rules. This is done using the STATIC_ASSUME(X)
macro, which declare !X as unreachable.
* Have the fast path (when the buffer has enough space) completely
inlined to allow the compiler to batch single byte writes to the
buffer into larger stores.

242:   # define UNREACHABLE(X) X   #endif    + #ifdef HAS___BUILTIN_ASSUME + # define STATIC_ASSUME(X) __builtin_assume(X) + #else + # define STATIC_ASSUME(X) do { if (!(X)) UNREACHABLE(); } while(0) + #endif +    #ifndef HAVE_WORKING_REALLOC_NULL   #define realloc(PTR, SZ) pike_realloc(PTR,SZ)   #endif