1 /* Configuration definitions.
2 Copyright (C) 2008, 2009 Red Hat, Inc.
3 This file is part of Red Hat elfutils.
5 Red Hat elfutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by the
7 Free Software Foundation; version 2 of the License.
9 Red Hat elfutils is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with Red Hat elfutils; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18 In addition, as a special exception, Red Hat, Inc. gives You the
19 additional right to link the code of Red Hat elfutils with code licensed
20 under an Open Source Initiative certified open source license
21 (http://www.opensource.org/licenses/index.php) and to distribute linked
22 combinations including the two. Non-GPL Code permitted under this
23 exception must only link to the code of Red Hat elfutils through those
24 well defined interfaces identified in the file named EXCEPTION found in
25 the source code files (the "Approved Interfaces"). The files of Non-GPL
26 Code may instantiate templates or use macros or inline functions from
27 the Approved Interfaces without causing the resulting work to be covered
28 by the GNU General Public License. Only Red Hat, Inc. may make changes
29 or additions to the list of Approved Interfaces. Red Hat's grant of
30 this exception is conditioned upon your not adding any new exceptions.
31 If you wish to add a new Approved Interface or exception, please contact
32 Red Hat. You must obey the GNU General Public License in all respects
33 for all of the Red Hat elfutils code and other code used in conjunction
34 with Red Hat elfutils except the Non-GPL Code covered by this exception.
35 If you modify this file, you may extend this exception to your version
36 of the file, but you are not obligated to do so. If you do not wish to
37 provide this exception without modification, you must delete this
38 exception statement from your version and license this file solely under
39 the GPL without exception.
41 Red Hat elfutils is an included package of the Open Invention Network.
42 An included package of the Open Invention Network is a package for which
43 Open Invention Network licensees cross-license their patents. No patent
44 license is granted, either expressly or impliedly, by designation as an
45 included package. Should you wish to participate in the Open Invention
46 Network licensing program, please visit www.openinventionnetwork.com
47 <http://www.openinventionnetwork.com>. */
55 # define rwlock_define(class,name) class pthread_rwlock_t name
56 # define RWLOCK_CALL(call) \
57 ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); })
58 # define rwlock_init(lock) RWLOCK_CALL (init (&lock, NULL))
59 # define rwlock_fini(lock) RWLOCK_CALL (destroy (&lock))
60 # define rwlock_rdlock(lock) RWLOCK_CALL (rdlock (&lock))
61 # define rwlock_wrlock(lock) RWLOCK_CALL (wrlock (&lock))
62 # define rwlock_unlock(lock) RWLOCK_CALL (unlock (&lock))
64 /* Eventually we will allow multi-threaded applications to use the
65 libraries. Therefore we will add the necessary locking although
66 the macros used expand to nothing for now. */
67 # define rwlock_define(class,name) class int name
68 # define rwlock_init(lock) ((void) (lock))
69 # define rwlock_fini(lock) ((void) (lock))
70 # define rwlock_rdlock(lock) ((void) (lock))
71 # define rwlock_wrlock(lock) ((void) (lock))
72 # define rwlock_unlock(lock) ((void) (lock))
73 #endif /* USE_LOCKS */
75 /* gettext helper macro. */
78 /* Compiler-specific definitions. */
79 #define strong_alias(name, aliasname) \
80 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
83 # define internal_function __attribute__ ((regparm (3), stdcall))
85 # define internal_function /* nothing */
88 #define internal_strong_alias(name, aliasname) \
89 extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function;
91 #define attribute_hidden \
92 __attribute__ ((visibility ("hidden")))
94 /* Define ALLOW_UNALIGNED if the architecture allows operations on
95 unaligned memory locations. */
96 #if defined __i386__ || defined __x86_64__
97 # define ALLOW_UNALIGNED 1
99 # define ALLOW_UNALIGNED 0
104 asm (".section predict_data, \"aw\"; .previous\n"
105 ".section predict_line, \"a\"; .previous\n"
106 ".section predict_file, \"a\"; .previous");
108 # define debugpred__(e, E) \
109 ({ long int _e = !!(e); \
110 asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \
111 ".section predict_line; .quad %c1\n" \
112 ".section predict_file; .quad %c2; .popsection\n" \
113 "addq $1,..predictcnt%=(,%0,8)" \
114 : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
115 __builtin_expect (_e, E); \
118 # elif defined __i386__
119 asm (".section predict_data, \"aw\"; .previous\n"
120 ".section predict_line, \"a\"; .previous\n"
121 ".section predict_file, \"a\"; .previous");
123 # define debugpred__(e, E) \
124 ({ long int _e = !!(e); \
125 asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \
126 ".section predict_line; .long %c1\n" \
127 ".section predict_file; .long %c2; .popsection\n" \
128 "incl ..predictcnt%=(,%0,8)" \
129 : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
130 __builtin_expect (_e, E); \
135 # define unlikely(e) debugpred__ (e,0)
136 # define likely(e) debugpred__ (e,1)
140 # define unlikely(expr) __builtin_expect (!!(expr), 0)
141 # define likely(expr) __builtin_expect (!!(expr), 1)
144 #define obstack_calloc(ob, size) \
145 ({ size_t _s = (size); memset (obstack_alloc (ob, _s), '\0', _s); })
146 #define obstack_strdup(ob, str) \
147 ({ const char *_s = (str); obstack_copy0 (ob, _s, strlen (_s)); })
148 #define obstack_strndup(ob, str, n) \
149 ({ const char *_s = (str); obstack_copy0 (ob, _s, strnlen (_s, n)); })
151 #if __STDC_VERSION__ >= 199901L
152 # define flexarr_size /* empty */
154 # define flexarr_size 0
157 /* Calling conventions. */
159 # define CALLING_CONVENTION regparm (3), stdcall
160 # define AND_CALLING_CONVENTION , regparm (3), stdcall
162 # define CALLING_CONVENTION
163 # define AND_CALLING_CONVENTION
166 /* Avoid PLT entries. */
168 # define INTUSE(name) _INTUSE(name)
169 # define _INTUSE(name) __##name##_internal
170 # define INTDEF(name) _INTDEF(name)
171 # define _INTDEF(name) \
172 extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name)));
173 # define INTDECL(name) _INTDECL(name)
174 # define _INTDECL(name) \
175 extern __typeof__ (name) __##name##_internal attribute_hidden;
177 # define INTUSE(name) name
178 # define INTDEF(name) /* empty */
179 # define INTDECL(name) /* empty */
182 /* This macro is used by the tests conditionalize for standalone building. */
183 #define ELFUTILS_HEADER(name) <lib##name.h>
187 # define OLD_VERSION(name, version) \
188 asm (".globl _compat." #version "." #name "\n" \
189 "_compat." #version "." #name " = " #name "\n" \
190 ".symver _compat." #version "." #name "," #name "@" #version);
191 # define NEW_VERSION(name, version) \
192 asm (".symver " #name "," #name "@@@" #version);
193 # define COMPAT_VERSION(name, version, prefix) \
194 asm (".symver _compat." #version "." #name "," #name "@" #version); \
195 __typeof (name) _compat_##prefix##_##name asm ("_compat." #version "." #name);
197 # define OLD_VERSION(name, version) /* Nothing for static linking. */
198 # define NEW_VERSION(name, version) /* Nothing for static linking. */
199 # define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SHARED"
203 #endif /* eu-config.h */