[libpng15] Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON

runtime checks
This commit is contained in:
John Bowler
2013-02-19 10:20:06 -06:00
committed by Glenn Randers-Pehrson
parent 1b69de718e
commit d19ad72e28
7 changed files with 73 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.5.15beta06 - February 18, 2013 Libpng 1.5.15beta06 - February 19, 2013
This is not intended to be a public release. It will be replaced 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. within a few weeks by a public version or by another test version.
@@ -55,9 +55,11 @@ Version 1.5.15beta05 [February 17, 2013]
library calls. library calls.
Fixed a race condition in the creation of the build 'scripts' directory Fixed a race condition in the creation of the build 'scripts' directory
while building with a parallel make. while building with a parallel make.
Use parentheses more consistently in "#if define(MACRO)" tests. Use parentheses more consistently in "#if defined(MACRO)" tests.
Version 1.5.15beta06 [February 18, 2013] Version 1.5.15beta06 [February 19, 2013]
Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON
runtime checks
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@@ -4013,9 +4013,11 @@ Version 1.5.15beta05 [February 17, 2013]
library calls. library calls.
Fixed a race condition in the creation of the build 'scripts' directory Fixed a race condition in the creation of the build 'scripts' directory
while building with a parallel make. while building with a parallel make.
Use parentheses more consistently in "#if define(MACRO)" tests. Use parentheses more consistently in "#if defined(MACRO)" tests.
Version 1.5.15beta06 [February 18, 2013] Version 1.5.15beta06 [February 19, 2013]
Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON
runtime checks
=========================================================================== ===========================================================================
NOTICE November 17, 2012: NOTICE November 17, 2012:

View File

@@ -16,12 +16,17 @@
#include "../pngpriv.h" #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, /* __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 * Andoid intends to define __ANDROID__, however there are bugs in their
* toolchain; use -D__ANDROID__ to work round this. * toolchain; use -D__ANDROID__ to work round this.
*
* __ARM_NEON__ is used to ensure that the compiler has the appropriate ARM
* NEON support
*/ */
#if defined __linux__ && defined __arm__
#define CHECK_NEON #ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
#include <signal.h> /* for sig_atomic_t */ #include <signal.h> /* for sig_atomic_t */
#ifdef __ANDROID__ #ifdef __ANDROID__
@@ -43,7 +48,7 @@ png_have_neon(png_structp png_ptr)
return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
} }
#else #elif defined(__linux__)
/* The generic __linux__ implementation requires reading /proc/self/auxv and /* The generic __linux__ implementation requires reading /proc/self/auxv and
* looking at each element for one that records NEON capabilities. * looking at each element for one that records NEON capabilities.
*/ */
@@ -143,14 +148,20 @@ png_have_neon(png_structp png_ptr)
close(fd); close(fd);
return 0; return 0;
} }
#endif /* !__ANDROID__ */ #else
#endif /* __linux__ && __arm__ */ /* We don't know how to do a run-time check on this system */
# error "no support for run-time ARM NEON checks"
#endif /* OS checks */
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
#endif
void void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp) png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{ {
#ifdef __arm__ #ifdef PNG_ARM_NEON_CHECK_SUPPORTED
#ifdef CHECK_NEON
static volatile sig_atomic_t no_neon = -1; /* not checked */ static volatile sig_atomic_t no_neon = -1; /* not checked */
if (no_neon < 0) if (no_neon < 0)
@@ -158,7 +169,7 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
if (no_neon) if (no_neon)
return; return;
#endif #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
/* IMPORTANT: any new external functions used here must be declared using /* IMPORTANT: any new external functions used here must be declared using
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
@@ -188,8 +199,5 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth4_neon; png_read_filter_row_paeth4_neon;
} }
#else
PNG_UNUSED(pp)
PNG_UNUSED(bpp)
#endif
} }
#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */

View File

@@ -10,11 +10,14 @@
* and license in png.h * and license in png.h
*/ */
/* This is required to get the symbol renames, which are #defines */ /* This is required to get the symbol renames, which are #defines, and also
* includes the value of PNG_FILTER_OPTIMIZATIONS.
*/
#define PNG_VERSION_INFO_ONLY #define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h" #include "../pngpriv.h"
#ifdef __arm__ #if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
defined(__ARM_NEON__)
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif #endif
@@ -229,4 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1
pop {r4,pc} pop {r4,pc}
endfunc endfunc
#endif #endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */

View File

@@ -172,15 +172,22 @@ AC_SUBST([binconfigs])
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack]) AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
AC_ARG_ENABLE([arm-neon], AC_ARG_ENABLE([arm-neon],
AC_HELP_STRING([--enable-arm-neon], [Enable ARM NEON optimizations]), AS_HELP_STRING([[[--enable-arm-neon]]],
[if test "${enableval}" = yes; then [Enable ARM NEON optimizations: use 'always' to turn off run-time checks]),
[if test "${enableval}" = "yes" -o "${enableval}" = "always"; then
AC_DEFINE([PNG_FILTER_OPTIMIZATIONS], AC_DEFINE([PNG_FILTER_OPTIMIZATIONS],
[png_init_filter_functions_neon], [png_init_filter_functions_neon],
[ARM NEON filter initialization function]) [ARM NEON filter initialization function])
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1],
[Align row buffers]) [Align row buffers])
if test "${enableval}" = "always"; then
AC_DEFINE([PNG_NO_ARM_NEON_CHECK], [],
[Turn off run-time checking for ARM NEON support])
fi
fi]) fi])
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes]) AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above # Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])

