]>
The Tcpdump Group git mirrors - libpcap/blob - pcap/compiler-tests.h
1 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
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
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
35 #ifndef lib_pcap_compiler_tests_h
36 #define lib_pcap_compiler_tests_h
40 * This was introduced by Clang:
42 * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
44 * in some version (which version?); it has been picked up by GCC 5.0.
46 #ifndef __has_attribute
48 * It's a macro, so you can check whether it's defined to check
49 * whether it's supported.
51 * If it's not, define it to always return 0, so that we move on to
52 * the fallback checks.
54 #define __has_attribute(x) 0
58 * Check whether this is GCC major.minor or a later release, or some
59 * compiler that claims to be "just like GCC" of that version or a
63 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 3))
64 #define PCAP_IS_AT_LEAST_GNUC_VERSION_2_3 1
66 #define PCAP_IS_AT_LEAST_GNUC_VERSION_2_3 0
69 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
70 #define PCAP_IS_AT_LEAST_GNUC_VERSION_2_5 1
72 #define PCAP_IS_AT_LEAST_GNUC_VERSION_2_5 0
75 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
76 #define PCAP_IS_AT_LEAST_GNUC_VERSION_3_1 1
78 #define PCAP_IS_AT_LEAST_GNUC_VERSION_3_1 0
81 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
82 #define PCAP_IS_AT_LEAST_GNUC_VERSION_3_4 1
84 #define PCAP_IS_AT_LEAST_GNUC_VERSION_3_4 0
87 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
88 #define PCAP_IS_AT_LEAST_GNUC_VERSION_4_5 1
90 #define PCAP_IS_AT_LEAST_GNUC_VERSION_4_5 0
94 * Check wehether this is Sun C/SunPro C/Oracle Studio major.minor
97 * The version number in __SUNPRO_C is encoded in hex BCD, with the
98 * uppermost hex digit being the major version number, the next
99 * one or two hex digits being the minor version number, and
100 * the last digit being the patch version.
102 * It represents the *compiler* version, not the product version;
105 * https://sourceforge.net/p/predef/wiki/Compilers/
107 * for a partial mapping, which we assume continues for later
108 * 12.x product releases.
110 #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
112 (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
113 (((major) << 8) | ((minor) << 4)))
115 #if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 5)
116 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_5 1
118 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_5 0
121 #if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 9)
122 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_9 1
124 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_9 0
127 #if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 13)
128 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_13 1
130 #define PCAP_IS_AT_LEAST_SUNC_VERSION_5_13 0
134 * Check wehether this is IBM XL C major.minor or a later release.
136 * The version number in __xlC__ has the major version in the
137 * upper 8 bits and the minor version in the lower 8 bits.
140 #if defined(__xlC__) && __xlC__ >= ((10 << 8) | 1)
141 #define PCAP_IS_AT_LEAST_XL_C_VERSION_10_1 1
143 #define PCAP_IS_AT_LEAST_XL_C_VERSION_10_1 0
146 #if defined(__xlC__) && __xlC__ >= ((12 << 8) | 0)
147 #define PCAP_IS_AT_LEAST_XL_C_VERSION_12_0 1
149 #define PCAP_IS_AT_LEAST_XL_C_VERSION_12_0 0
153 * Check wehether this is Sun C/SunPro C/Oracle Studio major.minor
154 * or a later release.
156 * The version number in __HP_aCC is encoded in zero-padded decimal BCD,
157 * with the "A." stripped off, the uppermost two decimal digits being
158 * the major version number, the next two decimal digits being the minor
159 * version number, and the last two decimal digits being the patch version.
160 * (Strip off the A., remove the . between the major and minor version
161 * number, and add two digits of patch.)
164 #if defined(__HP_aCC) && (__HP_aCC >= (6*10000 + 10*100))
165 #define PCAP_IS_AT_LEAST_HP_C_VERSION_6_10 1
167 #define PCAP_IS_AT_LEAST_HP_C_VERSION_6_10 0
170 #endif /* lib_pcap_funcattrs_h */