libamxc  1.10.3
C Generic Data Containers
amxc_macros.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #if !defined(__AMXC_MACROS_H__)
56 #define __AMXC_MACROS_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #if !defined(USE_DOXYGEN)
64 
65 #ifndef PRIVATE
66 #define PRIVATE __attribute__ ((visibility("hidden")))
67 #endif
68 
69 #ifndef UNUSED
70 #define UNUSED __attribute__((unused))
71 #endif
72 
73 #ifndef WARN_UNUSED_RETURN
74 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result))
75 #endif
76 
77 #ifndef CONSTRUCTOR_LVL
78 #define CONSTRUCTOR_LVL(x) __attribute__((constructor(x)))
79 #endif
80 
81 #ifndef DESTRUCTOR_LVL
82 #define DESTRUCTOR_LVL(x) __attribute__((destructor(x)))
83 #endif
84 
85 #ifndef CONSTRUCTOR
86 #define CONSTRUCTOR __attribute__((constructor))
87 #endif
88 
89 #ifndef DESTRUCTOR
90 #define DESTRUCTOR __attribute__((destructor))
91 #endif
92 
93 #else // !defined(USE_DOXYGEN)
94 
95 #ifndef PRIVATE
96 #define PRIVATE
97 #endif
98 
99 #ifndef UNUSED
100 #define UNUSED
101 #endif
102 
103 #ifndef WARN_UNUSED_RETURN
104 #define WARN_UNUSED_RETURN
105 #endif
106 
107 #ifndef CONSTRUCTOR_LVL
108 #define CONSTRUCTOR_LVL(x)
109 #endif
110 
111 #ifndef DESTRUCTOR_LVL
112 #define DESTRUCTOR_LVL(x)
113 #endif
114 
115 #ifndef CONSTRUCTOR
116 #define CONSTRUCTOR
117 #endif
118 
119 #ifndef DESTRUCTOR
120 #define DESTRUCTOR
121 #endif
122 
123 #endif // !defined(USE_DOXYGEN)
124 
125 #ifndef when_null
126 #define when_null(x, l) if((x) == NULL) { goto l; }
127 #endif
128 
129 #ifndef when_not_null
130 #define when_not_null(x, l) if((x) != NULL) { goto l; }
131 #endif
132 
133 #ifndef when_true
134 #define when_true(x, l) if((x)) { goto l; }
135 #endif
136 
137 #ifndef when_false
138 #define when_false(x, l) if(!(x)) { goto l; }
139 #endif
140 
141 #ifndef when_failed
142 #define when_failed(x, l) if((x) != 0) { goto l; }
143 #endif
144 
145 #ifndef when_str_empty
146 #define when_str_empty(x, l) if((x) == NULL || *(x) == 0) { goto l; }
147 #endif
148 
149 #ifndef when_null_status
150 #define when_null_status(x, l, c) if((x) == NULL) { c; goto l; }
151 #endif
152 
153 #ifndef when_not_null_status
154 #define when_not_null_status(x, l, c) if((x) != NULL) { c; goto l; }
155 #endif
156 
157 #ifndef when_true_status
158 #define when_true_status(x, l, c) if((x)) { c; goto l; }
159 #endif
160 
161 #ifndef when_false_status
162 #define when_false_status(x, l, c) if(!(x)) { c; goto l; }
163 #endif
164 
165 #ifndef when_failed_status
166 #define when_failed_status(x, l, c) if((x) != 0) { c; goto l; }
167 #endif
168 
169 
170 #ifndef when_str_empty_status
171 #define when_str_empty_status(x, l, c) if((x) == NULL || (x)[0] == '\0') { c; goto l; }
172 #endif
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif // __AMXC_MACROS_H__