From 86010a17e2304960707a19e9cc493b3ca6692a8f Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 10 Jun 2018 15:01:22 +1000 Subject: [PATCH] Add a wuffs_base__status type --- cmd/wuffs-c/internal/cgen/base/base-impl.c | 2 +- cmd/wuffs-c/internal/cgen/base/base-public.h | 24 ++++++++++++++++-- cmd/wuffs-c/internal/cgen/data.go | 8 +++--- gen/c/base.c | 26 +++++++++++++++++--- gen/c/std/adler32.c | 24 ++++++++++++++++-- gen/c/std/crc32.c | 24 ++++++++++++++++-- gen/c/std/deflate.c | 24 ++++++++++++++++-- gen/c/std/gif.c | 24 ++++++++++++++++-- gen/c/std/gzip.c | 24 ++++++++++++++++-- gen/c/std/lzw.c | 24 ++++++++++++++++-- gen/c/std/zlib.c | 24 ++++++++++++++++-- gen/h/std/adler32.h | 24 ++++++++++++++++-- gen/h/std/crc32.h | 24 ++++++++++++++++-- gen/h/std/deflate.h | 24 ++++++++++++++++-- gen/h/std/gif.h | 24 ++++++++++++++++-- gen/h/std/gzip.h | 24 ++++++++++++++++-- gen/h/std/lzw.h | 24 ++++++++++++++++-- gen/h/std/zlib.h | 24 ++++++++++++++++-- 18 files changed, 359 insertions(+), 37 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/base/base-impl.c b/cmd/wuffs-c/internal/cgen/base/base-impl.c index d55407f8..ae18068f 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-impl.c +++ b/cmd/wuffs-c/internal/cgen/base/base-impl.c @@ -18,6 +18,6 @@ // !! wuffs_base__status__string data goes here. -const char* wuffs_base__status__string(int32_t s) { +const char* wuffs_base__status__string(wuffs_base__status s) { return "unknown status"; } diff --git a/cmd/wuffs-c/internal/cgen/base/base-public.h b/cmd/wuffs-c/internal/cgen/base/base-public.h index 990c4790..ede9e3ee 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-public.h +++ b/cmd/wuffs-c/internal/cgen/base/base-public.h @@ -52,7 +52,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -61,7 +81,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index d859d960..1c541cb2 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -21,9 +21,11 @@ const basePublicH = "" + "as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The version extension\n// (such as \"\", \"beta\" or \"rc.1\") is part of the string representation (such as\n// \"1.2.3-beta\") but not the uint64_t representation.\n//\n// All three of major, minor and patch being zero means that this is a\n// work-in-progress version, not a release version, and has no backwards or\n// forwards compatibility guarantees.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_EXTENSION \"\"\n#define WUFFS_VERSION_STRING \"0.0.0\"\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g(" + ")\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n" + "" + - "// ---------------- Numeric Types\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" + + "// --------\n\n// A status code is either zero (OK), positive (a recoverable suspension or\n// pause in processing) or negative (a non-recoverable error).\ntypedef int32_t wuffs_base__status;\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\nstatic inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint8_t wuffs_base__u8__max(uint8_t x, uint8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__min(uint16_t x, uint16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__max(uint16_t x, uint16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__min(uint32_t x, uint32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__max(uint32_t x, uint32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__min(uint64_t x, uint64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__max(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\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" + + "" + + "// ---------------- Numeric Types\n\nstatic inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint8_t wuffs_base__u8__max(uint8_t x, uint8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__min(uint16_t x, uint16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__max(uint16_t x, uint16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__min(uint32_t x, uint32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__max(uint32_t x, uint32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__min(uint64_t x, uint64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__max(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\n\n" + "" + "// --------\n\n// Saturating arithmetic (sat_add, sat_sub) branchless bit-twiddling algorithms\n// are per https://locklessinc.com/articles/sat_arithmetic/\n//\n// It is important that the underlying types are unsigned integers, as signed\n// integer arithmetic overflow is undefined behavior in C.\n\nstatic inline uint8_t wuffs_base__u8__sat_add(uint8_t x, uint8_t y) {\n uint8_t res = x + y;\n res |= -(res < x);\n return res;\n}\n\nstatic inline uint8_t wuffs_base__u8__sat_sub(uint8_t x, uint8_t y) {\n uint8_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\nstatic inline uint16_t wuffs_base__u16__sat_add(uint16_t x, uint16_t y) {\n uint16_t res = x + y;\n res |= -(res < x);\n return res;\n}\n\nstatic inline uint16_t wuffs_base__u16__sat_sub(uint16_t x, uint16_t y) {\n uint16_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\nstatic inline uint32_t wuffs_base__u32__sat_add(uint32_t x, uint32_t y) {\n uint32_t res = x + y;\n res |= -(res < x);\n return res;\n}\n\nstatic inline uint32_t wuffs_base__u32__sat_sub(uint32_t x" + ", uint32_t y) {\n uint32_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\nstatic inline uint64_t wuffs_base__u64__sat_add(uint64_t x, uint64_t y) {\n uint64_t res = x + y;\n res |= -(res < x);\n return res;\n}\n\nstatic inline uint64_t wuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {\n uint64_t res = x - y;\n res &= -(res <= x);\n return res;\n}\n\n" + @@ -121,7 +123,7 @@ const basePrivateH = "" + "" const baseImplC = "" + - "// Copyright 2018 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// !! base-public.h goes here.\n\n// !! wuffs_base__status__string data goes here.\n\nconst char* wuffs_base__status__string(int32_t s) {\n return \"unknown status\";\n}\n" + + "// Copyright 2018 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// !! base-public.h goes here.\n\n// !! wuffs_base__status__string data goes here.\n\nconst char* wuffs_base__status__string(wuffs_base__status s) {\n return \"unknown status\";\n}\n" + "" type template_args_short_read struct { diff --git a/gen/c/base.c b/gen/c/base.c index f2cab935..d1ba034f 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -66,7 +66,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -75,7 +95,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; @@ -1227,6 +1247,6 @@ static inline wuffs_base__table_u8 wuffs_base__image_buffer__plane( #endif // WUFFS_BASE_PUBLIC_H -const char* wuffs_base__status__string(int32_t s) { +const char* wuffs_base__status__string(wuffs_base__status s) { return "unknown status"; } diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index a5d0a11d..f89f34d3 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index dec7c034..8b9e2a0b 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index c87f4a3e..3aff8435 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index fd3366aa..5f123f11 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 72e8f4a9..02c102fd 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index 60794350..f3bfa78e 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index bdf841a7..7ba51846 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 1fc09faa..1d02175c 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 80e6c945..6dd356f0 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index e23b6ecc..81f00b40 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 4b345e46..37a2a386 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index 009db986..000910fa 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index d31c076e..e79a723a 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y; diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 5af0a45c..23a1aec6 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -55,7 +55,27 @@ typedef struct { } wuffs_base__empty_struct; -// ---------------- Numeric Types +// -------- + +// A status code is either zero (OK), positive (a recoverable suspension or +// pause in processing) or negative (a non-recoverable error). +typedef int32_t wuffs_base__status; + +static inline bool wuffs_base__status__is_error(wuffs_base__status s) { + return s < 0; +} + +static inline bool wuffs_base__status__is_ok(wuffs_base__status s) { + return s == 0; +} + +static inline bool wuffs_base__status__is_suspension(wuffs_base__status s) { + return s > 0; +} + +const char* wuffs_base__status__string(wuffs_base__status s); + +// -------- // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks @@ -64,7 +84,7 @@ typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) -// -------- +// ---------------- Numeric Types static inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) { return x < y ? x : y;