blob: 34023f05d820c86df6e8da427e4f694a68b75bf1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#ifndef NEOVIM_FUNC_ATTR_H
#define NEOVIM_FUNC_ATTR_H
// gcc and clang expose their version as follows:
//
// gcc 4.7.2:
// __GNUC__ = 4
// __GNUC_MINOR__ = 7
// __GNUC_PATCHLEVEL = 2
//
// clang 3.4 (claims compat with gcc 4.2.1):
// __GNUC__ = 4
// __GNUC_MINOR__ = 2
// __GNUC_PATCHLEVEL = 1
// __clang__ = 1
// __clang_major__ = 3
// __clang_minor__ = 4
//
// To view the default defines of these compilers, you can perform:
//
// $ gcc -E -dM - </dev/null
// $ echo | clang -dM -E -
#ifdef __GNUC__
// place defines for all gnulikes here, for now that's gcc, clang and
// intel.
// place these after the argument list of the function declaration
// (not definition), like so:
// void myfunc(void) FUNC_ATTR_ALWAYS_INLINE;
#define FUNC_ATTR_MALLOC __attribute__((malloc))
#define FUNC_ATTR_ALLOC_ALIGN(x) __attribute__((alloc_align(x)))
#define FUNC_ATTR_PURE __attribute__ ((pure))
#define FUNC_ATTR_CONST __attribute__((const))
#define FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#define FUNC_ATTR_ALWAYS_INLINE __attribute__((always_inline))
#ifdef __clang__
// clang only
#elif defined(__INTEL_COMPILER)
// intel only
#else
// gcc only
#define FUNC_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
#define FUNC_ATTR_ALLOC_SIZE_PROD(x,y) __attribute__((alloc_size(x,y)))
#endif
#endif
// define function attributes that haven't been defined for this specific
// compiler.
#ifndef FUNC_ATTR_MALLOC
#define FUNC_ATTR_MALLOC
#endif
#ifndef FUNC_ATTR_ALLOC_SIZE
#define FUNC_ATTR_ALLOC_SIZE(x)
#endif
#ifndef FUNC_ATTR_ALLOC_SIZE_PROD
#define FUNC_ATTR_ALLOC_SIZE_PROD(x,y)
#endif
#ifndef FUNC_ATTR_ALLOC_ALIGN
#define FUNC_ATTR_ALLOC_ALIGN(x)
#endif
#ifndef FUNC_ATTR_PURE
#define FUNC_ATTR_PURE
#endif
#ifndef FUNC_ATTR_CONST
#define FUNC_ATTR_CONST
#endif
#ifndef FUNC_ATTR_WARN_UNUSED_RESULT
#define FUNC_ATTR_WARN_UNUSED_RESULT
#endif
#ifndef FUNC_ATTR_ALWAYS_INLINE
#define FUNC_ATTR_ALWAYS_INLINE
#endif
#endif // NEOVIM_FUNC_ATTR_H
|