VirtualBox

source: vbox/trunk/src/libs/libpng-1.6.42/contrib/powerpc-vsx/linux.c@ 105132

最後變更 在這個檔案從105132是 103316,由 vboxsync 提交於 14 月 前

libpng-1.6.42: Applied and adjusted our libpng changes to 1.6.42. bugref:8515

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.2 KB
 
1/* contrib/powerpc-vsx/linux.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: [email protected]
12 *
13 * png_have_vsx implemented for Linux by reading the widely available
14 * pseudo-file /proc/cpuinfo.
15 *
16 * This code is strict ANSI-C and is probably moderately portable; it does
17 * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
18 */
19
20#include <stdio.h>
21#include <string.h>
22#include <stdlib.h>
23#include "png.h"
24
25#ifndef MAXLINE
26# define MAXLINE 1024
27#endif
28
29static int
30png_have_vsx(png_structp png_ptr)
31{
32 FILE *f;
33
34 const char *string = "altivec supported";
35 char input[MAXLINE];
36 char *token = NULL;
37
38 PNG_UNUSED(png_ptr)
39
40 f = fopen("/proc/cpuinfo", "r");
41 if (f != NULL)
42 {
43 memset(input,0,MAXLINE);
44 while(fgets(input,MAXLINE,f) != NULL)
45 {
46 token = strstr(input,string);
47 if(token != NULL)
48 return 1;
49 }
50 }
51#ifdef PNG_WARNINGS_SUPPORTED
52 else
53 png_warning(png_ptr, "/proc/cpuinfo open failed");
54#endif
55 return 0;
56}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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