MinGW fix: Use _MSC_VER instead of _WIN32 where appropriate
Use _MSC_VER (instead of _WIN32) for things that are specific for Visual Studio. Also remove #include <winsock2.h> from hiredis.h, as it leaks too many symbols and defines into the global namespace, which is undesirable for a public interface header. Anyone who uses the the affected parts of the hiredis API needs to include the appropriate headers anyway in order to declare struct timeval variables.
This commit is contained in:
parent
3af99d5fd5
commit
85fee25653
6
async.c
6
async.c
@ -32,11 +32,8 @@
|
|||||||
#include "fmacros.h"
|
#include "fmacros.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _WIN32
|
#ifndef _MSC_VER
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#else
|
|
||||||
#define strcasecmp stricmp
|
|
||||||
#define strncasecmp strnicmp
|
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -46,6 +43,7 @@
|
|||||||
#include "dict.c"
|
#include "dict.c"
|
||||||
#include "sds.h"
|
#include "sds.h"
|
||||||
#include "sslio.h"
|
#include "sslio.h"
|
||||||
|
#include "win32.h"
|
||||||
|
|
||||||
#define _EL_ADD_READ(ctx) \
|
#define _EL_ADD_READ(ctx) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
#define __HIREDIS_H
|
#define __HIREDIS_H
|
||||||
#include "read.h"
|
#include "read.h"
|
||||||
#include <stdarg.h> /* for va_list */
|
#include <stdarg.h> /* for va_list */
|
||||||
#ifndef _WIN32
|
#ifndef _MSC_VER
|
||||||
#include <sys/time.h> /* for struct timeval */
|
#include <sys/time.h> /* for struct timeval */
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
struct timeval; /* forward declaration */
|
||||||
#endif
|
#endif
|
||||||
#include <stdint.h> /* uintXX_t, etc */
|
#include <stdint.h> /* uintXX_t, etc */
|
||||||
#include "sds.h" /* for sds */
|
#include "sds.h" /* for sds */
|
||||||
|
2
sds.h
2
sds.h
@ -34,7 +34,7 @@
|
|||||||
#define __SDS_H
|
#define __SDS_H
|
||||||
|
|
||||||
#define SDS_MAX_PREALLOC (1024*1024)
|
#define SDS_MAX_PREALLOC (1024*1024)
|
||||||
#ifdef _WIN32
|
#ifdef _MSC_VER
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,7 +50,9 @@
|
|||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
typedef signed long ssize_t;
|
typedef signed long ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Emulate the parts of the BSD socket API that we need (override the winsock signatures). */
|
/* 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);
|
int win32_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
|
||||||
|
10
win32.h
10
win32.h
@ -2,10 +2,20 @@
|
|||||||
#define _WIN32_HELPER_INCLUDE
|
#define _WIN32_HELPER_INCLUDE
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#include <winsock2.h> /* for struct timeval */
|
||||||
|
|
||||||
#ifndef inline
|
#ifndef inline
|
||||||
#define inline __inline
|
#define inline __inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef strcasecmp
|
||||||
|
#define strcasecmp stricmp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef strncasecmp
|
||||||
|
#define strncasecmp strnicmp
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef va_copy
|
#ifndef va_copy
|
||||||
#define va_copy(d,s) ((d) = (s))
|
#define va_copy(d,s) ((d) = (s))
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user