[libpng15] Corrected Android builds and corrected libpng.vers with symbol

prefixing This adds an API to set optimization options externally,
    providing an alternative and general solution for the non-portable
    run-time tests used by the ARM Neon code.  It also makes those tests
    compile and link on Android.
  The order of settings vs options in pnglibconf.h is reversed to allow
    settings to depend on options and options can now set (or override) the
    defaults for settings.
This commit is contained in:
John Bowler 2013-03-04 16:44:59 -06:00 committed by Glenn Randers-Pehrson
parent 85d027f3d0
commit c34143f615
16 changed files with 563 additions and 270 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.15beta08 - March 2, 2013
Libpng 1.5.15beta08 - March 4, 2013
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.
@ -68,7 +68,7 @@ Version 1.5.15beta07 [February 27, 2013]
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
with CRLF line endings.
Version 1.5.15beta08 [March 2, 2013]
Version 1.5.15beta08 [March 4, 2013]
Avoid a possible memory leak in contrib/gregbook/readpng.c
Made the _SUPPORTED macro definitions consistent. The change made in
libpng15 to #define *_SUPPORTED 1, to match the use of -D*_SUPPORTED
@ -81,6 +81,15 @@ Version 1.5.15beta08 [March 2, 2013]
safer to go for consistency, given the change in 1.6, not correctness here,
particularly as 'make check' currently warns anyway on the symbols.dfn check
because of the inconsistencies.
Corrected Android builds and corrected libpng.vers with symbol
prefixing This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android.
The order of settings vs options in pnglibconf.h is reversed to allow
settings to depend on options and options can now set (or override) the
defaults for settings.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

11
CHANGES
View File

@ -4026,7 +4026,7 @@ Version 1.5.15beta07 [February 27, 2013]
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
with CRLF line endings.
Version 1.5.15beta08 [March 2, 2013]
Version 1.5.15beta08 [March 4, 2013]
Avoid a possible memory leak in contrib/gregbook/readpng.c
Made the _SUPPORTED macro definitions consistent. The change made in
libpng15 to #define *_SUPPORTED 1, to match the use of -D*_SUPPORTED
@ -4039,6 +4039,15 @@ Version 1.5.15beta08 [March 2, 2013]
safer to go for consistency, given the change in 1.6, not correctness here,
particularly as 'make check' currently warns anyway on the symbols.dfn check
because of the inconsistencies.
Corrected Android builds and corrected libpng.vers with symbol
prefixing This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android.
The order of settings vs options in pnglibconf.h is reversed to allow
settings to depend on options and options can now set (or override) the
defaults for settings.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -174,7 +174,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
rm -f $@ dfn?.out
test -z "$(CPPFLAGS)"
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1\
version=search ${srcdir}/pngconf.h -\
${srcdir}/scripts/pnglibconf.dfa 1>&2
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2

View File

@ -16,16 +16,7 @@
#include "../pngpriv.h"
#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
defined(__ARM_NEON__)
/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number,
* Andoid intends to define __ANDROID__, however there are bugs in their
* toolchain; use -D__ANDROID__ to work round this.
*
* __ARM_NEON__ is used to ensure that the compiler has the appropriate ARM
* NEON support
*/
#ifdef PNG_ARM_NEON_SUPPORTED
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
#include <signal.h> /* for sig_atomic_t */
@ -45,7 +36,8 @@ png_have_neon(png_structp png_ptr)
* implemented as below, therefore it is better to cache the result (these
* function calls may be slow!)
*/
return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
PNG_UNUSED(png_ptr)
return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}
#elif defined(__linux__)
@ -161,15 +153,39 @@ png_have_neon(png_structp png_ptr)
void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{
case PNG_OPTION_UNSET:
/* Allow the run-time check to execute if it has been enabled -
* thus both API and CHECK can be turned on. If it isn't supported
* this case will fall through to the 'default' below, which just
* returns.
*/
#endif /* PNG_ARM_NEON_API_SUPPORTED */
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
static volatile sig_atomic_t no_neon = -1; /* not checked */
{
static volatile sig_atomic_t no_neon = -1; /* not checked */
if (no_neon < 0)
no_neon = !png_have_neon(pp);
if (no_neon < 0)
no_neon = !png_have_neon(pp);
if (no_neon)
return;
if (no_neon)
return;
}
#ifdef PNG_ARM_NEON_API_SUPPORTED
break;
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifdef PNG_ARM_NEON_API_SUPPORTED
case PNG_OPTION_ON:
/* Option turned on */
break;
default: /* OFF or INVALID */
return;
}
#endif
/* IMPORTANT: any new external functions used here must be declared using
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the

View File

@ -1,6 +1,6 @@
Libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.5.15beta08 - February 27, 2013
libpng version 1.5.15beta08 - March 4, 2013
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -11,7 +11,7 @@ Libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.5.15beta08 - February 27, 2013
libpng versions 0.97, January 1998, through 1.5.15beta08 - March 4, 2013
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -509,8 +509,7 @@ you can retrieve with
If you call the png_set_read_user_chunk_fn() function, then all unknown
chunks will be saved when read, in case your callback function will need
one or more of them. This behavior can be changed with the
png_set_keep_unknown_chunks() function, described below.
one or more of them.
At this point, you can set up a callback function that will be
called after each row has been read, which you can use to control
@ -604,7 +603,11 @@ callback function:
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* ignore all unknown chunks: */
# if PNG_LIBPNG_VER < 10700
png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
# else
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
# endif
/* except for vpAg: */
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@ -4622,7 +4625,7 @@ Other rules can be inferred by inspecting the libpng source.
XIV. Y2K Compliance in libpng
February 27, 2013
March 4, 2013
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.

