1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-25 16:47:38 +01:00

Pull attribute macros from libunwind_i.h' to new header compiler.h'

Pull attribute macros from `libunwind_i.h' to new header `compiler.h',
to allow the macros to also be used in the tests.
This commit is contained in:
Tommi Rantala 2012-09-19 12:12:16 +03:00
parent 80e852cb38
commit dc680c0b52
3 changed files with 69 additions and 34 deletions

View file

@ -36,7 +36,7 @@ nodist_include_HEADERS = include/libunwind-common.h
SUBDIRS = src tests doc SUBDIRS = src tests doc
noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \
include/libunwind_i.h include/mempool.h \ include/compiler.h include/libunwind_i.h include/mempool.h \
include/remote.h \ include/remote.h \
include/tdep-arm/dwarf-config.h \ include/tdep-arm/dwarf-config.h \
include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \ include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \

66
include/compiler.h Normal file
View file

@ -0,0 +1,66 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2001-2005 Hewlett-Packard Co
Copyright (C) 2007 David Mosberger-Tang
Contributed by David Mosberger-Tang <dmosberger@gmail.com>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/* Compiler specific useful bits that are used in libunwind, and also in the
* tests. */
#ifndef COMPILER_H
#define COMPILER_H
#ifdef __GNUC__
# define UNUSED __attribute__((unused))
# define NORETURN __attribute__((noreturn))
# define ALIAS(name) __attribute__((alias (#name)))
# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
# define ALWAYS_INLINE inline __attribute__((always_inline))
# define HIDDEN __attribute__((visibility ("hidden")))
# define PROTECTED __attribute__((visibility ("protected")))
# else
# define ALWAYS_INLINE
# define HIDDEN
# define PROTECTED
# endif
# if (__GNUC__ >= 3)
# define likely(x) __builtin_expect ((x), 1)
# define unlikely(x) __builtin_expect ((x), 0)
# else
# define likely(x) (x)
# define unlikely(x) (x)
# endif
#else
# define ALWAYS_INLINE
# define UNUSED
# define NORETURN
# define ALIAS(name)
# define HIDDEN
# define PROTECTED
# define likely(x) (x)
# define unlikely(x) (x)
#endif
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
#endif /* COMPILER_H */

View file

@ -35,6 +35,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# include "config.h" # include "config.h"
#endif #endif
#include "compiler.h"
#ifdef HAVE___THREAD #ifdef HAVE___THREAD
/* For now, turn off per-thread caching. It uses up too much TLS /* For now, turn off per-thread caching. It uses up too much TLS
memory per thread even when the thread never uses libunwind at memory per thread even when the thread never uses libunwind at
@ -70,45 +72,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# endif # endif
#endif #endif
#ifdef __GNUC__
# define UNUSED __attribute__((unused))
# define NORETURN __attribute__((noreturn))
# define ALIAS(name) __attribute__((alias (#name)))
# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
# define ALWAYS_INLINE inline __attribute__((always_inline))
# define HIDDEN __attribute__((visibility ("hidden")))
# define PROTECTED __attribute__((visibility ("protected")))
# else
# define ALWAYS_INLINE
# define HIDDEN
# define PROTECTED
# endif
# if (__GNUC__ >= 3)
# define likely(x) __builtin_expect ((x), 1)
# define unlikely(x) __builtin_expect ((x), 0)
# else
# define likely(x) (x)
# define unlikely(x) (x)
# endif
#else
# define ALWAYS_INLINE
# define UNUSED
# define NORETURN
# define ALIAS(name)
# define HIDDEN
# define PROTECTED
# define likely(x) (x)
# define unlikely(x) (x)
#endif
#ifdef DEBUG #ifdef DEBUG
# define UNW_DEBUG 1 # define UNW_DEBUG 1
#else #else
# define UNW_DEBUG 0 # define UNW_DEBUG 0
#endif #endif
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
/* Make it easy to write thread-safe code which may or may not be /* Make it easy to write thread-safe code which may or may not be
linked against libpthread. The macros below can be used linked against libpthread. The macros below can be used
unconditionally and if -lpthread is around, they'll call the unconditionally and if -lpthread is around, they'll call the