diff --git a/ANNOUNCE b/ANNOUNCE index 622114f4d..37a01a71e 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.3beta07 - June 6, 2013 +Libpng 1.6.3beta07 - June 8, 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. @@ -77,7 +77,7 @@ Version 1.6.3beta06 [May 12, 2013] right zlib header files. Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile -Version 1.6.3beta07 [June 6, 2013] +Version 1.6.3beta07 [June 8, 2013] Removed a redundant test in png_set_IHDR(). Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt) Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt @@ -86,6 +86,13 @@ Version 1.6.3beta07 [June 6, 2013] Make ARM NEON support work at compile time (not just configure time). This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when using a compiler that compiles for multiple architectures at one time. + Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from + pnglibconf.h, allowing more of the decisions to be made internally + (pngpriv.h) during the compile. Without this, symbol prefixing is broken + under certain circumstances on ARM platforms. Now only the API parts of + the optimizations ('check' vs 'api') are exposed in the public header files + except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the + decision about whether or not to use the optimizations. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 738cc8b5a..4615e2be7 100644 --- a/CHANGES +++ b/CHANGES @@ -4561,7 +4561,7 @@ Version 1.6.3beta06 [May 12, 2013] right zlib header files. Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile -Version 1.6.3beta07 [June 6, 2013] +Version 1.6.3beta07 [June 8, 2013] Removed a redundant test in png_set_IHDR(). Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt) Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt @@ -4570,6 +4570,13 @@ Version 1.6.3beta07 [June 6, 2013] Make ARM NEON support work at compile time (not just configure time). This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when using a compiler that compiles for multiple architectures at one time. + Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from + pnglibconf.h, allowing more of the decisions to be made internally + (pngpriv.h) during the compile. Without this, symbol prefixing is broken + under certain circumstances on ARM platforms. Now only the API parts of + the optimizations ('check' vs 'api') are exposed in the public header files + except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the + decision about whether or not to use the optimizations. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/arm/arm_init.c b/arm/arm_init.c index c24b2a083..dbde0ac6a 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -16,7 +16,7 @@ #include "../pngpriv.h" -#ifdef PNG_ARM_NEON_SUPPORTED +#if PNG_ARM_NEON_OPT > 0 #ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ #include /* for sig_atomic_t */ @@ -216,4 +216,4 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) png_read_filter_row_paeth4_neon; } } -#endif /* PNG_ARM_NEON_SUPPORTED */ +#endif /* PNG_ARM_NEON_OPT > 0 */ diff --git a/arm/filter_neon.S b/arm/filter_neon.S index 827d1a390..f3053201d 100644 --- a/arm/filter_neon.S +++ b/arm/filter_neon.S @@ -11,7 +11,7 @@ */ /* This is required to get the symbol renames, which are #defines, and also - * includes the definition (or not) of PNG_ARM_NEON_SUPPORTED. + * includes the definition (or not) of PNG_ARM_NEON_OPT. */ #define PNG_VERSION_INFO_ONLY #include "../pngpriv.h" @@ -20,7 +20,7 @@ .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ #endif -#ifdef PNG_ARM_NEON_SUPPORTED +#if PNG_ARM_NEON_OPT > 0 #ifdef __ELF__ # define ELF @@ -232,4 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1 pop {r4,pc} endfunc -#endif /* PNG_ARM_NEON_SUPPORTED */ +#endif /* PNG_ARM_NEON_OPT > 0 */ diff --git a/configure.ac b/configure.ac index 4bf8efff5..36ec44104 100644 --- a/configure.ac +++ b/configure.ac @@ -244,7 +244,7 @@ AC_ARG_ENABLE([arm-neon], [case "$enableval" in no|off) # disable the default enabling on __ARM_NEON__ systems: - AC_DEFINE([PNG_ARM_NEON_NOT_SUPPORTED], [], + AC_DEFINE([PNG_ARM_NEON_OPT], [0], [Disable ARM Neon optimizations]) # Prevent inclusion of the assembler files below: enable_arm_neon=no;; @@ -255,8 +255,11 @@ AC_ARG_ENABLE([arm-neon], AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [], [Turn on ARM Neon optimizations at run-time]);; yes|on) - AC_DEFINE([PNG_ARM_NEON_SUPPORTED], [], - [Enable ARM Neon optimizations]);; + AC_DEFINE([PNG_ARM_NEON_OPT], [2], + [Enable ARM Neon optimizations]) + AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass -mfpu=neon] + [to the compiler.]);; *) AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) esac]) diff --git a/pngconf.h b/pngconf.h index 23eee5201..8ae68b93c 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.3beta07 - June 6, 2013 + * libpng version 1.6.3beta07 - June 8, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -194,30 +194,6 @@ * PNG_USE_DLL is set. */ -/* Compile time options. - * ===================== - * In a multi-arch build the compiler may compile the code several times for the - * same object module, producing different codes for different architectures. - * When this happens configure-time setting of the target host options cannot be - * done and this interferes with the handling of the ARM NEON optimizations, and - * possibly other similiar optimizations. Put additional tests here; in general - * this is needed when the same option can be changed at both compile time and - * run time depending on the target OS (i.e. iOS vs Android.) - */ -#ifdef __ARM_NEON__ - /* If the default below causes problems set PNG_ARM_NEON_NOT_SUPPORTED either - * by passing --enable-arm-neon=no to configure or setting it in some other - * way when pnglibconf.h is built. - */ -# if (!defined PNG_ARM_NEON_SUPPORTED) && (!defined PNG_ARM_NEON_NOT_SUPPORTED) -# define PNG_ARM_NEON_SUPPORTED -# endif -#endif - -#if (defined PNG_ARM_NEON_SUPPORTED) && (defined PNG_ARM_NEON_NOT_SUPPORTED) -# error configuration: ARM_NEON cannot both be supported and disabled -#endif - /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings @@ -262,6 +238,7 @@ # define PNGAPI _stdcall # endif # endif /* compiler/api */ + /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) diff --git a/pngpriv.h b/pngpriv.h index fcfea42fb..c42aed796 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -88,6 +88,38 @@ # endif #endif +/* Compile time options. + * ===================== + * In a multi-arch build the compiler may compile the code several times for the + * same object module, producing different binaries for different architectures. + * When this happens configure-time setting of the target host options cannot be + * done and this interferes with the handling of the ARM NEON optimizations, and + * possibly other similiar optimizations. Put additional tests here; in general + * this is needed when the same option can be changed at both compile time and + * run time depending on the target OS (i.e. iOS vs Android.) The changes have + * to occur here to get the symbol prefixing to work consistently. + */ +#ifndef PNG_ARM_NEON_OPT + /* ARM NEON optimizations are being controlled by the compiler settings, + * typically the target FPU. If the FPU has been set to NEON (-mfpu=neon + * with GCC) then the compiler will define __ARM_NEON__ and we can rely + * unconditionally on NEON instructions not crashing, otherwise we must + * disable use of NEON instructions: + */ +# ifdef __ARM_NEON__ +# define PNG_ARM_NEON_OPT 2 +# else +# define PNG_ARM_NEON_OPT 0 +# endif +#endif + +#if PNG_ARM_NEON_OPT > 0 + /* NEON optimizations are to be at least considered by libpng, enable the + * callbacks to do this. (This is what matters for the symbol prefixing.) + */ +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon +#endif + /* Is this a build of a DLL where compilation of the object modules requires * different preprocessor settings to those required for a simple library? If * so PNG_BUILD_DLL must be set. diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index ff00b450c..ae9f323c0 100755 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -193,31 +193,38 @@ setting PREFIX setting DEFAULT_READ_MACROS default 1 -# This setting allows a hardware or configuration specific filter optimization -# function to be specified, the argument is the name of the filter initializaion -# function to use. - -setting FILTER_OPTIMIZATIONS - # 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: +# These options are specific to the ARM NEON hardware optimizations. At present +# these optimizations depend on GCC specific pre-processing of an assembler (.S) +# file so they probably won't work with other compilers. # -# ARM_NEON: the optimization itself -# ARM_NEON_NOT: disable the optimization even on systems that apparently support -# it (where the compiler defines __ARM_NEON__). -# 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_NOT disabled -option ARM_NEON_API disabled enables SET_OPTION ARM_NEON -option ARM_NEON_CHECK disabled enables ARM_NEON +# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by +# the compiler, typically as a result of specifying +# -mfpu=neon on the command line.) +# 0: disable (even if the CPU has a NEON FPU.) +# 1: check at run time (via ARM_NEON_{API,CHECK}) +# 2: switch on unconditionally (inadvisable - instead pass +# -mfpu=neon to GCC in CFLAGS) +# When building libpng avoid using any setting other than '0'; '1' is +# set automatically when either 'API' or 'CHECK' are configured in, +# '2' should not be necessary as -mfpu=neon will achieve the same +# effect as well as applying NEON optimizations to the rest of the +# libpng code. +# NOTE: any setting other than '0' requires ALIGNED_MEMORY +# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on +# with png_set_option +# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon +# extensions are supported, this is poorly supported and +# deprectated - use the png_set_option API. +setting ARM_NEON_OPT +option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION, + sets ARM_NEON_OPT 1 +option ARM_NEON_CHECK disabled requires ALIGNED_MEMORY, + sets ARM_NEON_OPT 1 # These settings configure the default compression level (0-9) and 'strategy'; # strategy is as defined by the implementors of zlib, it describes the input diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 1363f2d12..905fb4861 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -2,7 +2,7 @@ /* pnglibconf.h - library build configuration */ -/* Libpng version 1.6.3beta07 - May 12, 2013 */ +/* Libpng version 1.6.3beta07 - June 8, 2013 */ /* Copyright (c) 1998-2013 Glenn Randers-Pehrson */ @@ -20,7 +20,6 @@ #define PNG_ALIGNED_MEMORY_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_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/