From c1cc0f3f4c3d4abd11ca68c59446a29ff6f95003 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 18 Oct 2024 16:16:16 +0300 Subject: [PATCH] [libpng16] build: Rename a private function to benefit C++Builder Embarcadero's compilers, old (Borland-based) and new (Clang-based), do have full support for Standard C. The Clang-based compiler is claiming, through the macro __STDC_VERSION__, to support C99 and C11, whereas the Borland-based compiler supports ANSI C, as it has for decades. However, their run-time library is exposing global functions beyond the scope of Standard C, for backwards compatibility with the older Borland products. One of these functions is `randomize`, which clashes with a function inside pngvalid.c that incidentally has the same name. Building libpng in "Strict ANSI C" mode, in which all Borland-specific globals are hidden (e.g. via `bcc32 -A`), would have been a workable solution for the Borland-based ANSI C compiler, but no such solution appears to exist for the Clang-based C90/C99/C11 compiler. Fortunately, renaming a private function inside a test program is a cost-free alternative fix. This is a cherry-pick of commit 6184164aa73ee764b1822f44d3db7619cf84f3fa from branch 'libpng18'. --- contrib/libtests/pngvalid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 74352e5c3..bddf32141 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -303,20 +303,20 @@ make_four_random_bytes(png_uint_32* seed, png_bytep bytes) #if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\ defined PNG_WRITE_FILTER_SUPPORTED static void -randomize(void *pv, size_t size) +randomize_bytes(void *pv, size_t size) { static png_uint_32 random_seed[2] = {0x56789abc, 0xd}; make_random_bytes(random_seed, pv, size); } -#define R8(this) randomize(&(this), sizeof (this)) +#define R8(this) randomize_bytes(&(this), sizeof (this)) #ifdef PNG_READ_SUPPORTED static png_byte random_byte(void) { unsigned char b1[1]; - randomize(b1, sizeof b1); + randomize_bytes(b1, sizeof b1); return b1[0]; } #endif /* READ */ @@ -325,7 +325,7 @@ static png_uint_16 random_u16(void) { unsigned char b2[2]; - randomize(b2, sizeof b2); + randomize_bytes(b2, sizeof b2); return png_get_uint_16(b2); } @@ -335,7 +335,7 @@ static png_uint_32 random_u32(void) { unsigned char b4[4]; - randomize(b4, sizeof b4); + randomize_bytes(b4, sizeof b4); return png_get_uint_32(b4); } #endif /* READ_FILLER || READ_RGB_TO_GRAY */