summaryrefslogtreecommitdiff
path: root/contrib/powerpc-vsx/linux_aux.c
blob: 6ec048e80a23106334c15e444e594dd75e819976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* contrib/powerpc-vsx/linux_aux.c
 *
 * Copyright (c) 2017 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
 *
 * STATUS: TESTED
 * BUG REPORTS: png-mng-implement@sourceforge.net
 *
 * png_have_vsx implemented for Linux by using the auxiliary vector mechanism.
 *
 * 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)
{
   unsigned long auxv = getauxval(AT_HWCAP);

   PNG_UNUSED(png_ptr)

   if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
      return 1;
   else
      return 0;
}