parse_proc_cpuinfo (int bufsize)
{
  char *buffer = (char *)malloc(bufsize);
  FILE *fd;

  if (!buffer)
    return 0;

  fd = fopen("/proc/cpuinfo", "r");
  if (fd) {
    while (fgets(buffer, bufsize, fd)) {
      if (!strchr(buffer, '\n') && !feof(fd)) {
        /* "impossible" happened - insufficient size of the buffer! */
        fclose(fd);
        free(buffer);
        return 0;
      }
      if (check_cpuinfo(buffer, "CPU part", "0xd03") ||
          check_cpuinfo(buffer, "CPU part", "0xd07"))
        /* The Cortex-A53 has a slow tbl implementation.  We can gain a few
           percent speedup by disabling the use of that instruction.  The
           speedup on Cortex-A57 is more subtle but still measurable. */
        simd_features &= ~JSIMD_FASTTBL;
      else if (check_cpuinfo(buffer, "CPU part", "0x0a1"))
        /* The SIMD version of Huffman encoding is slower than the C version on
           Cavium ThunderX.  Also, ld3 and st3 are abyssmally slow on that
           CPU. */
        simd_huffman = simd_features = 0;
    }
    fclose(fd);
  }
  free(buffer);
  return 1;
}
Exemple #2
0
int
main(int argc, char *argv[])
{
	START(argc, argv, "util_cpuid");

	check_cpuinfo();

	DONE(NULL);
}