- assigned_to: nobody --> atp
Here's a snippit from the calibrate_delay function
in linux/init/main.c:
================== gtest.c ========================
unsigned long loops_per_jiffy = (1<<12);
extern unsigned long volatile jiffies;
static inline void __delay(unsigned long loops)
{
__asm__ __volatile__(
"1:\tsobgtr %0, 1b\n"
: "=r" (loops)
: "0" (loops) );
}
void calibrate_delay(void)
{
unsigned long ticks;
loops_per_jiffy = (1<<12);
while (loops_per_jiffy <<= 1) {
/* wait for "start of" clock tick */
ticks = jiffies;
while (ticks == jiffies)
/* nothing */;
/* Go .. */
ticks = jiffies;
__delay(loops_per_jiffy);
ticks = jiffies - ticks;
if (ticks)
break;
}
Compile this with this Makefile:
===================== Makefile ===================
CFLAGS=-nostartfiles -nostdlib -Wall -O1 -fno-strength-reduce
all: g.lst no-g.lst
g.lst: gtest.c Makefile
vax-dec-linux-gcc $(CFLAGS) -c -o g.o \
$< -Wa,-adnls=g.lst -g
rm g.o
no-g.lst: gtest.c Makefile
vax-dec-linux-gcc $(CFLAGS) -c -o no-g.o \
$< -Wa,-adnls=no-g.lst
rm no-g.o
====================================================
(You may need to convert spaces back to tabs, Mozilla
won't let me insert a TAB char in this box).
The generate assembly code is different. This is
evidenced by the BogoMIPS rating being lower when main.c
is compiled with -g.
-g should only affect the generation of debugging info.
The generated code should be the same (and optimized
to -O1 in this case).