The align trick used in duk_hbuffer_fixed uses a union which includes an
IEEE double for align-by-8. Also include a duk_uint64_t if available in
case double/integer align requirements differ.
* Convert memory helpers like duk_memcmp() to macros where possible: for some
reason automatic inlining with -Os doesn't do the right thing and the
footprint impact is over 1kB. The duk_memcmp() helper is an inlined
function because it returns a value and assertions would otherwise lead
to multiple evaluation of arguments.
* Differentiate between C99+ and "unsafe" call sites. For example, use
duk_memcpy() when the call site obeys C99+ restrictions, and
duk_memcpy_unsafe() when either pointer may be NULL when the size is zero.
Same for all helpers.
* Add internal wrappers also to DUK_MEMMOVE(), DUK_MEMSET(), and
DUK_MEMZERO().
* Use the wrappers everywhere for consistency: the zero-size cases will then
always be safe, and if the target is fine with invalid pointers in the zero
size case, the whole check can be omitted easily.
* Remove a few zero size checks as they're no longer necessary.
Add internal helpers to deal with undefined behavior cases explicitly.
When DUK_USE_ALLOW_UNDEFINED_BEHAVIOR is set, skip the (almost always
unnecessary) explicit checks to improve footprint and performance.
Also split duk_util_misc.c into a few better scoped files.
The cast from duk_hbuffer to duk_hbuffer_fixed seemingly increases alignment
requirement from 4 to 8 because duk_hbuffer_fixed is forced to pack to 8 bytes
(so that data following the buffer is properly aligned). However, because the
struct base pointer is always aligned by 8 when the platform requires alignment
by 8, the warning is harmless and can be avoided by casting through a void *.
When noreturn attribute is not available, avoid warnings by e.g. returning
dummy values (never actually used because of e.g. a longjmp) with the
DUK_WO_NORETURN() macro.