From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32401 invoked by alias); 1 Nov 2005 16:13:29 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 32379 invoked by uid 22791); 1 Nov 2005 16:13:26 -0000 Date: Tue, 01 Nov 2005 16:13:00 -0000 From: "Frank Ch. Eigler" To: systemtap@sources.redhat.com Subject: version-sensitive ifdef Message-ID: <20051101161318.GB12185@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2005-q4/txt/msg00115.txt.bz2 Hi - I'm committing code for PR 1425. It adds a baby preprocessor to the parser, to allow a script to include or exclude tokens based on the target kernel version. For now, the version string comparison is done with a routine from rpmlib, which is henceforth a prerequisite. From the amended man page: A simple conditional preprocessing stage is run as a part of parsing. The general form is similar to the cond ? exp1 : exp2 ternary opera- tor: %( CONDITION %? TRUE-TOKENS %) %( CONDITION %? TRUE-TOKENS %: FALSE-TOKENS %) The CONDITION is a very limited expression consisting of three parts. The first part is the identifier kernel_vr or kernel_v to refer to the kernel version number, with ("2.6.13-1.322FC3smp") or without ("2.6.13") the release code suffix. The second part is one of the six standard numeric comparison operators <, <=, ==, !=, >, and >=. The third part is a string literal that contains an RPM-style version-re- lease value. The condition is deemed satisfied if the version of the target kernel (as optionally overridden by the -r option) compares to the given version string. The comparison is performed by the RPM li- brary function rpmvercmp. The TRUE-TOKENS and FALSE-TOKENS are zero or more general parser tokens (possibly including nested preprocessor conditionals), and are pasted into the input stream if the condition is true or false. For example, the following code induces a parse er- ror unless the target kernel version is newer than 2.6.5: %( kernel_v <= "2.6.5" %? **ERROR** %) # invalid token sequence The following code might adapt to hypothetical kernel version drift: probe kernel.function ( %( kernel_v <= "2.6.12" %? "__mm_do_fault" %: %( kernel_vr == "2.6.13-1.8273FC3smp" %? "do_page_fault" %: UNSUPPORTED %) %) ) { /* ... */ }