Attempt to create .deps directory every time we build objects.
[doas.git] / attributes.h
blobfdfbfdd548956e2247a238e1a86e37737b1ed0a1
1 /*
2 * Copyright (c) 2021-2022 Sergey Sushilin <sergeysushilin@protonmail.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _ATTRIBUTES_H
18 #define _ATTRIBUTES_H 1
20 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
21 || defined(__clang__) || __SUNPRO_C >= 0x5110 \
22 || defined(__TINYC__) || __HP_cc >= 61000
23 # define __noreturn __attribute__((__noreturn__))
24 #else
25 # define __noreturn /* Nothing. */
26 #endif
28 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
29 # define __pure __attribute__((__pure__))
30 #else
31 # define __pure /* Nothing. */
32 #endif
34 #undef __const
35 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
36 # define __const __attribute__((__const__))
37 #else
38 # define __const /* Nothing. */
39 #endif
41 #if !defined(__nonnull)
42 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined(__clang__)
43 # define __nonnull(params) __attribute__((__nonnull__ params))
44 # else
45 # define __nonnull(params) /* Nothing. */
46 # endif
47 #endif
49 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
50 # define __unused __attribute__((__unused__))
51 #else
52 # define __unused /* Nothing. */
53 #endif
55 #undef __warn_unused_result
56 /* Warn about unused results of certain
57 function calls which can lead to problems. */
58 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
59 # define __warn_unused_result __attribute__((__warn_unused_result__))
60 #else
61 # define __warn_unused_result /* Nothing. */
62 #endif
64 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
65 # define __format_printf(p1, p2) __attribute__((__format__(__gnu_printf__, p1, p2)))
66 #elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
67 # define __format_printf(p1, p2) __attribute__((__format__(__printf__, p1, p2)))
68 #else
69 # define __format_printf(p1, p2) /* Nothing. */
70 #endif
72 #if __GNUC__ >= 11
73 # define __dealloc(f, n) __attribute__((__malloc__ (f, n)))
74 # define __malloc __attribute__((__malloc__))
75 #elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
76 # define __dealloc(f, n) /* Nothing. */
77 # define __malloc __attribute__((__malloc__))
78 #else
79 # define __dealloc(f, n) /* Nothing. */
80 # define __malloc /* Nothing. */
81 #endif
83 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
84 # define __alloc_size(params) __attribute__((__alloc_size__ params))
85 #else
86 # define __alloc_size(params) /* Nothing. */
87 #endif
89 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
90 # define __packed __attribute__((__packed__))
91 #else
92 # define __packed /* Nothing. */
93 #endif
95 #undef __returns_nonnull
96 #if (__GNUC__ >= 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__PCC__)
97 # define __returns_nonnull __attribute__((__returns_nonnull__))
98 #else
99 # define __returns_nonnull /* Nothing. */
100 #endif
102 #if __GNUC__ >= 7
103 # define fallthrough __attribute__((__fallthrough__))
104 #else
105 # define fallthrough ((void)0)
106 #endif
108 #endif /* _ATTRIBUTES_H */