From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 3 03:05:13 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 797F0106566C; Sun, 3 Jul 2011 03:05:13 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 1D4768FC0A; Sun, 3 Jul 2011 03:05:12 +0000 (UTC) Received: by vxg33 with SMTP id 33so4240606vxg.13 for ; Sat, 02 Jul 2011 20:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=xrSVdwivqvf7kRSzijmwCLlH76uRTBIXqIYbCz3WqAQ=; b=UAD3+bqzxhnhpfJRk0L7q5i/2h6exfrkT4+yCA3zYAyUUizUqmSIPXP1TK4opkLBMF nS/bnxcd1y0OyMCM7JtBIwlVAPifJYIejVt641iS7iHCQdj7GicRR7EkUEy1WOWbDaaS knDqzquEQub94zu52Pp8aROGTjT7UK2twpkzE= MIME-Version: 1.0 Received: by 10.220.8.193 with SMTP id i1mr1840270vci.108.1309662312212; Sat, 02 Jul 2011 20:05:12 -0700 (PDT) Received: by 10.220.92.201 with HTTP; Sat, 2 Jul 2011 20:05:12 -0700 (PDT) In-Reply-To: <20110703020827.GA5763@sandvine.com> References: <20110702193724.5c55a6c9@kan.dnsalias.net> <20110703020827.GA5763@sandvine.com> Date: Sat, 2 Jul 2011 20:05:12 -0700 Message-ID: From: Garrett Cooper To: Ed Maste Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Robert 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 03:05:13 -0000 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__. =A0If 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: > =A0 =A0 =A0 =A0builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR);= =A0 =A0 =A0\ > >> 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 softwar= e > 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? =A0Where is it defined? 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: $ echo '' | gcc -E -xc -dM -c - 2>&1 | grep linux #define __linux 1 #define __linux__ 1 #define __gnu_linux__ 1 #define linux 1 HTH, -Garrett