Suchen

Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

5.8. Conditional compilation

download PDF

5.8.1. Conditions

One of the steps of parsing is a simple conditional preprocessing stage. The general form of this is similar to the ternary operator (Section Section 5.6.7, “Ternary operator”).
%( CONDITION %? TRUE-TOKENS %)
%( CONDITION %? TRUE-TOKENS %: FALSE-TOKENS %)
The CONDITION is a limited expression whose format is determined by its first keyword. The following is the general syntax.
%( <condition> %? <code> [ %: <code> ] %)

5.8.2. Conditions based on kernel version: kernel_v, kernel_vr

If the first part of a conditional expression is the identifier kernel_v or kernel_vr, the second part must be one of six standard numeric comparison operators “<”, “<=”, “==”, “!=”, “>”, or “>=”, and the third part must be a string literal that contains an RPM-style version-release value. The condition returns true if the version of the target kernel (as optionally overridden by the -r option) matches the given version string. The comparison is performed by the glibc function strverscmp.
kernel_v refers to the kernel version number only, such as “2.6.13".
kernel_vr refers to the kernel version number including the release code suffix, such as “2.6.13-1.322FC3smp”.

5.8.3. Conditions based on architecture: arch

If the first part of the conditional expression is the identifier arch which refers to the processor architecture, then the second part is a string comparison operator ”==” or ”!=”, and the third part is a string literal for matching it. This comparison is a simple string equality or inequality. The currently supported architecture strings are i386, i686, x86_64, ia64, s390x and ppc64.

5.8.4. True and False Tokens

TRUE-TOKENS and FALSE-TOKENS are zero or more general parser tokens, possibly including nested preprocessor conditionals, that are pasted into the input stream if the condition is true or false. For example, the following code induces a parse error unless the target kernel version is newer than 2.6.5.
%( kernel_v <= "2.6.5" %? **ERROR** %) # invalid token sequence
The following code adapts 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 %)
%)) { /* ... */ }

%( arch == "ia64" %?
probe syscall.vliw = kernel.function("vliw_widget") {}
%)
Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.