Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jul 2011 17:37:30 +0200
From:      Robert Millan <rmh@debian.org>
To:        Alexander Kabaev <kabaev@gmail.com>
Cc:        Garrett Cooper <yanegomi@gmail.com>, freebsd-hackers@freebsd.org, Ed Maste <emaste@freebsd.org>
Subject:   Re: [PATCH] __FreeBSD_kernel__
Message-ID:  <CAOfDtXOcfbNw6St5CMN4GB_psf8hZEV=hpL4q3mmQXqWeLmqXQ@mail.gmail.com>
In-Reply-To: <20110703103531.4a553271@kan.dnsalias.net>
References:  <CAOfDtXPUxQO1zbnxh8sh%2By7g=d8QaH2svYtEQJ06L4d%2BQKG8VA@mail.gmail.com> <20110702193724.5c55a6c9@kan.dnsalias.net> <20110703020827.GA5763@sandvine.com> <CAGH67wQAv4Tf8HjccN2GZzgD2u1ZrORABtGehxXjeg109%2BRNWQ@mail.gmail.com> <20110703103531.4a553271@kan.dnsalias.net>

next in thread | previous in thread | raw e-mail | index | archive | help
2011/7/3 Alexander Kabaev <kabaev@gmail.com>:
> __linux__ is exactly what __FreeBSD__ is and dies not identify kernel
> but rather Linux as whole OS, whatever that might be these days.
>
> There does not appear to be an universal macro that identifies
> environment as using Linux kernel regardless of the rest of components
> used (say, to identify Android and Ubuntu or something embedded with
> ucLibc as running Linux kernel with different userland
> implementations).

I think I'll cowardly try to stick to a practical POV and avoid the
discussion about names that tends to get people excited about :-)

So from a purely practical perspective:

- If __linux__ is defined, this implies you're using a specific kernel.
- If you're using that specific kernel, this implies __linux__ is defined.

which explains why using __linux__ to identify the kernel is useful
and reliable.

Can __linux__ be used to identify more things?  Most notably, can
__linux__ be used to identify userland API?

- If __linux__ is defined, this does not imply you're using GNU libc.
- If you're using GNU libc, this does not imply __linux__ is defined.

which explains why using __linux__ to identify libc is a bad idea.
However, it can be useful to identify a set of different C libraries
(Glibc, Bionic, uclibc, etc) if they share the property you're
interested in.

-- 
Robert Millan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfDtXOcfbNw6St5CMN4GB_psf8hZEV=hpL4q3mmQXqWeLmqXQ>