View File

@ -1,4 +1,4 @@
.TH LIBPNG 3 "February 27, 2013"
.TH LIBPNG 3 "March 4, 2013"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta08
.SH SYNOPSIS
@ -277,7 +277,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta08
\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
\fBvoid png_set_check_for_invalid_index(png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
@ -492,7 +492,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
Libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.5.15beta08 - February 27, 2013
libpng version 1.5.15beta08 - March 4, 2013
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -503,7 +503,7 @@ Libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.5.15beta08 - February 27, 2013
libpng versions 0.97, January 1998, through 1.5.15beta08 - March 4, 2013
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -1001,8 +1001,7 @@ you can retrieve with
If you call the png_set_read_user_chunk_fn() function, then all unknown
chunks will be saved when read, in case your callback function will need
one or more of them. This behavior can be changed with the
png_set_keep_unknown_chunks() function, described below.
one or more of them.
At this point, you can set up a callback function that will be
called after each row has been read, which you can use to control
@ -1096,7 +1095,11 @@ callback function:
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* ignore all unknown chunks: */
# if PNG_LIBPNG_VER < 10700
png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
# else
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
# endif
/* except for vpAg: */
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@ -5115,7 +5118,7 @@ Other rules can be inferred by inspecting the libpng source.
.SH XIV. Y2K Compliance in libpng
February 27, 2013
March 4, 2013
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
@ -5401,7 +5404,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.5.15beta08 - February 27, 2013:
Libpng version 1.5.15beta08 - March 4, 2013:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -5424,7 +5427,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.5.15beta08, February 27, 2013, are
libpng versions 1.2.6, August 15, 2004, through 1.5.15beta08, March 4, 2013, are
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@ -5523,7 +5526,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
February 27, 2013
March 4, 2013
.\" end of man page

25
png.c
View File

@ -658,13 +658,13 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.5.15beta08 - February 27, 2013" PNG_STRING_NEWLINE \
"libpng version 1.5.15beta08 - March 4, 2013" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.5.15beta08 - February 27, 2013\
return "libpng version 1.5.15beta08 - March 4, 2013\
Copyright (c) 1998-2013 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -2878,3 +2878,24 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
}
#endif /* READ_GAMMA */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
/* HARDWARE OPTION SUPPORT */
#ifdef PNG_SET_OPTION_SUPPORTED
int PNGAPI
png_set_option(png_structp png_ptr, int option, int onoff)
{
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
(option & 1) == 0)
{
int mask = 3 << option;
int setting = (2 + (onoff != 0)) << option;
int current = png_ptr->options;
png_ptr->options = (png_byte)((current & ~mask) | setting);
return (current & mask) >> option;
}
return PNG_OPTION_INVALID;
}
#endif

