![]() | |||||||||||
Messages in this thread |
Andi Kleen <ak@suse.de> writes: > Good point. I somehow assumed that __builtin_expect would just signify > a boolean, but if I read gcc source correctly this was wrong. Yeh, it's a long so you'll get no cast warnings too. > Here is an updated patch. [snip ... ] > --- include/linux/kernel.h-LIKELY Tue Sep 18 11:12:20 2001 > +++ include/linux/kernel.h Tue Sep 18 14:35:17 2001 > @@ -171,4 +171,14 @@ > char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ > }; > > + > +/* This loses on a few early 2.96 snapshots, but hopefully nobody uses them anymore. */ > +#if __GNUC__ > 2 || (__GNUC__ == 2 && _GNUC_MINOR__ == 96) > +#define likely(x) __builtin_expect(!!(x), 1) > +#define unlikely(x) __builtin_expect((x), 0) unlikely() also needs to be... #define unlikely(x) __builtin_expect(!(x), 1) ...or... #define unlikely(x) __builtin_expect(!!(x), 0) > +#else > +#define likely(x) (x) > +#define unlikely(x) (x) > +#endif > + > #endif -- # James Antill -- james@and.org :0: * ^From: .*james@and\.org /dev/null - 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/ | ||||||||||
| Last update: 2005-03-22 13:03 [from the cache] ©2003-2008 | |||||||||||