1 /* contrib/powerpc-vsx/linux_aux.c
2 *
3 * Copyright (c) 2017 Glenn Randers-Pehrson
4 * Written by Vadim Barkov, 2017.
5 *
6 * This code is released under the libpng license.
7 * For conditions of distribution and use, see the disclaimer
8 * and license in png.h
9 *
10 * STATUS: TESTED
11 * BUG REPORTS: png-mng-implement@sourceforge.net
12 *
13 * png_have_vsx implemented for Linux by using the auxiliary vector mechanism.
14 *
15 * This code is strict ANSI-C and is probably moderately portable; it does
16 * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
17 */
18
19 #include "sys/auxv.h"
20 #include "png.h"
21
22 static int
23 png_have_vsx(png_structp png_ptr)
24 {
25 unsigned long auxv = getauxval(AT_HWCAP);
26
27 PNG_UNUSED(png_ptr)
28
29 if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
30 return 1;
31 else
32 return 0;
33 }