53
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5.15beta08 - February 27, 2013
* libpng version 1.5.15beta08 - March 4, 2013
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.5.15beta08 - February 27, 2013: Glenn
* libpng versions 0.97, January 1998, through 1.5.15beta08 - March 4, 2013: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -216,7 +216,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.5.15beta08, February 27, 2013, are
* libpng versions 1.2.6, August 15, 2004, through 1.5.15beta08, March 4, 2013, are
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -328,7 +328,7 @@
* Y2K compliance in libpng:
* =========================
*
* February 27, 2013
* March 4, 2013
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
@ -395,7 +395,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.5.15beta08"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.15beta08 - February 27, 2013\n"
" libpng version 1.5.15beta08 - March 4, 2013\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@ -2660,6 +2660,47 @@ PNG_EXPORT(235, int, png_get_palette_max, (png_const_structp png_ptr,
# endif
#endif /* CHECK_FOR_INVALID_INDEX */
/*******************************************************************************
* IMPLEMENTATION OPTIONS
*******************************************************************************
*
* Support for arbitrary implementation-specific optimizations. The API allows
* particular options to be turned on or off. 'Option' is the number of the
* option and 'onoff' is 0 (off) or non-0 (on). The value returned is given
* by the PNG_OPTION_ defines below.
*
* HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
* are detected at run time, however sometimes it may be impossible
* to do this in user mode, in which case it is necessary to discover
* the capabilities in an OS specific way. Such capabilities are
* listed here when libpng has support for them and must be turned
* ON by the application if present.
*
* SOFTWARE: sometimes software optimizations actually result in performance
* decrease on some architectures or systems, or with some sets of
* PNG images. 'Software' options allow such optimizations to be
* selected at run time.
*/
#ifdef PNG_SET_OPTION_SUPPORTED
#ifdef PNG_ARM_NEON_API_SUPPORTED
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
#endif
#define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
#define PNG_OPTION_INVALID 1 /* Option number out of range */
#define PNG_OPTION_OFF 2
#define PNG_OPTION_ON 3
PNG_EXPORT(236, int, png_set_option, (png_structp png_ptr, int option,
int onoff));
#endif
/*******************************************************************************
* END OF HARDWARE OPTIONS
******************************************************************************/
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/
@ -2669,7 +2710,7 @@ PNG_EXPORT(235, int, png_get_palette_max, (png_const_structp png_ptr,
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(235);
PNG_EXPORT_LAST_ORDINAL(236);
#endif
#ifdef __cplusplus

View File

@ -355,5 +355,10 @@ struct png_struct_def
/* New member added in libpng-1.5.7 */
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row);
/* Options */
#ifdef PNG_SET_OPTION_SUPPORTED
png_byte options; /* On/off state (up to 4 options) */
#endif
};
#endif /* PNGSTRUCT_H */

View File

