VirtualBox

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

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

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

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.2 KB
 
1
2/* contrib/mips-msa/linux.c
3 *
4 * Copyright (c) 2020-2023 Cosmin Truta
5 * Copyright (c) 2016 Glenn Randers-Pehrson
6 * Written by Mandar Sahastrabuddhe, 2016.
7 * Updated by Sui Jingfeng, 2021.
8 *
9 * This code is released under the libpng license.
10 * For conditions of distribution and use, see the disclaimer
11 * and license in png.h
12 *
13 * On Linux, png_have_msa is implemented by reading the pseudo-file
14 * "/proc/self/auxv".
15 *
16 * See contrib/mips-msa/README before reporting bugs.
17 *
18 * STATUS: SUPPORTED
19 * BUG REPORTS: [email protected]
20 */
21
22#include <elf.h>
23#include <fcntl.h>
24#include <stdlib.h>
25#include <unistd.h>
26
27static int
28png_have_msa(png_structp png_ptr)
29{
30 Elf64_auxv_t aux;
31 int fd;
32 int has_msa = 0;
33
34 fd = open("/proc/self/auxv", O_RDONLY);
35 if (fd >= 0)
36 {
37 while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
38 {
39 if (aux.a_type == AT_HWCAP)
40 {
41 uint64_t hwcap = aux.a_un.a_val;
42
43 has_msa = (hwcap >> 1) & 1;
44 break;
45 }
46 }
47 close(fd);
48 }
49#ifdef PNG_WARNINGS_SUPPORTED
50 else
51 png_warning(png_ptr, "/proc/self/auxv open failed");
52#endif
53
54 return has_msa;
55}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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