mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 08:47:28 +01:00
1 parent
8ed5d1327b
commit
2142aa65fc
3 files changed
+88
-66
No files matched your search
@@ -190,6 +190,17 @@ wuffs_private_impl__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
|
||||
|
||||
// ---------------- Slices and Tables
|
||||
|
||||
// This function basically returns (ptr + len), except that that expression is
|
||||
// Undefined Behavior in C (but not C++) when ptr is NULL, even if len is zero.
|
||||
//
|
||||
// Precondition: (ptr != NULL) || (len == 0).
|
||||
static inline const uint8_t* //
|
||||
wuffs_private_impl__ptr_u8_plus_len(const uint8_t* ptr, size_t len) {
|
||||
return ptr ? (ptr + len) : NULL;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_private_impl__slice_u8__prefix returns up to the first up_to bytes of
|
||||
// s.
|
||||
static inline wuffs_base__slice_u8 //
|
||||
|
||||
@@ -748,18 +748,18 @@ func (g *gen) writeIterateRound(b *buffer, assigns []*a.Node, body []*a.Node, ro
|
||||
b.printf("%s%s.len = %d;\n", vPrefix, name, length)
|
||||
}
|
||||
name0 := assigns[0].AsAssign().LHS().Ident().Str(g.tm)
|
||||
b.printf("uint8_t* %send%d_%s = ", iPrefix, round, name0)
|
||||
b.printf("const uint8_t* %send%d_%s = wuffs_private_impl__ptr_u8_plus_len(", iPrefix, round, name0)
|
||||
if (length == 1) && (advance == 1) && (unroll == 1) {
|
||||
b.printf("%sslice_%s.ptr + %sslice_%s.len;\n",
|
||||
b.printf("%sslice_%s.ptr, %sslice_%s.len);\n",
|
||||
iPrefix, name0, iPrefix, name0)
|
||||
} else if length == advance {
|
||||
b.printf("%s%s.ptr + (((%sslice_%s.len - (size_t)(%s%s.ptr - %sslice_%s.ptr)) / %d) * %d);\n",
|
||||
b.printf("%s%s.ptr, (((%sslice_%s.len - (size_t)(%s%s.ptr - %sslice_%s.ptr)) / %d) * %d));\n",
|
||||
vPrefix, name0, iPrefix, name0,
|
||||
vPrefix, name0, iPrefix, name0,
|
||||
length*unroll, length*unroll)
|
||||
} else {
|
||||
b.printf("%s%s.ptr + wuffs_private_impl__iterate_total_advance("+
|
||||
"(%sslice_%s.len - (size_t)(%s%s.ptr - %sslice_%s.ptr)), %d, %d);\n",
|
||||
b.printf("%s%s.ptr, wuffs_private_impl__iterate_total_advance("+
|
||||
"(%sslice_%s.len - (size_t)(%s%s.ptr - %sslice_%s.ptr)), %d, %d));\n",
|
||||
vPrefix, name0, iPrefix, name0,
|
||||
vPrefix, name0, iPrefix, name0,
|
||||
length+(advance*(unroll-1)), advance*unroll)
|
||||
|
||||
Reference in new issue
Block a user