Add doc/note/zero-initialization.md

This commit is contained in:
Nigel Tao committed 2019-11-14 20:45:48 +11:00
1 parent cb7e9e0ce9
commit f10849d20b
4 files changed
+65 -32

No files matched your search

+2 -15
View File
@@ -109,21 +109,8 @@ extern "C" {
// that the buffer is contained by the receiver struct, as opposed to being
// passed as a separately allocated "work buffer".
//
// With or without this bit set, the Wuffs compiler still enforces that no
// reads or writes will overflow internal buffers' bounds. Even with this bit
// set, the Wuffs standard library also considers reading from an uninitialized
// buffer to be a bug, and strives to never do so, but unlike buffer overflows,
// it is not a bug class that the Wuffs compiler eliminates.
//
// For those paranoid about security, leave this bit unset, so that
// wuffs_foo__bar__initialize will initialize the entire struct value to zeroes
// (unless WUFFS_INITIALIZE__ALREADY_ZEROED is set).
//
// Setting this bit (avoiding a fixed-size cost) gives a small absolute
// improvement on micro-benchmarks, mostly noticable (in relative terms) only
// when the actual work to do (i.e. the input) is also small. Look for
// WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED in
// https://github.com/google/wuffs/blob/master/doc/benchmarks.md for numbers.
// For more detail, see:
// https://github.com/google/wuffs/blob/master/doc/note/zero-initialization.md
#define WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED \
((uint32_t)0x00000002)