X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fhave.h;h=a155b04b41abe7a94f106bc8430b52fac6cb8914;hb=d93d4f9dbd09bc5e53a9b5eeb1cc94939fee32bc;hp=f19c599288cc9bc7b100cf1980bb80efa9169653;hpb=cfc9fee931c70554353ce6c4acc3407baac08745;p=tinc diff --git a/src/have.h b/src/have.h index f19c5992..a155b04b 100644 --- a/src/have.h +++ b/src/have.h @@ -21,7 +21,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #define WINVER 0x0600 #define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN @@ -29,6 +29,8 @@ #define _CRT_NONSTDC_NO_WARNINGS #endif +#define __STDC_WANT_LIB_EXT1__ 1 + #include #include #include @@ -45,13 +47,59 @@ #include #include +#ifdef HAVE_STATIC_ASSERT +#define STATIC_ASSERT(expr, msg) _Static_assert((expr), msg) +#else +#define STATIC_ASSERT(check, msg) +#endif + +#ifdef HAVE_ATTR_PACKED +#define PACKED(...) __VA_ARGS__ __attribute__((__packed__)) +#else +#ifdef _MSC_VER +#define PACKED(...) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop)) +#else +#warning Your compiler does not support __packed__. Use at your own risk. +#endif +#endif + +#if defined(HAVE_ATTR_MALLOC_WITH_ARG) +#define ATTR_DEALLOCATOR(dealloc) __attribute__((__malloc__(dealloc))) +#else +#define ATTR_DEALLOCATOR(dealloc) +#endif + +#ifdef HAVE_ATTR_MALLOC +#define ATTR_MALLOC __attribute__((__malloc__)) +#else +#define ATTR_MALLOC +#endif + +#ifdef HAVE_ATTR_NONNULL +#define ATTR_NONNULL __attribute__((__nonnull__)) +#else +#define ATTR_NONNULL +#endif + +#ifdef HAVE_ATTR_WARN_UNUSED_RESULT +#define ATTR_WARN_UNUSED __attribute__((__warn_unused_result__)) +#else +#define ATTR_WARN_UNUSED +#endif + +#ifdef HAVE_ATTR_FORMAT +#define ATTR_FORMAT(func, str, nonstr) __attribute__((format(func, str, nonstr))) +#else +#define ATTR_FORMAT(func, str, nonstr) +#endif + #ifdef HAVE_ALLOCA_H #include #elif defined(HAVE_NETBSD) #define alloca(size) __builtin_alloca(size) #endif -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #ifdef HAVE_W32API_H #include #endif @@ -65,7 +113,7 @@ #include #include #endif -#endif // HAVE_MINGW +#endif // HAVE_WINDOWS #ifdef HAVE_TERMIOS_H #include @@ -85,11 +133,14 @@ #include #endif +#ifdef HAVE_SYS_RANDOM_H +#include +#endif + #ifdef HAVE_SYS_TIME_H #include #endif - #ifdef HAVE_SYS_TYPES_H #include #endif @@ -237,7 +288,7 @@ #undef STATUS #endif -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #define SLASH "\\" #else #define SLASH "/"