Blame lib/eu-config.h

Packit 032894
/* Configuration definitions.
Packit 032894
   Copyright (C) 2008, 2009 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifndef EU_CONFIG_H
Packit 032894
#define EU_CONFIG_H	1
Packit 032894
Packit 032894
#ifdef USE_LOCKS
Packit 032894
# include <pthread.h>
Packit 032894
# include <assert.h>
Packit 032894
# define rwlock_define(class,name)	class pthread_rwlock_t name
Packit 032894
# define RWLOCK_CALL(call)		\
Packit 032894
  ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); })
Packit 032894
# define rwlock_init(lock)		RWLOCK_CALL (init (&lock, NULL))
Packit 032894
# define rwlock_fini(lock)		RWLOCK_CALL (destroy (&lock))
Packit 032894
# define rwlock_rdlock(lock)		RWLOCK_CALL (rdlock (&lock))
Packit 032894
# define rwlock_wrlock(lock)		RWLOCK_CALL (wrlock (&lock))
Packit 032894
# define rwlock_unlock(lock)		RWLOCK_CALL (unlock (&lock))
Packit 032894
#else
Packit 032894
/* Eventually we will allow multi-threaded applications to use the
Packit 032894
   libraries.  Therefore we will add the necessary locking although
Packit 032894
   the macros used expand to nothing for now.  */
Packit 032894
# define rwlock_define(class,name) class int name
Packit 032894
# define rwlock_init(lock) ((void) (lock))
Packit 032894
# define rwlock_fini(lock) ((void) (lock))
Packit 032894
# define rwlock_rdlock(lock) ((void) (lock))
Packit 032894
# define rwlock_wrlock(lock) ((void) (lock))
Packit 032894
# define rwlock_unlock(lock) ((void) (lock))
Packit 032894
#endif	/* USE_LOCKS */
Packit 032894
Packit 032894
/* gettext helper macro.  */
Packit 032894
#define N_(Str) Str
Packit 032894
Packit 032894
/* Compiler-specific definitions.  */
Packit 032894
#define strong_alias(name, aliasname) \
Packit 032894
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
Packit 032894
Packit 032894
#ifdef __i386__
Packit 032894
# define internal_function __attribute__ ((regparm (3), stdcall))
Packit 032894
#else
Packit 032894
# define internal_function /* nothing */
Packit 032894
#endif
Packit 032894
Packit 032894
#define internal_strong_alias(name, aliasname) \
Packit 032894
  extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function;
Packit 032894
Packit 032894
#ifdef HAVE_VISIBILITY
Packit 032894
#define attribute_hidden \
Packit 032894
  __attribute__ ((visibility ("hidden")))
Packit 032894
#else
Packit 032894
#define attribute_hidden /* empty */
Packit 032894
#endif
Packit 032894
Packit 032894
#ifdef HAVE_GCC_STRUCT
Packit 032894
#define attribute_packed \
Packit 032894
  __attribute__ ((packed, gcc_struct))
Packit 032894
#else
Packit 032894
#define attribute_packed \
Packit 032894
  __attribute__ ((packed))
Packit 032894
#endif
Packit 032894
Packit 032894
/* Define ALLOW_UNALIGNED if the architecture allows operations on
Packit 032894
   unaligned memory locations.  */
Packit 032894
#define SANITIZE_UNDEFINED 1
Packit 032894
#if (defined __i386__ || defined __x86_64__) && ! CHECK_UNDEFINED
Packit 032894
# define ALLOW_UNALIGNED	1
Packit 032894
#else
Packit 032894
# define ALLOW_UNALIGNED	0
Packit 032894
#endif
Packit 032894
Packit 032894
#if DEBUGPRED
Packit 032894
# ifdef __x86_64__
Packit 032894
asm (".section predict_data, \"aw\"; .previous\n"
Packit 032894
     ".section predict_line, \"a\"; .previous\n"
Packit 032894
     ".section predict_file, \"a\"; .previous");
