On 07/10/07 07:39 -0600, Jordan Crouse wrote:
There has got to be a way that we can turn this into a general purpose macro to make it easy for developers to mark new functions as shared without understanding whats happening above
Like maybe this (avert your eyes, children!):
#if SHARED #define FUNC(func, ret, args...) \ ret stage0##func(args) #define EXTERN(func,ret,args...) \ ret (*func)(args) = stage0##func #else #define FUNC(func, ret, args...) \ ret func(args) #define EXTERN(func,ret,args...) #endif
/* Syntax: * func - function name * ret - return value * args - function arguments */
#define _SHARED(func,ret,args...) \ FUNC(func,ret,##args); \ EXTERN(func,ret,##args)
/* Example */
_SHARED(printk, int, char *, ...);
/* Resolves to: int printk(char *, ...); ; (when !SHARED)
int stage0printk(char *, ...); int (*printk)(char *, ...) = stage0printk; (when SHARED) */
Jordan