mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 00:38:14 +01:00
Remove unused byte-swapping functions
This commit is contained in:
1 parent
c3ef038c79
commit
94c054a341
3 files changed
-76
No files matched your search
@@ -261,43 +261,6 @@ wuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// Clang also defines "__GNUC__".
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__u16__byte_swapped(uint16_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap16(x);
|
||||
#else
|
||||
return (x >> 8) | (x << 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__u32__byte_swapped(uint32_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap32(x);
|
||||
#else
|
||||
static const uint32_t mask8 = 0x00FF00FF;
|
||||
x = ((x >> 8) & mask8) | ((x & mask8) << 8);
|
||||
return (x >> 16) | (x << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__u64__byte_swapped(uint64_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap64(x);
|
||||
#else
|
||||
static const uint64_t mask8 = 0x00FF00FF00FF00FF;
|
||||
static const uint64_t mask16 = 0x0000FFFF0000FFFF;
|
||||
x = ((x >> 8) & mask8) | ((x & mask8) << 8);
|
||||
x = ((x >> 16) & mask16) | ((x & mask16) << 16);
|
||||
return (x >> 32) | (x << 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------- Slices and Tables
|
||||
|
||||
// WUFFS_BASE__SLICE is a 1-dimensional buffer.
|
||||
|
||||
@@ -32,8 +32,6 @@ const baseBasePublicH = "" +
|
||||
"// --------\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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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 //\nwuffs_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" +
|
||||
"" +
|
||||
"// --------\n\n// Clang also defines \"__GNUC__\".\n\nstatic inline uint16_t //\nwuffs_base__u16__byte_swapped(uint16_t x) {\n#if defined(__GNUC__)\n return __builtin_bswap16(x);\n#else\n return (x >> 8) | (x << 8);\n#endif\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__byte_swapped(uint32_t x) {\n#if defined(__GNUC__)\n return __builtin_bswap32(x);\n#else\n static const uint32_t mask8 = 0x00FF00FF;\n x = ((x >> 8) & mask8) | ((x & mask8) << 8);\n return (x >> 16) | (x << 16);\n#endif\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__byte_swapped(uint64_t x) {\n#if defined(__GNUC__)\n return __builtin_bswap64(x);\n#else\n static const uint64_t mask8 = 0x00FF00FF00FF00FF;\n static const uint64_t mask16 = 0x0000FFFF0000FFFF;\n x = ((x >> 8) & mask8) | ((x & mask8) << 8);\n x = ((x >> 16) & mask16) | ((x & mask16) << 16);\n return (x >> 32) | (x << 32);\n#endif\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Slices and Tables\n\n// WUFFS_BASE__SLICE is a 1-dimensional buffer.\n//\n// len measures a number of elements, not necessarily a size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty slice.\n#define WUFFS_BASE__SLICE(T) \\\n struct { \\\n T* ptr; \\\n size_t len; \\\n }\n\n// WUFFS_BASE__TABLE is a 2-dimensional buffer.\n//\n// width height, and stride measure a number of elements, not necessarily a\n// size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty table.\n#define WUFFS_BASE__TABLE(T) \\\n struct { \\\n T* ptr; \\\n size_t width; \\\n size_t height; \\\n size_t stride; \\\n }\n\ntypedef WUFFS_BASE__SLICE(uint8_t) wuffs_base__slice_u8;\ntypedef WUFFS_BASE__SLICE(uint16_t) wuffs_base__slice_u16;\ntypedef WUFFS_BASE__SLICE(uint32_t) wuffs_base__slice_u32;\ntypedef WUFFS_BASE__SLICE(uint64_t) wuffs_base__slice_u64;\n\ntypedef WUFFS_BASE__TABLE(u" +
|
||||
"int8_t) wuffs_base__table_u8;\ntypedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;\ntypedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;\ntypedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;\n\n// wuffs_base__slice_u8__subslice_i returns s[i:].\n//\n// It returns an empty slice if i is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr + i,\n .len = s.len - i,\n });\n }\n return ((wuffs_base__slice_u8){});\n}\n\n// wuffs_base__slice_u8__subslice_j returns s[:j].\n//\n// It returns an empty slice if j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr,\n .len = j,\n });\n }\n return ((wuffs_base__slice_u8){});\n}\n\n// wuffs_base__slice_u8__subslice_" +
|
||||
"ij returns s[i:j].\n//\n// It returns an empty slice if i or j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,\n uint64_t i,\n uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return ((wuffs_base__slice_u8){\n .ptr = s.ptr + i,\n .len = j - i,\n });\n }\n return ((wuffs_base__slice_u8){});\n}\n\n" +
|
||||
|
||||
@@ -299,43 +299,6 @@ wuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// Clang also defines "__GNUC__".
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__u16__byte_swapped(uint16_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap16(x);
|
||||
#else
|
||||
return (x >> 8) | (x << 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__u32__byte_swapped(uint32_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap32(x);
|
||||
#else
|
||||
static const uint32_t mask8 = 0x00FF00FF;
|
||||
x = ((x >> 8) & mask8) | ((x & mask8) << 8);
|
||||
return (x >> 16) | (x << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__u64__byte_swapped(uint64_t x) {
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_bswap64(x);
|
||||
#else
|
||||
static const uint64_t mask8 = 0x00FF00FF00FF00FF;
|
||||
static const uint64_t mask16 = 0x0000FFFF0000FFFF;
|
||||
x = ((x >> 8) & mask8) | ((x & mask8) << 8);
|
||||
x = ((x >> 16) & mask16) | ((x & mask16) << 16);
|
||||
return (x >> 32) | (x << 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------- Slices and Tables
|
||||
|
||||
// WUFFS_BASE__SLICE is a 1-dimensional buffer.
|
||||
|
||||
Reference in new issue
Block a user