mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
update libpng
update libpng, the repo now requires a vcpkg setup for integrating but skipping the install step should allow it to work for windows an linux, mac might need more
This commit is contained in:
parent
c593d860a0
commit
5d644b4ffb
300 changed files with 25573 additions and 17698 deletions
|
|
@ -1,64 +1,54 @@
|
|||
/* contrib/mips-msa/linux.c
|
||||
*
|
||||
* Copyright (c) 2020-2023 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, 2016.
|
||||
* Last changed in libpng 1.6.25beta03 [August 29, 2016]
|
||||
* Updated by Sui Jingfeng, 2021.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/mips-msa/README before reporting bugs
|
||||
* On Linux, png_have_msa is implemented by reading the pseudo-file
|
||||
* "/proc/self/auxv".
|
||||
*
|
||||
* See contrib/mips-msa/README before reporting bugs.
|
||||
*
|
||||
* STATUS: SUPPORTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_msa implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int
|
||||
png_have_msa(png_structp png_ptr)
|
||||
{
|
||||
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
Elf64_auxv_t aux;
|
||||
int fd;
|
||||
int has_msa = 0;
|
||||
|
||||
char *string = "msa";
|
||||
char word[10];
|
||||
|
||||
if (f != NULL)
|
||||
fd = open("/proc/self/auxv", O_RDONLY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
while(!feof(f))
|
||||
while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
|
||||
{
|
||||
int ch = fgetc(f);
|
||||
static int i = 0;
|
||||
|
||||
while(!(ch <= 32))
|
||||
if (aux.a_type == AT_HWCAP)
|
||||
{
|
||||
word[i++] = ch;
|
||||
ch = fgetc(f);
|
||||
uint64_t hwcap = aux.a_un.a_val;
|
||||
|
||||
has_msa = (hwcap >> 1) & 1;
|
||||
break;
|
||||
}
|
||||
|
||||
int val = strcmp(string, word);
|
||||
|
||||
if (val == 0)
|
||||
return 1;
|
||||
|
||||
i = 0;
|
||||
memset(word, 0, 10);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
close(fd);
|
||||
}
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
return has_msa;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue