On Sat, Nov 19, 2011 at 07:56:20PM +0200, Kostik Belousov wrote: > I fully agree with an idea that compiler is not an authorative source > of the knowledge of the FreeBSD version. Even more, I argue that we shall > not rely on compiler for this at all. Ideally, we should be able to > build FreeBSD using the stock compilers without local modifications. > Thus relying on the symbols defined by compiler, and not the source > is the thing to avoid and consistently remove. > > We must do this to be able to use third-party tooldchain for FreeBSD builds. > > That said, why not define __FreeBSD_kernel as equal to __FreeBSD_version ? > And then make more strong wording about other systems that use the macro, > e.g. remove 'may' from the kFreeBSD example. > Also, please remove the smile from comment.
Ok. New patch attached. -- Robert Millan
Index: sys/sys/param.h =================================================================== --- sys/sys/param.h (revision 227580) +++ sys/sys/param.h (working copy) @@ -60,6 +60,22 @@ #undef __FreeBSD_version #define __FreeBSD_version 1000001 /* Master, propagated to newvers */ +/* + * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, + * which by definition is always true on FreeBSD. This macro is also defined + * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD + * + * It is tempting to use this macro in userland code when we want to enable + * kernel-specific routines, and in fact it's fine to do this in code that + * is part of FreeBSD itself. However, be aware that as presence of this + * macro is still not widespread (e.g. older FreeBSD versions, 3rd party + * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in + * external applications without also checking for __FreeBSD__ as an + * alternative. + */ +#undef __FreeBSD_kernel__ +#define __FreeBSD_kernel__ __FreeBSD_version + #ifdef _KERNEL #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004
signature.asc
Description: Digital signature
