start shipping ctfconvert & ctfmerge in /usr/bin
[unleashed.git] / contrib / tcpdump / funcattrs.h
blob63d3f5656cf0900a8ec614cf3f27daedd586e620
1 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
2 /*
3 * Copyright (c) 1993, 1994, 1995, 1996, 1997
4 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the Computer Systems
17 * Engineering Group at Lawrence Berkeley Laboratory.
18 * 4. Neither the name of the University nor of the Laboratory may be used
19 * to endorse or promote products derived from this software without
20 * specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 #ifndef lib_funcattrs_h
36 #define lib_funcattrs_h
39 * Attributes to apply to functions and their arguments, using various
40 * compiler-specific extensions.
44 * This was introduced by Clang:
46 * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
48 * in some version (which version?); it has been picked up by GCC 5.0.
50 #ifndef __has_attribute
52 * It's a macro, so you can check whether it's defined to check
53 * whether it's supported.
55 * If it's not, define it to always return 0, so that we move on to
56 * the fallback checks.
58 #define __has_attribute(x) 0
59 #endif
62 * NORETURN, before a function declaration, means "this function
63 * never returns". (It must go before the function declaration, e.g.
64 * "extern NORETURN func(...)" rather than after the function
65 * declaration, as the MSVC version has to go before the declaration.)
67 #if __has_attribute(noreturn) \
68 || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
69 || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
70 || (defined(__xlC__) && __xlC__ >= 0x0A01) \
71 || (defined(__HP_aCC) && __HP_aCC >= 61000)
73 * Compiler with support for __attribute((noreturn)), or GCC 2.5 and
74 * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
75 * and later (do any earlier versions of XL C support this?), or
76 * HP aCC A.06.10 and later.
78 #define NORETURN __attribute((noreturn))
79 #elif defined(_MSC_VER)
81 * MSVC.
83 #define NORETURN __declspec(noreturn)
84 #else
85 #define NORETURN
86 #endif
89 * PRINTFLIKE(x,y), after a function declaration, means "this function
90 * does printf-style formatting, with the xth argument being the format
91 * string and the yth argument being the first argument for the format
92 * string".
94 #if __has_attribute(__format__) \
95 || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
96 || (defined(__xlC__) && __xlC__ >= 0x0A01) \
97 || (defined(__HP_aCC) && __HP_aCC >= 61000)
99 * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
100 * and later (do any earlier versions of XL C support this?),
101 * or HP aCC A.06.10 and later.
103 #define PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
104 #else
105 #define PRINTFLIKE(x,y)
106 #endif
109 * For flagging arguments as format strings in MSVC.
111 #if _MSC_VER >= 1400
112 #include <sal.h>
113 #if _MSC_VER > 1400
114 #define FORMAT_STRING(p) _Printf_format_string_ p
115 #else
116 #define FORMAT_STRING(p) __format_string p
117 #endif
118 #else
119 #define FORMAT_STRING(p) p
120 #endif
122 #endif /* lib_funcattrs_h */