@ -5,8 +5,9 @@
# awk -f checksym.awk official-def list-to-check
#
# Output is a file in the current directory called 'symbols.new',
# stdout holds error messages. Error code indicates success or
# failure.
# the value of the awk variable "of" (which can be changed on the
# command line if required.) stdout holds error messages. Error
# code indicates success or failure.
#
# NOTE: this is a pure, old fashioned, awk script. It will
# work with any awk
@ -21,6 +22,7 @@ BEGIN{
mastero = 0 # highest ordinal in master file
symbolo = 0 # highest ordinal in png.h
missing = "error"# log an error on missing symbols
of="symbols.new" # default to a fixed name
}
# Read existing definitions from the master file (the first
@ -111,6 +113,16 @@ END{
err = 1
}
unexported=0
# Add a standard header to symbols.new:
print ";Version INSERT-VERSION-HERE" >of
print ";--------------------------------------------------------------" >of
print "; LIBPNG symbol list as a Win32 DEF file" >of
print "; Contains all the symbols that can be exported from libpng" >of
print ";--------------------------------------------------------------" >of
print "LIBRARY" >of
print "" >of
print "EXPORTS" >of
for (o=1; o<=lasto; ++o) {
if (symbol[o] == "" && removed[o] == "") {
if (unexported == 0) unexported = o
@ -151,11 +163,11 @@ END{
# Finally generate symbols.new
if (symbol[o] != "")
print " " symbol[o], "@" o > "symbols.new"
print " " symbol[o], "@" o > of
}
if (err != 0) {
print "*** A new list is in symbols.new ***"
print "*** A new list is in", of, "***"
exit 1
}
}

View File

@ -61,75 +61,143 @@ $1 ~ /^PNG_DFN_END_SORT/{
}
/^[^"]*PNG_DFN *".*"[^"]*$/{
# A definition line, apparently correctly formated, extract the
# definition then replace any doubled "" that remain with a single
# double quote. Notice that the original doubled double quotes
# may have been split by tokenization
orig=$0
# A definition line, apparently correctly formated, extract the
# definition then replace any doubled "" that remain with a single
# double quote. Notice that the original doubled double quotes
# may have been split by tokenization
#
# Sometimes GCC splits the PNG_DFN lines, we know this has happened
# if the quotes aren't closed and must read another line. In this
# case it is essential to reject lines that start '#' because those
# are introduced #line directives.
orig=$0
line=$0
lineno=FNR
if (lineno == "") lineno=NR
if (gsub(/^[^"]*PNG_DFN *"/,"") != 1 || gsub(/"[^"]*$/, "") != 1) {
print "line", NR, "processing failed:"
if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) {
print "line", lineno ": processing failed:"
print orig
print $0
err=1
} else {
next
} else {
++out_count
}
}
# Now examine quotes within the value:
#
# @" - delete this and any following spaces
# "@ - delete this and any original spaces
# @' - replace this by a double quote
#
# This allows macro substitution by the C compiler thus:
#
# #define first_name John
# #define last_name Smith
#
# PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'"
#
# Might get C preprocessed to:
#
# PNG_DFN "#define foo @'@" John "@ @" Smith "@@'"
#
# Which this script reduces to:
#
# #define name "John Smith"
#
while (sub(/@" */, "")) {
if (!sub(/ *"@/, "")) {
print "unbalanced @\" ... \"@ pair"
err=1
break
}
}
# Now examine quotes within the value:
#
# @" - delete this and any following spaces
# "@ - delete this and any preceding spaces
# @' - replace this by a double quote
#
# This allows macro substitution by the C compiler thus:
#
# #define first_name John
# #define last_name Smith
#
# PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'"
#
# Might get C preprocessed to:
#
# PNG_DFN "#define foo @'@" John "@ @" Smith "@@'"
#
# Which this script reduces to:
#
# #define name "John Smith"
#
while (1) {
# While there is an @" remove it and the next "@
if (line ~ /@"/) {
if (line ~ /@".*"@/) {
# Do this special case first to avoid swallowing extra spaces
# before or after the @ stuff:
if (!sub(/@" *"@/, "", line)) {
# Ok, do it in pieces - there has to be a non-space between the
# two. NOTE: really weird things happen if a leading @" is
# lost - the code will error out below (I believe).
if (!sub(/@" */, "", line) || !sub(/ *"@/, "", line)) {
print "line", lineno, ": internal error:", orig
exit 1
}
}
}
# Put any needed double quotes in
gsub(/@'/,"\"")
# There is no matching "@. Assume a split line
else while (1) {
if (getline nextline) {
# If the line starts with '#' it is a preprocesor line directive
# from cc -E, skip it:
if (nextline !~ /^#/) {
line = line " " nextline
break
}
} else {
# This is end-of-input - probably a missig "@ on the first line:
print "line", lineno ": unbalanced @\" ... \"@ pair"
err=1
next
}
}
# Remove any trailing spaces (not really required, but for
# editorial consistency
sub(/ *$/, "")
# Keep going until all the @" have gone
continue
}
if (sort)
array[$(sort)] = $0
# Attempt to remove a trailing " (not preceded by '@') - if this can
# be done stop now, if not assume a split line again
if (sub(/"[^"]*$/, "", line))
break
else
print $0 >out
next
# Read another line
while (1) {
if (getline nextline) {
if (nextline !~ /^#/) {
line = line " " nextline
# Go back to stripping @" "@ pairs
break
}
} else {
print "line", lineno ": unterminated PNG_DFN string"
err=1
next
}
}
}
# Put any needed double quotes in (at the end, because these would otherwise
# interfere with the processing above.)
gsub(/@'/,"\"", line)
# Remove any trailing spaces (not really required, but for
# editorial consistency
sub(/ *$/, "", line)
# Remove trailing CR
sub(/ $/, "", line)
if (sort) {
if (split(line, parts) < sort) {
print "line", lineno ": missing sort field:", line
err=1
} else
array[parts[sort]] = line
}
else
print line >out
next
}
/PNG_DFN/{
print "line", NR, "incorrectly formated PNG_DFN line:"
print $0
err = 1
print "line", NR, "incorrectly formated PNG_DFN line:"
print $0
err = 1
}
END{
if (out_count > 0 || err > 0)
if (out_count > 0 || err > 0)
exit err
print "no definition lines found"
exit 1
print "no definition lines found"
exit 1
}

View File

@ -64,11 +64,15 @@ BEGIN{
logunsupported=0 # write unsupported options too
# Precreate arrays
# for each option:
option[""] = "" # list of all options: default enabled/disabled
done[""] = 1 # marks option as having been output
requires[""] = "" # requires by option
iffs[""] = "" # if by option
enabledby[""] = "" # options that enable it by option
sets[""] = "" # settings set by each option
setval[""] = "" # value to set (indexed: 'option sets[option]')
# for each setting:
setting[""] = "" # requires by setting
defaults[""] = "" # used for a defaulted value
doneset[""] = 1 # marks setting as having been output
@ -200,7 +204,7 @@ $1 == "com"{
if (NF > 1) {
# sub(/^[ ]*com[ ]*/, "")
$1 = ""
print comment, $0, cend >out
print comment $0, cend >out
} else
print start end >out
next
@ -237,7 +241,9 @@ $1 == "file" && NF >= 2{
next
}
# option NAME ( (requires|enables|if) NAME* | on | off | disabled )*
# option NAME ( (requires|enables|if) NAME* | on | off | disabled |
# sets SETTING VALUE+ )*
#
# Declares an option 'NAME' and describes its default setting (disabled)
# and its relationship to other options. The option is disabled
# unless *all* the options listed after 'requires' are set and at
@ -252,95 +258,152 @@ $1 == "file" && NF >= 2{
# be later) entry may turn an option on or off explicitly.
$1 == "option" && NF >= 2{
onoff = option[$2] # records current (and the default is "", enabled)
opt = $2
sub(/,$/,"",opt)
onoff = option[opt] # records current (and the default is "", enabled)
key = ""
for (i=3; i<=NF; ++i) {
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
key = ""
if (onoff != $(i)) {
# on or off can zap disabled or enabled:
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) {
# It's easy to mis-spell the option when turning it
# on or off, so warn about it here:
if (onoff == "" && ($(i) == "on" || $(i) == "off")) {
print $2 ": ERROR: turning unrecognized option", $(i)
# For the moment error out - it is safer
err = 1 # prevent END{} running
exit 1
}
onoff = $(i)
} else {
# Print a message, otherwise the error
# below is incomprehensible
print $2 ": currently", onoff ": attempt to turn", $(i)
break
}
istart = 3
do {
if (istart == 1) { # continuation line
val = getline
if (val != 1) { # error reading it
if (val == 0)
print "option", opt ": ERROR: missing contination line"
else
print "option", opt ": ERROR: error reading continuation line"
# This is a hard error
err = 1 # prevent END{} running
exit 1
}
} else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") {
key = $(i)
} else if (key == "requires") {
requires[$2] = requires[$2] " " $(i)
} else if (key == "if") {
iffs[$2] = iffs[$2] " " $(i)
} else if (key == "enables") {
enabledby[$(i)] = enabledby[$(i)] " " $2
} else
break # bad line format
}
}
for (i=istart; i<=NF; ++i) {
val=$(i)
sub(/,$/,"",val)
if (val == "on" || val == "off" || val == "disabled") {
key = ""
if (onoff != val) {
# on or off can zap disabled or enabled:
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
(val == "on" || val == "off")) {
# It's easy to mis-spell the option when turning it
# on or off, so warn about it here:
if (onoff == "" && (val == "on" || val == "off")) {
print "option", opt ": ERROR: turning unrecognized option", val
# For the moment error out - it is safer
err = 1 # prevent END{} running
exit 1
}
onoff = val
} else {
# Print a message, otherwise the error
# below is incomprehensible
print "option", opt ": currently", onoff ": attempt to turn", val
break
}
}
} else if (val == "requires" || val == "if" || val == "enables" || val =="sets") {
key = val
} else if (key == "requires") {
requires[opt] = requires[opt] " " val
} else if (key == "if") {
iffs[opt] = iffs[opt] " " val
} else if (key == "enables") {
enabledby[val] = enabledby[val] " " opt
} else if (key == "sets") {
sets[opt] = sets[opt] " " val
key = "setval"
set = val
} else if (key == "setval") {
setval[opt " " set] = setval[opt " " set] " " val
} else
break # bad line format
}
istart = 1
} while (i > NF && $0 ~ /,$/)
if (i > NF) {
# Set the option, defaulting to 'enabled'
if (onoff == "") onoff = "enabled"
option[$2] = onoff
option[opt] = onoff
next
}
# Else fall through to the error handler
}
# chunk NAME [requires OPT] [on|off|disabled]
# chunk NAME [requires OPT] [enables LIST] [on|off|disabled]
# Expands to the 'option' settings appropriate to the reading and
# writing of an ancilliary PNG chunk 'NAME':
#
# option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
# option READ_NAME enables NAME
# option READ_NAME enables NAME LIST
# [option READ_NAME off]
# option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
# option WRITE_NAME enables NAME
# option WRITE_NAME enables NAME LIST
# [option WRITE_NAME off]
pre != 0 && $1 == "chunk" && NF >= 2{
# 'chunk' is handled on the first pass by writing appropriate
# 'option' lines into the intermediate file.
opt = $2
sub(/,$/,"",opt)
onoff = ""
reqread = ""
reqwrite = ""
i = 3 # indicates format error
if (NF > 2) {
enables = ""
req = 0
istart = 3
do {
if (istart == 1) { # continuation line
val = getline
if (val != 1) { # error reading it
if (val == 0)
print "chunk", opt ": ERROR: missing contination line"
else
print "chunk", opt ": ERROR: error reading continuation line"
# This is a hard error
err = 1 # prevent END{} running
exit 1
}
}
# read the keywords/additional OPTS
req = 0
for (i=3; i<=NF; ++i) {
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
if (onoff != $(i)) {
for (i=istart; i<=NF; ++i) {
val = $(i)
sub(/,$/,"",val)
if (val == "on" || val == "off" || val == "disabled") {
if (onoff != val) {
if (onoff == "")
onoff = $(i)
onoff = val
else
break # on/off conflict
}
} else if ($(i) == "requires")
req = 0
} else if (val == "requires")
req = 1
else if (req != 1)
else if (val == "enables")
req = 2
else if (req == 1){
reqread = reqread " READ_" val
reqwrite = reqwrite " WRITE_" val
} else if (req == 2)
enables = enables " " val
else
break # bad line: handled below
else {
reqread = reqread " READ_" $(i)
reqwrite = reqwrite " WRITE_" $(i)
}
}
}
istart = 1
} while (i > NF && $0 ~ /,$/)
if (i > NF) {
# Output new 'option' lines to the intermediate file (out)
print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2, onoff >out
print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2, onoff >out
print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out
print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out
next
}
# Else hit the error handler below - bad line format!
@ -471,83 +534,7 @@ END{
exit 0
}
# Do the 'setting' values first, the algorithm the standard
# tree walk (O(1)) done in an O(2) while/for loop; interations
# settings x depth, outputing the deepest required macros
# first.
print "" >out
print "/* SETTINGS */" >out
print comment, "settings", cend >out
# Sort (in dfn.awk) on field 2, the setting name
print "PNG_DFN_START_SORT 2" >out
finished = 0
while (!finished) {
finished = 1
movement = 0 # done nothing
for (i in setting) if (!doneset[i]) {
nreqs = split(setting[i], r)
if (nreqs > 0) {
for (j=1; j<=nreqs; ++j) if (!doneset[r[j]]) {
break
}
if (j<=nreqs) {
finished = 0
continue # try a different setting
}
}
# All the requirements have been processed, output
# this setting.
if (deb) print "setting", i
deflt = defaults[i]
# A leading @ means leave it unquoted so the preprocessor
# can substitute the build time value
if (deflt ~ /^ @/)
deflt = " " subs substr(deflt, 3) sube
# Remove any spurious trailing spaces
sub(/ *$/,"",deflt)
print "" >out
print "/* setting: ", i >out
print " * requires:" setting[i] >out
print " * default: ", defaults[i] defltinfo, "*/" >out
if (defaults[i] == "") { # no default, only check if defined
print "#ifdef PNG_" i >out
}
for (j=1; j<=nreqs; ++j) {
print "# ifndef PNG_" r[j] >out
print error, i, "requires", r[j] end >out
print "# endif" >out
}
if (defaults[i] != "") { # default handling
print "#ifdef PNG_" i >out
}
# PNG_<i> is defined, so substitute the value:
print def i, subs "PNG_" i sube end >out
if (defaults[i] != "") {
print "#else /*default*/" >out
# And add the default definition for the benefit
# of later settings an options test:
print "# define PNG_" i deflt >out
print def i deflt end >out
}
print "#endif" >out
doneset[i] = 1
++movement
}
if (!finished && !movement) {
print "setting: loop or missing setting in 'requires', cannot process:"
for (i in setting) if (!doneset[i]) {
print " setting", i, "requires" setting[i]
}
exit 1
}
}
print "PNG_DFN_END_SORT" >out
print comment, "end of settings", cend >out
# Now do the options - somewhat more complex. The dependency
# Do the options first (allowing options to set settings). The dependency
# tree is thus:
#
# name > name
@ -639,7 +626,7 @@ END{
}
if (err) exit 1
# Sort options too
# Sort options:
print "PNG_DFN_START_SORT 2" >out
# option[i] is now the complete list of all the tokens we may
@ -679,8 +666,9 @@ END{
print "" >out
print "/* option:", i, option[i] >out
print " * requires: " requires[i] >out
print " * if: " iffs[i] >out
print " * enabled-by:" enabledby[i], "*/" >out
print " * if: " iffs[i] >out
print " * enabled-by:" enabledby[i] >out
print " * sets: " sets[i], "*/" >out
print "#undef PNG_on" >out
print "#define PNG_on 1" >out
@ -763,6 +751,21 @@ END{
print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out
} else if (i !~ /^ok_/) {
print def i sup >out
# Supported option, set required settings
nreqs = split(sets[i], r)
for (j=1; j<=nreqs; ++j) {
print "# ifdef PNG_set_" r[j] >out
# Some other option has already set a value:
print error, i, "sets", r[j] ": duplicate setting" end >out
print error, " previous value: " end "PNG_set_" r[j] >out
print "# else" >out
# Else set the default: note that this won't accept arbitrary
# values, the setval string must be acceptable to all the C
# compilers we use. That means it must be VERY simple; a number,
# a name or a string.
print "# define PNG_set_" r[j], setval[i " " r[j]] >out
print "# endif" >out
}
}
print "# endif /* definition */" >out
print "#endif /*requires, if*/" >out
@ -796,6 +799,93 @@ END{
print "PNG_DFN_END_SORT" >out
print comment, "end of options", cend >out
# Do the 'setting' values second, the algorithm the standard
# tree walk (O(1)) done in an O(2) while/for loop; interations
# settings x depth, outputing the deepest required macros
# first.
print "" >out
print "/* SETTINGS */" >out
print comment, "settings", cend >out
# Sort (in dfn.awk) on field 2, the setting name
print "PNG_DFN_START_SORT 2" >out
finished = 0
while (!finished) {
finished = 1
movement = 0 # done nothing
for (i in setting) if (!doneset[i]) {
nreqs = split(setting[i], r)
if (nreqs > 0) {
# By default assume the requires values are options, but if there
# is no option with that name check for a setting
for (j=1; j<=nreqs; ++j) if (option[r[j]] == "" && !doneset[r[j]]) {
break
}
if (j<=nreqs) {
finished = 0
continue # try a different setting
}
}
# All the requirements have been processed, output
# this setting.
if (deb) print "setting", i
deflt = defaults[i]
# Remove any spurious trailing spaces
sub(/ *$/,"",deflt)
# A leading @ means leave it unquoted so the preprocessor
# can substitute the build time value
if (deflt ~ /^ @/)
deflt = " " subs substr(deflt, 3) sube
print "" >out
print "/* setting: ", i >out
print " * requires:" setting[i] >out
print " * default: ", defaults[i] deflt, "*/" >out
for (j=1; j<=nreqs; ++j) {
if (option[r[j]] != "")
print "#ifndef PNG_" r[j] "_SUPPORTED" >out
else
print "#ifndef PNG_" r[j] >out
print error, i, "requires", r[j] end >out
print "# endif" >out
}
# The precedence is:
#
# 1) External definition; trumps:
# 2) Option 'sets' value; trumps:
# 3) Setting 'default'
#
print "#ifdef PNG_" i >out
# PNG_<i> is defined, so substitute the value:
print def i, subs "PNG_" i sube end >out
print "#else /* use default */" >out
print "# ifdef PNG_set_" i >out
# Value from an option 'sets' argument
print def i, subs "PNG_set_" i sube end >out
# This is so that subsequent tests on the setting work:
print "# define PNG_" i, "1" >out
if (defaults[i] != "") {
print "# else /*default*/" >out
print def i deflt end >out
print "# define PNG_" i, "1" >out
}
print "# endif /* defaults */" >out
print "#endif /* setting", i, "*/" >out
doneset[i] = 1
++movement
}
if (!finished && !movement) {
print "setting: loop or missing setting in 'requires', cannot process:"
for (i in setting) if (!doneset[i]) {
print " setting", i, "requires" setting[i]
}
exit 1
}
}
print "PNG_DFN_END_SORT" >out
print comment, "end of settings", cend >out
# Regular end - everything looks ok
if (protect != "") {
print start "#endif", "/*", protect, "*/" end >out

View File

@ -27,7 +27,7 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
# The syntax is detailed in scripts/options.awk, this is a summary
# only:
#
# setting <name> [default]
# setting <name> [requires ...] [default]
# #define PNG_<name> <value> /* value comes from current setting */
# option <name> [requires ...] [if ...] [enables ...] [disabled]
# #define PNG_<name>_SUPPORTED if the requirements are met and
@ -191,12 +191,23 @@ option WRITE enables WRITE_INT_FUNCTIONS
setting FILTER_OPTIMIZATIONS
# This option turns on runtime checks for ARM NEON support, it is irrelevant
# on other platforms and it is irrelevant unless NEON code is turned on. Checks
# are on by default
option ARM_NEON_CHECK
# Implementation specific control of the optimizations, enabled by those
# hardware or software options that need it (typically when run-time choices
# must be made by the user)
option SET_OPTION disabled
# These options are specific to the ARM NEON hardware optimizations:
#
# ARM_NEON: the optimization itself
# ARM_NEON_API: allow the optimization to be switched on with png_set_hardware
# ARM_NEON_CHECK: compile a run-time check to see if Neon extensions are
# supported, this is poorly supported and deprectated - use the
# png_set_hardware API.
option ARM_NEON disabled,
sets FILTER_OPTIMIZATIONS png_init_filter_functions_neon
option ARM_NEON_API disabled enables SET_OPTION ARM_NEON
option ARM_NEON_CHECK disabled enables ARM_NEON
# Generic options - affect both read and write.
option WARNINGS
@ -369,6 +380,12 @@ option INCH_CONVERSIONS
option BUILD_GRAYSCALE_PALETTE
# This changes the default for the ARM NEON optimizations according to
# __ARM_NEON__
@#ifdef __ARM_NEON__
@# define PNG_ARM_NEON_SUPPORTED
@#endif
# IN DEVELOPMENT
# These are currently experimental features; define them if you want

View File

@ -1,43 +1,25 @@
/* libpng STANDARD API DEFINITION */
/* 1.5.15beta08 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* Libpng 1.5.15beta08 - March 2, 2013 */
/* libpng version 1.5.15beta08 - March 4, 2013 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
/* and license in png.h */
/* pnglibconf.h */
/* Machine generated file: DO NOT EDIT */
/* Derived from: scripts/pnglibconf.dfa */
/* If you edit this file by hand you must obey the rules expressed in */
/* pnglibconf.dfa with respect to the dependencies between the following */
/* symbols. It is much better to generate a new file using */
/* scripts/libpngconf.mak */
#ifndef PNGLCONF_H
#define PNGLCONF_H
/* settings */
#define PNG_API_RULE 0
#define PNG_CALLOC_SUPPORTED
#define PNG_COST_SHIFT 3
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
#define PNG_sCAL_PRECISION 5
/* end of settings */
/* options */
#define PNG_16BIT_SUPPORTED
#define PNG_ALIGNED_MEMORY_SUPPORTED
#define PNG_ARM_NEON_CHECK_SUPPORTED
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
/*#undef PNG_ARM_NEON_SUPPORTED*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
@ -116,6 +98,7 @@
#define PNG_SETJMP_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
/*#undef PNG_SET_OPTION_SUPPORTED*/
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_TEXT_SUPPORTED
@ -188,4 +171,18 @@
#define PNG_tRNS_SUPPORTED
#define PNG_zTXt_SUPPORTED
/* end of options */
/* settings */
#define PNG_API_RULE 0
#define PNG_CALLOC_SUPPORTED
#define PNG_COST_SHIFT 3
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
#define PNG_sCAL_PRECISION 5
/* end of settings */
#endif /* PNGLCONF_H */

View File

@ -1,3 +1,4 @@
;Version 1.5.15beta08
;--------------------------------------------------------------
; LIBPNG symbol list as a Win32 DEF file
; Contains all the symbols that can be exported from libpng
@ -5,7 +6,6 @@
LIBRARY
EXPORTS
;Version 1.5.15beta08
png_access_version_number @1
png_set_sig_bytes @2
png_sig_cmp @3
@ -241,3 +241,4 @@ EXPORTS
png_set_cHRM_XYZ_fixed @233
png_set_check_for_invalid_index @234
png_get_palette_max @235
png_set_option @236

View File

@ -35,13 +35,14 @@
* defaulted to 'off' in scripts/pnglibconf.dfa
*
* Maintenance: if scripts/pnglibconf.dfa options are changed
* from, or to, 'off' this needs updating!
* from, or to, 'disabled' this needs updating!
*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_ERROR_NUMBERS_SUPPORTED
#define PNG_READ_BIG_ENDIAN_SUPPORTED /* should do nothing! */
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#define PNG_SET_OPTION_SUPPORTED
#undef PNG_H
#include "../png.h"