Changeset 14651 for trunk


Ignore:
Timestamp:
Feb 14, 2011, 7:50:31 AM (9 years ago)
Author:
gb
Message:

Define and call check_arm_cpu(), which now wants an ARMv7 or
later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r14644 r14651  
    15501550#endif
    15511551
     1552#ifdef ARM
     1553Boolean
     1554check_arm_cpu()
     1555{
     1556  Boolean win = false;
     1557#ifdef LINUX
     1558/* It's hard to determine ARM features in general, and especially
     1559   hard to do so from user mode.  Parse /proc/cpuinfo.
     1560   According to Android's cpufeatures library, some ARMv6 chips
     1561   are reported to have archutecture version 7; check the ELF
     1562   architecture in this case.
     1563
     1564   (In other words, we assume that we're on ARMv7 or later if
     1565   the reported architecture is > 7, or if it's = 7 and the
     1566   ELF architecture is "v7l".)
     1567*/
     1568  FILE *f = fopen("/proc/cpuinfo", "r");
     1569  char *procline = NULL, *cpuline = NULL, **lineptr, *line = NULL;
     1570  size_t n;
     1571  ssize_t result;
     1572
     1573  if (f) {
     1574    while (1) {
     1575      n = 0;
     1576      line = NULL;
     1577      lineptr = &line;
     1578      result = getline(lineptr, &n, f);
     1579      if (result < 0) {
     1580        break;
     1581      }
     1582      line = *lineptr;
     1583      if (strncmp(line,"Processor",sizeof("Processor")-1) == 0) {
     1584        procline = line;
     1585      } else if (strncmp(line, "CPU architecture",sizeof("CPU architecture")-1) == 0) {
     1586        cpuline = line;
     1587      } else {
     1588        free(line);
     1589      }
     1590    }
     1591    line = NULL;
     1592    if (cpuline) {
     1593      line = index(cpuline,':');
     1594      if (line) {
     1595        n = strtol(line+1,lineptr,0);
     1596        if (n >= 7) {
     1597          if (n == 7) {
     1598            if (procline) {
     1599              win = (strstr(procline, "v7l") != NULL);
     1600            }
     1601          } else {
     1602            win = true;
     1603          }
     1604        }
     1605      }
     1606    }
     1607    if (procline) {
     1608      free(procline);
     1609    }
     1610    if (cpuline) {
     1611      free(cpuline);
     1612    }
     1613    fclose(f);
     1614  }
     1615#endif
     1616  return win;
     1617}
     1618#endif 
     1619
    15521620void
    15531621lazarus()
     
    18001868#ifdef X86
    18011869  if (!check_x86_cpu()) {
     1870    fprintf(dbgout, "CPU doesn't support required features\n");
     1871    exit(1);
     1872  }
     1873#endif
     1874
     1875#ifdef ARM
     1876  if (!check_arm_cpu()) {
    18021877    fprintf(dbgout, "CPU doesn't support required features\n");
    18031878    exit(1);
Note: See TracChangeset for help on using the changeset viewer.