Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
debugpred.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008, 2009 Red Hat, Inc.
3  Copyright (c) 2011, 2012 The University of Utah
4 
5  This file primarily contains the `likely/unlikely' definitions from
6  Red Hat elfutils file `lib/eu-config.h'.
7 
8  Red Hat elfutils is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by the
10  Free Software Foundation; version 2 of the License.
11 
12  Red Hat elfutils is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with Red Hat elfutils; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
20 
21  In addition, as a special exception, Red Hat, Inc. gives You the
22  additional right to link the code of Red Hat elfutils with code licensed
23  under an Open Source Initiative certified open source license
24  (http://www.opensource.org/licenses/index.php) and to distribute linked
25  combinations including the two. Non-GPL Code permitted under this
26  exception must only link to the code of Red Hat elfutils through those
27  well defined interfaces identified in the file named EXCEPTION found in
28  the source code files (the "Approved Interfaces"). The files of Non-GPL
29  Code may instantiate templates or use macros or inline functions from
30  the Approved Interfaces without causing the resulting work to be covered
31  by the GNU General Public License. Only Red Hat, Inc. may make changes
32  or additions to the list of Approved Interfaces. Red Hat's grant of
33  this exception is conditioned upon your not adding any new exceptions.
34  If you wish to add a new Approved Interface or exception, please contact
35  Red Hat. You must obey the GNU General Public License in all respects
36  for all of the Red Hat elfutils code and other code used in conjunction
37  with Red Hat elfutils except the Non-GPL Code covered by this exception.
38  If you modify this file, you may extend this exception to your version
39  of the file, but you are not obligated to do so. If you do not wish to
40  provide this exception without modification, you must delete this
41  exception statement from your version and license this file solely under
42  the GPL without exception.
43 
44  Red Hat elfutils is an included package of the Open Invention Network.
45  An included package of the Open Invention Network is a package for which
46  Open Invention Network licensees cross-license their patents. No patent
47  license is granted, either expressly or impliedly, by designation as an
48  included package. Should you wish to participate in the Open Invention
49  Network licensing program, please visit www.openinventionnetwork.com
50  <http://www.openinventionnetwork.com>. */
51 
52 #ifndef __DEBUGPRED_H__
53 #define __DEBUGPRED_H__
54 
55 #define DEBUGPRED 1
56 #ifndef PIC
57 #define PIC 1
58 #endif
59 
63 #if DEBUGPRED
64 # ifdef __x86_64__
65 asm (".section predict_data, \"aw\"; .previous\n"
66  ".section predict_line, \"a\"; .previous\n"
67  ".section predict_file, \"a\"; .previous");
68 # ifndef PIC
69 # define debugpred__(e, E) \
70  ({ long int _e = !!(e); \
71  asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \
72  ".section predict_line; .quad %c1\n" \
73  ".section predict_file; .quad %c2; .popsection\n" \
74  "addq $1,..predictcnt%=(,%0,8)" \
75  : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
76  __builtin_expect (_e, E); \
77  })
78 # endif
79 # elif defined __i386__
80 asm (".section predict_data, \"aw\"; .previous\n"
81  ".section predict_line, \"a\"; .previous\n"
82  ".section predict_file, \"a\"; .previous");
83 # ifndef PIC
84 # define debugpred__(e, E) \
85  ({ long int _e = !!(e); \
86  asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \
87  ".section predict_line; .long %c1\n" \
88  ".section predict_file; .long %c2; .popsection\n" \
89  "incl ..predictcnt%=(,%0,8)" \
90  : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
91  __builtin_expect (_e, E); \
92  })
93 # endif
94 # endif
95 # ifdef debugpred__
96 # define unlikely(e) debugpred__ (e,0)
97 # define likely(e) debugpred__ (e,1)
98 # endif
99 #endif
100 #ifndef likely
101 # define unlikely(expr) __builtin_expect (!!(expr), 0)
102 # define likely(expr) __builtin_expect (!!(expr), 1)
103 #endif
104 
105 #endif /* __DEBUGPRED_H__ */