이 콘텐츠는 선택한 언어로 제공되지 않습니다.

5.8. Conditional compilation


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

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.