From: Arnd B. <ar...@ar...> - 2009-06-25 21:11:36
|
On Thursday 25 June 2009, Jaya Kumar wrote: > The patch looks good. I was going to suggest that it might be > attractive to use __attribute__(weak) for each of the dummy functions > instead of ifdefs in this case, but I can't remember if there was a > consensus about attribute-weak versus ifdefs. We rarely use weak functions, the canonical way to express an optional subsystem is along the lines of /* include/linux/foo.h */ #ifdef CONFIG_FOO extern int bar(void); #else static inline int bar(void) { return 0; } #endif --- /* foo/foo.c */ int bar(void) { /* the real thing here */ ... } --- # foo/Makefile obj-$(CONFIG_FOO) += foo.c Most uses of __weak or __attribute__((weak)) are for working default implementations that can be overridden by architecture specific code. However, for these the preferred way to express seems to have shifted towards variations of: /* include/linux/foo.h */ #include <asm/foo.h> #ifndef bar static inline int bar(void) { /* generic implementation */ ... } #endif /* arch/*/include/asm/foo.h */ #define bar bar static inline int bar(void) { /* arch specific implementation */ ... } Arnd <>< |