Build: Fixed a few warnings.
unsigned INT64 -> UINT64
Build: Changed API for CAST_STRUCT_LITERAL().
Fixes build issues with some compilers.
Configure: Probe support for C99-style struct literal expressions.
In C99 the expression syntax was extended to allow struct literals
in expressions, provided that they are preceeded by a suitable cast.
Adds macro CAST_STRUCT_LITERAL(), and updates buffer.h to use it.
Potential fix for build failures on NT.
byte_buffer: added flags to control growth
The way the buffer growth (exponential or not) can now be controlled by
setting flags. Additionally there is a flag to toggle between standard
realloc and mexec_realloc. This will be used to allocate space for
generating machine code.
byte buffer: reorganize struct
The previous layout did lead to better code in small test cases,
however in most situations in Pike it is not benefitial. The new layout
makes checking the buffer space more expensive, but we only have to
update the destination pointer after writing data into the buffer.
byte_buffer: added APIs for set/get
This will be used for updating jmp instructions.
Build [C99]: Removed #include of <stdint.h>.
It doesn't seem to be used.
Fixes compilation issues on Solaris 8.
byte_buffer: added API for exact allocation size
In some situations we know almost for sure how much data we will write
into the buffer. In those situations we do not want to always allocate
power of 2 sized buffer. Instead, this new API allows growing the buffer
by exactly as many bytes as needed.
Some other small changes:
* added a bit of documentation.
* generate a fatal on size overflow only in debug mode.
buffer: added buffer_get_string
buffer_get_string returns a zero terminated string. This is used when
e.g. printing from a buffer to stderr.
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.
buffer: added _nothrow variants
This variant of buffer_ensure_space() will return 0 instead of
throwing an exception in OOM situation. It is sometimes easier to
handle this explicitly, than registering an exception handler.
buffer: added buffer_advance()
buffer: do not include pike_error
Including pike_error.h from within buffer.h creates all kinds of
problems. Since we only use it with debug enabled, we can move that code