VirtualBox

source: vbox/trunk/src/libs/libpng-1.6.37/contrib/mips-msa/linux.c@ 98108

Last change on this file since 98108 was 96425, checked in by vboxsync, 2 years ago

src/libs: Switch to libpng-1.6.37, bugref:8515 [re-export]

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1/* contrib/mips-msa/linux.c
2 *
3 * Copyright (c) 2016 Glenn Randers-Pehrson
4 * Written by Mandar Sahastrabuddhe, 2016.
5 * Last changed in libpng 1.6.25beta03 [August 29, 2016]
6 *
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
10 *
11 * SEE contrib/mips-msa/README before reporting bugs
12 *
13 * STATUS: SUPPORTED
14 * BUG REPORTS: png-mng-implement@sourceforge.net
15 *
16 * png_have_msa implemented for Linux by reading the widely available
17 * pseudo-file /proc/cpuinfo.
18 *
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.
21 */
22
23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27static int
28png_have_msa(png_structp png_ptr)
29{
30 FILE *f = fopen("/proc/cpuinfo", "rb");
31
32 char *string = "msa";
33 char word[10];
34
35 if (f != NULL)
36 {
37 while(!feof(f))
38 {
39 int ch = fgetc(f);
40 static int i = 0;
41
42 while(!(ch <= 32))
43 {
44 word[i++] = ch;
45 ch = fgetc(f);
46 }
47
48 int val = strcmp(string, word);
49
50 if (val == 0)
51 return 1;
52
53 i = 0;
54 memset(word, 0, 10);
55 }
56
57 fclose(f);
58 }
59#ifdef PNG_WARNINGS_SUPPORTED
60 else
61 png_warning(png_ptr, "/proc/cpuinfo open failed");
62#endif
63 return 0;
64}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette