1dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala/* libunwind - a platform-independent unwind library
2dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala   Copyright (C) 2001-2005 Hewlett-Packard Co
3dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala   Copyright (C) 2007 David Mosberger-Tang
4dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala	Contributed by David Mosberger-Tang <dmosberger@gmail.com>
5dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
6dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaThis file is part of libunwind.
7dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
8dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaPermission is hereby granted, free of charge, to any person obtaining
9dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantalaa copy of this software and associated documentation files (the
10dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala"Software"), to deal in the Software without restriction, including
11dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantalawithout limitation the rights to use, copy, modify, merge, publish,
12dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantaladistribute, sublicense, and/or sell copies of the Software, and to
13dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantalapermit persons to whom the Software is furnished to do so, subject to
14dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantalathe following conditions:
15dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
16dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaThe above copyright notice and this permission notice shall be
17dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantalaincluded in all copies or substantial portions of the Software.
18dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
19dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi RantalaWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
26dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
27dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala/* Compiler specific useful bits that are used in libunwind, and also in the
28dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala * tests. */
29dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
30dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#ifndef COMPILER_H
31dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#define COMPILER_H
32dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
33dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#ifdef __GNUC__
3426fc1563fba945d0356e4a7dd935a6a57b3c03dbTommi Rantala# define ALIGNED(x)	__attribute__((aligned(x)))
357d471b144013924f8d80e532a693fb77dbe73c2bTommi Rantala# define CONST_ATTR	__attribute__((__const__))
36dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define UNUSED		__attribute__((unused))
37e3e49dc28aee0dc78f0243d932a5c950aaec7e3eTommi Rantala# define NOINLINE	__attribute__((noinline))
38dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define NORETURN	__attribute__((noreturn))
39dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define ALIAS(name)	__attribute__((alias (#name)))
40dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
41dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define ALWAYS_INLINE	inline __attribute__((always_inline))
42dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define HIDDEN	__attribute__((visibility ("hidden")))
43dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define PROTECTED	__attribute__((visibility ("protected")))
44dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# else
45dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define ALWAYS_INLINE
46dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define HIDDEN
47dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define PROTECTED
48dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# endif
49e0653f9e3a0004a62f6c7afb57885bb473b17537Tommi Rantala# define WEAK		__attribute__((weak))
50dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# if (__GNUC__ >= 3)
51dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define likely(x)	__builtin_expect ((x), 1)
52dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define unlikely(x)	__builtin_expect ((x), 0)
53dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# else
54dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define likely(x)	(x)
55dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#  define unlikely(x)	(x)
56dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# endif
57dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#else
5826fc1563fba945d0356e4a7dd935a6a57b3c03dbTommi Rantala# define ALIGNED(x)
59dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define ALWAYS_INLINE
607d471b144013924f8d80e532a693fb77dbe73c2bTommi Rantala# define CONST_ATTR
61dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define UNUSED
62e3e49dc28aee0dc78f0243d932a5c950aaec7e3eTommi Rantala# define NOINLINE
63dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define NORETURN
64dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define ALIAS(name)
65dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define HIDDEN
66dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define PROTECTED
67e0653f9e3a0004a62f6c7afb57885bb473b17537Tommi Rantala# define WEAK
68dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define likely(x)	(x)
69dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala# define unlikely(x)	(x)
70dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#endif
71dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
72dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#define ARRAY_SIZE(a)	(sizeof (a) / sizeof ((a)[0]))
73dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala
74dc680c0b52a4113cf9cf5b924714d79fb1654ee2Tommi Rantala#endif /* COMPILER_H */
75