diff options
author | Mark Nunberg <mnunberg@users.noreply.github.com> | 2019-08-09 07:37:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-09 07:37:28 -0400 |
commit | ac49287c3dc5abd92545024484194275ce7899fd (patch) | |
tree | 26f04129e515667c0605676dffa8514f91d9798e | |
parent | 3af99d5fd5c2352cd73e851686bb18de122897f1 (diff) | |
parent | bbbafc5324aa0986c486756f260853fc8e8faf93 (diff) |
Merge pull request #663 from mbitsnbites/mingw-support-2
Windows: MinGW fixes and Windows Travis builders
-rw-r--r-- | .travis.yml | 33 | ||||
-rw-r--r-- | async.c | 6 | ||||
-rw-r--r-- | hiredis.h | 4 | ||||
-rw-r--r-- | sds.h | 30 | ||||
-rw-r--r-- | sockcompat.h | 2 | ||||
-rw-r--r-- | win32.h | 10 |
6 files changed, 64 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml index 51171c0..4a29823 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,3 +56,36 @@ script: - cmake .. ${EXTRA_CMAKE_OPTS} - make VERBOSE=1 - ctest -V + +matrix: + include: + # Windows MinGW cross compile on Linux + - os: linux + dist: xenial + compiler: mingw + addons: + apt: + packages: + - ninja-build + - gcc-mingw-w64-x86-64 + - g++-mingw-w64-x86-64 + script: + - mkdir build && cd build + - CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_WITH_INSTALL_RPATH=on + - ninja -v + + # Windows MSVC 2017 + - os: windows + compiler: msvc + env: + - MATRIX_EVAL="CC=cl.exe && CXX=cl.exe" + before_install: + - eval "${MATRIX_EVAL}" + install: + - choco install ninja + script: + - mkdir build && cd build + - cmd.exe /C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 && + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release && + ninja -v' + - ctest -V @@ -32,11 +32,8 @@ #include "fmacros.h" #include <stdlib.h> #include <string.h> -#ifndef _WIN32 +#ifndef _MSC_VER #include <strings.h> -#else -#define strcasecmp stricmp -#define strncasecmp strnicmp #endif #include <assert.h> #include <ctype.h> @@ -46,6 +43,7 @@ #include "dict.c" #include "sds.h" #include "sslio.h" +#include "win32.h" #define _EL_ADD_READ(ctx) \ do { \ @@ -35,10 +35,10 @@ #define __HIREDIS_H #include "read.h" #include <stdarg.h> /* for va_list */ -#ifndef _WIN32 +#ifndef _MSC_VER #include <sys/time.h> /* for struct timeval */ #else -#include <winsock2.h> +struct timeval; /* forward declaration */ #endif #include <stdint.h> /* uintXX_t, etc */ #include "sds.h" /* for sds */ @@ -34,7 +34,7 @@ #define __SDS_H #define SDS_MAX_PREALLOC (1024*1024) -#ifdef _WIN32 +#ifdef _MSC_VER #define __attribute__(x) #endif @@ -135,20 +135,20 @@ static inline void sdssetlen(sds s, size_t newlen) { case SDS_TYPE_5: { unsigned char *fp = ((unsigned char*)s)-1; - *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); + *fp = (unsigned char)(SDS_TYPE_5 | (newlen << SDS_TYPE_BITS)); } break; case SDS_TYPE_8: - SDS_HDR(8,s)->len = newlen; + SDS_HDR(8,s)->len = (uint8_t)newlen; break; case SDS_TYPE_16: - SDS_HDR(16,s)->len = newlen; + SDS_HDR(16,s)->len = (uint16_t)newlen; break; case SDS_TYPE_32: - SDS_HDR(32,s)->len = newlen; + SDS_HDR(32,s)->len = (uint32_t)newlen; break; case SDS_TYPE_64: - SDS_HDR(64,s)->len = newlen; + SDS_HDR(64,s)->len = (uint64_t)newlen; break; } } @@ -159,21 +159,21 @@ static inline void sdsinclen(sds s, size_t inc) { case SDS_TYPE_5: { unsigned char *fp = ((unsigned char*)s)-1; - unsigned char newlen = SDS_TYPE_5_LEN(flags)+inc; + unsigned char newlen = SDS_TYPE_5_LEN(flags)+(unsigned char)inc; *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); } break; case SDS_TYPE_8: - SDS_HDR(8,s)->len += inc; + SDS_HDR(8,s)->len += (uint8_t)inc; break; case SDS_TYPE_16: - SDS_HDR(16,s)->len += inc; + SDS_HDR(16,s)->len += (uint16_t)inc; break; case SDS_TYPE_32: - SDS_HDR(32,s)->len += inc; + SDS_HDR(32,s)->len += (uint32_t)inc; break; case SDS_TYPE_64: - SDS_HDR(64,s)->len += inc; + SDS_HDR(64,s)->len += (uint64_t)inc; break; } } @@ -203,16 +203,16 @@ static inline void sdssetalloc(sds s, size_t newlen) { /* Nothing to do, this type has no total allocation info. */ break; case SDS_TYPE_8: - SDS_HDR(8,s)->alloc = newlen; + SDS_HDR(8,s)->alloc = (uint8_t)newlen; break; case SDS_TYPE_16: - SDS_HDR(16,s)->alloc = newlen; + SDS_HDR(16,s)->alloc = (uint16_t)newlen; break; case SDS_TYPE_32: - SDS_HDR(32,s)->alloc = newlen; + SDS_HDR(32,s)->alloc = (uint32_t)newlen; break; case SDS_TYPE_64: - SDS_HDR(64,s)->alloc = newlen; + SDS_HDR(64,s)->alloc = (uint64_t)newlen; break; } } diff --git a/sockcompat.h b/sockcompat.h index e0b2e5e..56006c1 100644 --- a/sockcompat.h +++ b/sockcompat.h @@ -50,7 +50,9 @@ #include <ws2tcpip.h> #include <stddef.h> +#ifdef _MSC_VER typedef signed long ssize_t; +#endif /* Emulate the parts of the BSD socket API that we need (override the winsock signatures). */ int win32_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); @@ -2,10 +2,20 @@ #define _WIN32_HELPER_INCLUDE #ifdef _MSC_VER +#include <winsock2.h> /* for struct timeval */ + #ifndef inline #define inline __inline #endif +#ifndef strcasecmp +#define strcasecmp stricmp +#endif + +#ifndef strncasecmp +#define strncasecmp strnicmp +#endif + #ifndef va_copy #define va_copy(d,s) ((d) = (s)) #endif |