Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Nov 2011 12:40:42 +0100
From:      Robert Millan <rmh@freebsd.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        Adrian Chadd <adrian@freebsd.org>, freebsd-current@freebsd.org, Warner Losh <imp@bsdimp.com>, freebsd-arch@freebsd.org
Subject:   Re: [PATCH] Detect GNU/kFreeBSD in user-visible kernel headers
Message-ID:  <20111120114042.GA1256@thorin>
In-Reply-To: <20111119175620.GV50300@deviant.kiev.zoral.com.ua>
References:  <CAOfDtXPX1Rv9T7%2B1jYQbkM14tRY7mqgCzPcUqvHxFaRObbwvEg@mail.gmail.com> <201111170959.56767.jhb@freebsd.org> <CAOfDtXNy8r5ww5xSwhH-4w7daWdzB0KsVbO75JAOT=-Wzi%2BdHw@mail.gmail.com> <201111171632.34979.jhb@freebsd.org> <CAOfDtXMFk%2BC_eUsb6190UHHM0cgu3jf1M_M9oq4ibuYuke4pYQ@mail.gmail.com> <CAOfDtXP6ShN3DezN0u4PUVt9ft__2a%2BYwo3in9w01eQnfAQ7sQ@mail.gmail.com> <20111119175620.GV50300@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--uZ3hkaAS1mZxFaxD
Content-Type: multipart/mixed; boundary="45Z9DzgjV8m4Oswq"
Content-Disposition: inline


--45Z9DzgjV8m4Oswq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.
>=20
> We must do this to be able to use third-party tooldchain for FreeBSD buil=
ds.
>=20
> 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.

--=20
Robert Millan

--45Z9DzgjV8m4Oswq
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="freebsd_kernel.diff"
Content-Transfer-Encoding: quoted-printable

Index: sys/sys/param.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 */
=20
+/*
+ * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBS=
D,
+ * which by definition is always true on FreeBSD. This macro is also defin=
ed
+ * 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

--45Z9DzgjV8m4Oswq--

--uZ3hkaAS1mZxFaxD
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/kFreeBSD)

iQIcBAEBCAAGBQJOyOc6AAoJELd1onhloKnOtqcP/i5iauSTUFGr+KKByL67pChM
AnQyq223iEfPn21v9kKuD8wIBqoetQCYMUPfd4QyNI5SEDi/4kSr4LWG4h81wKCQ
6WjEesPb5lCG+/7+mp4SpLgVHQAwXarNLTP5KKCYKyROrj3DC1tTPjkBuknfcA89
Qp2on7e2vNzd9D+CFO0ol+q3Y5Oy/NkiN5GFLfDo01B2fELTn7b91VxkbkNGki4b
Mz35uaiLMLOdzVt9iskbpRA2aCndRgIzMeSs04XHZvVpykj/wi50TXtpkfI8FeKG
U+AyFTjY99ltJlpwcaU8iPnkLTiUdORtHp44pdNccSKBHcfR9ru55RRQm9aZ63ud
XqaSC+WZaMLa3gMFf7+6NF4KB8h/HvnjGqe9g7bSLD6SgsmTa1QRx3m9h483gQ4J
rwzy+jPj7BgL4SvQT0ZM4VUNwxCa13z3+Q5sCyVOxfgCI2SS+7w4kgRGXSN0rByF
y5xlE+eF3N8X7NnmnEpRubEQIrU+Yeiby5QMR/kqbDb/MBUTVGkUisFNPKpvfkcJ
UsbEpOVnnadrslmylYvb+0UDoy5g35IdpQVq6hSLNGObgPHl3A6g+JCGU4Dev49X
xTtuOxJKXwWM/uJh1R9CpI/AihlFMrvaJhp4OXmH4nQO/KPOy2MwLP87PiqJ3nn4
uTF3AW2xq69KGB4qSere
=GLmz
-----END PGP SIGNATURE-----

--uZ3hkaAS1mZxFaxD--



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