Date: 11/20/06 (Code WTF) Keywords: linux Вот такой код в mm/slab.c, чудная особенность в том, что оно не скомпилируется с выключенным оптимизатором... /*
* This function must be completely optimized away if a constant is passed to
* it. Mostly the same as what is in linux/slab.h except it returns an index.
*/
static __always_inline int index_of(const size_t size)
{
extern void __bad_size(void);
if (__builtin_constant_p(size)) {
int i = 0;
#define CACHE(x) \
if (size <=x) \
return i; \
else \
i++;
#include "linux/kmalloc_sizes.h"
#undef CACHE
__bad_size();
} else
__bad_size();
return 0;
}
Source: http://community.livejournal.com/code_wtf/59064.html
|