diff --git a/CMakeLists.txt b/CMakeLists.txt index 4293aebf3f..0f544271bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,13 +349,13 @@ 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) + set(SSIZE_T_DEF "typedef int ssize_t;") endif() check_type_size("off_t" SIZEOF_OFF_T) if(SIZEOF_OFF_T STREQUAL "") # off_t is a signed type in POSIX no narrower than int. # Set it to "long int" to match the behavior of AC_TYPE_OFF_T (autotools). - set(off_t long int) + set(OFF_T_DEF "typedef long int off_t;") endif() check_type_size("int" SIZEOF_INT) diff --git a/clamav-config.h.cmake.in b/clamav-config.h.cmake.in index 8e3da0b91e..54f1620185 100644 --- a/clamav-config.h.cmake.in +++ b/clamav-config.h.cmake.in @@ -581,11 +581,22 @@ #define inline @INLINE_KEYWORD@ #endif -/* Define to `long int' if does not define. */ -#cmakedefine off_t @off_t@ - /* Define to `int' if does not define. */ -#cmakedefine ssize_t @ssize_t@ +#ifndef SSIZE_T_DEFINED + #if defined(_MSC_VER) + #include + typedef SSIZE_T ssize_t; + #else + @SSIZE_T_DEF@ + #endif + # define SSIZE_T_DEFINED +#endif + +/* Define to `long int' if does not define. */ +#ifndef OFF_T_DEFINED + @OFF_T_DEF@ + #define OFF_T_DEFINED +#endif /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is diff --git a/win32/clamav-config.h b/win32/clamav-config.h index 00a44f92ff..03f975f8e1 100644 --- a/win32/clamav-config.h +++ b/win32/clamav-config.h @@ -573,7 +573,8 @@ /* #undef off_t */ /* Define to `int' */ -typedef int ssize_t; +#include +typedef SSIZE_T ssize_t; /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is diff --git a/win32/compat/net.h b/win32/compat/net.h index d8fad78104..0b86fea76c 100644 --- a/win32/compat/net.h +++ b/win32/compat/net.h @@ -24,9 +24,15 @@ /* Don't include clamav-config.h, because that brings in platform.h and platform.h will make these functions recursive ;-). */ -#ifndef ssize_t +#ifndef SSIZE_T_DEFINED +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#else typedef int ssize_t; #endif +#define SSIZE_T_DEFINED +#endif #define F_GETFL 1 #define F_SETFL 2 diff --git a/win32/llvmbuild/include/llvm/System/DataTypes.h b/win32/llvmbuild/include/llvm/System/DataTypes.h index 17323cf911..26cdce3a75 100644 --- a/win32/llvmbuild/include/llvm/System/DataTypes.h +++ b/win32/llvmbuild/include/llvm/System/DataTypes.h @@ -109,7 +109,8 @@ typedef short int16_t; typedef unsigned short uint16_t; typedef signed char int8_t; typedef unsigned char uint8_t; -typedef signed int ssize_t; +#include +typedef SSIZE_T ssize_t; /* Certain compatibility updates to VC++ introduce the `cstdint' * header, which defines the INT*_C macros. On default installs they * are absent. */