From b3b71680778feed1d3a2f129aab6c8ac7fa93f4e Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Tue, 3 May 2011 22:30:19 -0500 Subject: [PATCH] [devel] Added appropriate feature test macros (_POSIX_SOURCE, _ISOC99_SOURCE) to ensure libpng sees the correct API. --- ANNOUNCE | 9 +++++++-- CHANGES | 7 ++++++- pngpriv.h | 15 +++++++++++++++ pngtest.c | 2 ++ pngvalid.c | 2 ++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 0232ae619..3937b7f47 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.3beta05 - April 29, 2011 +Libpng 1.5.3beta05 - May 4, 2011 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -76,7 +76,12 @@ Version 1.5.3beta04 [April 27, 2011] Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to avoid a clash with the png_jmpbuf macro on some platforms. -Version 1.5.3beta05 [April 29, 2011] +Version 1.5.3beta05 [May 4, 2011] + Added appropriate feature test macros to ensure libpng sees the correct API + _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and pngvalid.c to ensure + that POSIX conformant systems disable non-POSIX APIs. _ISOC99_SOURCE is + defined in pngpriv.h to obtain the ISO C99 snprintf definition, when + available. Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index 35b5c3de7..47dd7de3f 100644 --- a/CHANGES +++ b/CHANGES @@ -3337,7 +3337,12 @@ Version 1.5.3beta04 [April 27, 2011] Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to avoid a possible clash with the png_jmpbuf macro on some platforms. -Version 1.5.3beta05 [April 29, 2011] +Version 1.5.3beta05 [May 4, 2011] + Added appropriate feature test macros to ensure libpng sees the correct API + _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and pngvalid.c to ensure + that POSIX conformant systems disable non-POSIX APIs. _ISOC99_SOURCE is + defined in pngpriv.h to obtain the ISO C99 snprintf definition, when + available. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngpriv.h b/pngpriv.h index 3486c13e2..9f32ba609 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -25,6 +25,21 @@ #ifndef PNGPRIV_H #define PNGPRIV_H +/* Feature Test Macros. The following are defined here to ensure that correctly + * implemented libraries reveal the APIs libpng needs to build and hide those + * that are not needed and potentially damaging to the compilation. + * + * Feature Test Macros must be defined before any system header is included (see + * POSIX 1003.1 2.8.2 "POSIX Symbols." + * + * These macros only have an effect if the operating system supports either + * POSIX 1003.1 or C99, or both. On other operating systems (particularly + * Windows/Visual Studio) there is no effect; the OS specific tests below are + * still required (as of 2011-05-02.) + */ +#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ +#define _ISOC99_SOURCE 1 /* for snprintf */ + /* This is required for the definition of abort(), used as a last ditch * error handler when all else fails. */ diff --git a/pngtest.c b/pngtest.c index d89ad8039..f6d8d3802 100644 --- a/pngtest.c +++ b/pngtest.c @@ -31,6 +31,8 @@ * of files at once by typing "pngtest -m file1.png file2.png ..." */ +#define _POSIX_SOURCE 1 + #include "zlib.h" #include "png.h" /* Copied from pngpriv.h but only used in error messages below. */ diff --git a/pngvalid.c b/pngvalid.c index 116184b40..945529bec 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -19,6 +19,8 @@ * transformations performed by libpng. */ +#define _POSIX_SOURCE 1 + #include "png.h" #if PNG_LIBPNG_VER < 10500 /* This delibarately lacks the PNG_CONST. */