Re: [PATCH] video: arch specific page protection support for deferred io
From: Arnd Bergmann <arnd@arndb.de>
Date: 2009-06-25 20:56:12
Also in:
linux-mm
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 <><
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>