2008-09-23 08:01:33 Why don't using preprocessor #ifdef with anomaly
Jean-Francois Argentino (FRANCE)
Message: 62552
Hello,
Could somebody explain me why, whenever we have test regarding to an anomaly, it use a C "if"? For performance issue, it would be better to use a "#ifndef", isn't it?
For example, in asm/blackfin.h, why not using:
[CODE]
static inline void SSYNC(void)
{
int _tmp;
#ifdef ANOMALY_05000312
__asm__ __volatile__(
"cli %0;"
"nop;"
"nop;"
"ssync;"
"sti %0;"
: "=d" (_tmp)
);
#else #ifdef ANOMALY_05000244
__asm__ __volatile__(
"nop;"
"nop;"
"nop;"
"ssync;"
);
#else
__asm__ __volatile__("ssync;");
#endif
}
[/CODE]
instead of:
[CODE]
static inline void SSYNC(void)
{
int _tmp;
if (ANOMALY_05000312)
__asm__ __volatile__(
"cli %0;"
"nop;"
"nop;"
"ssync;"
"sti %0;"
: "=d" (_tmp)
);
else if (ANOMALY_05000244)
__asm__ __volatile__(
"nop;"
"nop;"
"nop;"
"ssync;"
);
else
__asm__ __volatile__("ssync;");
}
[/CODE]
TranslateQuoteReplyEditDelete
2008-09-23 09:51:32 Re: Why don't using preprocessor #ifdef with anomaly
Robin Getz (UNITED STATES)
Message: 62557
Jean-Francois:
gcc removes dead code.
if (0) will goto dead code
C is easier to read/maintain than ifdefs.
-Robin
QuoteReplyEditDelete
2008-09-23 12:34:32 Re: Why don't using preprocessor #ifdef with anomaly
Jean-Francois Argentino (FRANCE)
Message: 62570
GCC is definitly too smart for me...
Thanks for your answer.