OSDN Git Service

Merge pull request #36314 (suigintoh/ultramonkey-l7-v3/fix_signum_cast into master).
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / utility.h
1 /*!
2  *    @file    utility.h
3  *    @brief    utility macro header.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2009  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24
25 #ifndef  __UTILITY_H__
26 #define  __UTILITY_H__
27
28 //! gcc extension code output macro.
29 //! static "if" weight algorithm teach compiler.
30 //! compiler output CPU TBL code.
31 //! usage:
32 //!    if( likely( hoge ) ){ fastcall } else { slowcall }
33 //! if( unlikely( hoge ) ){ slowcall } else { fastcall }
34 #define likely(c)   __builtin_expect(!!(c), 1)
35 #define unlikely(c) __builtin_expect(!!(c), 0)
36
37 #endif  //__UTILITY_H__