diff --git a/doc/changelog.md b/doc/changelog.md index d6999045..c5577582 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -29,7 +29,6 @@ The LICENSE has changed from a single license (Apache 2) to a dual license - Changed `lzw.set_literal_width` to `lzw.set_quirk`. - Changed `set_quirk_enabled!(quirk: u32, enabled: bool)` to `set_quirk!(key: u32, value: u64) status`. -- Changed `wuffs_base__empty_foo` to return non-NULL ptr. - Deprecated `std/lzw.decoder.flush`. - Fixed `PIXEL_FORMAT__YA_{NON,}PREMUL` constant values. - Generated constants now default to unsigned. diff --git a/internal/cgen/base/all-impl.c b/internal/cgen/base/all-impl.c index f0387abc..01cdc56e 100644 --- a/internal/cgen/base/all-impl.c +++ b/internal/cgen/base/all-impl.c @@ -111,21 +111,6 @@ const uint32_t wuffs_private_impl__pixel_format__bits_per_channel[16] = { 0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40, }; -const uint8_t // - wuffs_private_impl__placeholder_u8_with_non_null_address = 0; - -const uint16_t // - wuffs_private_impl__placeholder_u16_with_non_null_address = 0; - -const uint32_t // - wuffs_private_impl__placeholder_u32_with_non_null_address = 0; - -const uint64_t // - wuffs_private_impl__placeholder_u64_with_non_null_address = 0; - -const wuffs_base__token // - wuffs_private_impl__placeholder_token_with_non_null_address = {0}; - // ¡ INSERT wuffs_base__status strings. // ¡ INSERT vtable names. diff --git a/internal/cgen/base/fundamental-public.h b/internal/cgen/base/fundamental-public.h index c3965eb7..1db9d0d9 100644 --- a/internal/cgen/base/fundamental-public.h +++ b/internal/cgen/base/fundamental-public.h @@ -395,28 +395,6 @@ wuffs_base__strip_const_from_u64_ptr(const uint64_t* ptr) { // -------- -// wuffs_private_impl__placeholder_etc_with_non_null_address provides non-NULL -// pointers to various integer types. These values aren't intended to ever be -// modified and their addresses aren't intended to ever be dereferenced. -// -// It's just that adding 0 to a NULL pointer can be undefined behavior (and -// UBSAN will complain), so functions like wuffs_base__empty_slice_u8 need some -// arbitrary non-NULL placeholder pointer, even though the slice has 0 length. - -extern const uint8_t // - wuffs_private_impl__placeholder_u8_with_non_null_address; - -extern const uint16_t // - wuffs_private_impl__placeholder_u16_with_non_null_address; - -extern const uint32_t // - wuffs_private_impl__placeholder_u32_with_non_null_address; - -extern const uint64_t // - wuffs_private_impl__placeholder_u64_with_non_null_address; - -// -------- - // wuffs_base__empty_struct is used when a Wuffs function returns an empty // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". @@ -1438,8 +1416,7 @@ wuffs_base__make_slice_u64_ij(uint64_t* ptr, size_t i, size_t j) { static inline wuffs_base__slice_u8 // wuffs_base__empty_slice_u8(void) { wuffs_base__slice_u8 ret; - ret.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1447,8 +1424,7 @@ wuffs_base__empty_slice_u8(void) { static inline wuffs_base__slice_u16 // wuffs_base__empty_slice_u16(void) { wuffs_base__slice_u16 ret; - ret.ptr = wuffs_base__strip_const_from_u16_ptr( - &wuffs_private_impl__placeholder_u16_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1456,8 +1432,7 @@ wuffs_base__empty_slice_u16(void) { static inline wuffs_base__slice_u32 // wuffs_base__empty_slice_u32(void) { wuffs_base__slice_u32 ret; - ret.ptr = wuffs_base__strip_const_from_u32_ptr( - &wuffs_private_impl__placeholder_u32_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1465,8 +1440,7 @@ wuffs_base__empty_slice_u32(void) { static inline wuffs_base__slice_u64 // wuffs_base__empty_slice_u64(void) { wuffs_base__slice_u64 ret; - ret.ptr = wuffs_base__strip_const_from_u64_ptr( - &wuffs_private_impl__placeholder_u64_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1526,8 +1500,7 @@ wuffs_base__make_table_u64(uint64_t* ptr, static inline wuffs_base__table_u8 // wuffs_base__empty_table_u8(void) { wuffs_base__table_u8 ret; - ret.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1537,8 +1510,7 @@ wuffs_base__empty_table_u8(void) { static inline wuffs_base__table_u16 // wuffs_base__empty_table_u16(void) { wuffs_base__table_u16 ret; - ret.ptr = wuffs_base__strip_const_from_u16_ptr( - &wuffs_private_impl__placeholder_u16_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1548,8 +1520,7 @@ wuffs_base__empty_table_u16(void) { static inline wuffs_base__table_u32 // wuffs_base__empty_table_u32(void) { wuffs_base__table_u32 ret; - ret.ptr = wuffs_base__strip_const_from_u32_ptr( - &wuffs_private_impl__placeholder_u32_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1559,8 +1530,7 @@ wuffs_base__empty_table_u32(void) { static inline wuffs_base__table_u64 // wuffs_base__empty_table_u64(void) { wuffs_base__table_u64 ret; - ret.ptr = wuffs_base__strip_const_from_u64_ptr( - &wuffs_private_impl__placeholder_u64_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; diff --git a/internal/cgen/base/io-public.h b/internal/cgen/base/io-public.h index d9243ad4..12de6feb 100644 --- a/internal/cgen/base/io-public.h +++ b/internal/cgen/base/io-public.h @@ -118,8 +118,7 @@ wuffs_base__slice_u8__writer(wuffs_base__slice_u8 s) { static inline wuffs_base__io_buffer // wuffs_base__empty_io_buffer(void) { wuffs_base__io_buffer ret; - ret.data.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.data.ptr = NULL; ret.data.len = 0; ret.meta.wi = 0; ret.meta.ri = 0; diff --git a/internal/cgen/base/token-public.h b/internal/cgen/base/token-public.h index 526d25e1..f707ab6c 100644 --- a/internal/cgen/base/token-public.h +++ b/internal/cgen/base/token-public.h @@ -277,9 +277,6 @@ wuffs_base__token::length() const { // -------- -extern const wuffs_base__token // - wuffs_private_impl__placeholder_token_with_non_null_address; - #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" @@ -309,8 +306,7 @@ wuffs_base__make_slice_token(wuffs_base__token* ptr, size_t len) { static inline wuffs_base__slice_token // wuffs_base__empty_slice_token(void) { wuffs_base__slice_token ret; - ret.ptr = wuffs_base__strip_const_from_token_ptr( - &wuffs_private_impl__placeholder_token_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -399,8 +395,7 @@ wuffs_base__slice_token__writer(wuffs_base__slice_token s) { static inline wuffs_base__token_buffer // wuffs_base__empty_token_buffer(void) { wuffs_base__token_buffer ret; - ret.data.ptr = wuffs_base__strip_const_from_token_ptr( - &wuffs_private_impl__placeholder_token_with_non_null_address); + ret.data.ptr = NULL; ret.data.len = 0; ret.meta.wi = 0; ret.meta.ri = 0; diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 105af911..7242567d 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -451,28 +451,6 @@ wuffs_base__strip_const_from_u64_ptr(const uint64_t* ptr) { // -------- -// wuffs_private_impl__placeholder_etc_with_non_null_address provides non-NULL -// pointers to various integer types. These values aren't intended to ever be -// modified and their addresses aren't intended to ever be dereferenced. -// -// It's just that adding 0 to a NULL pointer can be undefined behavior (and -// UBSAN will complain), so functions like wuffs_base__empty_slice_u8 need some -// arbitrary non-NULL placeholder pointer, even though the slice has 0 length. - -extern const uint8_t // - wuffs_private_impl__placeholder_u8_with_non_null_address; - -extern const uint16_t // - wuffs_private_impl__placeholder_u16_with_non_null_address; - -extern const uint32_t // - wuffs_private_impl__placeholder_u32_with_non_null_address; - -extern const uint64_t // - wuffs_private_impl__placeholder_u64_with_non_null_address; - -// -------- - // wuffs_base__empty_struct is used when a Wuffs function returns an empty // struct. In C, if a function f returns void, you can't say "x = f()", but in // Wuffs, if a function g returns empty, you can say "y = g()". @@ -1715,8 +1693,7 @@ wuffs_base__make_slice_u64_ij(uint64_t* ptr, size_t i, size_t j) { static inline wuffs_base__slice_u8 // wuffs_base__empty_slice_u8(void) { wuffs_base__slice_u8 ret; - ret.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1724,8 +1701,7 @@ wuffs_base__empty_slice_u8(void) { static inline wuffs_base__slice_u16 // wuffs_base__empty_slice_u16(void) { wuffs_base__slice_u16 ret; - ret.ptr = wuffs_base__strip_const_from_u16_ptr( - &wuffs_private_impl__placeholder_u16_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1733,8 +1709,7 @@ wuffs_base__empty_slice_u16(void) { static inline wuffs_base__slice_u32 // wuffs_base__empty_slice_u32(void) { wuffs_base__slice_u32 ret; - ret.ptr = wuffs_base__strip_const_from_u32_ptr( - &wuffs_private_impl__placeholder_u32_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1742,8 +1717,7 @@ wuffs_base__empty_slice_u32(void) { static inline wuffs_base__slice_u64 // wuffs_base__empty_slice_u64(void) { wuffs_base__slice_u64 ret; - ret.ptr = wuffs_base__strip_const_from_u64_ptr( - &wuffs_private_impl__placeholder_u64_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -1803,8 +1777,7 @@ wuffs_base__make_table_u64(uint64_t* ptr, static inline wuffs_base__table_u8 // wuffs_base__empty_table_u8(void) { wuffs_base__table_u8 ret; - ret.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1814,8 +1787,7 @@ wuffs_base__empty_table_u8(void) { static inline wuffs_base__table_u16 // wuffs_base__empty_table_u16(void) { wuffs_base__table_u16 ret; - ret.ptr = wuffs_base__strip_const_from_u16_ptr( - &wuffs_private_impl__placeholder_u16_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1825,8 +1797,7 @@ wuffs_base__empty_table_u16(void) { static inline wuffs_base__table_u32 // wuffs_base__empty_table_u32(void) { wuffs_base__table_u32 ret; - ret.ptr = wuffs_base__strip_const_from_u32_ptr( - &wuffs_private_impl__placeholder_u32_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -1836,8 +1807,7 @@ wuffs_base__empty_table_u32(void) { static inline wuffs_base__table_u64 // wuffs_base__empty_table_u64(void) { wuffs_base__table_u64 ret; - ret.ptr = wuffs_base__strip_const_from_u64_ptr( - &wuffs_private_impl__placeholder_u64_with_non_null_address); + ret.ptr = NULL; ret.width = 0; ret.height = 0; ret.stride = 0; @@ -3123,8 +3093,7 @@ wuffs_base__slice_u8__writer(wuffs_base__slice_u8 s) { static inline wuffs_base__io_buffer // wuffs_base__empty_io_buffer(void) { wuffs_base__io_buffer ret; - ret.data.ptr = wuffs_base__strip_const_from_u8_ptr( - &wuffs_private_impl__placeholder_u8_with_non_null_address); + ret.data.ptr = NULL; ret.data.len = 0; ret.meta.wi = 0; ret.meta.ri = 0; @@ -3585,9 +3554,6 @@ wuffs_base__token::length() const { // -------- -extern const wuffs_base__token // - wuffs_private_impl__placeholder_token_with_non_null_address; - #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" @@ -3617,8 +3583,7 @@ wuffs_base__make_slice_token(wuffs_base__token* ptr, size_t len) { static inline wuffs_base__slice_token // wuffs_base__empty_slice_token(void) { wuffs_base__slice_token ret; - ret.ptr = wuffs_base__strip_const_from_token_ptr( - &wuffs_private_impl__placeholder_token_with_non_null_address); + ret.ptr = NULL; ret.len = 0; return ret; } @@ -3707,8 +3672,7 @@ wuffs_base__slice_token__writer(wuffs_base__slice_token s) { static inline wuffs_base__token_buffer // wuffs_base__empty_token_buffer(void) { wuffs_base__token_buffer ret; - ret.data.ptr = wuffs_base__strip_const_from_token_ptr( - &wuffs_private_impl__placeholder_token_with_non_null_address); + ret.data.ptr = NULL; ret.data.len = 0; ret.meta.wi = 0; ret.meta.ri = 0; @@ -16049,21 +16013,6 @@ const uint32_t wuffs_private_impl__pixel_format__bits_per_channel[16] = { 0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40, }; -const uint8_t // - wuffs_private_impl__placeholder_u8_with_non_null_address = 0; - -const uint16_t // - wuffs_private_impl__placeholder_u16_with_non_null_address = 0; - -const uint32_t // - wuffs_private_impl__placeholder_u32_with_non_null_address = 0; - -const uint64_t // - wuffs_private_impl__placeholder_u64_with_non_null_address = 0; - -const wuffs_base__token // - wuffs_private_impl__placeholder_token_with_non_null_address = {0}; - const char wuffs_base__note__i_o_redirect[] = "@base: I/O redirect"; const char wuffs_base__note__end_of_data[] = "@base: end of data"; const char wuffs_base__note__metadata_reported[] = "@base: metadata reported";