Date: Sat, 19 Nov 2011 10:32:50 +0100 From: Robert Millan <rmh@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: Kostik Belousov <kostikbel@gmail.com>, 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: <CAOfDtXP6ShN3DezN0u4PUVt9ft__2a%2BYwo3in9w01eQnfAQ7sQ@mail.gmail.com> In-Reply-To: <CAOfDtXMFk%2BC_eUsb6190UHHM0cgu3jf1M_M9oq4ibuYuke4pYQ@mail.gmail.com> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
--90e6ba6e89d62986f104b21323a0 Content-Type: text/plain; charset=UTF-8 2011/11/18 Robert Millan <rmh@freebsd.org>: > 2011/11/17 John Baldwin <jhb@freebsd.org>: >> 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 NiArNjAsMjMgQEAKICN1bmRlZiBfX0ZyZWVCU0RfdmVyc2lvbgogI2RlZmluZSBfX0ZyZWVCU0Rf dmVyc2lvbiAxMDAwMDAxCS8qIE1hc3RlciwgcHJvcGFnYXRlZCB0byBuZXd2ZXJzICovCiAKKy8q CisgKiBfX0ZyZWVCU0Rfa2VybmVsX18gaW5kaWNhdGVzIHRoYXQgdGhpcyBzeXN0ZW0gdXNlcyB0 aGUga2VybmVsIG9mIEZyZWVCU0QsCisgKiB3aGljaCBieSBkZWZpbml0aW9uIGlzIGFsd2F5cyB0 cnVlIG9uIEZyZWVCU0QgOi0pLiBUaGlzIG1hY3JvIG1heSBhbHNvCisgKiBiZSBkZWZpbmVkIG9u IG90aGVyIHN5c3RlbXMgdGhhdCB1c2UgdGhlIGtlcm5lbCBvZiBGcmVlQlNELCBzdWNoIGFzCisg KiBHTlUva0ZyZWVCU0QuCisgKgorICogSXQgaXMgdGVtcHRpbmcgdG8gdXNlIHRoaXMgbWFjcm8g aW4gdXNlcmxhbmQgY29kZSB3aGVuIHdlIHdhbnQgdG8gZW5hYmxlCisgKiBrZXJuZWwtc3BlY2lm aWMgcm91dGluZXMsIGFuZCBpbiBmYWN0IGl0J3MgZmluZSB0byBkbyB0aGlzIGluIGNvZGUgdGhh dAorICogaXMgcGFydCBvZiBGcmVlQlNEIGl0c2VsZi4gIEhvd2V2ZXIsIGJlIGF3YXJlIHRoYXQg YXMgcHJlc2VuY2Ugb2YgdGhpcworICogbWFjcm8gaXMgc3RpbGwgbm90IHdpZGVzcHJlYWQgKGUu Zy4gb2xkZXIgRnJlZUJTRCB2ZXJzaW9ucywgM3JkIHBhcnR5CisgKiBjb21waWxlcnMsIGV0Yyks IGl0IGlzIFNUUk9OR0xZIERJU0NPVVJBR0VEIHRvIGNoZWNrIGZvciB0aGlzIG1hY3JvIGluCisg KiBleHRlcm5hbCBhcHBsaWNhdGlvbnMgd2l0aG91dCBhbHNvIGNoZWNraW5nIGZvciBfX0ZyZWVC U0RfXyBhcyBhbgorICogYWx0ZXJuYXRpdmUuCisgKi8KKyN1bmRlZiBfX0ZyZWVCU0Rfa2VybmVs X18KKyNkZWZpbmUgX19GcmVlQlNEX2tlcm5lbF9fIChfX0ZyZWVCU0RfdmVyc2lvbiAvIDEwMDAw MCkKKwogI2lmZGVmIF9LRVJORUwKICNkZWZpbmUJUF9PU1JFTF9TSUdXQUlUCQk3MDAwMDAKICNk ZWZpbmUJUF9PU1JFTF9TSUdTRUdWCQk3MDAwMDQK --90e6ba6e89d62986f104b21323a0--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfDtXP6ShN3DezN0u4PUVt9ft__2a%2BYwo3in9w01eQnfAQ7sQ>