From owner-freebsd-current@FreeBSD.ORG Sun Nov 20 11:40:49 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A6EE106566B; Sun, 20 Nov 2011 11:40:49 +0000 (UTC) (envelope-from rmh.aybabtu@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 4BFEF8FC0A; Sun, 20 Nov 2011 11:40:47 +0000 (UTC) Received: by wwg14 with SMTP id 14so7934503wwg.31 for ; Sun, 20 Nov 2011 03:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=C4aW2lOCoRiybYjlCwU5KOcWW1a9JN0btpBchS8XgwE=; b=GAV6oVHn7/i+QRRbtinBzxQTl75MULTM9/YnFsS3Et2ZcY+D5Czap31KLW718ZEQdV YyzPNOJ4og7O8VftpTXOJkxtBIu2Pc7V+sm2C1bKaM1tS06QiFyyrEbROTZ9px8TWXyI DYXuBP9NRAKRiu9KMgUNuLQED16928ihbCTng= Received: by 10.216.30.206 with SMTP id k56mr1350964wea.98.1321789247206; Sun, 20 Nov 2011 03:40:47 -0800 (PST) Received: from thorin (52.Red-95-122-67.staticIP.rima-tde.net. [95.122.67.52]) by mx.google.com with ESMTPS id m25sm8430800wbp.6.2011.11.20.03.40.44 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 20 Nov 2011 03:40:46 -0800 (PST) Sender: Robert Millan Received: from rmh by thorin with local (Exim 4.72) (envelope-from ) id 1RS5lL-0000L0-0a; Sun, 20 Nov 2011 12:40:43 +0100 Date: Sun, 20 Nov 2011 12:40:42 +0100 From: Robert Millan To: Kostik Belousov Message-ID: <20111120114042.GA1256@thorin> References: <201111170959.56767.jhb@freebsd.org> <201111171632.34979.jhb@freebsd.org> <20111119175620.GV50300@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uZ3hkaAS1mZxFaxD" Content-Disposition: inline In-Reply-To: <20111119175620.GV50300@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Adrian Chadd , freebsd-current@freebsd.org, Warner Losh , freebsd-arch@freebsd.org Subject: Re: [PATCH] Detect GNU/kFreeBSD in user-visible kernel headers X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Nov 2011 11:40:49 -0000 --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--