X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fhave.h;h=1d1bedfcccad6796916d98141c765ffdf6301634;hb=244002d83466a85ac4fbb5327e26a60fe44168fd;hp=faa4c9e0f38be54d7d9448b08646577ccba5e046;hpb=d10834e92015f1e0e5bf74e03b161b3a5dc363fb;p=tinc diff --git a/src/have.h b/src/have.h index faa4c9e0..1d1bedfc 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-2016 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,12 +21,12 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __TINC_HAVE_H__ -#define __TINC_HAVE_H__ - -#ifdef HAVE_MINGW -#define WINVER WindowsXP +#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 @@ -35,17 +38,50 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include -#ifdef HAVE_MINGW +#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_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 + +#ifdef _MSC_VER +#include +#include +#include #endif +#endif // HAVE_WINDOWS #ifdef HAVE_TERMIOS_H #include @@ -57,6 +93,10 @@ /* Include system specific headers */ +#ifdef HAVE_STDDEF_H +#include +#endif + #ifdef HAVE_SYSLOG_H #include #endif @@ -78,6 +118,10 @@ #include #endif +#ifdef HAVE_SYS_MMAN_H +#include +#endif + #ifdef HAVE_SYS_WAIT_H #include #endif @@ -100,6 +144,8 @@ #ifdef HAVE_DIRENT_H #include +#elif defined(_MSC_VER) +#include "dirent.h" #endif /* SunOS really wants sys/socket.h BEFORE net/if.h, @@ -207,10 +253,10 @@ #undef STATUS #endif -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #define SLASH "\\" #else #define SLASH "/" #endif -#endif /* __TINC_SYSTEM_H__ */ +#endif