s3/packaging: Fix typo in comment.
[Samba.git] / lib / util / attr.h
blobf64b272a674e12b44916b5eda69df06238cd5a99
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 #ifdef __GNUC__
24 /** gcc attribute used on function parameters so that it does not emit
25 * warnings about them being unused. **/
26 # define UNUSED(param) param __attribute__ ((unused))
27 #else
28 # define UNUSED(param) param
29 /** Feel free to add definitions for other compilers here. */
30 #endif
32 #ifdef HAVE_VISIBILITY_ATTR
33 # define _PUBLIC_ __attribute__((visibility("default")))
34 #else
35 # define _PUBLIC_
36 #endif
38 #ifndef _DEPRECATED_
39 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
40 #define _DEPRECATED_ __attribute__ ((deprecated))
41 #else
42 #define _DEPRECATED_
43 #endif
44 #endif
46 #ifndef _WARN_UNUSED_RESULT_
47 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
48 #define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
49 #else
50 #define _WARN_UNUSED_RESULT_
51 #endif
52 #endif
54 #ifndef _NORETURN_
55 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
56 #define _NORETURN_ __attribute__ ((noreturn))
57 #else
58 #define _NORETURN_
59 #endif
60 #endif
62 #ifndef _PURE_
63 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
64 #define _PURE_ __attribute__((pure))
65 #else
66 #define _PURE_
67 #endif
68 #endif
70 #ifndef NONNULL
71 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
72 #define NONNULL(param) param __attribute__((nonnull))
73 #else
74 #define NONNULL(param) param
75 #endif
76 #endif
78 #ifndef PRINTF_ATTRIBUTE
79 #if __GNUC__ >= 3
80 /** Use gcc attribute to check printf fns. a1 is the 1-based index of
81 * the parameter containing the format, and a2 the index of the first
82 * argument. Note that some gcc 2.x versions don't handle this
83 * properly **/
84 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
85 #else
86 #define PRINTF_ATTRIBUTE(a1, a2)
87 #endif
88 #endif
90 #endif /* __UTIL_ATTR_H__ */