| 1 |
/* |
| 2 |
# This file is part of the Astrometry.net suite. |
| 3 |
# Licensed under a 3-clause BSD style license - see LICENSE |
| 4 |
*/ |
| 5 |
|
| 6 |
// borrowed from http://rlove.org/log/2005102601. |
| 7 |
|
| 8 |
#ifndef ASTROMETRY_KEYWORDS_H |
| 9 |
#define ASTROMETRY_KEYWORDS_H |
| 10 |
|
| 11 |
#ifdef __GNUC__ |
| 12 |
#define ATTRIB_FORMAT(style,fmt,start) __attribute__ ((format(style,fmt,start))) |
| 13 |
#endif |
| 14 |
|
| 15 |
// this snippet borrowed from GNU libc features.h: |
| 16 |
#if defined __GNUC__ |
| 17 |
# define GNUC_PREREQ(maj, min) \ |
| 18 |
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) |
| 19 |
#else |
| 20 |
# define GNUC_PREREQ(maj, min) 0 |
| 21 |
#endif |
| 22 |
|
| 23 |
#if GNUC_PREREQ (3, 0) |
| 24 |
|
| 25 |
// Clang masquerades as gcc but isn't compatible. Someone should file a |
| 26 |
// lawsuit. Clang treats inlining differently; see |
| 27 |
// http://clang.llvm.org/compatibility.html#inline |
| 28 |
|
| 29 |
#if defined __clang__ || GNUC_PREREQ (5, 0) |
| 30 |
|
| 31 |
// After gcc 5.0, -std=gnu11 is the default (vs -std=gnu89 in previous |
| 32 |
// versions). This affects inlining semantics, among other things. |
| 33 |
|
| 34 |
#define InlineDeclare |
| 35 |
#define InlineDefineH |
| 36 |
#define InlineDefineC |
| 37 |
|
| 38 |
#else |
| 39 |
|
| 40 |
// plain old gcc |
| 41 |
|
| 42 |
#define INCLUDE_INLINE_SOURCE 1 |
| 43 |
|
| 44 |
#define InlineDeclare extern inline |
| 45 |
#define InlineDefineH extern inline |
| 46 |
#define InlineDefineC |
| 47 |
|
| 48 |
#endif |
| 49 |
|
| 50 |
// See: |
| 51 |
// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html |
| 52 |
|
| 53 |
# define Inline inline |
| 54 |
# define Pure __attribute__ ((pure)) |
| 55 |
# define Const __attribute__ ((const)) |
| 56 |
# define Noreturn __attribute__ ((noreturn)) |
| 57 |
# define Malloc __attribute__ ((malloc)) |
| 58 |
# define Used __attribute__ ((used)) |
| 59 |
# define Unused __attribute__ ((unused)) |
| 60 |
# define VarUnused __attribute__ ((unused)) |
| 61 |
# define Packed __attribute__ ((packed)) |
| 62 |
# define likely(x) __builtin_expect (!!(x), 1) |
| 63 |
# define unlikely(x) __builtin_expect (!!(x), 0) |
| 64 |
# define Noinline __attribute__ ((noinline)) |
| 65 |
// alloc_size |
| 66 |
|
| 67 |
// new in gcc-3.1: |
| 68 |
#if GNUC_PREREQ (3, 1) |
| 69 |
# define Deprecated __attribute__ ((deprecated)) |
| 70 |
#else |
| 71 |
# define Deprecated |
| 72 |
#endif |
| 73 |
|
| 74 |
// new in gcc-3.4: |
| 75 |
#if GNUC_PREREQ (3, 4) |
| 76 |
# define Must_check __attribute__ ((warn_unused_result)) |
| 77 |
# define WarnUnusedResult __attribute__ ((warn_unused_result)) |
| 78 |
#else |
| 79 |
# define Must_check |
| 80 |
# define WarnUnusedResult |
| 81 |
#endif |
| 82 |
|
| 83 |
// new in gcc-4.1: |
| 84 |
#if GNUC_PREREQ (4, 1) |
| 85 |
|
| 86 |
#if defined __clang__ |
| 87 |
// clang complains very loudly about this being ignored... |
| 88 |
# define Flatten |
| 89 |
#else |
| 90 |
# define Flatten __attribute__ (( flatten)) |
| 91 |
#endif |
| 92 |
|
| 93 |
#else |
| 94 |
# define Flatten |
| 95 |
#endif |
| 96 |
|
| 97 |
#else |
| 98 |
|
| 99 |
// not gnuc >= 3.0 |
| 100 |
|
| 101 |
# define InlineDeclare |
| 102 |
# define InlineDefineH |
| 103 |
# define InlineDefineC |
| 104 |
# define Inline |
| 105 |
# define Pure |
| 106 |
# define Const |
| 107 |
# define Noreturn |
| 108 |
# define Malloc |
| 109 |
# define Must_check |
| 110 |
# define Deprecated |
| 111 |
# define Used |
| 112 |
# define Unused |
| 113 |
# define VarUnused |
| 114 |
# define Packed |
| 115 |
# define likely(x) (x) |
| 116 |
# define unlikely(x) (x) |
| 117 |
# define Noinline |
| 118 |
# define WarnUnusedResult |
| 119 |
# define Flatten |
| 120 |
|
| 121 |
#endif |
| 122 |
|
| 123 |
#endif // ASTROMETRY_KEYWORDS_H |