X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/d230f8b6870c4f5c3c3156ce78751b86c6b463fb..a15e52bb2722f9c9719cd9909d70c03a10e170c4:/netdissect-stdinc.h diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h index da1d8dcd..c7c53db4 100644 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -85,6 +85,11 @@ typedef unsigned long long uint64_t; typedef long long int64_t; #endif + + /* + * We have _strtoi64(). Use that for strtoint64_t(). + */ + #define strtoint64_t _strtoi64 #endif /* @@ -166,14 +171,35 @@ #ifdef _MSC_VER /* * Compiler is MSVC. - * + */ + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have strtoll(). Use that for strtoint64_t(). + */ + #define strtoint64_t strtoll + #else + /* + * Earlier VS; we don't have strtoll(), but we do have + * _strtoi64(). Use that for strtoint64_t(). + */ + #define strtoint64_t _strtoi64 + #endif + + /* * Microsoft's documentation doesn't speak of LL as a valid * suffix for 64-bit integers, so we'll just use i64. */ #define INT64_T_CONSTANT(constant) (constant##i64) #else /* - * Non-Microsoft compiler; assume LL works. + * Non-Microsoft compiler. + * + * XXX - should we use strtoll or should we use _strtoi64()? + */ + #define strtoint64_t strtoll + + /* + * Assume LL works. */ #define INT64_T_CONSTANT(constant) (constant##LL) #endif @@ -194,7 +220,7 @@ #define inline __inline #endif -#ifdef AF_INET6 +#if defined(AF_INET6) && !defined(HAVE_OS_IPV6_SUPPORT) #define HAVE_OS_IPV6_SUPPORT #endif @@ -235,6 +261,11 @@ typedef char* caddr_t; #include +/* + * Assume all UN*Xes have strtoll(), and use it for strtoint64_t(). + */ +#define strtoint64_t strtoll + /* * Assume LL works. */ @@ -304,8 +335,8 @@ typedef char* caddr_t; * an 80386, so, for example, it avoids the bswap instruction added in * the 80486. * - * (We don't use them on OS X; Apple provides their own, which *doesn't* - * avoid the bswap instruction, as OS X only supports machines that + * (We don't use them on macOS; Apple provides their own, which *doesn't* + * avoid the bswap instruction, as macOS only supports machines that * have it.) */ #if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl) @@ -390,7 +421,20 @@ struct in6_addr { #define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y) #define DIAG_DO_PRAGMA(x) _Pragma (#x) -#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 +/* + * The current clang compilers also define __GNUC__ and __GNUC_MINOR__ + * thus we need to test the clang case before the GCC one + */ +#if defined(__clang__) +# if (__clang_major__ * 100) + __clang_minor__ >= 208 +# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x) +# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) +# define DIAG_ON(x) DIAG_PRAGMA(pop) +# else +# define DIAG_OFF(x) +# define DIAG_ON(x) +# endif +#elif defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 # define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x) # if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 # define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) @@ -399,15 +443,20 @@ struct in6_addr { # define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) # define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x)) # endif -#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208) -# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x) -# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) -# define DIAG_ON(x) DIAG_PRAGMA(pop) #else # define DIAG_OFF(x) # define DIAG_ON(x) #endif +/* Use for clang specific warnings */ +#ifdef __clang__ +# define DIAG_OFF_CLANG(x) DIAG_OFF(x) +# define DIAG_ON_CLANG(x) DIAG_ON(x) +#else +# define DIAG_OFF_CLANG(x) +# define DIAG_ON_CLANG(x) +#endif + /* * For dealing with APIs which are only deprecated in OSX (like the OpenSSL API) */ @@ -428,13 +477,6 @@ struct in6_addr { */ #include "funcattrs.h" -#ifndef min -#define min(a,b) ((a)>(b)?(b):(a)) -#endif -#ifndef max -#define max(a,b) ((b)>(a)?(b):(a)) -#endif - #ifdef __ATTRIBUTE___FALLTHROUGH_OK # define ND_FALL_THROUGH __attribute__ ((fallthrough)) #else