2021-07-24 16:51:02 +08:00
|
|
|
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the Computer Systems
|
|
|
|
* Engineering Group at Lawrence Berkeley Laboratory.
|
|
|
|
* 4. Neither the name of the University nor of the Laboratory may be used
|
|
|
|
* to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _diag_control_h
|
|
|
|
#define _diag_control_h
|
|
|
|
|
|
|
|
#include "compiler-tests.h"
|
|
|
|
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
/*
|
|
|
|
* Clang and GCC both support this way of putting pragmas into #defines.
|
|
|
|
* We don't use it unless we have a compiler that supports it; the
|
|
|
|
* warning-suppressing pragmas differ between Clang and GCC, so we test
|
|
|
|
* for both of those separately.
|
|
|
|
*/
|
|
|
|
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
|
|
|
|
#endif
|
|
|
|
|
Address some issues with XL C on Linux/POWER9.
XL C 16.1.1 Community Edition for Linux generated three warnings for
every file:
In file included from ./tcpdump.c:155:
./netdissect.h:254:8: warning: 1540-2990 The attribute
"__attribute__((format(printf, 2, 3)))" is not supported. The
attribute is ignored.
PRINTFLIKE_FUNCPTR(2, 3);
^
./netdissect.h:259:10: warning: 1540-2990 The attribute
" __attribute__((format(printf, 3, 4)))" is not supported.
The attribute is ignored.
PRINTFLIKE_FUNCPTR(3, 4);
^
./netdissect.h:263:9: warning: 1540-2990 The attribute
" __attribute__((format(printf, 2, 3)))" is not supported. The
attribute is ignored.
PRINTFLIKE_FUNCPTR(2, 3);
^
As it turns out, this is a bug in the compiler. In compiler-tests.h
update ND_IS_AT_LEAST_XL_C_VERSION() to tell newer XL C versions. In
funcattrs.h exempt XL C 16.1 from PRINTFLIKE_FUNCPTR().
In the course of preparing these changes notice that XL C uses the Clang
block in diag-control.h (XL C mimics both Clang and GCC to some extent),
although the behaviour is different between the two compilers. Add a new
block for XL C there.
In build_common.sh add more comments to explain XL C quirks and detect
XL C for Linux too so it receives the right CFLAGS. Update CHANGES to
mention this and earlier improvements.
2021-07-27 21:06:28 +08:00
|
|
|
/*
|
|
|
|
* XL C 12.1 and 13.1 for AIX require no attention in this department.
|
|
|
|
* XL C 16.1 defines both __GNUC__ and __clang__, so has to be tested first.
|
|
|
|
*/
|
|
|
|
#if ND_IS_AT_LEAST_XL_C_VERSION(16,1)
|
|
|
|
/*
|
|
|
|
* See respective Clang note below.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_ASSIGN_ENUM \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wassign-enum")
|
|
|
|
#define DIAG_ON_ASSIGN_ENUM \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
2021-07-24 16:51:02 +08:00
|
|
|
/*
|
|
|
|
* The current clang compilers also define __GNUC__ and __GNUC_MINOR__
|
|
|
|
* thus we need to test the clang case before the GCC one
|
|
|
|
*/
|
Address some issues with XL C on Linux/POWER9.
XL C 16.1.1 Community Edition for Linux generated three warnings for
every file:
In file included from ./tcpdump.c:155:
./netdissect.h:254:8: warning: 1540-2990 The attribute
"__attribute__((format(printf, 2, 3)))" is not supported. The
attribute is ignored.
PRINTFLIKE_FUNCPTR(2, 3);
^
./netdissect.h:259:10: warning: 1540-2990 The attribute
" __attribute__((format(printf, 3, 4)))" is not supported.
The attribute is ignored.
PRINTFLIKE_FUNCPTR(3, 4);
^
./netdissect.h:263:9: warning: 1540-2990 The attribute
" __attribute__((format(printf, 2, 3)))" is not supported. The
attribute is ignored.
PRINTFLIKE_FUNCPTR(2, 3);
^
As it turns out, this is a bug in the compiler. In compiler-tests.h
update ND_IS_AT_LEAST_XL_C_VERSION() to tell newer XL C versions. In
funcattrs.h exempt XL C 16.1 from PRINTFLIKE_FUNCPTR().
In the course of preparing these changes notice that XL C uses the Clang
block in diag-control.h (XL C mimics both Clang and GCC to some extent),
although the behaviour is different between the two compilers. Add a new
block for XL C there.
In build_common.sh add more comments to explain XL C quirks and detect
XL C for Linux too so it receives the right CFLAGS. Update CHANGES to
mention this and earlier improvements.
2021-07-27 21:06:28 +08:00
|
|
|
#elif ND_IS_AT_LEAST_CLANG_VERSION(2,8)
|
2021-07-24 16:51:02 +08:00
|
|
|
/*
|
|
|
|
* Clang complains if you OR together multiple enum values of a
|
|
|
|
* given enum type and them pass it as an argument of that enum
|
|
|
|
* type. Some libcap-ng routines use enums to define bit flags;
|
|
|
|
* we want to squelch the warnings that produces.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_ASSIGN_ENUM \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wassign-enum")
|
|
|
|
#define DIAG_ON_ASSIGN_ENUM \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It also legitimately complains about some code in the BSD
|
|
|
|
* getopt_long() - that code explicitly and deliberately
|
|
|
|
* violates the contract by permuting the argument vector
|
|
|
|
* (declared as char const *argv[], meaning "I won't change
|
|
|
|
* the vector by changing any of its elements), as do the
|
|
|
|
* GNU and Solaris getopt_long(). This is documented in the
|
|
|
|
* man pages for all versions; it can be suppressed by setting
|
|
|
|
* the environment variable POSIXLY_CORRECT or by putting a "+"
|
|
|
|
* at the beginning of the option string.
|
|
|
|
*
|
|
|
|
* We suppress the warning.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_CAST_QUAL \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wcast-qual")
|
|
|
|
#define DIAG_ON_CAST_QUAL \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Suppress deprecation warnings.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
|
|
|
|
#define DIAG_ON_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
2021-08-05 21:18:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clang supports the generic C11 extension even if run with the -std=gnu99
|
|
|
|
* flag, which leads FreeBSD <sys/cdefs.h> to use the extension, which
|
|
|
|
* results in Clang emitting a -Wc11-extensions warning. The warning is not
|
|
|
|
* documented in the user manual, but it happens with Clang 10.0.1 on
|
|
|
|
* FreeBSD 12.2, so let's use that as a reference.
|
|
|
|
*/
|
|
|
|
#if ND_IS_AT_LEAST_CLANG_VERSION(10,0)
|
|
|
|
#define DIAG_OFF_C11_EXTENSIONS \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wc11-extensions")
|
|
|
|
#define DIAG_ON_C11_EXTENSIONS \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
|
|
|
#endif
|
2024-02-28 02:33:24 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When Clang correctly detects an old-style function prototype after
|
|
|
|
* preprocessing, the warning can be irrelevant to this source tree because
|
|
|
|
* the prototype comes from a system header macro.
|
|
|
|
*/
|
|
|
|
#if ND_IS_AT_LEAST_CLANG_VERSION(5,0)
|
|
|
|
#define DIAG_OFF_STRICT_PROTOTYPES \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wstrict-prototypes")
|
|
|
|
#define DIAG_ON_STRICT_PROTOTYPES \
|
|
|
|
DIAG_DO_PRAGMA(clang diagnostic pop)
|
|
|
|
#endif
|
2021-07-24 16:51:02 +08:00
|
|
|
#elif ND_IS_AT_LEAST_GNUC_VERSION(4,2)
|
|
|
|
/* GCC apparently doesn't complain about ORing enums together. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It does, however, complain about casting away constness in
|
|
|
|
* missing/getopt_long.c.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_CAST_QUAL \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wcast-qual")
|
|
|
|
#define DIAG_ON_CAST_QUAL \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic pop)
|
|
|
|
|
2023-12-01 17:05:18 +08:00
|
|
|
#if ND_IS_AT_LEAST_GNUC_VERSION(4,5)
|
|
|
|
/*
|
|
|
|
* GCC warns about unused return values if a function is marked as
|
|
|
|
* "warn about ignoring this function's return value".
|
|
|
|
*
|
|
|
|
* Clang appears to let you ignore a result without a warning by
|
|
|
|
* casting the function result to void, so we don't appear to
|
|
|
|
* need this for Clang.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_WARN_UNUSED_RESULT \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wunused-result")
|
|
|
|
#define DIAG_ON_WARN_UNUSED_RESULT \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic pop)
|
|
|
|
#endif
|
|
|
|
|
2021-07-24 16:51:02 +08:00
|
|
|
/*
|
|
|
|
* Suppress deprecation warnings.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic push) \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
|
|
|
|
#define DIAG_ON_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(GCC diagnostic pop)
|
2021-08-05 21:18:55 +08:00
|
|
|
/*
|
|
|
|
* GCC supports -Wc99-c11-compat since version 5.1.0, but the warning does
|
|
|
|
* not trigger for now, so let's just leave it be.
|
2024-02-28 02:33:24 +08:00
|
|
|
*
|
|
|
|
* GCC does not currently generate any -Wstrict-prototypes warnings that
|
|
|
|
* would need silencing as is done for Clang above.
|
2021-08-05 21:18:55 +08:00
|
|
|
*/
|
Squelch E_DEPRECATED_ATT about MD5 from Sun C.
The diagnostic macro pair is already in place, but it is not defined for
Sun C, fix that.
OpenSSL 1.0.2za 24 Aug 2021
cc: Studio 12.6 Sun C 5.15 SunOS_i386 2017/05/30
"./print-tcp.c", line 922: warning: "MD5_Init" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 124
"./print-tcp.c", line 927: warning: "MD5_Update" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 125
"./print-tcp.c", line 928: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 929: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 930: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 933: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 936: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 937: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 939: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 941: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 942: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 943: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 945: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 957: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 963: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 967: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 968: warning: "MD5_Final" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 126
"./signature.c", line 65: warning: "MD5_Init" is deprecated...
"./signature.c", line 66: warning: "MD5_Update" is deprecated...
"./signature.c", line 67: warning: "MD5_Final" is deprecated...
"./signature.c", line 99: warning: "MD5_Init" is deprecated...
"./signature.c", line 100: warning: "MD5_Update" is deprecated...
"./signature.c", line 101: warning: "MD5_Update" is deprecated...
"./signature.c", line 102: warning: "MD5_Final" is deprecated...
"./signature.c", line 107: warning: "MD5_Init" is deprecated...
"./signature.c", line 108: warning: "MD5_Update" is deprecated...
"./signature.c", line 109: warning: "MD5_Update" is deprecated...
"./signature.c", line 110: warning: "MD5_Final" is deprecated...
2024-03-15 06:07:40 +08:00
|
|
|
#elif ND_IS_AT_LEAST_SUNC_VERSION(5,5)
|
|
|
|
/*
|
2024-04-09 21:15:35 +08:00
|
|
|
* error_messages() is a valid pragma.
|
Squelch E_DEPRECATED_ATT about MD5 from Sun C.
The diagnostic macro pair is already in place, but it is not defined for
Sun C, fix that.
OpenSSL 1.0.2za 24 Aug 2021
cc: Studio 12.6 Sun C 5.15 SunOS_i386 2017/05/30
"./print-tcp.c", line 922: warning: "MD5_Init" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 124
"./print-tcp.c", line 927: warning: "MD5_Update" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 125
"./print-tcp.c", line 928: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 929: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 930: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 933: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 936: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 937: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 939: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 941: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 942: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 943: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 945: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 957: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 963: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 967: warning: "MD5_Update" is deprecated...
"./print-tcp.c", line 968: warning: "MD5_Final" is deprecated,
declared in : "/usr/include/openssl/md5.h", line 126
"./signature.c", line 65: warning: "MD5_Init" is deprecated...
"./signature.c", line 66: warning: "MD5_Update" is deprecated...
"./signature.c", line 67: warning: "MD5_Final" is deprecated...
"./signature.c", line 99: warning: "MD5_Init" is deprecated...
"./signature.c", line 100: warning: "MD5_Update" is deprecated...
"./signature.c", line 101: warning: "MD5_Update" is deprecated...
"./signature.c", line 102: warning: "MD5_Final" is deprecated...
"./signature.c", line 107: warning: "MD5_Init" is deprecated...
"./signature.c", line 108: warning: "MD5_Update" is deprecated...
"./signature.c", line 109: warning: "MD5_Update" is deprecated...
"./signature.c", line 110: warning: "MD5_Final" is deprecated...
2024-03-15 06:07:40 +08:00
|
|
|
*/
|
2024-04-09 21:15:35 +08:00
|
|
|
#if ND_IS_AT_LEAST_SUNC_VERSION(5,13)
|
|
|
|
/*
|
|
|
|
* E_DEPRECATED_ATT is a valid warning tag.
|
|
|
|
*/
|
|
|
|
#define DIAG_OFF_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(error_messages(off,E_DEPRECATED_ATT))
|
|
|
|
#define DIAG_ON_DEPRECATION \
|
|
|
|
DIAG_DO_PRAGMA(error_messages(default,E_DEPRECATED_ATT))
|
|
|
|
#endif
|
2021-08-05 21:18:55 +08:00
|
|
|
#endif
|
|
|
|
|
2021-08-15 17:54:50 +08:00
|
|
|
/*
|
|
|
|
* GCC needs this on AIX for longjmp().
|
|
|
|
*/
|
|
|
|
#if ND_IS_AT_LEAST_GNUC_VERSION(5,1)
|
|
|
|
/*
|
|
|
|
* Beware that the effect of this builtin is more than just squelching the
|
|
|
|
* warning! GCC trusts it enough for the process to segfault if the control
|
|
|
|
* flow reaches the builtin (an infinite empty loop in the same context would
|
|
|
|
* squelch the warning and ruin the process too, albeit in a different way).
|
|
|
|
* So please remember to use this very carefully.
|
|
|
|
*/
|
|
|
|
#define ND_UNREACHABLE __builtin_unreachable();
|
2023-02-19 18:29:41 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DIAG_OFF_ASSIGN_ENUM
|
|
|
|
#define DIAG_OFF_ASSIGN_ENUM
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_ASSIGN_ENUM
|
|
|
|
#define DIAG_ON_ASSIGN_ENUM
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_OFF_CAST_QUAL
|
|
|
|
#define DIAG_OFF_CAST_QUAL
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_CAST_QUAL
|
|
|
|
#define DIAG_ON_CAST_QUAL
|
|
|
|
#endif
|
2023-12-01 17:05:18 +08:00
|
|
|
#ifndef DIAG_OFF_WARN_UNUSED_RESULT
|
|
|
|
#define DIAG_OFF_WARN_UNUSED_RESULT
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_WARN_UNUSED_RESULT
|
|
|
|
#define DIAG_ON_WARN_UNUSED_RESULT
|
|
|
|
#endif
|
2023-02-19 18:29:41 +08:00
|
|
|
#ifndef DIAG_OFF_DEPRECATION
|
|
|
|
#define DIAG_OFF_DEPRECATION
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_DEPRECATION
|
|
|
|
#define DIAG_ON_DEPRECATION
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_OFF_C11_EXTENSIONS
|
|
|
|
#define DIAG_OFF_C11_EXTENSIONS
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_C11_EXTENSIONS
|
|
|
|
#define DIAG_ON_C11_EXTENSIONS
|
|
|
|
#endif
|
2024-02-28 02:33:24 +08:00
|
|
|
#ifndef DIAG_OFF_STRICT_PROTOTYPES
|
|
|
|
#define DIAG_OFF_STRICT_PROTOTYPES
|
|
|
|
#endif
|
|
|
|
#ifndef DIAG_ON_STRICT_PROTOTYPES
|
|
|
|
#define DIAG_ON_STRICT_PROTOTYPES
|
|
|
|
#endif
|
2023-02-19 18:29:41 +08:00
|
|
|
#ifndef ND_UNREACHABLE
|
|
|
|
#define ND_UNREACHABLE
|
2021-08-15 17:54:50 +08:00
|
|
|
#endif
|
|
|
|
|
2021-07-24 16:51:02 +08:00
|
|
|
#endif /* _diag_control_h */
|