mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add base.utility.cpu_arch_is_32_bit()
This commit is contained in:
1 parent
39e2044102
commit
4993f88a66
5 files changed
+43
-23
No files matched your search
@@ -132,6 +132,9 @@ func (g *gen) writeBuiltinCall(b *buffer, n *a.Expr, sideEffectsOnly bool, depth
|
||||
return g.writeBuiltinTokenWriter(b, recv, method.Ident(), n.Args(), depth)
|
||||
case t.IDUtility:
|
||||
switch method.Ident() {
|
||||
case t.IDCPUArchIs32Bit:
|
||||
b.writes("(sizeof(void*) == 4)")
|
||||
return nil
|
||||
case t.IDEmptyIOReader, t.IDEmptyIOWriter:
|
||||
if !g.currFunk.usesEmptyIOBuffer {
|
||||
g.currFunk.usesEmptyIOBuffer = true
|
||||
|
||||
@@ -271,6 +271,7 @@ var Funcs = []string{
|
||||
|
||||
// ---- utility
|
||||
|
||||
"utility.cpu_arch_is_32_bit() bool",
|
||||
"utility.empty_io_reader() io_reader",
|
||||
"utility.empty_io_writer() io_writer",
|
||||
"utility.empty_range_ii_u32() range_ii_u32",
|
||||
|
||||
+18
-16
@@ -624,14 +624,15 @@ const (
|
||||
|
||||
// -------- 0x200 block.
|
||||
|
||||
IDAdvance = ID(0x200)
|
||||
IDCPUArch = ID(0x201)
|
||||
IDInitialize = ID(0x202)
|
||||
IDLength = ID(0x203)
|
||||
IDReset = ID(0x204)
|
||||
IDSet = ID(0x205)
|
||||
IDUnroll = ID(0x206)
|
||||
IDUpdate = ID(0x207)
|
||||
IDAdvance = ID(0x200)
|
||||
IDCPUArch = ID(0x201)
|
||||
IDCPUArchIs32Bit = ID(0x202)
|
||||
IDInitialize = ID(0x203)
|
||||
IDLength = ID(0x204)
|
||||
IDReset = ID(0x205)
|
||||
IDSet = ID(0x206)
|
||||
IDUnroll = ID(0x207)
|
||||
IDUpdate = ID(0x208)
|
||||
|
||||
// TODO: range/rect methods like intersection and contains?
|
||||
|
||||
@@ -1045,14 +1046,15 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
|
||||
// -------- 0x200 block.
|
||||
|
||||
IDAdvance: "advance",
|
||||
IDCPUArch: "cpu_arch",
|
||||
IDInitialize: "initialize",
|
||||
IDLength: "length",
|
||||
IDReset: "reset",
|
||||
IDSet: "set",
|
||||
IDUnroll: "unroll",
|
||||
IDUpdate: "update",
|
||||
IDAdvance: "advance",
|
||||
IDCPUArch: "cpu_arch",
|
||||
IDCPUArchIs32Bit: "cpu_arch_is_32_bit",
|
||||
IDInitialize: "initialize",
|
||||
IDLength: "length",
|
||||
IDReset: "reset",
|
||||
IDSet: "set",
|
||||
IDUnroll: "unroll",
|
||||
IDUpdate: "update",
|
||||
|
||||
IDHighBits: "high_bits",
|
||||
IDLowBits: "low_bits",
|
||||
|
||||
@@ -22325,12 +22325,22 @@ wuffs_deflate__decoder__decode_blocks(
|
||||
}
|
||||
self->private_impl.f_end_of_block = false;
|
||||
while (true) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_status = wuffs_deflate__decoder__decode_huffman_fast64(self, a_dst, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
if (sizeof(void*) == 4) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_status = wuffs_deflate__decoder__decode_huffman_fast64(self, a_dst, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
} else {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_status = wuffs_deflate__decoder__decode_huffman_fast64(self, a_dst, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_error(&v_status)) {
|
||||
status = v_status;
|
||||
|
||||
@@ -258,7 +258,11 @@ pri func decoder.decode_blocks?(dst: base.io_writer, src: base.io_reader) {
|
||||
|
||||
this.end_of_block = false
|
||||
while true {
|
||||
status = this.decode_huffman_fast64!(dst: args.dst, src: args.src)
|
||||
if this.util.cpu_arch_is_32_bit() {
|
||||
status = this.decode_huffman_fast64!(dst: args.dst, src: args.src)
|
||||
} else {
|
||||
status = this.decode_huffman_fast64!(dst: args.dst, src: args.src)
|
||||
}
|
||||
if status.is_error() {
|
||||
return status
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user