michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a michael@0: * boolean predicate should be branch-predicted. michael@0: */ michael@0: michael@0: #ifndef mozilla_Likely_h michael@0: #define mozilla_Likely_h michael@0: michael@0: #if defined(__clang__) || defined(__GNUC__) michael@0: # define MOZ_LIKELY(x) (__builtin_expect(!!(x), 1)) michael@0: # define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0)) michael@0: #else michael@0: # define MOZ_LIKELY(x) (!!(x)) michael@0: # define MOZ_UNLIKELY(x) (!!(x)) michael@0: #endif michael@0: michael@0: #endif /* mozilla_Likely_h */