EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
attributes.h
Go to the documentation of this file.
1 
13 #ifndef ATTRIBUTES_H
14 #define ATTRIBUTES_H
15 
16 #include <stdlib.h> // required for `free()` definition in `__must_free`
17 
18 #ifndef __must_check
19 #if defined __has_attribute
20 #if __has_attribute(__warn_unused_result__)
28 #define __must_check __attribute__((__warn_unused_result__))
29 #else
30 #define __must_check
31 #endif /* __has_attribute(__warn_unused_result__) */
32 #else
33 #define __must_check
34 #endif /* defined __has_attribute */
35 #endif /* __has_attribute */
36 
37 #ifndef __maybe_unused
38 #if defined __has_attribute
39 #if __has_attribute(unused)
47 #define __maybe_unused __attribute__((unused))
48 #else
49 #define __maybe_unused
50 #endif /* __has_attribute(unused) */
51 #else
52 #define __maybe_unused
53 #endif /* defined __has_attribute */
54 #endif /* __maybe_unused */
55 
56 #if defined __has_attribute
57 #if __has_attribute(packed)
68 #define STRUCT_PACKED __attribute__((packed))
69 #else
70 #define STRUCT_PACKED
71 #endif /* __has_attribute(packed) */
72 #else
73 #define STRUCT_PACKED
74 #endif /* defined __has_attribute */
75 
76 #if __GNUC__ >= 11 // this syntax will throw an error in GCC 10 or Clang, since
77  // __attribute__((malloc)) accepts no args
92 #define __must_free __attribute__((malloc(free, 1))) __must_check
93 #else
94 #define __must_free __must_check
95 #endif /* __GNUC__ >= 11 */
96 
97 #endif /* ATTRIBUTES_H */