Messages in this thread | | | From | Kyle Moffett <> | Subject | Re: What policy for BUG_ON()? | Date | Tue, 31 Aug 2004 17:30:24 -0400 |
| |
On Aug 31, 2004, at 13:39, Albert Cahalan wrote: > Expensive function calls won't get optimized away unless you > mark them __attribute__((__const__)) or __attribute__((__pure__)). > (perhaps that should be encouraged) > > Then of course the compiler must assume that the function > really needed the arguments it was passed, and that it > might have modified memory, and so on. > > Eh, how about a BUG_ON_WITH_SIDE_EFFECT() macro?
Due to the potentially large number of existing BUG_ON() usages with side effects, it might be better to do this:
#if DEBUG # define BUG_ON(cond) do { if (cond) BUG(); } while(0) # define BUG_CHECK(cond) do { if (cond) BUG(); } while(0) #else # define BUG_ON(cond) do { if (cond); } while(0) # define BUG_CHECK(cond) do { } while(0) #endif
Then in most cases new statements would use BUG_CHECK, especially if they contain expensive unnecessary function calls or critical sections.
This would break the least amount of existing code, and provide both methods to kernel developers.
Cheers, Kyle Moffett
-----BEGIN GEEK CODE BLOCK----- Version: 3.12 GCM/CS/IT/U d- s++: a17 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$ L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+ PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r !y?(-) ------END GEEK CODE BLOCK------
- 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/
| |