diff --git a/cmd/wuffs-c/internal/cgen/base-header.h b/cmd/wuffs-c/internal/cgen/base-header.h index 4924cc80..fdf6c975 100644 --- a/cmd/wuffs-c/internal/cgen/base-header.h +++ b/cmd/wuffs-c/internal/cgen/base-header.h @@ -565,6 +565,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -575,6 +576,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index f27240e7..a1f689a7 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -50,7 +50,8 @@ const baseHeader = "" + "in_inclusive_x, s.min_inclusive_x);\n r.min_inclusive_y =\n wuffs_base__u32__min(r.min_inclusive_y, s.min_inclusive_y);\n r.max_exclusive_x =\n wuffs_base__u32__max(r.max_exclusive_x, s.max_exclusive_x);\n r.max_exclusive_y =\n wuffs_base__u32__max(r.max_exclusive_y, s.max_exclusive_y);\n return r;\n}\n\nstatic inline uint32_t wuffs_base__rect_ie_u32__width(\n wuffs_base__rect_ie_u32 r) {\n return wuffs_base__u32__sat_sub(r.max_exclusive_x, r.min_inclusive_x);\n}\n\nstatic inline uint32_t wuffs_base__rect_ie_u32__height(\n wuffs_base__rect_ie_u32 r) {\n return wuffs_base__u32__sat_sub(r.max_exclusive_y, r.min_inclusive_y);\n}\n\n" + "" + "// ---------------- I/O\n\n// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length), plus\n// additional indexes into that buffer, plus an opened / closed flag.\n//\n// A value with all fields NULL or zero is a valid, empty buffer.\ntypedef struct {\n uint8_t* ptr; // Pointer.\n size_t len; // Length.\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n bool closed; // No further writes are expected.\n} wuffs_base__io_buffer;\n\n// wuffs_base__io_limit provides a limited view of a 1-dimensional byte stream:\n// its first N bytes. That N can be greater than a buffer's current read or\n// write capacity. N decreases naturally over time as bytes are read from or\n// written to the stream.\n//\n// A value with all fields NULL or zero is a valid, unlimited view.\ntypedef struct wuffs_base__io_limit {\n uint64_t* ptr_to_len; // Pointer to N.\n struct wuffs_base__io_limit* next; // Linked list of limits.\n} wuffs_base__io_limit;\n\ntypedef" + - " struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n wuffs_base__io_limit limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__io_reader;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n wuffs_base__io_limit limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__io_writer;\n\nstatic inline wuffs_base__io_reader wuffs_base__io_buffer__reader(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_reader ret = ((wuffs_base__io_reader){});\n if (buf) {\n ret.private_impl.buf = buf;\n }\n return ret;\n}\n\nstatic inline wuffs_base__io_writer wuffs_base__io_buffer__writer(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_writer ret = ((wuffs_base__io_writer){});\n if (buf) {\n ret.private_impl.buf = buf;\n }\n return ret;\n}\n\n" + + " struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n uint8_t* bounds[2];\n wuffs_base__io_limit limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__io_reader;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n uint8_t* bounds[2];\n wuffs_base__io_limit limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__io_writer;\n\nstatic inline wuffs_base__io_reader wuffs_base__io_buffer__reader(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_reader ret = ((wuffs_base__io_reader){});\n if (buf) {\n ret.private_impl.buf = buf;\n }\n return ret;\n}\n\nstatic inline wuffs_base__io_writer wuffs_base__io_buffer__writer(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_writer ret = ((wuffs_base__io_writer){});\n if (buf) {\n ret.private_im" + + "pl.buf = buf;\n }\n return ret;\n}\n\n" + "" + "// ---------------- Images\n\n// wuffs_base__pixel_format encodes the format of the bytes that constitute an\n// image frame's pixel data. Its bits:\n// - bit 31 is reserved.\n// - bits 30 .. 28 encodes color (and channel order, in terms of memory).\n// - bits 27 .. 26 are reserved.\n// - bits 25 .. 24 encodes transparency.\n// - bit 23 indicates big-endian/MSB-first (as opposed to little/LSB).\n// - bit 22 indicates floating point (as opposed to integer).\n// - bits 21 .. 20 are the number of planes, minus 1. Zero means packed.\n// - bits 19 .. 16 encodes the number of bits (depth) in an index value.\n// Zero means direct, not palette-indexed.\n// - bits 15 .. 12 encodes the number of bits (depth) in the 3rd channel.\n// - bits 11 .. 8 encodes the number of bits (depth) in the 2nd channel.\n// - bits 7 .. 4 encodes the number of bits (depth) in the 1st channel.\n// - bits 3 .. 0 encodes the number of bits (depth) in the 0th channel.\n//\n// The bit fields of a wuffs_base" + "__pixel_format are not independent. For\n// example, the number of planes should not be greater than the number of\n// channels. Similarly, bits 15..4 are unused (and should be zero) if bits\n// 31..24 (color and transparency) together imply only 1 channel (gray, no\n// alpha) and floating point samples should mean a bit depth of 16, 32 or 64.\n//\n// Formats hold between 1 and 4 channels. For example: Y (1 channel: gray), YA\n// (2 channels: gray and alpha), BGR (3 channels: blue, green, red) or CMYK (4\n// channels: cyan, magenta, yellow, black).\n//\n// For direct formats with N > 1 channels, those channels can be laid out in\n// either 1 (packed) or N (planar) planes. For example, RGBA data is usually\n// packed, but YUV data is usually planar, due to chroma subsampling (for\n// details, see the wuffs_base__pixel_subsampling type). For indexed formats,\n// the palette (always 256 × 4 bytes) holds up to 4 packed bytes of color data\n// per index value, and there is only 1 plane (for the index). The distance\n// between s" + diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 2e471560..0bc2d457 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 30fc91b1..9b6a27ba 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index d4c812ef..c69d0d39 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 81f08955..4d9210fe 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 112023ff..3066677c 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 4137cd2f..05ae0f19 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 913fe689..7ce88553 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 89fc7373..3f3236c1 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index 5d60df0b..ba5c3204 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 854c4779..b617b2b7 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index a38cedbe..cee3c787 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 6f8c7016..a3b9354d 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -568,6 +568,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl; @@ -578,6 +579,7 @@ typedef struct { // compatibility or safety guarantee if you do so. struct { wuffs_base__io_buffer* buf; + uint8_t* bounds[2]; wuffs_base__io_limit limit; uint8_t* mark; } private_impl;