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