Added auxv-based VSX detection method for PowerPC and enabled it by default

This commit is contained in:
Vadim Barkov 2017-01-31 11:59:11 +00:00
parent d0d310f1cb
commit bea573d370
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,34 @@
/* contrib/powerpc-vsx/linux.c
*
* Copyright (c) 2016 Glenn Randers-Pehrson
* Written by Vadim Barkov, 2017.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* SEE contrib/powerpc-vsx/README before reporting bugs
*
* STATUS: COMPILED
* BUG REPORTS: png-mng-implement@sourceforge.net
*
* png_have_vsx implemented for Linux by reading the widely available
* pseudo-file /proc/cpuinfo. Result is cached so if function will be called
* multiple times only one reading is perfomed.
*
* This code is strict ANSI-C and is probably moderately portable; it does
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
*/
#include "sys/auxv.h"
#include "png.h"
static int
png_have_vsx(png_structp png_ptr)
{
const unsigned long auxv = getauxval( AT_HWCAP );
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX ))
return 1;
else
return 0;
}

View File

@ -32,7 +32,7 @@
*/
#ifndef PNG_POWERPC_VSX_FILE
# ifdef __linux__
# define PNG_POWERPC_VSX_FILE "contrib/powerpc-vsx/linux.c"
# define PNG_POWERPC_VSX_FILE "contrib/powerpc-vsx/linux_aux.c"
# endif
#endif