-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattribs.h
47 lines (40 loc) · 1.29 KB
/
attribs.h
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
/**
* @file attribs.h
* @author TheSomeMan
* @date 2020-10-20
* @copyright Ruuvi Innovations Ltd, license BSD-3-Clause.
*/
#ifndef ATTRIBS_H
#define ATTRIBS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUC__
#define ATTRIBUTE(attrs) __attribute__(attrs)
#else
#define ATTRIBUTE(attrs)
#endif
#define ATTR_NORETURN ATTRIBUTE((noreturn))
#define ATTR_UNUSED ATTRIBUTE((unused))
#define ATTR_MALLOC ATTRIBUTE((malloc))
#define ATTR_MALLOC_SIZE(idx) ATTRIBUTE((alloc_size(idx)))
#define ATTR_CALLOC_SIZE(nmemb, size) ATTRIBUTE((alloc_size(nmemb, size)))
#define ATTR_RETURNS_NONNULL ATTRIBUTE((returns_nonnull))
#define ATTR_CONST ATTRIBUTE((const))
#define ATTR_PURE ATTRIBUTE((pure))
#define ATTR_WARN_UNUSED_RESULT ATTRIBUTE((warn_unused_result))
#define ATTR_PRINTF(idx_fmt, idx_args) ATTRIBUTE((format(printf, idx_fmt, idx_args)))
#define ATTR_NONNULL(arg_idx, ...) ATTRIBUTE((nonnull(arg_idx, ##__VA_ARGS__)))
#if !defined(__clang__)
#if defined(__GNUC__) && (__GNUC__ >= 7)
#define ATTR_FALLTHROUGH __attribute__((fallthrough))
#else
#define ATTR_FALLTHROUGH (void)0
#endif
#else
#define ATTR_FALLTHROUGH (void)0
#endif
#ifdef __cplusplus
}
#endif
#endif // ATTRIBS_H