public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* version-sensitive ifdef
@ 2005-11-01 16:13 Frank Ch. Eigler
  0 siblings, 0 replies; only message in thread
From: Frank Ch. Eigler @ 2005-11-01 16:13 UTC (permalink / raw)
  To: systemtap

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 %) %)
          ) { /* ... */ }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-01 16:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-01 16:13 version-sensitive ifdef Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).