2016-08-02 18:49:42 +10:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2016-08-02 18:49:42 +10:00
|
|
|
*
|
|
|
|
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_ANNOTATION_HPP
|
|
|
|
#define __UTIL_ANNOTATION_HPP
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
constexpr inline
|
|
|
|
bool
|
|
|
|
likely (T &&t)
|
|
|
|
{ return __builtin_expect (!!t, true); }
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
constexpr inline
|
|
|
|
bool
|
|
|
|
unlikely (T &&t)
|
|
|
|
{ return __builtin_expect (!!t, false); }
|
|
|
|
|
2018-08-01 13:07:58 +10:00
|
|
|
|
|
|
|
constexpr inline
|
|
|
|
long
|
|
|
|
expect (long val, long typical)
|
|
|
|
{
|
|
|
|
return __builtin_expect (val, typical);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 18:49:42 +10:00
|
|
|
#endif
|