X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fhave.h;h=6c9d6754369a55e43cb4eaeb4ec6b32c7f70a536;hb=0fe69908838248c28624beb540257892db6bdcbd;hp=a054c5636a0f30e3da78c2a26ea4e15b7fbe4968;hpb=d7f6737cfcae75e8c2f522c68aaedee0519a6131;p=tinc diff --git a/src/have.h b/src/have.h index a054c563..6c9d6754 100644 --- a/src/have.h +++ b/src/have.h @@ -1,7 +1,10 @@ +#ifndef TINC_HAVE_H +#define TINC_HAVE_H + /* have.h -- include headers which are known to exist Copyright (C) 1998-2005 Ivo Timmermans - 2003-2013 Guus Sliepen + 2003-2021 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,40 +21,91 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __TINC_HAVE_H__ -#define __TINC_HAVE_H__ - -#ifdef HAVE_MINGW -#ifdef WITH_WINDOWS2000 -#define WINVER Windows2000 -#else -#define WINVER WindowsXP -#endif +#ifdef HAVE_WINDOWS +#define WINVER 0x0600 +#define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_NONSTDC_NO_WARNINGS #endif #include #include #include +#include #include #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #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 -#ifdef HAVE_MINGW +#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_WINDOWS +#ifdef HAVE_W32API_H #include +#endif + #include #include #include -#endif -#ifdef HAVE_STDBOOL_H -#include +#ifdef _MSC_VER +#include +#include +#include #endif +#endif // HAVE_WINDOWS #ifdef HAVE_TERMIOS_H #include @@ -63,16 +117,20 @@ /* Include system specific headers */ +#ifdef HAVE_STDDEF_H +#include +#endif + #ifdef HAVE_SYSLOG_H #include #endif -#ifdef HAVE_SYS_TIME_H -#include +#ifdef HAVE_SYS_RANDOM_H +#include #endif -#ifdef HAVE_TIME_H -#include +#ifdef HAVE_SYS_TIME_H +#include #endif #ifdef HAVE_SYS_TYPES_H @@ -87,6 +145,10 @@ #include #endif +#ifdef HAVE_SYS_MMAN_H +#include +#endif + #ifdef HAVE_SYS_WAIT_H #include #endif @@ -109,6 +171,8 @@ #ifdef HAVE_DIRENT_H #include +#elif defined(_MSC_VER) +#include "dirent.h" #endif /* SunOS really wants sys/socket.h BEFORE net/if.h, @@ -216,10 +280,10 @@ #undef STATUS #endif -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #define SLASH "\\" #else #define SLASH "/" #endif -#endif /* __TINC_SYSTEM_H__ */ +#endif