Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

#define RT_LIKELY ( expr   )     (expr)

Give the compiler a hint that an expression is very likely to hold true.

Some compilers support explicit branch prediction so that the CPU backend can hint the processor and also so that code blocks can be reordered such that the predicted path sees a more linear flow, thus improving cache behaviour, etc.

IPRT provides the macros RT_LIKELY() and RT_UNLIKELY() as a way to utilize this compiler feature when present.

A few notes about the usage:

  • Generally, use RT_UNLIKELY() with error condition checks (unless you have some _strong_ reason to do otherwise, in which case document it), and/or RT_LIKELY() with success condition checks, assuming you want to optimize for the success path.

  • Other than that, if you don't know the likelihood of a test succeeding from empirical or other 'hard' evidence, don't make predictions unless you happen to be a Dirk Gently.

  • These macros are meant to be used in places that get executed a lot. It is wasteful to make predictions in code that is executed rarely (e.g. at subsystem initialization time) as the basic block reordering that this affects can often generate larger code.

Returns:
the boolean result of the expression.
Parameters:
expr The expression that's very likely to be true.
See also:
RT_UNLIKELY

Definition at line 921 of file cdefs.h.

Referenced by _init(), iprt::MiniString::copyFrom(), guestProp::DECLINLINE(), VBoxNetDhcpCfg::matchesMacAddress(), pcnetIoportReadU16(), pcnetIoportReadU32(), pcnetPollTimer(), pcnetRdtePoll(), pcnetTdtePoll(), VBoxNetDhcpWriteCursor::put(), iprt::MiniString::reserve(), RTDECL(), RTR0DECL(), rtstrFormatType(), rtUtf16CalcLatin1Length(), rtUtf16RecodeAsLatin1(), supdrvGipUpdate(), supdrvGipUpdatePerCpu(), supdrvIOCtl(), supdrvIOCtlFast(), vbglR3DoIOCtl(), VBoxDrvDarwinIOCtlSlow(), VBoxDrvFreeBSDIOCtlSlow(), VBoxDrvLinuxIOCtl(), VBoxDrvLinuxIOCtlSlow(), VBoxDrvSolarisIOCtlSlow(), vboxguestLinuxIOCtl(), VBoxNetFltSolarisModOpen(), VBoxNetFltSolarisModReadPut(), vboxNetFltSolarisOpenStream(), vboxNetFltSolarispIp6Timer(), vboxNetFltSolarisSetupIp6Polling(), VMMR3DECL(), vmmR3DoGCTest(), and vmmR3DoTrapTest().


Generated by  Doxygen 1.6.0   Back to index