diff options
Diffstat (limited to 'spec/rtems/basedefs/req/predict-true-0.yml')
-rw-r--r-- | spec/rtems/basedefs/req/predict-true-0.yml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/rtems/basedefs/req/predict-true-0.yml b/spec/rtems/basedefs/req/predict-true-0.yml new file mode 100644 index 00000000..9c75707d --- /dev/null +++ b/spec/rtems/basedefs/req/predict-true-0.yml @@ -0,0 +1,27 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: ../if/predict-true +non-functional-type: interface +rationale: | + Example: ``if ( ${../if/predict-true:/name}( 99 > i ) ) { ... }``. + The GNU C compiler uses this information for branch optimization. + ``builtin-expect-probability`` defaults to 90%. + Note the misleading name: The macro tells the compiler to assume + "the result is 1" not "the result is not 0" as one would expect for + ``true``. +references: [] +requirement-type: non-functional +text: | + When the code is compiled with the GNU C compiler, + and the ${../if/predict-true:/name} macro is used as a conditional + in ``if``-expressions and loop expressions, + and ${../if/predict-true:/params[0]/name} after undergoing all possible C + pre-processor substitutions is an integral expression, + the macro shall cause the compiler to assume that by the percentage of + cases defined by ``builtin-expect-probability`` the expression evaluates + to 1. +type: requirement |