mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Rename some I/O private methods
This commit is contained in:
1 parent
eb0cbd802a
commit
baf1b9f9e6
3 files changed
+135
-135
No files matched your search
@@ -61,20 +61,20 @@ wuffs_base__io_writer__is_valid(wuffs_base__io_writer o) {
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
if (!distance) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
if ((size_t)(ptr - start) < (size_t)(distance)) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
if ((size_t)(iop_w - start) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
start = ptr - distance;
|
||||
size_t n = end - ptr;
|
||||
start = iop_w - distance;
|
||||
size_t n = io1_w - iop_w;
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
} else {
|
||||
@@ -91,14 +91,14 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// Alternatively, or additionally, have a sloppy_copy_n_from_history method
|
||||
// that copies 8 bytes at a time, possibly writing more than length bytes?
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -106,84 +106,84 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// wuffs_base__io_writer__copy_n_from_history function above, but has stronger
|
||||
// pre-conditions. The caller needs to prove that:
|
||||
// - distance > 0
|
||||
// - distance <= (*ptr_ptr - start)
|
||||
// - length <= (end - *ptr_ptr)
|
||||
// - distance <= (*ptr_iop_w - start)
|
||||
// - length <= (io1_w - *ptr_iop_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
start = ptr - distance;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
start = iop_w - distance;
|
||||
uint32_t n = length;
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint8_t** ptr_ioptr_r,
|
||||
uint8_t* iobounds1_r) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t* io1_r) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
uint8_t* ioptr_r = *ptr_ioptr_r;
|
||||
if (n > ((size_t)(iobounds1_r - ioptr_r))) {
|
||||
n = iobounds1_r - ioptr_r;
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, ioptr_r, n);
|
||||
*ptr_ioptr_w += n;
|
||||
*ptr_ioptr_r += n;
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > length) {
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -191,8 +191,8 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ptr_iop,
|
||||
uint8_t** ptr_io1,
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t** ptr_io1_r,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = data.len;
|
||||
@@ -203,17 +203,17 @@ wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop = data.ptr;
|
||||
*ptr_io1 = data.ptr + data.len;
|
||||
*ptr_iop_r = data.ptr;
|
||||
*ptr_io1_r = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,
|
||||
uint8_t* ioptr_r,
|
||||
uint8_t* iop_r,
|
||||
uint64_t limit) {
|
||||
if (o && (((size_t)(o->private_impl.limit - ioptr_r)) > limit)) {
|
||||
o->private_impl.limit = ioptr_r + limit;
|
||||
if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {
|
||||
o->private_impl.limit = iop_r + limit;
|
||||
}
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
@@ -225,10 +225,10 @@ wuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
if (n <= ((size_t)(io1 - *ptr_iop))) {
|
||||
uint8_t* p = *ptr_iop;
|
||||
*ptr_iop += n;
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {
|
||||
if (n <= ((size_t)(io1_r - *ptr_iop_r))) {
|
||||
uint8_t* p = *ptr_iop_r;
|
||||
*ptr_iop_r += n;
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = p,
|
||||
.len = n,
|
||||
@@ -240,8 +240,8 @@ wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ioptr1_ptr,
|
||||
uint8_t** ioptr2_ptr,
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t** ptr_io1_w,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = 0;
|
||||
@@ -252,8 +252,8 @@ wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ioptr1_ptr = data.ptr;
|
||||
*ioptr2_ptr = data.ptr + data.len;
|
||||
*ptr_iop_w = data.ptr;
|
||||
*ptr_io1_w = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
|
||||
@@ -148,13 +148,13 @@ const baseImagePublicH = "" +
|
||||
const baseIOPrivateH = "" +
|
||||
"// ---------------- I/O\n\nstatic inline bool //\nwuffs_base__io_buffer__is_valid(wuffs_base__io_buffer buf) {\n return (buf.data.ptr || (buf.data.len == 0)) &&\n (buf.data.len >= buf.meta.wi) && (buf.meta.wi >= buf.meta.ri);\n}\n\n// TODO: wuffs_base__io_reader__is_eof is no longer used by Wuffs per se, but\n// it might be handy to programs that use Wuffs. Either delete it, or promote\n// it to the public API.\n//\n// If making this function public (i.e. moving it to base-header.h), it also\n// needs to allow NULL (i.e. implicit, callee-calculated) mark/limit.\n\nstatic inline bool //\nwuffs_base__io_reader__is_eof(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n return buf && buf->meta.closed &&\n (buf->data.ptr + buf->meta.wi == o.private_impl.limit);\n}\n\nstatic inline bool //\nwuffs_base__io_reader__is_valid(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also " +
|
||||
"needs to allow NULL (i.e. implicit, callee-calculated) mark/limit.\n return buf ? ((buf->data.ptr <= o.private_impl.mark) &&\n (o.private_impl.mark <= o.private_impl.limit) &&\n (o.private_impl.limit <= buf->data.ptr + buf->data.len))\n : ((o.private_impl.mark == NULL) &&\n (o.private_impl.limit == NULL));\n}\n\nstatic inline bool //\nwuffs_base__io_writer__is_valid(wuffs_base__io_writer o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also needs to allow NULL (i.e. implicit, callee-calculated) mark/limit.\n return buf ? ((buf->data.ptr <= o.private_impl.mark) &&\n (o.private_impl.mark <= o.private_impl.limit) &&\n (o.private_impl.limit <= buf->data.ptr + buf->data.len))\n : ((o.private_impl.mark == NULL) &&\n (o.private_impl.limit == NULL));\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history(uin" +
|
||||
"t8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t length,\n uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* ptr = *ptr_ptr;\n if ((size_t)(ptr - start) < (size_t)(distance)) {\n return 0;\n }\n start = ptr - distance;\n size_t n = end - ptr;\n if ((size_t)(length) > n) {\n length = n;\n } else {\n n = length;\n }\n // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that\n // is mostly because 3 is the minimum length for the deflate format. This\n // function implementation shouldn't overfit to that one format. Perhaps the\n // copy_n_from_history Wuffs method should also take an unroll hint argument,\n // and the cgen can look if that argument is the constant expression '3'.\n //\n // See also wuffs_base__io_writer__copy_n_from_history_fast below.\n //\n // Alternatively, or additionally, ha" +
|
||||
"ve a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_ptr - start)\n// - length <= (end - *ptr_ptr)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t length,\n uint32_t distance) {\n uint8_t* ptr = *ptr_ptr;\n start = ptr - distance;\n uint32_t n = length;\n fo" +
|
||||
"r (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n uint8_t** ptr_ioptr_r,\n uint8_t* iobounds1_r) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = length;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n uint8_t* ioptr_r = *ptr_ioptr_r;\n if (n > ((size_t)(iobounds1_r - ioptr_r))) {\n n = iobounds1_r - ioptr_r;\n }\n if (n > 0) {\n memmove(ioptr_w, ioptr_r, n);\n *ptr_ioptr_w += n;\n *ptr_ioptr_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_ioptr_w,\n u" +
|
||||
"int8_t* iobounds1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,\n uint8_t* iobounds1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* ioptr_w = *ptr_ioptr_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(iobounds1_w - ioptr_w))) {\n n = iobounds1_w - ioptr_w;\n }\n if (n > 0) {\n memmove(ioptr_w, src.ptr, n);\n *ptr_ioptr_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set(wuffs_base__io_reader* o,\n wuffs_base__io_buffer* b,\n " +
|
||||
" uint8_t** ptr_iop,\n uint8_t** ptr_io1,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop = data.ptr;\n *ptr_io1 = data.ptr + data.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* ioptr_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - ioptr_r)) > limit)) {\n o->private_impl.limit = ioptr_r + limit;\n }\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic " +
|
||||
"inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {\n if (n <= ((size_t)(io1 - *ptr_iop))) {\n uint8_t* p = *ptr_iop;\n *ptr_iop += n;\n return ((wuffs_base__slice_u8){\n .ptr = p,\n .len = n,\n });\n }\n return ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ioptr1_ptr,\n uint8_t** ioptr2_ptr,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ioptr1_ptr = data.ptr;\n *ioptr2_ptr = data.ptr + data.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__" +
|
||||
"io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\n" +
|
||||
"t8_t** ptr_iop_w,\n uint8_t* start,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* iop_w = *ptr_iop_w;\n if ((size_t)(iop_w - start) < (size_t)(distance)) {\n return 0;\n }\n start = iop_w - distance;\n size_t n = io1_w - iop_w;\n if ((size_t)(length) > n) {\n length = n;\n } else {\n n = length;\n }\n // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that\n // is mostly because 3 is the minimum length for the deflate format. This\n // function implementation shouldn't overfit to that one format. Perhaps the\n // copy_n_from_history Wuffs method should also take an unroll hint argument,\n // and the cgen can look if that argument is the constant expression '3'.\n //\n // See also wuffs_base__io_writer__copy_n_from_history_fast below.\n //\n // Alternatively, or " +
|
||||
"additionally, have a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *iop_w++ = *start++;\n *iop_w++ = *start++;\n *iop_w++ = *start++;\n }\n for (; n; n--) {\n *iop_w++ = *start++;\n }\n *ptr_iop_w = iop_w;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - start)\n// - length <= (io1_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,\n uint8_t* start,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* iop_w = *ptr_iop_w;\n start = i" +
|
||||
"op_w - distance;\n uint32_t n = length;\n for (; n >= 3; n -= 3) {\n *iop_w++ = *start++;\n *iop_w++ = *start++;\n *iop_w++ = *start++;\n }\n for (; n; n--) {\n *iop_w++ = *start++;\n }\n *ptr_iop_w = iop_w;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n uint8_t* io1_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io1_r - iop_r))) {\n n = io1_r - iop_r;\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io" +
|
||||
"1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set(wuffs_base__io_reader* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uin" +
|
||||
"t8_t** ptr_io1_r,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_r = data.ptr;\n *ptr_io1_r = data.ptr + data.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* iop_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {\n o->private_impl.limit = iop_r + limit;\n }\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** " +
|
||||
"ptr_iop_r, uint8_t* io1_r, uint64_t n) {\n if (n <= ((size_t)(io1_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return ((wuffs_base__slice_u8){\n .ptr = p,\n .len = n,\n });\n }\n return ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io1_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_w = data.ptr;\n *ptr_io1_w = data.ptr + data.len;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n" +
|
||||
" return ((wuffs_base__empty_struct){});\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- I/O (Utility)\n\nstatic inline wuffs_base__io_reader //\nwuffs_base__utility__null_io_reader(const wuffs_base__utility* ignored) {\n return ((wuffs_base__io_reader){});\n}\n\nstatic inline wuffs_base__io_writer //\nwuffs_base__utility__null_io_writer(const wuffs_base__utility* ignored) {\n return ((wuffs_base__io_writer){});\n}\n" +
|
||||
""
|
||||
|
||||
@@ -3684,20 +3684,20 @@ wuffs_base__io_writer__is_valid(wuffs_base__io_writer o) {
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
if (!distance) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
if ((size_t)(ptr - start) < (size_t)(distance)) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
if ((size_t)(iop_w - start) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
start = ptr - distance;
|
||||
size_t n = end - ptr;
|
||||
start = iop_w - distance;
|
||||
size_t n = io1_w - iop_w;
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
} else {
|
||||
@@ -3714,14 +3714,14 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// Alternatively, or additionally, have a sloppy_copy_n_from_history method
|
||||
// that copies 8 bytes at a time, possibly writing more than length bytes?
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -3729,84 +3729,84 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// wuffs_base__io_writer__copy_n_from_history function above, but has stronger
|
||||
// pre-conditions. The caller needs to prove that:
|
||||
// - distance > 0
|
||||
// - distance <= (*ptr_ptr - start)
|
||||
// - length <= (end - *ptr_ptr)
|
||||
// - distance <= (*ptr_iop_w - start)
|
||||
// - length <= (io1_w - *ptr_iop_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
start = ptr - distance;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
start = iop_w - distance;
|
||||
uint32_t n = length;
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint8_t** ptr_ioptr_r,
|
||||
uint8_t* iobounds1_r) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t* io1_r) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
uint8_t* ioptr_r = *ptr_ioptr_r;
|
||||
if (n > ((size_t)(iobounds1_r - ioptr_r))) {
|
||||
n = iobounds1_r - ioptr_r;
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, ioptr_r, n);
|
||||
*ptr_ioptr_w += n;
|
||||
*ptr_ioptr_r += n;
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > length) {
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -3814,8 +3814,8 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ptr_iop,
|
||||
uint8_t** ptr_io1,
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t** ptr_io1_r,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = data.len;
|
||||
@@ -3826,17 +3826,17 @@ wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop = data.ptr;
|
||||
*ptr_io1 = data.ptr + data.len;
|
||||
*ptr_iop_r = data.ptr;
|
||||
*ptr_io1_r = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,
|
||||
uint8_t* ioptr_r,
|
||||
uint8_t* iop_r,
|
||||
uint64_t limit) {
|
||||
if (o && (((size_t)(o->private_impl.limit - ioptr_r)) > limit)) {
|
||||
o->private_impl.limit = ioptr_r + limit;
|
||||
if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {
|
||||
o->private_impl.limit = iop_r + limit;
|
||||
}
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
@@ -3848,10 +3848,10 @@ wuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
if (n <= ((size_t)(io1 - *ptr_iop))) {
|
||||
uint8_t* p = *ptr_iop;
|
||||
*ptr_iop += n;
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {
|
||||
if (n <= ((size_t)(io1_r - *ptr_iop_r))) {
|
||||
uint8_t* p = *ptr_iop_r;
|
||||
*ptr_iop_r += n;
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = p,
|
||||
.len = n,
|
||||
@@ -3863,8 +3863,8 @@ wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ioptr1_ptr,
|
||||
uint8_t** ioptr2_ptr,
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t** ptr_io1_w,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = 0;
|
||||
@@ -3875,8 +3875,8 @@ wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ioptr1_ptr = data.ptr;
|
||||
*ioptr2_ptr = data.ptr + data.len;
|
||||
*ptr_iop_w = data.ptr;
|
||||
*ptr_io1_w = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user