From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 3 14:35:39 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6F221065674 for ; Sun, 3 Jul 2011 14:35:39 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 7EFBF8FC17 for ; Sun, 3 Jul 2011 14:35:39 +0000 (UTC) Received: by vws18 with SMTP id 18so4401219vws.13 for ; Sun, 03 Jul 2011 07:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; bh=ni83C3ElTm/8TyAOKJ5lhYZWZ6sUDy6UsEEyRSfUddc=; b=NMuNhh9s6e8UpHOxqTu+BVhTEE946A4sR1pr4gNEa19UWY6vKweLkcAr3eNZCEsoxi WNfRwh82/0l1JfGtU4OYQHeA+QaJZek19F2iD15yOBY2iVo+KSSL8RI0Pci69WgW7XvO KuuLyQZtLPNki/zP8tZPZiH5tPtkmr1zCC4tI= Received: by 10.52.166.165 with SMTP id zh5mr3370208vdb.158.1309703738598; Sun, 03 Jul 2011 07:35:38 -0700 (PDT) Received: from kan.dnsalias.net (c-24-63-226-98.hsd1.ma.comcast.net [24.63.226.98]) by mx.google.com with ESMTPS id 20sm3030919vbe.15.2011.07.03.07.35.36 (version=SSLv3 cipher=OTHER); Sun, 03 Jul 2011 07:35:37 -0700 (PDT) Date: Sun, 3 Jul 2011 10:35:31 -0400 From: Alexander Kabaev To: Garrett Cooper Message-ID: <20110703103531.4a553271@kan.dnsalias.net> In-Reply-To: References: <20110702193724.5c55a6c9@kan.dnsalias.net> <20110703020827.GA5763@sandvine.com> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.1; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/iuc1qVM5aE7B20Se6WzXTHr"; protocol="application/pgp-signature" Cc: freebsd-hackers@freebsd.org, Robert, Ed Maste , Millan Subject: Re: [PATCH] __FreeBSD_kernel__ X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 14:35:40 -0000 --Sig_/iuc1qVM5aE7B20Se6WzXTHr Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable On Sat, 2 Jul 2011 20:05:12 -0700 Garrett Cooper wrote: > On Sat, Jul 2, 2011 at 7:08 PM, Ed Maste wrote: > > On Sat, Jul 02, 2011 at 07:37:24PM -0400, Alexander Kabaev wrote: > > > >> On Sat, 2 Jul 2011 17:41:03 +0200 > >> Robert Millan wrote: > >> > >> > My request is that FreeBSD also defines __FreeBSD_kernel__. =9AIf > >> > 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]. > > > > I think this is a good idea, especially if it means that a single > > change can make it into upstream projects to support both FreeBSD > > and Debian kFreeBSD. > > > >> 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. > > > > I suspect the proposed patch put it in GCC based on the fact that we > > already have __FreeBSD__ in contrib/gcc/config/freebsd-spec.h: > > =9A =9A =9A =9Abuiltin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR= ); > > =9A =9A\ > > > >> 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. > > > > I suspect this is probably a reasonable alternative, but may mean > > software will have to pick up an additional #include. > > > > Out of curiosity, what is the canonical way for software to > > identify a Linux kernel -- __linux__ or some variant? =9AWhere is it > > defined? >=20 > linux is most often reliably defined value based on my personal > experience and it's defined in gcc [look for > `builtin_define.*("linux");' (note: this is a regexp..)]. Example: >=20 > $ echo '' | gcc -E -xc -dM -c - 2>&1 | grep linux > #define __linux 1 > #define __linux__ 1 > #define __gnu_linux__ 1 > #define linux 1 >=20 > HTH, > -Garrett __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). --=20 Alexander Kabaev --Sig_/iuc1qVM5aE7B20Se6WzXTHr Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iD8DBQFOEH43Q6z1jMm+XZYRAl8ZAKDJtBR1I9io5uBJ8Cwb6gu7maPwaQCfcWu+ 3xGLMqKLpOoGKj+9LJqNEHI= =sPWw -----END PGP SIGNATURE----- --Sig_/iuc1qVM5aE7B20Se6WzXTHr--