diff --git a/cmd/wuffs-c/internal/cgen/base/base-public.h b/cmd/wuffs-c/internal/cgen/base/base-public.h index b3d7cf89..03287af5 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-public.h +++ b/cmd/wuffs-c/internal/cgen/base/base-public.h @@ -28,9 +28,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index 8a694fb0..cd4dea39 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -17,9 +17,9 @@ package cgen const basePublicH = "" + - "#ifndef WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n#define WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n\n// Copyright 2017 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#include \n#include \n#include \n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64" + - " bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, 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()\", b" + - "ut in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n} wuffs_base__utility;\n\n" + + "#ifndef WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n#define WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n\n// Copyright 2017 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#include \n#include \n#include \n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#ifdef __WORDSIZE\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size " + + "of either 32 or 64 bits\"\n#endif\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, 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, y" + + "ou 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// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n} wuffs_base__utility;\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" + "" + diff --git a/gen/c/base.c b/gen/c/base.c index a61c4678..ad3dfa02 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -42,9 +42,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 18b11044..f9016d38 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 1f752206..2d967ee2 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index ab6da326..64aebe05 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 8d39db88..7e7f00f7 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 24bc04b7..e7182ac8 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index f29b3dcc..922314bf 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 69e3a94a..621efd79 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 7dd317c5..1a9b850d 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 9e3bf0b3..44df2678 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index ed7f3651..4f9c9cbb 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 7bfeae8f..3fbea65e 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index b71d06e3..fab2a792 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index 3238418a..5d6214f2 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 6080f737..9820fe08 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -31,9 +31,11 @@ extern "C" { // Wuffs assumes that: // - converting a uint32_t to a size_t will never overflow. // - converting a size_t to a uint64_t will never overflow. +#ifdef __WORDSIZE #if (__WORDSIZE != 32) && (__WORDSIZE != 64) #error "Wuffs requires a word size of either 32 or 64 bits" #endif +#endif // WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/, // as a uint64_t. The major number is the high 32 bits. The minor number is the