From 4e0e794a356275237c7ecc9628b38c5e52ae5328 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Mon, 16 Sep 2019 08:56:21 -0700 Subject: [PATCH] Correct ssize_t on Windows There is no standard C type ssize_t. The modern C99 introduces ptrdiff_t which has an effectively equivilant (but subtly different) definition. This patch makes ssize_t the equivilant byte-width of size_t on Windows, using the stdint.h definition. The remaining issue is that every consumer on Windows must continue to define (either -Dssize_t=int64_t or -Dssize_t=ptrdiff_t) an override because ssize_t was resolved in the nghttp2-private config.h. These uses of ssize_t bleed out to the public API in nghttp2.h, leaving non-POSIX environments like Windows with an undefined ssize_t type. The cleanest solution in any later refactoring will be to switch all external declarations using ssize_t to use the C99-standard ptrdiff_t. This change requires a release notes notice as it causes an ABI change, only for those on a 64-bit win32 build environment. Signed-off-by: William A Rowe Jr wrowe@pivotal.io Signed-off-by: Yechiel Kalmenson ykalmenson@pivotal.io --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 363c041f..ae054b77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,11 @@ check_type_size("ssize_t" SIZEOF_SSIZE_T) if(SIZEOF_SSIZE_T STREQUAL "") # ssize_t is a signed type in POSIX storing at least -1. # Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools). - set(ssize_t int) + if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ssize_t int64_t) + else() + set(ssize_t int) + endif() endif() # AC_TYPE_UINT8_T # AC_TYPE_UINT16_T