From owner-freebsd-current@FreeBSD.ORG Sat Nov 19 09:32:52 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 E6EBA106566B; Sat, 19 Nov 2011 09:32:51 +0000 (UTC) (envelope-from rmh.aybabtu@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 83E048FC13; Sat, 19 Nov 2011 09:32:51 +0000 (UTC) Received: by iakl21 with SMTP id l21so6968002iak.13 for ; Sat, 19 Nov 2011 01:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=IBpB9xe8t6fN3MPJ8zOJtiwDnLxth/0H0Bqjoy59rIA=; b=rCEu1Etv6kMjKoVUQLj8sKfE4BMLCOkoCNDyeNQ9AAdYUGGexBH6vXJjbcRcfhUSAt VKl0iQOWjJdI4GwfZyMV1tzh0oKVrov68QfYKn2/ql3dN04HM6cj8NGdqghcXvtgRoqj afh2VshF0xVWYNNOAKtnlTEaytB3yzDkuRAKY= MIME-Version: 1.0 Received: by 10.42.135.66 with SMTP id o2mr6220493ict.0.1321695170889; Sat, 19 Nov 2011 01:32:50 -0800 (PST) Sender: rmh.aybabtu@gmail.com Received: by 10.42.243.198 with HTTP; Sat, 19 Nov 2011 01:32:50 -0800 (PST) In-Reply-To: References: <201111170959.56767.jhb@freebsd.org> <201111171632.34979.jhb@freebsd.org> Date: Sat, 19 Nov 2011 10:32:50 +0100 X-Google-Sender-Auth: 5ZcxXZGkHpU2HiuEor9e23h8dik Message-ID: From: Robert Millan To: John Baldwin Content-Type: multipart/mixed; boundary=90e6ba6e89d62986f104b21323a0 Cc: Kostik Belousov , 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: Sat, 19 Nov 2011 09:32:52 -0000 --90e6ba6e89d62986f104b21323a0 Content-Type: text/plain; charset=UTF-8 2011/11/18 Robert Millan : > 2011/11/17 John Baldwin : >> Hmm, I wonder if it's better to use the #ifndef approach rather than #undef >> so that when compilers are updated to DTRT we will honor their settings? > > Well, the compiler is supposed to know better than sys/param.h, I gave this a bit more thought.... The compiler knows about the system it was intended to build for, but sys/param.h *is* part of the system we're building for. It's impossible for sys/param.h to have the wrong information unless it's out of sync with the rest of the headers. As for the compiler, on FreeBSD it's hard for the compiler to be out of sync, because the system (in comparison with others) is tightly packaed and upgrade procedures are well defined. But if you take Debian, for example, we use the same compiler to build 8-STABLE, 9-STABLE and 10-CURRENT kernels. The compiler has no idea which version of FreeBSD the sources it is building come from. I wouldn't put compilers in general in a position where they're forced to know the FreeBSD major version beforehand because sys/param.h will give preference to the information coming from compiler. I propose this alternate patch which derives the major number from __FreeBSD_version instead. --90e6ba6e89d62986f104b21323a0 Content-Type: text/x-diff; charset=US-ASCII; name="freebsd_kernel.diff" Content-Disposition: attachment; filename="freebsd_kernel.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gv6f4hap0 SW5kZXg6IHN5cy9zeXMvcGFyYW0uaAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzeXMvc3lzL3BhcmFtLmgJKHJl dmlzaW9uIDIyNzU4MCkKKysrIHN5cy9zeXMvcGFyYW0uaAkod29ya2luZyBjb3B5KQpAQCAtNjAs NiArNjAsMjMgQEAKICN1bmRlZiBfX0ZyZWVCU0RfdmVyc2lvbgogI2RlZmluZS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