> -----Oorspronkelijk bericht----- > Van: openocd-development-boun...@lists.berlios.de > [mailto:openocd-development-boun...@lists.berlios.de] Namens > Albert Cahalan > Verzonden: maandag 27 april 2009 8:49 > Aan: Øyvind Harboe > CC: openocd-development@lists.berlios.de > Onderwerp: Re: [Openocd-development] [PATCH] Fix build errors > in SVN on x86_64 > > On Mon, Apr 27, 2009 at 1:41 AM, Øyvind Harboe > <oyvind.har...@zylin.com> wrote: > > What's wrong with this code? > > > > long long then=timeval_ms(); > > while ((timeval_ms()-then)<duration) > > > > This appears many places in the code. > > > > comparision will work unless the difference is greater than > 31/63 bits > > in signed mode... > > Assuming nothing is unsigned long long or bigger, it should > all promote to long long. That's 63 bits at minimum, not > counting the sign bit. > > Even if it were 31-bit, you'd have: > 24 days, 20 hours, 31 minutes, 23 seconds, 647 milliseconds > > That's quite the marathon debug session.
If the 'long long' is changed into 'unsigned long long', the code will always work even in wrap-around situations. Perhaps it is a better idea to specify (typedef) a timer type as unsigned long long for this purpose. Nico Coesel _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development