From 354146b4cab3ac19e48890844963362c2f874399 Mon Sep 17 00:00:00 2001 From: pcpa Date: Tue, 22 Apr 2014 14:39:10 -0300 Subject: [PATCH] ARM: Do not leave early init_jit if /proc is not mounted. * lib/jit_arm.c: Do not get confused with default settings if /proc is not mounted on Linux specific code path. --- ChangeLog | 5 +++++ lib/jit_arm.c | 49 ++++++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7170e8515..79bdd6f35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-22 Paulo Andrade + + * lib/jit_arm.c: Do not get confused with default settings + if /proc is not mounted on Linux specific code path. + 2014-04-09 Paulo Andrade * include/lightning/jit_aarch64.h, include/lightning/jit_arm.h, diff --git a/lib/jit_arm.c b/lib/jit_arm.c index 71c1a791d..e71fedabc 100644 --- a/lib/jit_arm.c +++ b/lib/jit_arm.c @@ -142,35 +142,34 @@ jit_get_cpu(void) char *ptr; char buf[128]; - if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) - return; - - while (fgets(buf, sizeof(buf), fp)) { - if (strncmp(buf, "CPU architecture:", 17) == 0) { - jit_cpu.version = strtol(buf + 17, &ptr, 10); - while (*ptr) { - if (*ptr == 'T' || *ptr == 't') { - ++ptr; + if ((fp = fopen("/proc/cpuinfo", "r")) != NULL) { + while (fgets(buf, sizeof(buf), fp)) { + if (strncmp(buf, "CPU architecture:", 17) == 0) { + jit_cpu.version = strtol(buf + 17, &ptr, 10); + while (*ptr) { + if (*ptr == 'T' || *ptr == 't') { + ++ptr; + jit_cpu.thumb = 1; + } + else if (*ptr == 'E' || *ptr == 'e') { + jit_cpu.extend = 1; + ++ptr; + } + else + ++ptr; + } + } + else if (strncmp(buf, "Features\t:", 10) == 0) { + if ((ptr = strstr(buf + 10, "vfpv"))) + jit_cpu.vfp = strtol(ptr + 4, NULL, 0); + if ((ptr = strstr(buf + 10, "neon"))) + jit_cpu.neon = 1; + if ((ptr = strstr(buf + 10, "thumb"))) jit_cpu.thumb = 1; - } - else if (*ptr == 'E' || *ptr == 'e') { - jit_cpu.extend = 1; - ++ptr; - } - else - ++ptr; } } - else if (strncmp(buf, "Features\t:", 10) == 0) { - if ((ptr = strstr(buf + 10, "vfpv"))) - jit_cpu.vfp = strtol(ptr + 4, NULL, 0); - if ((ptr = strstr(buf + 10, "neon"))) - jit_cpu.neon = 1; - if ((ptr = strstr(buf + 10, "thumb"))) - jit_cpu.thumb = 1; - } + fclose(fp); } - fclose(fp); #endif #if defined(__ARM_PCS_VFP) if (!jit_cpu.vfp)