discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Bug in volk on armv6


From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] Bug in volk on armv6
Date: Wed, 3 Jul 2013 10:55:06 -0400

On Mon, Jul 1, 2013 at 4:08 AM, Alexey Bazhin <address@hidden> wrote:
> Hi!
>
> I would like to report a bug in volk on armv6.
>
> There is infinite "while" cycle in volk/tmpl/volk_cpu.tmpl.c function
> "has_neon" (line 111).
>
> Code "while(!found_neon && auxvec_f) {" will loop infinitely if there
> is no neon in platform. found_neon will never be true and file
> descriptor auxvec_f will always be true.
>
> --
> Alexey Bazhin <address@hidden>

Ok, I see your point. Looks like we should be testing the return value
from fread, instead of auxvec_f. Can you confirm if this patch works?

diff --git a/volk/tmpl/volk_cpu.tmpl.c b/volk/tmpl/volk_cpu.tmpl.c
index 81fc679..b1a0a4a 100644
--- a/volk/tmpl/volk_cpu.tmpl.c
+++ b/volk/tmpl/volk_cpu.tmpl.c
@@ -116,10 +116,11 @@ static int has_neon(void){
     auxvec_f = fopen("/proc/self/auxv", "rb");
     if(!auxvec_f) return 0;

+    size_t r = 1;
     //so auxv is basically 32b of ID and 32b of value
     //so it goes like this
-    while(!found_neon && auxvec_f) {
-      fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
+    while(!found_neon && r) {
+      r = fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
       if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
         found_neon = 1;
     }

Or might be better to test 'if(r < 2)' after the fread line and break
in case an error occurs and we only get 1 character out and not try to
read from it again. Probably not a bit deal since we're only reading
in two chars at a time.

Tom



reply via email to

[Prev in Thread] Current Thread [Next in Thread]