source: trunk/server/lib/util/attr.h@ 888

Last change on this file since 888 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.8 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5
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.
10
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.
15
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/>.
18*/
19
20#ifndef __UTIL_ATTR_H__
21#define __UTIL_ATTR_H__
22
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
31
32#ifndef _DEPRECATED_
33#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
34#define _DEPRECATED_ __attribute__ ((deprecated))
35#else
36#define _DEPRECATED_
37#endif
38#endif
39
40#ifndef _WARN_UNUSED_RESULT_
41#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
42#define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
43#else
44#define _WARN_UNUSED_RESULT_
45#endif
46#endif
47
48#ifndef _NORETURN_
49#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
50#define _NORETURN_ __attribute__ ((noreturn))
51#else
52#define _NORETURN_
53#endif
54#endif
55
56#ifndef _PURE_
57#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
58#define _PURE_ __attribute__((pure))
59#else
60#define _PURE_
61#endif
62#endif
63
64#ifndef NONNULL
65#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
66#define NONNULL(param) param __attribute__((nonnull))
67#else
68#define NONNULL(param) param
69#endif
70#endif
71
72#ifndef PRINTF_ATTRIBUTE
73#if __GNUC__ >= 3
74/** Use gcc attribute to check printf fns. a1 is the 1-based index of
75 * the parameter containing the format, and a2 the index of the first
76 * argument. Note that some gcc 2.x versions don't handle this
77 * properly **/
78#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
79#else
80#define PRINTF_ATTRIBUTE(a1, a2)
81#endif
82#endif
83
84#ifndef FORMAT_ATTRIBUTE
85#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
86/** Use gcc attribute to check printf fns. a1 is argument to format()
87 * in the above macro. This is needed to support Heimdal's printf
88 * decorations. Note that some gcc 2.x versions don't handle this
89 * properly, and as such I've used the same minimum from heimdal: GCC 3.1 **/
90#define FORMAT_ATTRIBUTE(a) __attribute__ ((format a))
91#else
92#define FORMAT_ATTRIBUTE(a)
93#endif
94#endif
95
96#endif /* __UTIL_ATTR_H__ */
Note: See TracBrowser for help on using the repository browser.