Subject: Re: Checking for NetBSD version
To: None <martti.kuparinen@piuha.net>
From: Frederick Bruckman <fredb@immanent.net>
List: current-users
Date: 11/17/2003 01:59:02
On Mon, 17 Nov 2003 martti.kuparinen@piuha.net wrote:
> What is "the correct way" of checking NetBSD version (1.x vs -current) in
> source code (with preprocessor)? In other words, how should I rewrite
> the "if 1" line in the following code fragment?
>
>
> #if 1
> /* NetBSD 1.x does not have separate read/write statistics. */
> perf->rbytes = drive.dk_bytes;
> perf->wbytes = drive.dk_bytes;
> #else
> perf->rbytes = drive.dk_rbytes;
> perf->wbytes = drive.dk_wbytes;
> #endif
First, the short answer:
#include <sys/param.h>
#if __NetBSD_Version__ < 106100000 /* NetBSD 1.6J */
How did I know that? Usually, the feature you're looking for doesn't
exactly coincide with any kernel bump. You review the CVS log of the
relevant files, to come up with a date, then review the CVS log for
"src/sys/sys/param.h", and match that date with a version as best you
can. I happen to remember doing just that for exactly the particular
feature in question; see "pkgsrc/sysutils/gkrellm/patches/patch-ac".
Frederick