Describe implication of upstream ICU-22610
[samba.git] / lib / util / attr.h
blobaf3e2442b3ad7edb40b0b650f5250223c16745b9
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __UTIL_ATTR_H__
21 #define __UTIL_ATTR_H__
23 /* for old gcc releases that don't have the feature test macro __has_attribute */
24 #ifndef __has_attribute
25 #define __has_attribute(x) 0
26 #endif
28 #ifndef _UNUSED_
29 #if __has_attribute(unused) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
30 /** gcc attribute used on function parameters so that it does not emit
31 * warnings about them being unused. **/
32 # define _UNUSED_ __attribute__ ((unused))
33 #else
34 # define _UNUSED_
35 #endif
36 #endif
37 #ifndef UNUSED
38 #define UNUSED(param) param _UNUSED_
39 #endif
41 #ifndef _DEPRECATED_
42 #if __has_attribute(deprecated) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
43 #define _DEPRECATED_ __attribute__ ((deprecated))
44 #else
45 #define _DEPRECATED_
46 #endif
47 #endif
49 #ifndef _WARN_UNUSED_RESULT_
50 #if __has_attribute(warn_unused_result) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
51 #define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
52 #else
53 #define _WARN_UNUSED_RESULT_
54 #endif
55 #endif
57 #ifndef _NORETURN_
58 #if __has_attribute(noreturn) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
59 #define _NORETURN_ __attribute__ ((noreturn))
60 #else
61 #define _NORETURN_
62 #endif
63 #endif
65 #ifndef _PURE_
66 #if __has_attribute(pure) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
67 #define _PURE_ __attribute__((pure))
68 #else
69 #define _PURE_
70 #endif
71 #endif
73 #ifndef NONNULL
74 #if __has_attribute(nonnull) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
75 #define NONNULL(param) param __attribute__((nonnull))
76 #else
77 #define NONNULL(param) param
78 #endif
79 #endif
81 #ifndef PRINTF_ATTRIBUTE
82 #if __has_attribute(format) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
83 /** Use gcc attribute to check printf fns. a1 is the 1-based index of
84 * the parameter containing the format, and a2 the index of the first
85 * argument. Note that some gcc 2.x versions don't handle this
86 * properly **/
87 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
88 #else
89 #define PRINTF_ATTRIBUTE(a1, a2)
90 #endif
91 #endif
93 #ifndef FORMAT_ATTRIBUTE
94 #if __has_attribute(format) || ( (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) )
95 /** Use gcc attribute to check printf fns. a1 is argument to format()
96 * in the above macro. This is needed to support Heimdal's printf
97 * decorations. Note that some gcc 2.x versions don't handle this
98 * properly. **/
99 #define FORMAT_ATTRIBUTE(a) __attribute__ ((format a))
100 #else
101 #define FORMAT_ATTRIBUTE(a)
102 #endif
103 #endif
105 #endif /* __UTIL_ATTR_H__ */