Which of the following is more readable:
/* try atomic lock inline, if that fails, spin out of line */
"\tbtsl $1,%0\n"
"\tbne 2f\n"
"1:\n"
"\t.section .text.lock\n\n"
"\t2:\tcmpl $0,%0\n"
"\tbne 2b\n"
"\trep ; nop\n"
"\tjmpl 1b\n\n"
"\t.section .previous\n"
or:
/* try atomic lock inline, if that fails, spin out of line */
" btsl $1,%0
1:
.section .text.lock
2: cmpl $0,%0
bne 2b
jmpl 1b
.section .previous"
or:
while (unlikely(test_and_set_bit(1, lock))) {
while (lock.value)
arch_pause();
}
Ooops, sorry, ignore 3 -- that's only possible in a world where there is
intrinsic support in the compiler to generate the assembly we're aiming
for. But of the two assembly versions, I think the second is much more
readable. The few gcc people I've spoken to locally about this agreed with
me when I showed them some of the inline assembly bits in the two forms as
above.
-ben
-
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/