1b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Configuration definitions. 27e678fa3f6051f7ef24b4610c9a66cab858b6b6eUlrich Drepper Copyright (C) 2008, 2009 Red Hat, Inc. 3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard This file is part of elfutils. 4b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 5de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard This file is free software; you can redistribute it and/or modify 6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard it under the terms of either 7b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 8de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard * the GNU Lesser General Public License as published by the Free 9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard Software Foundation; either version 3 of the License, or (at 10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard your option) any later version 11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard or 13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard * the GNU General Public License as published by the Free 15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard Software Foundation; either version 2 of the License, or (at 16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard your option) any later version 17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard or both in parallel, as here. 19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard elfutils is distributed in the hope that it will be useful, but 21b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath WITHOUT ANY WARRANTY; without even the implied warranty of 22b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath General Public License for more details. 24b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 25de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard You should have received copies of the GNU General Public License and 26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard the GNU Lesser General Public License along with this program. If 27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard not, see <http://www.gnu.org/licenses/>. */ 28b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 29e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath#ifndef EU_CONFIG_H 30e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath#define EU_CONFIG_H 1 31e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath 327e678fa3f6051f7ef24b4610c9a66cab858b6b6eUlrich Drepper#ifdef USE_LOCKS 33b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# include <pthread.h> 34b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# include <assert.h> 35b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_define(class,name) class pthread_rwlock_t name 36b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define RWLOCK_CALL(call) \ 37b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); }) 38b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_init(lock) RWLOCK_CALL (init (&lock, NULL)) 39b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_fini(lock) RWLOCK_CALL (destroy (&lock)) 40b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_rdlock(lock) RWLOCK_CALL (rdlock (&lock)) 41b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_wrlock(lock) RWLOCK_CALL (wrlock (&lock)) 42b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_unlock(lock) RWLOCK_CALL (unlock (&lock)) 43b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 44b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Eventually we will allow multi-threaded applications to use the 45b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath libraries. Therefore we will add the necessary locking although 46b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath the macros used expand to nothing for now. */ 47b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_define(class,name) class int name 48b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_init(lock) ((void) (lock)) 49b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_fini(lock) ((void) (lock)) 50b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_rdlock(lock) ((void) (lock)) 51b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_wrlock(lock) ((void) (lock)) 52b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define rwlock_unlock(lock) ((void) (lock)) 537e678fa3f6051f7ef24b4610c9a66cab858b6b6eUlrich Drepper#endif /* USE_LOCKS */ 54b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 55b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* gettext helper macro. */ 56b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define N_(Str) Str 57b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 58b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Compiler-specific definitions. */ 59b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define strong_alias(name, aliasname) \ 60b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath extern __typeof (name) aliasname __attribute__ ((alias (#name))); 61b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 62b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#ifdef __i386__ 63b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define internal_function __attribute__ ((regparm (3), stdcall)) 64b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 65b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define internal_function /* nothing */ 66b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 67b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 68b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define internal_strong_alias(name, aliasname) \ 69b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function; 70b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 71b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define attribute_hidden \ 72b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath __attribute__ ((visibility ("hidden"))) 73b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 74b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Define ALLOW_UNALIGNED if the architecture allows operations on 75b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath unaligned memory locations. */ 76170f1bb0a8f49cd6c5e7b34aaa505928764866bbMark Wielaard#define SANITIZE_UNDEFINED 1 77170f1bb0a8f49cd6c5e7b34aaa505928764866bbMark Wielaard#if (defined __i386__ || defined __x86_64__) && ! CHECK_UNDEFINED 78b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define ALLOW_UNALIGNED 1 79b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 80b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define ALLOW_UNALIGNED 0 81b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 82b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 83b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#if DEBUGPRED 84b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# ifdef __x86_64__ 85b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrathasm (".section predict_data, \"aw\"; .previous\n" 86b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_line, \"a\"; .previous\n" 87b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_file, \"a\"; .previous"); 88b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# ifndef PIC 89b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define debugpred__(e, E) \ 90b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ long int _e = !!(e); \ 91b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \ 92b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_line; .quad %c1\n" \ 93b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_file; .quad %c2; .popsection\n" \ 94b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath "addq $1,..predictcnt%=(,%0,8)" \ 95b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \ 96b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath __builtin_expect (_e, E); \ 97b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath }) 98b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# endif 99b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# elif defined __i386__ 100b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrathasm (".section predict_data, \"aw\"; .previous\n" 101b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_line, \"a\"; .previous\n" 102b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_file, \"a\"; .previous"); 103b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# ifndef PIC 104b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define debugpred__(e, E) \ 105b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ long int _e = !!(e); \ 106b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \ 107b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_line; .long %c1\n" \ 108b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ".section predict_file; .long %c2; .popsection\n" \ 109b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath "incl ..predictcnt%=(,%0,8)" \ 110b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \ 111b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath __builtin_expect (_e, E); \ 112b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath }) 113b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# endif 114b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# endif 115b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# ifdef debugpred__ 116b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define unlikely(e) debugpred__ (e,0) 117b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define likely(e) debugpred__ (e,1) 118b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# endif 119b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 120b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#ifndef likely 121b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define unlikely(expr) __builtin_expect (!!(expr), 0) 122b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define likely(expr) __builtin_expect (!!(expr), 1) 123b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 124b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 125b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define obstack_calloc(ob, size) \ 126b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ size_t _s = (size); memset (obstack_alloc (ob, _s), '\0', _s); }) 127b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define obstack_strdup(ob, str) \ 128b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ const char *_s = (str); obstack_copy0 (ob, _s, strlen (_s)); }) 129b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define obstack_strndup(ob, str, n) \ 130b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath ({ const char *_s = (str); obstack_copy0 (ob, _s, strnlen (_s, n)); }) 131b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 132b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#if __STDC_VERSION__ >= 199901L 133b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define flexarr_size /* empty */ 134b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 135b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define flexarr_size 0 136b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 137b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 138b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Calling conventions. */ 139b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#ifdef __i386__ 140b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define CALLING_CONVENTION regparm (3), stdcall 141b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define AND_CALLING_CONVENTION , regparm (3), stdcall 142b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 143b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define CALLING_CONVENTION 144b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define AND_CALLING_CONVENTION 145b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 146b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 147b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* Avoid PLT entries. */ 148b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#ifdef PIC 149b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTUSE(name) _INTUSE(name) 150b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define _INTUSE(name) __##name##_internal 151b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTDEF(name) _INTDEF(name) 152b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define _INTDEF(name) \ 153b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name))); 154b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTDECL(name) _INTDECL(name) 155b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define _INTDECL(name) \ 156b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath extern __typeof__ (name) __##name##_internal attribute_hidden; 157b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#else 158b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTUSE(name) name 159b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTDEF(name) /* empty */ 160b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath# define INTDECL(name) /* empty */ 161b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#endif 162b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath 163b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath/* This macro is used by the tests conditionalize for standalone building. */ 164b4d6f0f8064f2b706ea9035ef0393d8299671390Roland McGrath#define ELFUTILS_HEADER(name) <lib##name.h> 165e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath 166e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath 167bafacacaf7659a4933604662daba26a480b29a8dMax Filippov#ifdef SYMBOL_VERSIONING 168ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath# define OLD_VERSION(name, version) \ 169ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath asm (".globl _compat." #version "." #name "\n" \ 170ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath "_compat." #version "." #name " = " #name "\n" \ 171ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath ".symver _compat." #version "." #name "," #name "@" #version); 172ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath# define NEW_VERSION(name, version) \ 173ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath asm (".symver " #name "," #name "@@@" #version); 174fba1588ee438e47a24e92fbd378756501933d00dJan Kratochvil# define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ 175fba1588ee438e47a24e92fbd378756501933d00dJan Kratochvil asm (".symver _compat." #version "." #name "," #name "@" #version); \ 176fba1588ee438e47a24e92fbd378756501933d00dJan Kratochvil __typeof (_compat_##prefix##_##name) _compat_##prefix##_##name \ 177fba1588ee438e47a24e92fbd378756501933d00dJan Kratochvil asm ("_compat." #version "." #name); 178ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath# define COMPAT_VERSION(name, version, prefix) \ 179ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath asm (".symver _compat." #version "." #name "," #name "@" #version); \ 180ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath __typeof (name) _compat_##prefix##_##name asm ("_compat." #version "." #name); 181ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath#else 182ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath# define OLD_VERSION(name, version) /* Nothing for static linking. */ 183ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath# define NEW_VERSION(name, version) /* Nothing for static linking. */ 184fba1588ee438e47a24e92fbd378756501933d00dJan Kratochvil# define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ 185bafacacaf7659a4933604662daba26a480b29a8dMax Filippov error "should use #ifdef SYMBOL_VERSIONING" 186bafacacaf7659a4933604662daba26a480b29a8dMax Filippov# define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING" 187ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath#endif 188ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath 189ebfb6484d5e164f2b7f428a8c92d55c4083f55fdRoland McGrath 190e74f911beecd79f051eaf9fa09b3d93144a01124Roland McGrath#endif /* eu-config.h */ 191