forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct stdc++ language and size issues for MSVC (envoyproxy#8572)
This patch makes consistent the type for ssize_t as used on Windows. We will favor describing it as a ptrdiff_t, which is standard C. Patches to tclap and nghttp2 are needed for this exercise. Linux is a 64ILP architecture, so there's no difference between int and [s]size_t and pointer widths. Windows is a 64P architecture, where only long long maps to the width of the size_t and C99 standard ptrdiff_t types. This leads to a number of places where the Envoy API has presented an explicit int or int32_t which is smaller than the ptrdiff_t on Windows. In some places we must cast to or from the API defined width. Several other misassumptions on the width of int are also addressed. Windows does not support alternately-named VA_ARGS which is not a standard C++ language feature in our baseline c++ 17 expectation. Other minor adjustments reflect other quirks of the MSVC compilier (some more correct and some simply buggy behavior). Windows MSVC needs various guards on unrecognized #pragmas, and will not support any preprocessor operations within the arguments to a macro; this is not stdc or stdc++. This patch largely ignores changes which are required for windows, and do not impact the linux/os-x compilation path. This patch is also missing the IoHandle abstraction of 'fd' arguments, storage and return codes, win32 error handling and win32 specific #include's handling. Risk Level: Moderate Testing: Passed locally on Windows (with additional patches) and Linux Signed-off-by: William A Rowe Jr <[email protected]> Signed-off-by: Yechiel Kalmenson <[email protected]>
- Loading branch information
1 parent
9dd7af9
commit 85e2038
Showing
99 changed files
with
270 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/include/tclap/StandardTraits.h b/include/tclap/StandardTraits.h | ||
index 46d7f6f..117057b 100644 | ||
--- a/include/tclap/StandardTraits.h | ||
+++ b/include/tclap/StandardTraits.h | ||
@@ -123,8 +123,9 @@ struct ArgTraits<unsigned char> { | ||
typedef ValueLike ValueCategory; | ||
}; | ||
|
||
-// Microsoft implements size_t awkwardly. | ||
-#if defined(_MSC_VER) && defined(_M_X64) | ||
+// Microsoft implements size_t awkwardly. | ||
+// Studio 2005 introduces unsigned long long, which conflicts with the size_t template | ||
+#if defined(_MSC_VER) && (_MSC_VER < 1400) && defined(_M_X64) | ||
/** | ||
* size_ts have value-like semantics. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,64 @@ | ||
#pragma once | ||
|
||
// NOLINT(namespace-envoy) | ||
|
||
// This common "platform.h" header exists to simplify the most common references | ||
// to non-ANSI C/C++ headers, required on Windows, Posix, Linux, BSD etc, | ||
// and to provide substitute definitions when absolutely required. | ||
// | ||
// The goal is to eventually not require this file of envoy header declarations, | ||
// but limit the use of these architecture-specific types and declarations | ||
// to the corresponding .cc implementation files. | ||
|
||
#ifdef _MSC_VER | ||
|
||
#include <windows.h> | ||
#include <winsock2.h> | ||
|
||
// These must follow afterwards | ||
#include <mswsock.h> | ||
#include <ws2tcpip.h> | ||
|
||
// <windows.h> defines some frequently used symbols, so we need to undef these interfering symbols. | ||
#undef DELETE | ||
#undef ERROR | ||
#undef GetMessage | ||
#undef interface | ||
#undef TRUE | ||
|
||
#include <io.h> | ||
#include <stdint.h> | ||
|
||
#define PACKED_STRUCT(definition, ...) \ | ||
__pragma(pack(push, 1)) definition, ##__VA_ARGS__; \ | ||
__pragma(pack(pop)) | ||
|
||
#ifdef _M_X64 | ||
using ssize_t = int64_t; | ||
#else | ||
#error Envoy is not supported on 32-bit Windows | ||
using ssize_t = ptrdiff_t; | ||
|
||
typedef unsigned int sa_family_t; | ||
|
||
#else // POSIX | ||
|
||
#include <arpa/inet.h> | ||
#include <ifaddrs.h> | ||
#include <netdb.h> | ||
#include <netinet/in.h> | ||
#include <netinet/tcp.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/mman.h> // for mode_t | ||
#include <sys/socket.h> | ||
#include <sys/uio.h> // for iovec | ||
#include <sys/un.h> | ||
#include <unistd.h> | ||
|
||
#if defined(__linux__) | ||
#include <linux/netfilter_ipv4.h> | ||
#endif | ||
|
||
#else | ||
#define PACKED_STRUCT(definition, ...) definition, ##__VA_ARGS__ __attribute__((packed)) | ||
|
||
#ifndef IP6T_SO_ORIGINAL_DST | ||
// From linux/netfilter_ipv6/ip6_tables.h | ||
#define IP6T_SO_ORIGINAL_DST 80 | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#include "common/grpc/common.h" | ||
|
||
#include <arpa/inet.h> | ||
|
||
#include <atomic> | ||
#include <cstdint> | ||
#include <cstring> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.