Even more preferably, just have (in a header file)
#ifdef CONFIG_SMP
inline int nr_running(void)
{
...
}
.. other SMP cases ..
#else
#define nr_running() (__nr_running)
.. other UP cases ..
#endif
if you just cannot make an efficient function that just works for both.
No, we don't adhere to this everywhere. But we should (and largely _do_)
try to.
Having the #ifdef's outside the code tends to have two advantages:
- it makes the code much more readable, and doesn't split things up.
- you have to choose your abstraction interfaces more carefully, which in
turn tends to make for better code.
Abstraction is nice - _especially_ when you have a compiler that sees
through the abstraction and can generate code as if it wasn't there.
Linus
-
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/