> void free_dma(unsigned int dmanr)
> {
> if (dmanr >= MAX_DMA_CHANNELS) {
> printk("Trying to free DMA%d\n", dmanr);
> return;
> }
>
> if (xchg(&dma_chan_busy[dmanr].lock, 0) == 0) {
> /* ERROR */ printk("Trying to free free DMA%d\n", dmanr);
> return;
> }
>
> } /* free_dma */
>
> Including a real_printk() at the line marked with ERROR will
> result in:
[snip]
> ...which is fine and contains the needed xchg call. However,
> substituting the printk() with "do {} while (0)" above,
> the "if" path seems to be completely removed by the optimizer:
>
> 00000088 <free_dma>:
> 88: c3 ret
> 89: 8d b4 26 00 00 00 00 lea 0x0(%esi,1),%esi
>
>
> I've looked at ./include/asm-i386/system.h which does some black
> magic with it, and I don't really understand that. However, the
> result is that the xchg gets optimized away, rendering at least
> the floppy module unuseable:-(
There is a comment that asm is not 100% valid.
My GCC 3.0.1 does not produce buggy code, guess why?
It does _not_ inline __xchg() even at -O99!
So much of compiler improvement 8-(
-- vda - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/