Redo the encoding of error codes

This commit is contained in:
Nigel Tao committed 2018-06-10 21:22:41 +10:00
1 parent 2ac2424e77
commit 43bb14e886
29 files changed
+1069 -1021

No files matched your search

+23 -24
View File
@@ -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);