]>
The Tcpdump Group git mirrors - tcpslice/blob - diag-control.h
2 * Copyright (c) 2021 The Tcpdump Group
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
18 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
28 #ifndef tcpslice_diag_control_h
29 #define tcpslice_diag_control_h
31 #include "compiler-tests.h"
32 #define DIAG_DO_PRAGMA(x) _Pragma (#x)
35 * XL C has to be tested first because starting with version 16.1 it defines
36 * both __GNUC__ and __clang__.
38 #if TCPSLICE_IS_AT_LEAST_XL_C_VERSION(1,0)
40 * GCC diagnostic pragmas became available in XL C version 16.1.0, for Linux
41 * only. XL C for Linux always defines __linux__.
43 #if TCPSLICE_IS_AT_LEAST_XL_C_VERSION(16,1) && defined(__linux__)
44 #define DIAG_OFF_PEDANTIC \
45 DIAG_DO_PRAGMA(GCC diagnostic push) \
46 DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic")
47 #define DIAG_ON_PEDANTIC \
48 DIAG_DO_PRAGMA(GCC diagnostic pop)
51 * Clang defines __GNUC__ and __GNUC_MINOR__, so has to be tested before GCC.
53 #elif TCPSLICE_IS_AT_LEAST_CLANG_VERSION(2,8)
54 #define DIAG_OFF_PEDANTIC \
55 DIAG_DO_PRAGMA(clang diagnostic push) \
56 DIAG_DO_PRAGMA(clang diagnostic ignored "-Wpedantic")
57 #define DIAG_ON_PEDANTIC \
58 DIAG_DO_PRAGMA(clang diagnostic pop)
60 * GCC 4.6 has working ignored/push/pop.
62 #elif TCPSLICE_IS_AT_LEAST_GNUC_VERSION(4,6)
64 * -Wpedantic became available in GCC 4.8.0.
66 #if TCPSLICE_IS_AT_LEAST_GNUC_VERSION(4,8)
67 #define DIAG_OFF_PEDANTIC \
68 DIAG_DO_PRAGMA(GCC diagnostic push) \
69 DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic")
70 #define DIAG_ON_PEDANTIC \
71 DIAG_DO_PRAGMA(GCC diagnostic pop)
75 #ifndef DIAG_OFF_PEDANTIC
76 #define DIAG_OFF_PEDANTIC
78 #ifndef DIAG_ON_PEDANTIC
79 #define DIAG_ON_PEDANTIC
82 #endif /* tcpslice_diag_control_h */