Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 1 | /* Configuration definitions. |
Ulrich Drepper | 7e678fa | 2009-01-10 18:02:05 -0800 | [diff] [blame] | 2 | Copyright (C) 2008, 2009 Red Hat, Inc. |
Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 3 | This file is part of Red Hat elfutils. |
| 4 | |
| 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. |
| 8 | |
| 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. |
| 13 | |
| 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. |
| 17 | |
| 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. |
| 40 | |
| 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>. */ |
| 48 | |
Roland McGrath | e74f911 | 2009-01-23 17:11:04 -0800 | [diff] [blame] | 49 | #ifndef EU_CONFIG_H |
| 50 | #define EU_CONFIG_H 1 |
| 51 | |
Ulrich Drepper | 7e678fa | 2009-01-10 18:02:05 -0800 | [diff] [blame] | 52 | #ifdef USE_LOCKS |
Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 53 | # include <pthread.h> |
| 54 | # include <assert.h> |
Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 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)) |
| 63 | #else |
| 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. */ |
Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 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)) |
Ulrich Drepper | 7e678fa | 2009-01-10 18:02:05 -0800 | [diff] [blame] | 73 | #endif /* USE_LOCKS */ |
Roland McGrath | b4d6f0f | 2008-08-25 22:55:17 +0000 | [diff] [blame] | 74 | |
| 75 | /* gettext helper macro. */ |
| 76 | #define N_(Str) Str |
| 77 | |
| 78 | /* Compiler-specific definitions. */ |
| 79 | #define strong_alias(name, aliasname) \ |
| 80 | extern __typeof (name) aliasname __attribute__ ((alias (#name))); |
| 81 | |
| 82 | #ifdef __i386__ |
| 83 | # define internal_function __attribute__ ((regparm (3), stdcall)) |
| 84 | #else |
| 85 | # define internal_function /* nothing */ |
| 86 | #endif |
| 87 | |
| 88 | #define internal_strong_alias(name, aliasname) \ |
| 89 | extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function; |
| 90 | |
| 91 | #define attribute_hidden \ |
| 92 | __attribute__ ((visibility ("hidden"))) |
| 93 | |
| 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 |
| 98 | #else |
| 99 | # define ALLOW_UNALIGNED 0 |
| 100 | #endif |
| 101 | |
| 102 | #if DEBUGPRED |
| 103 | # ifdef __x86_64__ |
| 104 | asm (".section predict_data, \"aw\"; .previous\n" |
| 105 | ".section predict_line, \"a\"; .previous\n" |
| 106 | ".section predict_file, \"a\"; .previous"); |
| 107 | # ifndef PIC |
| 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); \ |
| 116 | }) |
| 117 | # endif |
| 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"); |
| 122 | # ifndef PIC |
| 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); \ |
| 131 | }) |
| 132 | # endif |
| 133 | # endif |
| 134 | # ifdef debugpred__ |
| 135 | # define unlikely(e) debugpred__ (e,0) |
| 136 | # define likely(e) debugpred__ (e,1) |
| 137 | # endif |
| 138 | #endif |
| 139 | #ifndef likely |
| 140 | # define unlikely(expr) __builtin_expect (!!(expr), 0) |
| 141 | # define likely(expr) __builtin_expect (!!(expr), 1) |
| 142 | #endif |
| 143 | |
| 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)); }) |
| 150 | |
| 151 | #if __STDC_VERSION__ >= 199901L |
| 152 | # define flexarr_size /* empty */ |
| 153 | #else |
| 154 | # define flexarr_size 0 |
| 155 | #endif |
| 156 | |
| 157 | /* Calling conventions. */ |
| 158 | #ifdef __i386__ |
| 159 | # define CALLING_CONVENTION regparm (3), stdcall |
| 160 | # define AND_CALLING_CONVENTION , regparm (3), stdcall |
| 161 | #else |
| 162 | # define CALLING_CONVENTION |
| 163 | # define AND_CALLING_CONVENTION |
| 164 | #endif |
| 165 | |
| 166 | /* Avoid PLT entries. */ |
| 167 | #ifdef PIC |
| 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; |
| 176 | #else |
| 177 | # define INTUSE(name) name |
| 178 | # define INTDEF(name) /* empty */ |
| 179 | # define INTDECL(name) /* empty */ |
| 180 | #endif |
| 181 | |
| 182 | /* This macro is used by the tests conditionalize for standalone building. */ |
| 183 | #define ELFUTILS_HEADER(name) <lib##name.h> |
Roland McGrath | e74f911 | 2009-01-23 17:11:04 -0800 | [diff] [blame] | 184 | |
| 185 | |
| 186 | #endif /* eu-config.h */ |