1*7304104dSAndroid Build Coastguard Worker /* Configuration definitions. 2*7304104dSAndroid Build Coastguard Worker Copyright (C) 2008, 2009 Red Hat, Inc. 3*7304104dSAndroid Build Coastguard Worker This file is part of elfutils. 4*7304104dSAndroid Build Coastguard Worker 5*7304104dSAndroid Build Coastguard Worker This file is free software; you can redistribute it and/or modify 6*7304104dSAndroid Build Coastguard Worker it under the terms of either 7*7304104dSAndroid Build Coastguard Worker 8*7304104dSAndroid Build Coastguard Worker * the GNU Lesser General Public License as published by the Free 9*7304104dSAndroid Build Coastguard Worker Software Foundation; either version 3 of the License, or (at 10*7304104dSAndroid Build Coastguard Worker your option) any later version 11*7304104dSAndroid Build Coastguard Worker 12*7304104dSAndroid Build Coastguard Worker or 13*7304104dSAndroid Build Coastguard Worker 14*7304104dSAndroid Build Coastguard Worker * the GNU General Public License as published by the Free 15*7304104dSAndroid Build Coastguard Worker Software Foundation; either version 2 of the License, or (at 16*7304104dSAndroid Build Coastguard Worker your option) any later version 17*7304104dSAndroid Build Coastguard Worker 18*7304104dSAndroid Build Coastguard Worker or both in parallel, as here. 19*7304104dSAndroid Build Coastguard Worker 20*7304104dSAndroid Build Coastguard Worker elfutils is distributed in the hope that it will be useful, but 21*7304104dSAndroid Build Coastguard Worker WITHOUT ANY WARRANTY; without even the implied warranty of 22*7304104dSAndroid Build Coastguard Worker MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23*7304104dSAndroid Build Coastguard Worker General Public License for more details. 24*7304104dSAndroid Build Coastguard Worker 25*7304104dSAndroid Build Coastguard Worker You should have received copies of the GNU General Public License and 26*7304104dSAndroid Build Coastguard Worker the GNU Lesser General Public License along with this program. If 27*7304104dSAndroid Build Coastguard Worker not, see <http://www.gnu.org/licenses/>. */ 28*7304104dSAndroid Build Coastguard Worker 29*7304104dSAndroid Build Coastguard Worker #ifndef EU_CONFIG_H 30*7304104dSAndroid Build Coastguard Worker #define EU_CONFIG_H 1 31*7304104dSAndroid Build Coastguard Worker 32*7304104dSAndroid Build Coastguard Worker #ifdef USE_LOCKS 33*7304104dSAndroid Build Coastguard Worker # include <pthread.h> 34*7304104dSAndroid Build Coastguard Worker # include <assert.h> 35*7304104dSAndroid Build Coastguard Worker # define rwlock_define(class,name) class pthread_rwlock_t name 36*7304104dSAndroid Build Coastguard Worker # define once_define(class,name) class pthread_once_t name = PTHREAD_ONCE_INIT 37*7304104dSAndroid Build Coastguard Worker # define RWLOCK_CALL(call) \ 38*7304104dSAndroid Build Coastguard Worker ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); }) 39*7304104dSAndroid Build Coastguard Worker # define ONCE_CALL(call) \ 40*7304104dSAndroid Build Coastguard Worker ({ int _err = pthread_ ## call; assert_perror (_err); }) 41*7304104dSAndroid Build Coastguard Worker # define rwlock_init(lock) RWLOCK_CALL (init (&lock, NULL)) 42*7304104dSAndroid Build Coastguard Worker # define rwlock_fini(lock) RWLOCK_CALL (destroy (&lock)) 43*7304104dSAndroid Build Coastguard Worker # define rwlock_rdlock(lock) RWLOCK_CALL (rdlock (&lock)) 44*7304104dSAndroid Build Coastguard Worker # define rwlock_wrlock(lock) RWLOCK_CALL (wrlock (&lock)) 45*7304104dSAndroid Build Coastguard Worker # define rwlock_unlock(lock) RWLOCK_CALL (unlock (&lock)) 46*7304104dSAndroid Build Coastguard Worker # define once(once_control, init_routine) \ 47*7304104dSAndroid Build Coastguard Worker ONCE_CALL (once (&once_control, init_routine)) 48*7304104dSAndroid Build Coastguard Worker #else 49*7304104dSAndroid Build Coastguard Worker /* Eventually we will allow multi-threaded applications to use the 50*7304104dSAndroid Build Coastguard Worker libraries. Therefore we will add the necessary locking although 51*7304104dSAndroid Build Coastguard Worker the macros used expand to nothing for now. */ 52*7304104dSAndroid Build Coastguard Worker # define rwlock_define(class,name) class int name 53*7304104dSAndroid Build Coastguard Worker # define rwlock_init(lock) ((void) (lock)) 54*7304104dSAndroid Build Coastguard Worker # define rwlock_fini(lock) ((void) (lock)) 55*7304104dSAndroid Build Coastguard Worker # define rwlock_rdlock(lock) ((void) (lock)) 56*7304104dSAndroid Build Coastguard Worker # define rwlock_wrlock(lock) ((void) (lock)) 57*7304104dSAndroid Build Coastguard Worker # define rwlock_unlock(lock) ((void) (lock)) 58*7304104dSAndroid Build Coastguard Worker # define once_define(class,name) 59*7304104dSAndroid Build Coastguard Worker # define once(once_control, init_routine) init_routine() 60*7304104dSAndroid Build Coastguard Worker #endif /* USE_LOCKS */ 61*7304104dSAndroid Build Coastguard Worker 62*7304104dSAndroid Build Coastguard Worker #include <libintl.h> 63*7304104dSAndroid Build Coastguard Worker /* gettext helper macros. */ 64*7304104dSAndroid Build Coastguard Worker #define N_(Str) Str 65*7304104dSAndroid Build Coastguard Worker #define _(Str) dgettext ("elfutils", Str) 66*7304104dSAndroid Build Coastguard Worker 67*7304104dSAndroid Build Coastguard Worker /* Compiler-specific definitions. */ 68*7304104dSAndroid Build Coastguard Worker #define strong_alias(name, aliasname) \ 69*7304104dSAndroid Build Coastguard Worker extern __typeof (name) aliasname __attribute__ ((alias (#name))); 70*7304104dSAndroid Build Coastguard Worker 71*7304104dSAndroid Build Coastguard Worker #ifdef __i386__ 72*7304104dSAndroid Build Coastguard Worker # define internal_function __attribute__ ((regparm (3), stdcall)) 73*7304104dSAndroid Build Coastguard Worker #else 74*7304104dSAndroid Build Coastguard Worker # define internal_function /* nothing */ 75*7304104dSAndroid Build Coastguard Worker #endif 76*7304104dSAndroid Build Coastguard Worker 77*7304104dSAndroid Build Coastguard Worker #define internal_strong_alias(name, aliasname) \ 78*7304104dSAndroid Build Coastguard Worker extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function; 79*7304104dSAndroid Build Coastguard Worker 80*7304104dSAndroid Build Coastguard Worker #ifdef HAVE_VISIBILITY 81*7304104dSAndroid Build Coastguard Worker #define attribute_hidden \ 82*7304104dSAndroid Build Coastguard Worker __attribute__ ((visibility ("hidden"))) 83*7304104dSAndroid Build Coastguard Worker #else 84*7304104dSAndroid Build Coastguard Worker #define attribute_hidden /* empty */ 85*7304104dSAndroid Build Coastguard Worker #endif 86*7304104dSAndroid Build Coastguard Worker 87*7304104dSAndroid Build Coastguard Worker #ifdef HAVE_GCC_STRUCT 88*7304104dSAndroid Build Coastguard Worker #define attribute_packed \ 89*7304104dSAndroid Build Coastguard Worker __attribute__ ((packed, gcc_struct)) 90*7304104dSAndroid Build Coastguard Worker #else 91*7304104dSAndroid Build Coastguard Worker #define attribute_packed \ 92*7304104dSAndroid Build Coastguard Worker __attribute__ ((packed)) 93*7304104dSAndroid Build Coastguard Worker #endif 94*7304104dSAndroid Build Coastguard Worker 95*7304104dSAndroid Build Coastguard Worker /* Define ALLOW_UNALIGNED if the architecture allows operations on 96*7304104dSAndroid Build Coastguard Worker unaligned memory locations. */ 97*7304104dSAndroid Build Coastguard Worker #define SANITIZE_UNDEFINED 1 98*7304104dSAndroid Build Coastguard Worker #if (defined __i386__ || defined __x86_64__) && ! CHECK_UNDEFINED 99*7304104dSAndroid Build Coastguard Worker # define ALLOW_UNALIGNED 1 100*7304104dSAndroid Build Coastguard Worker #else 101*7304104dSAndroid Build Coastguard Worker # define ALLOW_UNALIGNED 0 102*7304104dSAndroid Build Coastguard Worker #endif 103*7304104dSAndroid Build Coastguard Worker 104*7304104dSAndroid Build Coastguard Worker #if DEBUGPRED 105*7304104dSAndroid Build Coastguard Worker # ifdef __x86_64__ 106*7304104dSAndroid Build Coastguard Worker asm (".section predict_data, \"aw\"; .previous\n" 107*7304104dSAndroid Build Coastguard Worker ".section predict_line, \"a\"; .previous\n" 108*7304104dSAndroid Build Coastguard Worker ".section predict_file, \"a\"; .previous"); 109*7304104dSAndroid Build Coastguard Worker # ifndef PIC 110*7304104dSAndroid Build Coastguard Worker # define debugpred__(e, E) \ 111*7304104dSAndroid Build Coastguard Worker ({ long int _e = !!(e); \ 112*7304104dSAndroid Build Coastguard Worker asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \ 113*7304104dSAndroid Build Coastguard Worker ".section predict_line; .quad %c1\n" \ 114*7304104dSAndroid Build Coastguard Worker ".section predict_file; .quad %c2; .popsection\n" \ 115*7304104dSAndroid Build Coastguard Worker "addq $1,..predictcnt%=(,%0,8)" \ 116*7304104dSAndroid Build Coastguard Worker : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \ 117*7304104dSAndroid Build Coastguard Worker __builtin_expect (_e, E); \ 118*7304104dSAndroid Build Coastguard Worker }) 119*7304104dSAndroid Build Coastguard Worker # endif 120*7304104dSAndroid Build Coastguard Worker # elif defined __i386__ 121*7304104dSAndroid Build Coastguard Worker asm (".section predict_data, \"aw\"; .previous\n" 122*7304104dSAndroid Build Coastguard Worker ".section predict_line, \"a\"; .previous\n" 123*7304104dSAndroid Build Coastguard Worker ".section predict_file, \"a\"; .previous"); 124*7304104dSAndroid Build Coastguard Worker # ifndef PIC 125*7304104dSAndroid Build Coastguard Worker # define debugpred__(e, E) \ 126*7304104dSAndroid Build Coastguard Worker ({ long int _e = !!(e); \ 127*7304104dSAndroid Build Coastguard Worker asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \ 128*7304104dSAndroid Build Coastguard Worker ".section predict_line; .long %c1\n" \ 129*7304104dSAndroid Build Coastguard Worker ".section predict_file; .long %c2; .popsection\n" \ 130*7304104dSAndroid Build Coastguard Worker "incl ..predictcnt%=(,%0,8)" \ 131*7304104dSAndroid Build Coastguard Worker : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \ 132*7304104dSAndroid Build Coastguard Worker __builtin_expect (_e, E); \ 133*7304104dSAndroid Build Coastguard Worker }) 134*7304104dSAndroid Build Coastguard Worker # endif 135*7304104dSAndroid Build Coastguard Worker # endif 136*7304104dSAndroid Build Coastguard Worker # ifdef debugpred__ 137*7304104dSAndroid Build Coastguard Worker # define unlikely(e) debugpred__ (e,0) 138*7304104dSAndroid Build Coastguard Worker # define likely(e) debugpred__ (e,1) 139*7304104dSAndroid Build Coastguard Worker # endif 140*7304104dSAndroid Build Coastguard Worker #endif 141*7304104dSAndroid Build Coastguard Worker #ifndef likely 142*7304104dSAndroid Build Coastguard Worker # define unlikely(expr) __builtin_expect (!!(expr), 0) 143*7304104dSAndroid Build Coastguard Worker # define likely(expr) __builtin_expect (!!(expr), 1) 144*7304104dSAndroid Build Coastguard Worker #endif 145*7304104dSAndroid Build Coastguard Worker 146*7304104dSAndroid Build Coastguard Worker #define obstack_calloc(ob, size) \ 147*7304104dSAndroid Build Coastguard Worker ({ size_t _s = (size); memset (obstack_alloc (ob, _s), '\0', _s); }) 148*7304104dSAndroid Build Coastguard Worker #define obstack_strdup(ob, str) \ 149*7304104dSAndroid Build Coastguard Worker ({ const char *_s = (str); obstack_copy0 (ob, _s, strlen (_s)); }) 150*7304104dSAndroid Build Coastguard Worker #define obstack_strndup(ob, str, n) \ 151*7304104dSAndroid Build Coastguard Worker ({ const char *_s = (str); obstack_copy0 (ob, _s, strnlen (_s, n)); }) 152*7304104dSAndroid Build Coastguard Worker 153*7304104dSAndroid Build Coastguard Worker #if __STDC_VERSION__ >= 199901L 154*7304104dSAndroid Build Coastguard Worker # define flexarr_size /* empty */ 155*7304104dSAndroid Build Coastguard Worker #else 156*7304104dSAndroid Build Coastguard Worker # define flexarr_size 0 157*7304104dSAndroid Build Coastguard Worker #endif 158*7304104dSAndroid Build Coastguard Worker 159*7304104dSAndroid Build Coastguard Worker /* Calling conventions. */ 160*7304104dSAndroid Build Coastguard Worker #ifdef __i386__ 161*7304104dSAndroid Build Coastguard Worker # define CALLING_CONVENTION regparm (3), stdcall 162*7304104dSAndroid Build Coastguard Worker # define AND_CALLING_CONVENTION , regparm (3), stdcall 163*7304104dSAndroid Build Coastguard Worker #else 164*7304104dSAndroid Build Coastguard Worker # define CALLING_CONVENTION 165*7304104dSAndroid Build Coastguard Worker # define AND_CALLING_CONVENTION 166*7304104dSAndroid Build Coastguard Worker #endif 167*7304104dSAndroid Build Coastguard Worker 168*7304104dSAndroid Build Coastguard Worker /* Avoid PLT entries. */ 169*7304104dSAndroid Build Coastguard Worker #ifdef PIC 170*7304104dSAndroid Build Coastguard Worker # define INTUSE(name) _INTUSE(name) 171*7304104dSAndroid Build Coastguard Worker # define _INTUSE(name) __##name##_internal 172*7304104dSAndroid Build Coastguard Worker # define INTDEF(name) _INTDEF(name) 173*7304104dSAndroid Build Coastguard Worker # define _INTDEF(name) \ 174*7304104dSAndroid Build Coastguard Worker extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name))); 175*7304104dSAndroid Build Coastguard Worker # define INTDECL(name) _INTDECL(name) 176*7304104dSAndroid Build Coastguard Worker # define _INTDECL(name) \ 177*7304104dSAndroid Build Coastguard Worker extern __typeof__ (name) __##name##_internal attribute_hidden; 178*7304104dSAndroid Build Coastguard Worker #else 179*7304104dSAndroid Build Coastguard Worker # define INTUSE(name) name 180*7304104dSAndroid Build Coastguard Worker # define INTDEF(name) /* empty */ 181*7304104dSAndroid Build Coastguard Worker # define INTDECL(name) /* empty */ 182*7304104dSAndroid Build Coastguard Worker #endif 183*7304104dSAndroid Build Coastguard Worker 184*7304104dSAndroid Build Coastguard Worker /* This macro is used by the tests conditionalize for standalone building. */ 185*7304104dSAndroid Build Coastguard Worker #define ELFUTILS_HEADER(name) <lib##name.h> 186*7304104dSAndroid Build Coastguard Worker 187*7304104dSAndroid Build Coastguard Worker /* Don't reorder with global asm blocks or optimize away. (Doesn't reliably 188*7304104dSAndroid Build Coastguard Worker keep it in the same LTO partition, though; -flto-partition=none may be 189*7304104dSAndroid Build Coastguard Worker still needed for some gcc versions < 10.) */ 190*7304104dSAndroid Build Coastguard Worker #ifdef __has_attribute 191*7304104dSAndroid Build Coastguard Worker # if __has_attribute(no_reorder) 192*7304104dSAndroid Build Coastguard Worker # define used_in_asm __attribute__ ((externally_visible, no_reorder)) 193*7304104dSAndroid Build Coastguard Worker # endif 194*7304104dSAndroid Build Coastguard Worker #endif 195*7304104dSAndroid Build Coastguard Worker #ifndef used_in_asm 196*7304104dSAndroid Build Coastguard Worker # define used_in_asm /* empty */ 197*7304104dSAndroid Build Coastguard Worker #endif 198*7304104dSAndroid Build Coastguard Worker 199*7304104dSAndroid Build Coastguard Worker #ifdef SYMBOL_VERSIONING 200*7304104dSAndroid Build Coastguard Worker # define NEW_INTDEF(name) __typeof (name) INTUSE(name) \ 201*7304104dSAndroid Build Coastguard Worker __attribute__ ((alias ("_new." #name))) attribute_hidden; 202*7304104dSAndroid Build Coastguard Worker # ifdef __has_attribute 203*7304104dSAndroid Build Coastguard Worker # if __has_attribute(symver) 204*7304104dSAndroid Build Coastguard Worker # define NEW_VERSION(name, version) \ 205*7304104dSAndroid Build Coastguard Worker __typeof (name) name __asm__ ("_new." #name) \ 206*7304104dSAndroid Build Coastguard Worker __attribute__ ((symver (#name "@@" #version))); 207*7304104dSAndroid Build Coastguard Worker # define OLD_VERSION(name, version) _OLD_VERSION1(name, __COUNTER__, version) 208*7304104dSAndroid Build Coastguard Worker # define _OLD_VERSION1(name, num, version) _OLD_VERSION2(name, num, version) 209*7304104dSAndroid Build Coastguard Worker # define _OLD_VERSION2(name, num, version) \ 210*7304104dSAndroid Build Coastguard Worker __typeof (name) _compat_old##num##_##name \ 211*7304104dSAndroid Build Coastguard Worker __asm__ ("_compat." #version "." #name) \ 212*7304104dSAndroid Build Coastguard Worker __attribute__ ((alias ("_new." #name), symver (#name "@" #version))); 213*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ 214*7304104dSAndroid Build Coastguard Worker __typeof (_compat_##prefix##_##name) _compat_##prefix##_##name \ 215*7304104dSAndroid Build Coastguard Worker __asm__ ("_compat." #version "." #name) \ 216*7304104dSAndroid Build Coastguard Worker __attribute__ ((symver (#name "@" #version))); 217*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION(name, version, prefix) \ 218*7304104dSAndroid Build Coastguard Worker asm (".symver _compat." #version "." #name "," #name "@" #version); \ 219*7304104dSAndroid Build Coastguard Worker __typeof (name) _compat_##prefix##_##name \ 220*7304104dSAndroid Build Coastguard Worker __asm__ ("_compat." #version "." #name) \ 221*7304104dSAndroid Build Coastguard Worker __attribute__ ((symver (#name "@" #version))); 222*7304104dSAndroid Build Coastguard Worker # endif 223*7304104dSAndroid Build Coastguard Worker # endif 224*7304104dSAndroid Build Coastguard Worker # ifndef NEW_VERSION 225*7304104dSAndroid Build Coastguard Worker # define OLD_VERSION(name, version) \ 226*7304104dSAndroid Build Coastguard Worker asm (".globl _compat." #version "." #name "\n\t" \ 227*7304104dSAndroid Build Coastguard Worker "_compat." #version "." #name " = _new." #name "\n\t" \ 228*7304104dSAndroid Build Coastguard Worker ".symver _compat." #version "." #name "," #name "@" #version); 229*7304104dSAndroid Build Coastguard Worker # define NEW_VERSION(name, version) \ 230*7304104dSAndroid Build Coastguard Worker __typeof (name) name __asm__ ("_new." #name) used_in_asm; \ 231*7304104dSAndroid Build Coastguard Worker asm (".symver _new." #name ", " #name "@@" #version); 232*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ 233*7304104dSAndroid Build Coastguard Worker __typeof (_compat_##prefix##_##name) _compat_##prefix##_##name \ 234*7304104dSAndroid Build Coastguard Worker __asm__ ("_compat." #version "." #name) used_in_asm; \ 235*7304104dSAndroid Build Coastguard Worker asm (".symver _compat." #version "." #name ", " #name "@" #version); 236*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION(name, version, prefix) \ 237*7304104dSAndroid Build Coastguard Worker __typeof (name) _compat_##prefix##_##name \ 238*7304104dSAndroid Build Coastguard Worker __asm__ ("_compat." #version "." #name) used_in_asm; \ 239*7304104dSAndroid Build Coastguard Worker asm (".symver _compat." #version "." #name ", " #name "@" #version); 240*7304104dSAndroid Build Coastguard Worker # endif 241*7304104dSAndroid Build Coastguard Worker #else 242*7304104dSAndroid Build Coastguard Worker # define NEW_INTDEF(name) INTDEF(name) 243*7304104dSAndroid Build Coastguard Worker # define OLD_VERSION(name, version) /* Nothing for static linking. */ 244*7304104dSAndroid Build Coastguard Worker # define NEW_VERSION(name, version) /* Nothing for static linking. */ 245*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ 246*7304104dSAndroid Build Coastguard Worker error "should use #ifdef SYMBOL_VERSIONING" 247*7304104dSAndroid Build Coastguard Worker # define COMPAT_VERSION(name, version, prefix) \ 248*7304104dSAndroid Build Coastguard Worker error "should use #ifdef SYMBOL_VERSIONING" 249*7304104dSAndroid Build Coastguard Worker #endif 250*7304104dSAndroid Build Coastguard Worker 251*7304104dSAndroid Build Coastguard Worker #ifndef FALLTHROUGH 252*7304104dSAndroid Build Coastguard Worker # ifdef HAVE_FALLTHROUGH 253*7304104dSAndroid Build Coastguard Worker # define FALLTHROUGH __attribute__ ((fallthrough)) 254*7304104dSAndroid Build Coastguard Worker # else 255*7304104dSAndroid Build Coastguard Worker # define FALLTHROUGH ((void) 0) 256*7304104dSAndroid Build Coastguard Worker # endif 257*7304104dSAndroid Build Coastguard Worker #endif 258*7304104dSAndroid Build Coastguard Worker 259*7304104dSAndroid Build Coastguard Worker #endif /* eu-config.h */ 260