Packit 032894
#  ifndef PIC
Packit 032894
#   define debugpred__(e, E) \
Packit 032894
  ({ long int _e = !!(e); \
Packit 032894
     asm volatile (".pushsection predict_data; ..predictcnt%=: .quad 0; .quad 0\n" \
Packit 032894
                   ".section predict_line; .quad %c1\n" \
Packit 032894
                   ".section predict_file; .quad %c2; .popsection\n" \
Packit 032894
                   "addq $1,..predictcnt%=(,%0,8)" \
Packit 032894
                   : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
Packit 032894
    __builtin_expect (_e, E); \
Packit 032894
  })
Packit 032894
#  endif
Packit 032894
# elif defined __i386__
Packit 032894
asm (".section predict_data, \"aw\"; .previous\n"
Packit 032894
     ".section predict_line, \"a\"; .previous\n"
Packit 032894
     ".section predict_file, \"a\"; .previous");
Packit 032894
#  ifndef PIC
Packit 032894
#   define debugpred__(e, E) \
Packit 032894
  ({ long int _e = !!(e); \
Packit 032894
     asm volatile (".pushsection predict_data; ..predictcnt%=: .long 0; .long 0\n" \
Packit 032894
                   ".section predict_line; .long %c1\n" \
Packit 032894
                   ".section predict_file; .long %c2; .popsection\n" \
Packit 032894
                   "incl ..predictcnt%=(,%0,8)" \
Packit 032894
                   : : "r" (_e == E), "i" (__LINE__), "i" (__FILE__)); \
Packit 032894
    __builtin_expect (_e, E); \
Packit 032894
  })
Packit 032894
#  endif
Packit 032894
# endif
Packit 032894
# ifdef debugpred__
Packit 032894
#  define unlikely(e) debugpred__ (e,0)
Packit 032894
#  define likely(e) debugpred__ (e,1)
Packit 032894
# endif
Packit 032894
#endif
Packit 032894
#ifndef likely
Packit 032894
# define unlikely(expr) __builtin_expect (!!(expr), 0)
Packit 032894
# define likely(expr) __builtin_expect (!!(expr), 1)
Packit 032894
#endif
Packit 032894
Packit 032894
#define obstack_calloc(ob, size) \
Packit 032894
  ({ size_t _s = (size); memset (obstack_alloc (ob, _s), '\0', _s); })
Packit 032894
#define obstack_strdup(ob, str) \
Packit 032894
  ({ const char *_s = (str); obstack_copy0 (ob, _s, strlen (_s)); })
Packit 032894
#define obstack_strndup(ob, str, n) \
Packit 032894
  ({ const char *_s = (str); obstack_copy0 (ob, _s, strnlen (_s, n)); })
Packit 032894
Packit 032894
#if __STDC_VERSION__ >= 199901L
Packit 032894
# define flexarr_size /* empty */
Packit 032894
#else
Packit 032894
# define flexarr_size 0
Packit 032894
#endif
Packit 032894
Packit 032894
/* Calling conventions.  */
Packit 032894
#ifdef __i386__
Packit 032894
# define CALLING_CONVENTION regparm (3), stdcall
Packit 032894
# define AND_CALLING_CONVENTION , regparm (3), stdcall
Packit 032894
#else
Packit 032894
# define CALLING_CONVENTION
Packit 032894
# define AND_CALLING_CONVENTION
Packit 032894
#endif
Packit 032894
Packit 032894
/* Avoid PLT entries.  */
Packit 032894
#ifdef PIC
Packit 032894
# define INTUSE(name) _INTUSE(name)
Packit 032894
# define _INTUSE(name) __##name##_internal
Packit 032894
# define INTDEF(name) _INTDEF(name)
Packit 032894
# define _INTDEF(name) \
Packit 032894
  extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name)));
Packit 032894
# define INTDECL(name) _INTDECL(name)
Packit 032894
# define _INTDECL(name) \
Packit 032894
  extern __typeof__ (name) __##name##_internal attribute_hidden;
Packit 032894
#else
Packit 032894
# define INTUSE(name) name
Packit 032894
# define INTDEF(name) /* empty */
Packit 032894
# define INTDECL(name) /* empty */
Packit 032894
#endif
Packit 032894
Packit 032894
/* This macro is used by the tests conditionalize for standalone building.  */
Packit 032894
#define ELFUTILS_HEADER(name) <lib##name.h>
Packit 032894
Packit 032894
Packit 032894
#ifdef SYMBOL_VERSIONING
Packit 032894
# define OLD_VERSION(name, version) \
Packit 032894
  asm (".globl _compat." #version "." #name "\n" \
Packit 032894
       "_compat." #version "." #name " = " #name "\n" \
Packit 032894
       ".symver _compat." #version "." #name "," #name "@" #version);
Packit 032894
# define NEW_VERSION(name, version) \
Packit 032894
  asm (".symver " #name "," #name "@@@" #version);
Packit 032894
# define COMPAT_VERSION_NEWPROTO(name, version, prefix) \
Packit 032894
  asm (".symver _compat." #version "." #name "," #name "@" #version); \
Packit 032894
  __typeof (_compat_##prefix##_##name) _compat_##prefix##_##name \
Packit 032894
    asm ("_compat." #version "." #name);
Packit 032894
# define COMPAT_VERSION(name, version, prefix) \
Packit 032894
  asm (".symver _compat." #version "." #name "," #name "@" #version); \
Packit 032894
  __typeof (name) _compat_##prefix##_##name asm ("_compat." #version "." #name);
Packit 032894
#else
Packit 032894
# define OLD_VERSION(name, version) /* Nothing for static linking.  */
Packit 032894
# define NEW_VERSION(name, version) /* Nothing for static linking.  */
Packit 032894
# define COMPAT_VERSION_NEWPROTO(name, version, prefix) \
Packit 032894
  error "should use #ifdef SYMBOL_VERSIONING"
Packit 032894
# define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING"
Packit 032894
#endif
Packit 032894
Packit 032894
#ifndef FALLTHROUGH
Packit 032894
# ifdef HAVE_FALLTHROUGH
Packit 032894
#  define FALLTHROUGH __attribute__ ((fallthrough))
Packit 032894
# else
Packit 032894
#  define FALLTHROUGH ((void) 0)
Packit 032894
# endif
Packit 032894
#endif
Packit 032894
Packit 032894
#endif	/* eu-config.h */