VirtualBox

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

Last change on this file since 107985 was 107813, checked in by vboxsync, 4 months ago

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

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