VirtualBox

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

Last change on this file since 107044 was 103316, checked in by vboxsync, 13 months ago

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

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
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: png-mng-implement@sourceforge.net
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}
Note: See TracBrowser for help on using the repository browser.

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