From 43bb14e88612c217911af353e780595b40bed828 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 10 Jun 2018 21:22:41 +1000 Subject: [PATCH] Redo the encoding of error codes --- cmd/wuffs-c/internal/cgen/base/base-public.h | 9 +- cmd/wuffs-c/internal/cgen/cgen.go | 96 +++---- cmd/wuffs-c/internal/cgen/data.go | 2 +- example/gifplayer/gifplayer.c | 1 + example/zcat/zcat.c | 1 + fuzz/c/std/gif_fuzzer.c | 1 + fuzz/c/std/zlib_fuzzer.c | 1 + gen/c/base.c | 9 +- gen/c/std/adler32.c | 120 +++++---- gen/c/std/crc32.c | 120 +++++---- gen/c/std/deflate.c | 226 +++++++++------- gen/c/std/gif.c | 197 +++++++------- gen/c/std/gzip.c | 249 +++++++++--------- gen/c/std/lzw.c | 128 ++++----- gen/c/std/zlib.c | 257 ++++++++++--------- gen/h/std/adler32.h | 47 ++-- gen/h/std/crc32.h | 47 ++-- gen/h/std/deflate.h | 82 +++--- gen/h/std/gif.h | 105 ++++---- gen/h/std/gzip.h | 166 ++++++------ gen/h/std/lzw.h | 51 ++-- gen/h/std/zlib.h | 168 ++++++------ test/c/std/adler32.c | 1 + test/c/std/crc32.c | 1 + test/c/std/deflate.c | 1 + test/c/std/gif.c | 1 + test/c/std/gzip.c | 1 + test/c/std/lzw.c | 1 + test/c/std/zlib.c | 1 + 29 files changed, 1069 insertions(+), 1021 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/base/base-public.h b/cmd/wuffs-c/internal/cgen/base/base-public.h index b0cb2939..37aff608 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-public.h +++ b/cmd/wuffs-c/internal/cgen/base/base-public.h @@ -55,7 +55,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; // !! INSERT wuffs_base__status names. diff --git a/cmd/wuffs-c/internal/cgen/cgen.go b/cmd/wuffs-c/internal/cgen/cgen.go index e0bac61a..7d19923c 100644 --- a/cmd/wuffs-c/internal/cgen/cgen.go +++ b/cmd/wuffs-c/internal/cgen/cgen.go @@ -122,29 +122,6 @@ func Do(args []string) error { }) } -const ( - maxNamespacedStatusCode = 255 - statusCodeNamespaceMask = 1< maxNamespacedStatusCode { - panic("too many built-in statuses") - } -} - type replacementPolicy bool const ( @@ -168,6 +145,7 @@ const ( type status struct { name string + value int8 msg string keyword t.ID } @@ -225,7 +203,7 @@ func insertBasePublicH(buf *buffer) error { for _, z := range builtin.StatusList { code := int32(z.Value) << 24 b.printf("#define %s %d // 0x%08X\n", - strings.ToUpper(cName(z.String(), "wuffs_base__")), code, uint32(code)) + strings.ToUpper(cName(z.String(), "WUFFS_BASE__")), code, uint32(code)) } b.writes("\n") return nil @@ -346,34 +324,29 @@ func (g *gen) genHeader(b *buffer) error { b.writes("\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n") b.writes("// ---------------- Status Codes\n\n") - b.writes(statusCodeDescription) - b.printf("//\n// Do not manipulate these bits directly; they are private implementation\n"+ - "// details. Use methods such as %sstatus__is_error instead.\n", g.pkgPrefix) b.printf("typedef int32_t %sstatus;\n\n", g.pkgPrefix) pkgID := g.checker.PackageID() b.printf("#define %spackageid %d // 0x%08X\n\n", g.pkgPrefix, pkgID, pkgID) - for i, z := range builtin.StatusList { - code := uint32(0) + for _, z := range builtin.StatusList { + name := z.Message if z.Keyword == t.IDError { - code |= 1 << 31 + name = "error " + name + } else if z.Keyword == t.IDSuspension { + name = "suspension " + name + } else { + name = "status " + name } - code |= uint32(i) - b.printf("#define %s %d // 0x%08X\n", strings.ToUpper(g.cName(z.String())), int32(code), code) + code := int32(z.Value) << 24 + b.printf("#define %s %d // 0x%08X\n", + strings.ToUpper(cName(name, g.PKGPREFIX)), code, uint32(code)) } b.writes("\n") - if len(g.statusList) > maxNamespacedStatusCode { - return fmt.Errorf("too many status codes") - } - for i, s := range g.statusList { - code := pkgID << statusCodeNamespaceShift - if s.keyword == t.IDError { - code |= 1 << 31 - } - code |= uint32(i) - b.printf("#define %s %d // 0x%08X\n", s.name, int32(code), code) + for _, s := range g.statusList { + code := (int32(s.value) << 24) | int32(pkgID) + b.printf("#define %s %d // 0x%08X\n", s.name, code, uint32(code)) } b.writes("\n") @@ -414,30 +387,28 @@ func (g *gen) genHeader(b *buffer) error { func (g *gen) genImpl(b *buffer) error { b.writes("#ifndef WUFFS_BASE_PRIVATE_H\n#define WUFFS_BASE_PRIVATE_H\n\n") b.writes(basePrivateH) - b.writes("\n") - b.printf("static const char* wuffs_base__status__strings[%d] = {\n", len(builtin.StatusList)) - for _, z := range builtin.StatusList { - b.printf("%q,", z.Message) - } - b.writes("};\n\n") b.writes("#endif // WUFFS_BASE_PRIVATE_H\n\n") b.writes("// ---------------- Status Codes Implementations\n\n") b.printf("bool %sstatus__is_error(%sstatus s) { return s < 0; }\n\n", g.pkgPrefix, g.pkgPrefix) - b.printf("const char* %sstatus__strings[%d] = {\n", g.pkgPrefix, len(g.statusList)) - for _, s := range g.statusList { - b.printf("%q,", g.pkgName+": "+s.msg) + { + messages := [256]string{} + for _, s := range g.statusList { + messages[uint8(s.value)] = g.pkgName + ": " + s.msg + } + if err := genStatusStringData(b, g.pkgPrefix, &messages); err != nil { + return err + } } - b.writes("};\n\n") b.printf("const char* %sstatus__string(%sstatus s) {\n", g.pkgPrefix, g.pkgPrefix) - b.printf("const char** a = NULL;\n") - b.printf("uint32_t n = 0;\n") - b.printf("switch ((s >> %d) & 0x%X) {\n", statusCodeNamespaceShift, statusCodeNamespaceMask) - b.printf("case 0: a = wuffs_base__status__strings; n = %d; break;\n", len(builtin.StatusList)) - b.printf("case %spackageid: a = %sstatus__strings; n = %d; break;\n", - g.pkgPrefix, g.pkgPrefix, len(g.statusList)) + b.printf("uint16_t o;") + b.printf("switch (s & 0x%X) {\n", (1<> 24)];\n", g.pkgPrefix) + b.printf("if (o) { return %sstatus__string_data + o; } break;\n", g.pkgPrefix) for _, u := range g.usesList { // TODO: is path.Base always correct? Should we check // validName(packageName)? @@ -445,8 +416,8 @@ func (g *gen) genImpl(b *buffer) error { b.printf("case wuffs_%s__packageid: return wuffs_%s__status__string(s);\n", useePkgName, useePkgName) } b.printf("}\n") - b.printf("uint32_t i = s & 0x%X;\n", 1< 0;\n}\n\nconst char* wuffs_base__status__string(wuffs_base__status s);\n\n" + + "// --------\n\n// A status code is either zero (OK), positive (a recoverable suspension or\n// pause in processing) or negative (a non-recoverable error). Its bits:\n// - bit 31 (the sign bit) indicates unrecoverable-ness: an error.\n// - bits 30 .. 24 are a package-namespaced numeric code\n// - bits 23 .. 21 are reserved.\n// - bits 20 .. 0 are the packageid (a namespace) as a base38 value.\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__status__is_error instead.\ntypedef int32_t wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline bool wuffs_base__status__is_error(wuffs_base__status s) {\n return s < 0;\n}\n\nstatic inline bool wuffs_base__status__is_ok(wuffs_base__status s) {\n return s == 0;\n}\n\nstatic inline bool wuffs_base__status__is_suspension(wuffs_base__status s) {\n return s > 0;\n}\n\nconst char* wuffs_base__status__string(wuffs_base__status s);\n\n" + "" + "// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" + "" + diff --git a/example/gifplayer/gifplayer.c b/example/gifplayer/gifplayer.c index 73f92072..6105375d 100644 --- a/example/gifplayer/gifplayer.c +++ b/example/gifplayer/gifplayer.c @@ -56,6 +56,7 @@ uint64_t micros_since_start(struct timespec* now) { // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../gen/c/base.c" #include "../../gen/c/std/gif.c" #include "../../gen/c/std/lzw.c" diff --git a/example/zcat/zcat.c b/example/zcat/zcat.c index d5a0d5c5..9da27c52 100644 --- a/example/zcat/zcat.c +++ b/example/zcat/zcat.c @@ -28,6 +28,7 @@ for a C compiler $cc, such as clang or gcc. // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../gen/c/base.c" #include "../../gen/c/std/crc32.c" #include "../../gen/c/std/deflate.c" #include "../../gen/c/std/gzip.c" diff --git a/fuzz/c/std/gif_fuzzer.c b/fuzz/c/std/gif_fuzzer.c index 22a6a408..1b908730 100644 --- a/fuzz/c/std/gif_fuzzer.c +++ b/fuzz/c/std/gif_fuzzer.c @@ -35,6 +35,7 @@ It should print "PASS", amongst other information, and exit(0). // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/gif.c" #include "../../../gen/c/std/lzw.c" #include "../fuzzlib/fuzzlib.c" diff --git a/fuzz/c/std/zlib_fuzzer.c b/fuzz/c/std/zlib_fuzzer.c index e6ab0926..64deaf61 100644 --- a/fuzz/c/std/zlib_fuzzer.c +++ b/fuzz/c/std/zlib_fuzzer.c @@ -35,6 +35,7 @@ It should print "PASS", amongst other information, and exit(0). // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/adler32.c" #include "../../../gen/c/std/deflate.c" #include "../../../gen/c/std/zlib.c" diff --git a/gen/c/base.c b/gen/c/base.c index 4f25308d..301cafcb 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -69,7 +69,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 780d4ab1..eb2e8e43 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,36 +1269,28 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_adler32__status__is_error instead. typedef int32_t wuffs_adler32__status; #define wuffs_adler32__packageid 681002 // 0x000A642A -#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 -#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 +#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_ADLER32__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_adler32__status__is_error(wuffs_adler32__status s); @@ -1890,25 +1889,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -1917,23 +1897,55 @@ bool wuffs_adler32__status__is_error(wuffs_adler32__status s) { return s < 0; } -const char* wuffs_adler32__status__strings[0] = {}; +static const char wuffs_adler32__status__string_data[] = { + 0x00, +}; + +static const uint16_t wuffs_adler32__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, +}; const char* wuffs_adler32__status__string(wuffs_adler32__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_adler32__packageid: - a = wuffs_adler32__status__strings; - n = 0; + o = wuffs_adler32__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_adler32__status__string_data + o; + } break; } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index d09a5d17..c9f6a9ea 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,35 +1269,27 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_crc32__status__is_error instead. typedef int32_t wuffs_crc32__status; #define wuffs_crc32__packageid 810620 // 0x000C5E7C -#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 -#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_CRC32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 +#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_CRC32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_CRC32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_crc32__status__is_error(wuffs_crc32__status s); @@ -1889,25 +1888,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -1916,23 +1896,55 @@ bool wuffs_crc32__status__is_error(wuffs_crc32__status s) { return s < 0; } -const char* wuffs_crc32__status__strings[0] = {}; +static const char wuffs_crc32__status__string_data[] = { + 0x00, +}; + +static const uint16_t wuffs_crc32__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, +}; const char* wuffs_crc32__status__string(wuffs_crc32__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_crc32__packageid: - a = wuffs_crc32__status__strings; - n = 0; + o = wuffs_crc32__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_crc32__status__string_data + o; + } break; } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index 90b37858..dd4350f6 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,66 +1269,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); @@ -1980,25 +1978,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -2007,41 +1986,110 @@ bool wuffs_deflate__status__is_error(wuffs_deflate__status s) { return s < 0; } -const char* wuffs_deflate__status__strings[17] = { - "deflate: bad Huffman code (over-subscribed)", - "deflate: bad Huffman code (under-subscribed)", - "deflate: bad Huffman code length count", - "deflate: bad Huffman code length repetition", - "deflate: bad Huffman code", - "deflate: bad Huffman minimum code length", - "deflate: bad block", - "deflate: bad distance", - "deflate: bad distance code count", - "deflate: bad literal/length code count", - "deflate: inconsistent stored block length", - "deflate: missing end-of-block code", - "deflate: no Huffman codes", - "deflate: internal error: inconsistent Huffman decoder state", - "deflate: internal error: inconsistent Huffman end_of_block", - "deflate: internal error: inconsistent distance", - "deflate: internal error: inconsistent n_bits", +static const char wuffs_deflate__status__string_data[] = { + 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, + 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, + 0x3A, 0x20, 0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, + 0x6E, 0x74, 0x20, 0x6E, 0x5F, 0x62, 0x69, 0x74, 0x73, 0x00, 0x64, 0x65, + 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, + 0x6E, 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, + 0x6E, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, + 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x64, 0x65, 0x66, + 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, + 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E, + 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x48, + 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x65, 0x6E, 0x64, 0x5F, 0x6F, + 0x66, 0x5F, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C, + 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, + 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E, 0x63, + 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x48, 0x75, + 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x64, 0x65, 0x63, 0x6F, 0x64, 0x65, + 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, + 0x61, 0x74, 0x65, 0x3A, 0x20, 0x6E, 0x6F, 0x20, 0x48, 0x75, 0x66, 0x66, + 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x64, 0x65, + 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x6D, 0x69, 0x73, 0x73, 0x69, + 0x6E, 0x67, 0x20, 0x65, 0x6E, 0x64, 0x2D, 0x6F, 0x66, 0x2D, 0x62, 0x6C, + 0x6F, 0x63, 0x6B, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x00, 0x64, 0x65, 0x66, + 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73, + 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x73, 0x74, 0x6F, 0x72, 0x65, + 0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6C, 0x65, 0x6E, 0x67, + 0x74, 0x68, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x6C, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6C, 0x2F, + 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, + 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, + 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x64, 0x69, 0x73, 0x74, 0x61, + 0x6E, 0x63, 0x65, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x63, 0x6F, 0x75, + 0x6E, 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, + 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, + 0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C, + 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, + 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x6D, 0x69, 0x6E, 0x69, 0x6D, 0x75, 0x6D, + 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, + 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, + 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, + 0x64, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, + 0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, + 0x72, 0x65, 0x70, 0x65, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x64, + 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, + 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, + 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x63, 0x6F, 0x75, 0x6E, + 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, + 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, + 0x6F, 0x64, 0x65, 0x20, 0x28, 0x75, 0x6E, 0x64, 0x65, 0x72, 0x2D, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, 0x29, 0x00, 0x64, + 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, + 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, + 0x20, 0x28, 0x6F, 0x76, 0x65, 0x72, 0x2D, 0x73, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x64, 0x29, 0x00, +}; + +static const uint16_t wuffs_deflate__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0001, 0x002E, 0x005D, 0x0098, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00D4, 0x00EE, 0x0111, 0x013B, 0x0162, 0x0183, 0x0199, 0x01AC, 0x01D5, + 0x01EF, 0x021B, 0x0242, 0x026F, }; const char* wuffs_deflate__status__string(wuffs_deflate__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_deflate__packageid: - a = wuffs_deflate__status__strings; - n = 17; + o = wuffs_deflate__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_deflate__status__string_data + o; + } break; } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 7dccdc0a..e67294bc 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,38 +1278,30 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_lzw__status__is_error instead. typedef int32_t wuffs_lzw__status; #define wuffs_lzw__packageid 1316776 // 0x001417A8 -#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 -#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_LZW__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_LZW__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 +#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_LZW__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_LZW__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_LZW__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_LZW__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_LZW__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_LZW__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_LZW__ERROR_BAD_CODE -799105024 // 0xD05EA000 -#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -799105023 // 0xD05EA001 +#define WUFFS_LZW__ERROR_BAD_CODE -15460440 // 0xFF1417A8 +#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -32237656 // 0xFE1417A8 bool wuffs_lzw__status__is_error(wuffs_lzw__status s); @@ -1381,45 +1380,37 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_gif__status__is_error instead. typedef int32_t wuffs_gif__status; #define wuffs_gif__packageid 1017222 // 0x000F8586 -#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 -#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GIF__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 +#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_GIF__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_GIF__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_GIF__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_GIF__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_GIF__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_GIF__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_GIF__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_GIF__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_GIF__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_GIF__ERROR_BAD_BLOCK -1105848320 // 0xBE161800 -#define WUFFS_GIF__ERROR_BAD_EXTENSION_LABEL -1105848319 // 0xBE161801 -#define WUFFS_GIF__ERROR_BAD_GRAPHIC_CONTROL -1105848318 // 0xBE161802 -#define WUFFS_GIF__ERROR_BAD_HEADER -1105848317 // 0xBE161803 -#define WUFFS_GIF__ERROR_BAD_LITERAL_WIDTH -1105848316 // 0xBE161804 -#define WUFFS_GIF__ERROR_NOT_ENOUGH_PIXEL_DATA -1105848315 // 0xBE161805 -#define WUFFS_GIF__ERROR_TOO_MUCH_PIXEL_DATA -1105848314 // 0xBE161806 +#define WUFFS_GIF__ERROR_BAD_BLOCK -15759994 // 0xFF0F8586 +#define WUFFS_GIF__ERROR_BAD_EXTENSION_LABEL -32537210 // 0xFE0F8586 +#define WUFFS_GIF__ERROR_BAD_GRAPHIC_CONTROL -49314426 // 0xFD0F8586 +#define WUFFS_GIF__ERROR_BAD_HEADER -66091642 // 0xFC0F8586 +#define WUFFS_GIF__ERROR_BAD_LITERAL_WIDTH -82868858 // 0xFB0F8586 +#define WUFFS_GIF__ERROR_NOT_ENOUGH_PIXEL_DATA -99646074 // 0xFA0F8586 +#define WUFFS_GIF__ERROR_TOO_MUCH_PIXEL_DATA -116423290 // 0xF90F8586 #define WUFFS_GIF__ERROR_INTERNAL_ERROR_INCONSISTENT_RI_WI \ - -1105848313 // 0xBE161807 + -1072724602 // 0xC00F8586 bool wuffs_gif__status__is_error(wuffs_gif__status s); @@ -2119,25 +2110,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -2146,30 +2118,73 @@ bool wuffs_gif__status__is_error(wuffs_gif__status s) { return s < 0; } -const char* wuffs_gif__status__strings[8] = { - "gif: bad block", "gif: bad extension label", - "gif: bad graphic control", "gif: bad header", - "gif: bad literal width", "gif: not enough pixel data", - "gif: too much pixel data", "gif: internal error: inconsistent ri/wi", +static const char wuffs_gif__status__string_data[] = { + 0x00, 0x67, 0x69, 0x66, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, + 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E, + 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x72, + 0x69, 0x2F, 0x77, 0x69, 0x00, 0x67, 0x69, 0x66, 0x3A, 0x20, 0x74, 0x6F, + 0x6F, 0x20, 0x6D, 0x75, 0x63, 0x68, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6C, + 0x20, 0x64, 0x61, 0x74, 0x61, 0x00, 0x67, 0x69, 0x66, 0x3A, 0x20, 0x6E, + 0x6F, 0x74, 0x20, 0x65, 0x6E, 0x6F, 0x75, 0x67, 0x68, 0x20, 0x70, 0x69, + 0x78, 0x65, 0x6C, 0x20, 0x64, 0x61, 0x74, 0x61, 0x00, 0x67, 0x69, 0x66, + 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x6C, 0x69, 0x74, 0x65, 0x72, 0x61, + 0x6C, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00, 0x67, 0x69, 0x66, 0x3A, + 0x20, 0x62, 0x61, 0x64, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, + 0x67, 0x69, 0x66, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x67, 0x72, 0x61, + 0x70, 0x68, 0x69, 0x63, 0x20, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, + 0x00, 0x67, 0x69, 0x66, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x65, 0x78, + 0x74, 0x65, 0x6E, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x6C, 0x61, 0x62, 0x65, + 0x6C, 0x00, 0x67, 0x69, 0x66, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x00, +}; + +static const uint16_t wuffs_gif__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0029, 0x0042, 0x005D, + 0x0074, 0x0084, 0x009D, 0x00B6, }; const char* wuffs_gif__status__string(wuffs_gif__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_gif__packageid: - a = wuffs_gif__status__strings; - n = 8; + o = wuffs_gif__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_gif__status__string_data + o; + } break; case wuffs_lzw__packageid: return wuffs_lzw__status__string(s); } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 969f1e4c..6684d436 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,35 +1278,27 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_crc32__status__is_error instead. typedef int32_t wuffs_crc32__status; #define wuffs_crc32__packageid 810620 // 0x000C5E7C -#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 -#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_CRC32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 +#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_CRC32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_CRC32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_crc32__status__is_error(wuffs_crc32__status s); @@ -1366,66 +1365,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); @@ -1543,40 +1533,32 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_gzip__status__is_error instead. typedef int32_t wuffs_gzip__status; #define wuffs_gzip__packageid 1041911 // 0x000FE5F7 -#define WUFFS_GZIP__STATUS_OK 0 // 0x00000000 -#define WUFFS_GZIP__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GZIP__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GZIP__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_GZIP__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_GZIP__STATUS_OK 0 // 0x00000000 +#define WUFFS_GZIP__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_GZIP__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_GZIP__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_GZIP__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_GZIP__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_GZIP__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_GZIP__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_GZIP__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_GZIP__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_GZIP__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_GZIP__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_GZIP__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_GZIP__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_GZIP__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_GZIP__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_GZIP__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_GZIP__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_GZIP__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_GZIP__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_GZIP__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -1080566784 // 0xBF97DC00 -#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -1080566783 // 0xBF97DC01 -#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -1080566782 // 0xBF97DC02 -#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566781 // 0xBF97DC03 +#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -15735305 // 0xFF0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -32512521 // 0xFE0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -49289737 // 0xFD0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_HEADER -66066953 // 0xFC0FE5F7 bool wuffs_gzip__status__is_error(wuffs_gzip__status s); @@ -2192,25 +2174,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -2219,32 +2182,66 @@ bool wuffs_gzip__status__is_error(wuffs_gzip__status s) { return s < 0; } -const char* wuffs_gzip__status__strings[4] = { - "gzip: bad checksum", - "gzip: bad compression method", - "gzip: bad encoding flags", - "gzip: bad header", +static const char wuffs_gzip__status__string_data[] = { + 0x00, 0x67, 0x7A, 0x69, 0x70, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x67, 0x7A, 0x69, 0x70, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, + 0x20, 0x66, 0x6C, 0x61, 0x67, 0x73, 0x00, 0x67, 0x7A, 0x69, 0x70, 0x3A, + 0x20, 0x62, 0x61, 0x64, 0x20, 0x63, 0x6F, 0x6D, 0x70, 0x72, 0x65, 0x73, + 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, + 0x67, 0x7A, 0x69, 0x70, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x63, 0x68, + 0x65, 0x63, 0x6B, 0x73, 0x75, 0x6D, 0x00, +}; + +static const uint16_t wuffs_gzip__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0001, 0x0012, 0x002B, 0x0048, }; const char* wuffs_gzip__status__string(wuffs_gzip__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_gzip__packageid: - a = wuffs_gzip__status__strings; - n = 4; + o = wuffs_gzip__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_gzip__status__string_data + o; + } break; case wuffs_crc32__packageid: return wuffs_crc32__status__string(s); case wuffs_deflate__packageid: return wuffs_deflate__status__string(s); } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index de7707bd..0c839ae6 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,38 +1269,30 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_lzw__status__is_error instead. typedef int32_t wuffs_lzw__status; #define wuffs_lzw__packageid 1316776 // 0x001417A8 -#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 -#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_LZW__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_LZW__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 +#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_LZW__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_LZW__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_LZW__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_LZW__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_LZW__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_LZW__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_LZW__ERROR_BAD_CODE -799105024 // 0xD05EA000 -#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -799105023 // 0xD05EA001 +#define WUFFS_LZW__ERROR_BAD_CODE -15460440 // 0xFF1417A8 +#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -32237656 // 0xFE1417A8 bool wuffs_lzw__status__is_error(wuffs_lzw__status s); @@ -1913,25 +1912,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -1940,26 +1920,58 @@ bool wuffs_lzw__status__is_error(wuffs_lzw__status s) { return s < 0; } -const char* wuffs_lzw__status__strings[2] = { - "lzw: bad code", - "lzw: cyclical prefix chain", +static const char wuffs_lzw__status__string_data[] = { + 0x00, 0x6C, 0x7A, 0x77, 0x3A, 0x20, 0x63, 0x79, 0x63, 0x6C, 0x69, + 0x63, 0x61, 0x6C, 0x20, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x20, + 0x63, 0x68, 0x61, 0x69, 0x6E, 0x00, 0x6C, 0x7A, 0x77, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x00, +}; + +static const uint16_t wuffs_lzw__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0001, 0x001C, }; const char* wuffs_lzw__status__string(wuffs_lzw__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_lzw__packageid: - a = wuffs_lzw__status__strings; - n = 2; + o = wuffs_lzw__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_lzw__status__string_data + o; + } break; } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 516777d1..2ba7fbfb 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,36 +1278,28 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_adler32__status__is_error instead. typedef int32_t wuffs_adler32__status; #define wuffs_adler32__packageid 681002 // 0x000A642A -#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 -#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 +#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_ADLER32__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_adler32__status__is_error(wuffs_adler32__status s); @@ -1367,66 +1366,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); @@ -1544,42 +1534,34 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_zlib__status__is_error instead. typedef int32_t wuffs_zlib__status; #define wuffs_zlib__packageid 2064249 // 0x001F7F79 -#define WUFFS_ZLIB__STATUS_OK 0 // 0x00000000 -#define WUFFS_ZLIB__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ZLIB__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ZLIB__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ZLIB__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ZLIB__STATUS_OK 0 // 0x00000000 +#define WUFFS_ZLIB__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ZLIB__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ZLIB__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ZLIB__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ZLIB__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ZLIB__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ZLIB__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ZLIB__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ZLIB__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ZLIB__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ZLIB__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_ZLIB__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_ZLIB__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ZLIB__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ZLIB__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ZLIB__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ZLIB__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_ZLIB__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -33692672 // 0xFDFDE400 -#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -33692671 // 0xFDFDE401 -#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -33692670 // 0xFDFDE402 -#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -33692669 // 0xFDFDE403 +#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -14712967 // 0xFF1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -31490183 // 0xFE1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -48267399 // 0xFD1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -65044615 // 0xFC1F7F79 #define WUFFS_ZLIB__ERROR_TODO_UNSUPPORTED_PRESET_DICTIONARY \ - -33692668 // 0xFDFDE404 + -1071677575 // 0xC01F7F79 bool wuffs_zlib__status__is_error(wuffs_zlib__status s); @@ -2191,25 +2173,6 @@ static inline wuffs_base__empty_struct wuffs_base__io_writer__set_mark( o->private_impl.bounds[0] = mark; return ((wuffs_base__empty_struct){}); } - -static const char* wuffs_base__status__strings[15] = { - "ok", - "bad wuffs version", - "bad sizeof receiver", - "bad receiver", - "bad argument", - "check_wuffs_version not called", - "check_wuffs_version called twice", - "invalid I/O operation", - "closed for writes", - "unexpected EOF", - "short read", - "short write", - "cannot return a suspension", - "invalid call sequence", - "end of data", -}; - #endif // WUFFS_BASE_PRIVATE_H // ---------------- Status Codes Implementations @@ -2218,33 +2181,71 @@ bool wuffs_zlib__status__is_error(wuffs_zlib__status s) { return s < 0; } -const char* wuffs_zlib__status__strings[5] = { - "zlib: bad checksum", - "zlib: bad compression method", - "zlib: bad compression window size", - "zlib: bad parity check", - "zlib: TODO: unsupported preset dictionary", +static const char wuffs_zlib__status__string_data[] = { + 0x00, 0x7A, 0x6C, 0x69, 0x62, 0x3A, 0x20, 0x54, 0x4F, 0x44, 0x4F, 0x3A, + 0x20, 0x75, 0x6E, 0x73, 0x75, 0x70, 0x70, 0x6F, 0x72, 0x74, 0x65, 0x64, + 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x74, 0x20, 0x64, 0x69, 0x63, 0x74, + 0x69, 0x6F, 0x6E, 0x61, 0x72, 0x79, 0x00, 0x7A, 0x6C, 0x69, 0x62, 0x3A, + 0x20, 0x62, 0x61, 0x64, 0x20, 0x70, 0x61, 0x72, 0x69, 0x74, 0x79, 0x20, + 0x63, 0x68, 0x65, 0x63, 0x6B, 0x00, 0x7A, 0x6C, 0x69, 0x62, 0x3A, 0x20, + 0x62, 0x61, 0x64, 0x20, 0x63, 0x6F, 0x6D, 0x70, 0x72, 0x65, 0x73, 0x73, + 0x69, 0x6F, 0x6E, 0x20, 0x77, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x20, 0x73, + 0x69, 0x7A, 0x65, 0x00, 0x7A, 0x6C, 0x69, 0x62, 0x3A, 0x20, 0x62, 0x61, + 0x64, 0x20, 0x63, 0x6F, 0x6D, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6F, + 0x6E, 0x20, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x7A, 0x6C, 0x69, + 0x62, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6B, + 0x73, 0x75, 0x6D, 0x00, +}; + +static const uint16_t wuffs_zlib__status__string_offsets[] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x002B, 0x0042, 0x0064, 0x0081, }; const char* wuffs_zlib__status__string(wuffs_zlib__status s) { - const char** a = NULL; - uint32_t n = 0; - switch ((s >> 10) & 0x1FFFFF) { + uint16_t o; + switch (s & 0x1FFFFF) { case 0: - a = wuffs_base__status__strings; - n = 15; - break; + return wuffs_base__status__string(s); case wuffs_zlib__packageid: - a = wuffs_zlib__status__strings; - n = 5; + o = wuffs_zlib__status__string_offsets[(uint8_t)(s >> 24)]; + if (o) { + return wuffs_zlib__status__string_data + o; + } break; case wuffs_adler32__packageid: return wuffs_adler32__status__string(s); case wuffs_deflate__packageid: return wuffs_deflate__status__string(s); } - uint32_t i = s & 0xFF; - return i < n ? a[i] : "unknown status"; + return "unknown status"; } // ---------------- Private Consts diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 19c21780..5f822b44 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,36 +1269,28 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_adler32__status__is_error instead. typedef int32_t wuffs_adler32__status; #define wuffs_adler32__packageid 681002 // 0x000A642A -#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 -#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 +#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_ADLER32__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_adler32__status__is_error(wuffs_adler32__status s); diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index f8c07784..09a447f0 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,35 +1269,27 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_crc32__status__is_error instead. typedef int32_t wuffs_crc32__status; #define wuffs_crc32__packageid 810620 // 0x000C5E7C -#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 -#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_CRC32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 +#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_CRC32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_CRC32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_crc32__status__is_error(wuffs_crc32__status s); diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index 8dc5e7f3..351f958b 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,66 +1269,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index f987c763..1e1a1730 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,38 +1278,30 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_lzw__status__is_error instead. typedef int32_t wuffs_lzw__status; #define wuffs_lzw__packageid 1316776 // 0x001417A8 -#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 -#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_LZW__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_LZW__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 +#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_LZW__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_LZW__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_LZW__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_LZW__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_LZW__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_LZW__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_LZW__ERROR_BAD_CODE -799105024 // 0xD05EA000 -#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -799105023 // 0xD05EA001 +#define WUFFS_LZW__ERROR_BAD_CODE -15460440 // 0xFF1417A8 +#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -32237656 // 0xFE1417A8 bool wuffs_lzw__status__is_error(wuffs_lzw__status s); @@ -1381,45 +1380,37 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_gif__status__is_error instead. typedef int32_t wuffs_gif__status; #define wuffs_gif__packageid 1017222 // 0x000F8586 -#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 -#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GIF__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 +#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_GIF__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_GIF__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_GIF__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_GIF__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_GIF__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_GIF__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_GIF__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_GIF__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_GIF__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_GIF__ERROR_BAD_BLOCK -1105848320 // 0xBE161800 -#define WUFFS_GIF__ERROR_BAD_EXTENSION_LABEL -1105848319 // 0xBE161801 -#define WUFFS_GIF__ERROR_BAD_GRAPHIC_CONTROL -1105848318 // 0xBE161802 -#define WUFFS_GIF__ERROR_BAD_HEADER -1105848317 // 0xBE161803 -#define WUFFS_GIF__ERROR_BAD_LITERAL_WIDTH -1105848316 // 0xBE161804 -#define WUFFS_GIF__ERROR_NOT_ENOUGH_PIXEL_DATA -1105848315 // 0xBE161805 -#define WUFFS_GIF__ERROR_TOO_MUCH_PIXEL_DATA -1105848314 // 0xBE161806 +#define WUFFS_GIF__ERROR_BAD_BLOCK -15759994 // 0xFF0F8586 +#define WUFFS_GIF__ERROR_BAD_EXTENSION_LABEL -32537210 // 0xFE0F8586 +#define WUFFS_GIF__ERROR_BAD_GRAPHIC_CONTROL -49314426 // 0xFD0F8586 +#define WUFFS_GIF__ERROR_BAD_HEADER -66091642 // 0xFC0F8586 +#define WUFFS_GIF__ERROR_BAD_LITERAL_WIDTH -82868858 // 0xFB0F8586 +#define WUFFS_GIF__ERROR_NOT_ENOUGH_PIXEL_DATA -99646074 // 0xFA0F8586 +#define WUFFS_GIF__ERROR_TOO_MUCH_PIXEL_DATA -116423290 // 0xF90F8586 #define WUFFS_GIF__ERROR_INTERNAL_ERROR_INCONSISTENT_RI_WI \ - -1105848313 // 0xBE161807 + -1072724602 // 0xC00F8586 bool wuffs_gif__status__is_error(wuffs_gif__status s); diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index b4aed4b0..9e403d54 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,35 +1278,27 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_crc32__status__is_error instead. typedef int32_t wuffs_crc32__status; #define wuffs_crc32__packageid 810620 // 0x000C5E7C -#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 -#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_CRC32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_CRC32__STATUS_OK 0 // 0x00000000 +#define WUFFS_CRC32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_CRC32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_CRC32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_CRC32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_CRC32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_CRC32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_CRC32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_CRC32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_CRC32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_CRC32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_CRC32__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_CRC32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_CRC32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_crc32__status__is_error(wuffs_crc32__status s); @@ -1366,66 +1365,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); @@ -1543,40 +1533,32 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_gzip__status__is_error instead. typedef int32_t wuffs_gzip__status; #define wuffs_gzip__packageid 1041911 // 0x000FE5F7 -#define WUFFS_GZIP__STATUS_OK 0 // 0x00000000 -#define WUFFS_GZIP__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GZIP__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GZIP__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_GZIP__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_GZIP__STATUS_OK 0 // 0x00000000 +#define WUFFS_GZIP__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_GZIP__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_GZIP__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_GZIP__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_GZIP__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_GZIP__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_GZIP__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_GZIP__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_GZIP__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_GZIP__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_GZIP__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_GZIP__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_GZIP__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_GZIP__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_GZIP__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_GZIP__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_GZIP__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_GZIP__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_GZIP__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_GZIP__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -1080566784 // 0xBF97DC00 -#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -1080566783 // 0xBF97DC01 -#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -1080566782 // 0xBF97DC02 -#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566781 // 0xBF97DC03 +#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -15735305 // 0xFF0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -32512521 // 0xFE0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -49289737 // 0xFD0FE5F7 +#define WUFFS_GZIP__ERROR_BAD_HEADER -66066953 // 0xFC0FE5F7 bool wuffs_gzip__status__is_error(wuffs_gzip__status s); diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index 5cdc8b15..07296641 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1262,38 +1269,30 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_lzw__status__is_error instead. typedef int32_t wuffs_lzw__status; #define wuffs_lzw__packageid 1316776 // 0x001417A8 -#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 -#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_LZW__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_LZW__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_LZW__STATUS_OK 0 // 0x00000000 +#define WUFFS_LZW__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_LZW__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_LZW__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_LZW__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_LZW__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_LZW__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_LZW__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_LZW__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_LZW__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_LZW__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_LZW__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_LZW__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_LZW__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_LZW__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_LZW__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_LZW__ERROR_BAD_CODE -799105024 // 0xD05EA000 -#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -799105023 // 0xD05EA001 +#define WUFFS_LZW__ERROR_BAD_CODE -15460440 // 0xFF1417A8 +#define WUFFS_LZW__ERROR_CYCLICAL_PREFIX_CHAIN -32237656 // 0xFE1417A8 bool wuffs_lzw__status__is_error(wuffs_lzw__status s); diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 3b844a2c..ec64315d 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -58,7 +58,14 @@ typedef struct { // -------- // A status code is either zero (OK), positive (a recoverable suspension or -// pause in processing) or negative (a non-recoverable error). +// pause in processing) or negative (a non-recoverable error). Its bits: +// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. +// - bits 30 .. 24 are a package-namespaced numeric code +// - bits 23 .. 21 are reserved. +// - bits 20 .. 0 are the packageid (a namespace) as a base38 value. +// +// Do not manipulate these bits directly; they are private implementation +// details. Use methods such as wuffs_base__status__is_error instead. typedef int32_t wuffs_base__status; #define WUFFS_BASE__STATUS_OK 0 // 0x00000000 @@ -1271,36 +1278,28 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_adler32__status__is_error instead. typedef int32_t wuffs_adler32__status; #define wuffs_adler32__packageid 681002 // 0x000A642A -#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 -#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ADLER32__STATUS_OK 0 // 0x00000000 +#define WUFFS_ADLER32__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ADLER32__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ADLER32__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ADLER32__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ADLER32__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_ADLER32__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ADLER32__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ADLER32__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ADLER32__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_ADLER32__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_ADLER32__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ADLER32__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 bool wuffs_adler32__status__is_error(wuffs_adler32__status s); @@ -1367,66 +1366,57 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_deflate__status__is_error instead. typedef int32_t wuffs_deflate__status; #define wuffs_deflate__packageid 848533 // 0x000CF295 -#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_DEFLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_DEFLATE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_DEFLATE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_DEFLATE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_DEFLATE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_DEFLATE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 11 // 0x0000000B + -285212672 // 0xEF000000 +#define WUFFS_DEFLATE__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_DEFLATE__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_DEFLATE__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 #define WUFFS_DEFLATE__ERROR_CANNOT_RETURN_A_SUSPENSION \ - -2147483636 // 0x8000000C -#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -536870912 // 0xE0000000 +#define WUFFS_DEFLATE__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_DEFLATE__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ - -1278585856 // 0xB3CA5400 + -15928683 // 0xFF0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_UNDER_SUBSCRIBED \ - -1278585855 // 0xB3CA5401 + -32705899 // 0xFE0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_COUNT \ - -1278585854 // 0xB3CA5402 + -49483115 // 0xFD0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE_LENGTH_REPETITION \ - -1278585853 // 0xB3CA5403 -#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -1278585852 // 0xB3CA5404 + -66260331 // 0xFC0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_CODE -83037547 // 0xFB0CF295 #define WUFFS_DEFLATE__ERROR_BAD_HUFFMAN_MINIMUM_CODE_LENGTH \ - -1278585851 // 0xB3CA5405 -#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -1278585850 // 0xB3CA5406 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -1278585849 // 0xB3CA5407 -#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -1278585848 // 0xB3CA5408 + -99814763 // 0xFA0CF295 +#define WUFFS_DEFLATE__ERROR_BAD_BLOCK -116591979 // 0xF90CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE -133369195 // 0xF80CF295 +#define WUFFS_DEFLATE__ERROR_BAD_DISTANCE_CODE_COUNT -150146411 // 0xF70CF295 #define WUFFS_DEFLATE__ERROR_BAD_LITERAL_LENGTH_CODE_COUNT \ - -1278585847 // 0xB3CA5409 + -166923627 // 0xF60CF295 #define WUFFS_DEFLATE__ERROR_INCONSISTENT_STORED_BLOCK_LENGTH \ - -1278585846 // 0xB3CA540A -#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE \ - -1278585845 // 0xB3CA540B -#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -1278585844 // 0xB3CA540C + -183700843 // 0xF50CF295 +#define WUFFS_DEFLATE__ERROR_MISSING_END_OF_BLOCK_CODE -200478059 // 0xF40CF295 +#define WUFFS_DEFLATE__ERROR_NO_HUFFMAN_CODES -217255275 // 0xF30CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE \ - -1278585843 // 0xB3CA540D + -1072893291 // 0xC00CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \ - -1278585842 // 0xB3CA540E + -1089670507 // 0xBF0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \ - -1278585841 // 0xB3CA540F + -1106447723 // 0xBE0CF295 #define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \ - -1278585840 // 0xB3CA5410 + -1123224939 // 0xBD0CF295 bool wuffs_deflate__status__is_error(wuffs_deflate__status s); @@ -1544,42 +1534,34 @@ extern "C" { // ---------------- Status Codes -// Status codes are int32_t values. Its bits: -// - bit 31 (the sign bit) indicates unrecoverable-ness: an error. -// - bits 30 .. 10 are the packageid: a namespace. -// - bits 9 .. 8 are reserved. -// - bits 7 .. 0 are a package-namespaced numeric code. -// -// Do not manipulate these bits directly; they are private implementation -// details. Use methods such as wuffs_zlib__status__is_error instead. typedef int32_t wuffs_zlib__status; #define wuffs_zlib__packageid 2064249 // 0x001F7F79 -#define WUFFS_ZLIB__STATUS_OK 0 // 0x00000000 -#define WUFFS_ZLIB__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_ZLIB__ERROR_BAD_SIZEOF_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_ZLIB__ERROR_BAD_RECEIVER -2147483645 // 0x80000003 -#define WUFFS_ZLIB__ERROR_BAD_ARGUMENT -2147483644 // 0x80000004 +#define WUFFS_ZLIB__STATUS_OK 0 // 0x00000000 +#define WUFFS_ZLIB__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000 +#define WUFFS_ZLIB__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000 +#define WUFFS_ZLIB__ERROR_BAD_RECEIVER -50331648 // 0xFD000000 +#define WUFFS_ZLIB__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000 #define WUFFS_ZLIB__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \ - -2147483643 // 0x80000005 + -268435456 // 0xF0000000 #define WUFFS_ZLIB__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \ - -2147483642 // 0x80000006 -#define WUFFS_ZLIB__ERROR_INVALID_I_O_OPERATION -2147483641 // 0x80000007 -#define WUFFS_ZLIB__ERROR_CLOSED_FOR_WRITES -2147483640 // 0x80000008 -#define WUFFS_ZLIB__ERROR_UNEXPECTED_EOF -2147483639 // 0x80000009 -#define WUFFS_ZLIB__SUSPENSION_SHORT_READ 10 // 0x0000000A -#define WUFFS_ZLIB__SUSPENSION_SHORT_WRITE 11 // 0x0000000B -#define WUFFS_ZLIB__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483636 // 0x8000000C -#define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D -#define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 14 // 0x0000000E + -285212672 // 0xEF000000 +#define WUFFS_ZLIB__ERROR_INVALID_I_O_OPERATION -805306368 // 0xD0000000 +#define WUFFS_ZLIB__ERROR_CLOSED_FOR_WRITES -1073741824 // 0xC0000000 +#define WUFFS_ZLIB__ERROR_UNEXPECTED_EOF -822083584 // 0xCF000000 +#define WUFFS_ZLIB__SUSPENSION_SHORT_READ 33554432 // 0x02000000 +#define WUFFS_ZLIB__SUSPENSION_SHORT_WRITE 50331648 // 0x03000000 +#define WUFFS_ZLIB__ERROR_CANNOT_RETURN_A_SUSPENSION -536870912 // 0xE0000000 +#define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -301989888 // 0xEE000000 +#define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 16777216 // 0x01000000 -#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -33692672 // 0xFDFDE400 -#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -33692671 // 0xFDFDE401 -#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -33692670 // 0xFDFDE402 -#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -33692669 // 0xFDFDE403 +#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -14712967 // 0xFF1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -31490183 // 0xFE1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -48267399 // 0xFD1F7F79 +#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -65044615 // 0xFC1F7F79 #define WUFFS_ZLIB__ERROR_TODO_UNSUPPORTED_PRESET_DICTIONARY \ - -33692668 // 0xFDFDE404 + -1071677575 // 0xC01F7F79 bool wuffs_zlib__status__is_error(wuffs_zlib__status s); diff --git a/test/c/std/adler32.c b/test/c/std/adler32.c index dba1e037..119ced1b 100644 --- a/test/c/std/adler32.c +++ b/test/c/std/adler32.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/adler32.c" #include "../testlib/testlib.c" #ifdef WUFFS_MIMIC diff --git a/test/c/std/crc32.c b/test/c/std/crc32.c index 889b132a..d602d8da 100644 --- a/test/c/std/crc32.c +++ b/test/c/std/crc32.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/crc32.c" #include "../testlib/testlib.c" #ifdef WUFFS_MIMIC diff --git a/test/c/std/deflate.c b/test/c/std/deflate.c index aabea65d..f0b73283 100644 --- a/test/c/std/deflate.c +++ b/test/c/std/deflate.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/deflate.c" #include "../testlib/testlib.c" #ifdef WUFFS_MIMIC diff --git a/test/c/std/gif.c b/test/c/std/gif.c index ed2f06b1..416ae57d 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/gif.c" #include "../../../gen/c/std/lzw.c" #include "../testlib/testlib.c" diff --git a/test/c/std/gzip.c b/test/c/std/gzip.c index 1fd78dfc..057254ae 100644 --- a/test/c/std/gzip.c +++ b/test/c/std/gzip.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/crc32.c" #include "../../../gen/c/std/deflate.c" #include "../../../gen/c/std/gzip.c" diff --git a/test/c/std/lzw.c b/test/c/std/lzw.c index 0a0af707..b3716539 100644 --- a/test/c/std/lzw.c +++ b/test/c/std/lzw.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/lzw.c" #include "../testlib/testlib.c" diff --git a/test/c/std/zlib.c b/test/c/std/zlib.c index 0d8fa249..54b58012 100644 --- a/test/c/std/zlib.c +++ b/test/c/std/zlib.c @@ -40,6 +40,7 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the // If building this program in an environment that doesn't easily accomodate // relative includes, you can use the script/inline-c-relative-includes.go // program to generate a stand-alone C file. +#include "../../../gen/c/base.c" #include "../../../gen/c/std/adler32.c" #include "../../../gen/c/std/deflate.c" #include "../../../gen/c/std/zlib.c"