sync with experimental
[luatex.git] / source / libs / libpng / libpng-src / contrib / mips-msa / linux.c
blob140215c4ea6e3167a7decc72855a5fc5f4cfb209
1 /* contrib/mips-msa/linux.c
3 * Copyright (c) 2016 Glenn Randers-Pehrson
4 * Written by Mandar Sahastrabuddhe, 2016.
5 * Last changed in libpng 1.6.25beta03 [August 29, 2016]
7 * This code is released under the libpng license.
8 * For conditions of distribution and use, see the disclaimer
9 * and license in png.h
11 * SEE contrib/mips-msa/README before reporting bugs
13 * STATUS: SUPPORTED
14 * BUG REPORTS: png-mng-implement@sourceforge.net
16 * png_have_msa implemented for Linux by reading the widely available
17 * pseudo-file /proc/cpuinfo.
19 * This code is strict ANSI-C and is probably moderately portable; it does
20 * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
23 #include <stdio.h>
24 #include <string.h>
25 #include <stdlib.h>
27 static int
28 png_have_msa(png_structp png_ptr)
30 FILE *f = fopen("/proc/cpuinfo", "rb");
32 char *string = "msa";
33 char word[10];
35 if (f != NULL)
37 while(!feof(f))
39 int ch = fgetc(f);
40 static int i = 0;
42 while(!(ch <= 32))
44 word[i++] = ch;
45 ch = fgetc(f);
48 int val = strcmp(string, word);
50 if (val == 0)
51 return 1;
53 i = 0;
54 memset(word, 0, 10);
57 fclose(f);
59 #ifdef PNG_WARNINGS_SUPPORTED
60 else
61 png_warning(png_ptr, "/proc/cpuinfo open failed");
62 #endif
63 return 0;