View File

@@ -127,6 +127,12 @@ logunsupported = 1
# - PNG_USER_VERSIONINFO_COMPANYNAME # - PNG_USER_VERSIONINFO_COMPANYNAME
# - PNG_USER_VERSIONINFO_LEGALTRADEMARKS # - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
# It is necessary to include configures definitions here so that AC_DEFINE
# in configure.ac works in a comprehensible way
@#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
@# include "config.h"
@#endif
@#ifdef PNG_USER_CONFIG @#ifdef PNG_USER_CONFIG
@# include "pngusr.h" @# include "pngusr.h"
@#endif @#endif
@@ -179,6 +185,18 @@ option READ_INT_FUNCTIONS requires READ
option WRITE_INT_FUNCTIONS disabled option WRITE_INT_FUNCTIONS disabled
option WRITE enables WRITE_INT_FUNCTIONS option WRITE enables WRITE_INT_FUNCTIONS
# 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
# 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
# Generic options - affect both read and write. # Generic options - affect both read and write.
option WARNINGS option WARNINGS
@@ -446,7 +464,7 @@ option CHECK_cHRM requires cHRM
# but can help (in theory) on some architectures. Only affects # but can help (in theory) on some architectures. Only affects
# internal structures. Added at libpng 1.4.0 # internal structures. Added at libpng 1.4.0
option ALIGN_MEMORY option ALIGNED_MEMORY
# Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING # Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING
# See png[wr]util.c, normally this should always be *on* # See png[wr]util.c, normally this should always be *on*

View File

@@ -3,7 +3,7 @@
/* pnglibconf.h - library build configuration */ /* pnglibconf.h - library build configuration */
/* Libpng 1.5.15beta06 - February 18, 2013 */ /* Libpng 1.5.15beta06 - February 19, 2013 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
@@ -36,7 +36,8 @@
/* end of settings */ /* end of settings */
/* options */ /* options */
#define PNG_16BIT_SUPPORTED 1 #define PNG_16BIT_SUPPORTED 1
#define PNG_ALIGN_MEMORY_SUPPORTED 1 #define PNG_ALIGNED_MEMORY_SUPPORTED
#define PNG_ARM_NEON_CHECK_SUPPORTED
#define PNG_BENIGN_ERRORS_SUPPORTED 1 #define PNG_BENIGN_ERRORS_SUPPORTED 1
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 1 #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 1
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 1 #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 1