mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[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'.
This commit is contained in:
parent
d9d70e6506
commit
c1cc0f3f4c
@ -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 ||\
|
#if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\
|
||||||
defined PNG_WRITE_FILTER_SUPPORTED
|
defined PNG_WRITE_FILTER_SUPPORTED
|
||||||
static void
|
static void
|
||||||
randomize(void *pv, size_t size)
|
randomize_bytes(void *pv, size_t size)
|
||||||
{
|
{
|
||||||
static png_uint_32 random_seed[2] = {0x56789abc, 0xd};
|
static png_uint_32 random_seed[2] = {0x56789abc, 0xd};
|
||||||
make_random_bytes(random_seed, pv, size);
|
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
|
#ifdef PNG_READ_SUPPORTED
|
||||||
static png_byte
|
static png_byte
|
||||||
random_byte(void)
|
random_byte(void)
|
||||||
{
|
{
|
||||||
unsigned char b1[1];
|
unsigned char b1[1];
|
||||||
randomize(b1, sizeof b1);
|
randomize_bytes(b1, sizeof b1);
|
||||||
return b1[0];
|
return b1[0];
|
||||||
}
|
}
|
||||||
#endif /* READ */
|
#endif /* READ */
|
||||||
@ -325,7 +325,7 @@ static png_uint_16
|
|||||||
random_u16(void)
|
random_u16(void)
|
||||||
{
|
{
|
||||||
unsigned char b2[2];
|
unsigned char b2[2];
|
||||||
randomize(b2, sizeof b2);
|
randomize_bytes(b2, sizeof b2);
|
||||||
return png_get_uint_16(b2);
|
return png_get_uint_16(b2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ static png_uint_32
|
|||||||
random_u32(void)
|
random_u32(void)
|
||||||
{
|
{
|
||||||
unsigned char b4[4];
|
unsigned char b4[4];
|
||||||
randomize(b4, sizeof b4);
|
randomize_bytes(b4, sizeof b4);
|
||||||
return png_get_uint_32(b4);
|
return png_get_uint_32(b4);
|
||||||
}
|
}
|
||||||
#endif /* READ_FILLER || READ_RGB_TO_GRAY */
|
#endif /* READ_FILLER || READ_RGB_TO_GRAY */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user