[PATCH] __FreeBSD_kernel__

Alexander Kabaev kabaev at gmail.com
Sat Jul 2 23:37:33 UTC 2011


On Sat, 2 Jul 2011 17:41:03 +0200
Robert Millan <rmh at debian.org> wrote:

> Since their inception, GNU/kFreeBSD systems had defined
> "__FreeBSD_kernel__" as builtin macro to indicate this is a system
> that uses the kernel of FreeBSD.  We couldn't define "__FreeBSD__"
> because this implies a full FreeBSD system, and a lot of software
> checks for this macro when it is concerned with userland (usually
> libc).
> 
> As a result of this, and of the considerable porting effort that
> followed, many 3rd party programs with kernel-specific extensions have
> been ported to recognize __FreeBSD_kernel__ as well. E.g.:
> 
> #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> // code for FreeBSD kernel
> #endif
> 
> My request is that FreeBSD also defines __FreeBSD_kernel__.  If this
> happens, life would be made a bit easier on both sides, as it'd be
> more natural for porters of either system to support both using a
> single macro [1].
> 
> [1] When porting software to support FreeBSD and systems with kernel
> of FreeBSD myself (as I did with e.g. GRUB), I generally took care to
> ensure both macros are checked for, but this isn't always the case.
> Having a unified macro would make it easier for developers of both
> systems to cooperate.
> 
> -- 
> Robert Millan


I do not think this belongs in GCC at all. You should already have a
defined symbol to identify your OS and that should be used in cases
where it matters. Alternatively, you should provide the symbol in
similar way in which we provide __FreeBSD_version, through well-known
header like sys/param.h and not pollute GCC. GCC is on the way to be
pushed out into ports in FreeBSD and it will not the the only usable
compiler before long. Your proposal will force similar changes in
Clang, Path64 and PCC, <what else>, to be really universal which is not
practical.

All IMHO.


-- 
Alexander Kabaev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110702/1b77543b/signature.pgp


More information about the freebsd-hackers mailing list