|
Rockbox mail archiveSubject: Re: Cowon D2 EABIRe: Cowon D2 EABI
From: pouly amaury <amaury.pouly_at_gmail.com>
Date: Tue, 15 Jun 2010 11:19:45 +0200 2010/6/15 Rafaël Carré <rafael.carre_at_gmail.com> > On Tue, 15 Jun 2010 00:02:14 +0100 > Rob Purchase <rob.purchase_at_googlemail.com> wrote: > > > On 14/06/2010 23:14, Andrew Poelstra wrote: > > > > 2. If you're just counting clock cycles, the 'volatile' specifier > > > should prevent gcc's loop optimizations, no? > > > 2. Yes, but this generates additional code since extra ldr/str > > instructions are generated each time the loop counter is accessed, > > You can add 'register' to a variable to (try to) avoid that. > > that would be 'register unsigned long x' in i2c-telechips.c > > If the code is too dependant of the compiler, perhaps just write it in > assembly? > > -- > Rafaël Carré > The register keyword doesn't help. I committed a solution with a nop but I know it's not optimal. However, it came to my mind that such a thing could work: (untested) unsigned long x; for (x = (unsigned)(FREQ>>22); x; x--) asm volatile("":::"memory"); Clobbering memory is likely to prevent gcc from optimizing the loop away. I just tested on a x86 with 4.4.1 and it works. And we would get the same instructions as before. I'll test it on a real target tonight but anyone is welcome to try and commit before if it works. Writing it in assembly could be an option but which one is better between ugly inline assembly code and ugly C timing code ? :) Regards Received on 2010-06-15 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |