Fixes for compilation under Windows (specifically MSVC). Also added MSVC supported "_inline", and fixed some WIN32 specific warnings.
(cherry picked from commit 92ea719804
)
This commit is contained in:
parent
7392697aec
commit
259bed7787
@ -255,6 +255,11 @@ Version 1.8.0
|
|||||||
Version 1.6.14
|
Version 1.6.14
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2011-03-18 Iain Denniston <iain.denniston(at)gmail.com>
|
||||||
|
|
||||||
|
Fixes for compilation under Windows (specifically MSVC). Also added
|
||||||
|
MSVC supported "_inline", and fixed some WIN32 specific warnings.
|
||||||
|
|
||||||
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
|
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
|
||||||
|
|
||||||
Several fixes to correctly use SOCKET (and related) types instead of
|
Several fixes to correctly use SOCKET (and related) types instead of
|
||||||
|
@ -922,7 +922,8 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(PTHREAD_MUTEX_RECURSIVE) && !defined(__DragonFly__)
|
#if !defined(PTHREAD_MUTEX_RECURSIVE) && !defined(__DragonFly__) && !defined(UPNP_USE_MSVCPP)
|
||||||
|
/* !defined(UPNP_USE_MSVCPP) should probably also have pthreads version check - but it's not clear if that is possible */
|
||||||
/* NK: Added for satisfying the gcc compiler */
|
/* NK: Added for satisfying the gcc compiler */
|
||||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||||
#endif
|
#endif
|
||||||
|
@ -292,8 +292,8 @@ static int SetPriority(
|
|||||||
/*! . */
|
/*! . */
|
||||||
ThreadPriority priority)
|
ThreadPriority priority)
|
||||||
{
|
{
|
||||||
int retVal = 0;
|
|
||||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
|
int retVal = 0;
|
||||||
int currentPolicy;
|
int currentPolicy;
|
||||||
int minPriority = 0;
|
int minPriority = 0;
|
||||||
int maxPriority = 0;
|
int maxPriority = 0;
|
||||||
@ -325,11 +325,12 @@ static int SetPriority(
|
|||||||
|
|
||||||
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
||||||
retVal = (sched_result == 0 || errno == EPERM) ? 0 : sched_result;
|
retVal = (sched_result == 0 || errno == EPERM) ? 0 : sched_result;
|
||||||
#else
|
|
||||||
retVal = 0;
|
|
||||||
#endif
|
|
||||||
exit_function:
|
exit_function:
|
||||||
return retVal;
|
return retVal;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
priority = priority;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifdef UPNP_USE_MSVCPP
|
#ifdef UPNP_USE_MSVCPP
|
||||||
/* define some things the M$ VC++ doesn't know */
|
/* define some things the M$ VC++ doesn't know */
|
||||||
#define UPNP_INLINE
|
#define UPNP_INLINE _inline
|
||||||
typedef __int64 int64_t;
|
typedef __int64 int64_t;
|
||||||
#define PRId64 "I64d"
|
#define PRId64 "I64d"
|
||||||
#define PRIzd "ld"
|
#define PRIzd "ld"
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <windef.h>
|
#ifndef UPNP_USE_MSVCPP
|
||||||
|
/* Removed: not required (and cause compilation issues) */
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
#include <windef.h>
|
||||||
|
#endif
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef UPNPINTTYPES_H
|
#ifndef UPNPINTTYPES_H
|
||||||
#define UPNPINTTYPES_H
|
#define UPNPINTTYPES_H
|
||||||
|
|
||||||
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
|
#if !defined(UPNP_USE_BCBPP)
|
||||||
|
|
||||||
/* Printf format for integers. */
|
/* Printf format for integers. */
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
|
#endif /* !defined(UPNP_USE_BCBPP) */
|
||||||
|
|
||||||
#endif /* UPNPINTTYPES_H */
|
#endif /* UPNPINTTYPES_H */
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
#ifndef UPNPSTDINT_H
|
#ifndef UPNPSTDINT_H
|
||||||
#define UPNPSTDINT_H
|
#define UPNPSTDINT_H
|
||||||
|
|
||||||
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
|
#if !defined(UPNP_USE_BCBPP)
|
||||||
|
|
||||||
/* Sized integer types. */
|
/* Sized integer types. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
|
#ifdef UPNP_USE_MSVCPP
|
||||||
|
/* no ssize_t defined for VC */
|
||||||
|
#ifdef _WIN64
|
||||||
|
typedef int64_t ssize_t;
|
||||||
|
#else
|
||||||
|
typedef int32_t ssize_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !defined(UPNP_USE_BCBPP) */
|
||||||
|
|
||||||
#endif /* UPNPSTDINT_H */
|
#endif /* UPNPSTDINT_H */
|
||||||
|
@ -51,6 +51,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifdef UPNP_USE_MSVCPP
|
||||||
|
#include <sys/types.h> /* needed for off_t */
|
||||||
|
#endif
|
||||||
#elif (defined(BSD) && BSD >= 199306)
|
#elif (defined(BSD) && BSD >= 199306)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#else
|
#else
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
/* Other systems have strncasecmp */
|
/* Other systems have strncasecmp */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UPNP_USE_MSVCPP
|
||||||
|
/* VC has strnlen which is already included but with (potentially) different linkage */
|
||||||
/* strnlen() is a GNU extension. */
|
/* strnlen() is a GNU extension. */
|
||||||
#if HAVE_STRNLEN
|
#if HAVE_STRNLEN
|
||||||
extern size_t strnlen(const char *s, size_t maxlen);
|
extern size_t strnlen(const char *s, size_t maxlen);
|
||||||
@ -38,6 +40,7 @@
|
|||||||
return p ? p - s : n;
|
return p ? p - s : n;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_STRNLEN */
|
#endif /* HAVE_STRNLEN */
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
/* strndup() is a GNU extension. */
|
/* strndup() is a GNU extension. */
|
||||||
#if HAVE_STRNDUP && !defined(WIN32)
|
#if HAVE_STRNDUP && !defined(WIN32)
|
||||||
|
@ -118,6 +118,7 @@ int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
|
|||||||
(Module == DOM && DEBUG_DOM) || (Module == HTTP && DEBUG_HTTP);
|
(Module == DOM && DEBUG_DOM) || (Module == HTTP && DEBUG_HTTP);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Module = Module; /* VC complains about this being unreferenced */
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpnpPrintf(Upnp_LogLevel DLevel,
|
void UpnpPrintf(Upnp_LogLevel DLevel,
|
||||||
|
@ -493,7 +493,8 @@ Cleanup_File:
|
|||||||
num_written = (size_t)nw;
|
num_written = (size_t)nw;
|
||||||
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
">>> (SENT) >>>\n"
|
">>> (SENT) >>>\n"
|
||||||
"%.*s\nbuf_length=%zd, num_written=%zd\n""------------\n",
|
"%.*s\nbuf_length=%" PRIzd ", num_written=%" PRIzd "\n"
|
||||||
|
"------------\n",
|
||||||
(int)buf_length, buf, buf_length, num_written);
|
(int)buf_length, buf, buf_length, num_written);
|
||||||
if (num_written != buf_length) {
|
if (num_written != buf_length) {
|
||||||
RetVal = 0;
|
RetVal = 0;
|
||||||
|
@ -112,7 +112,8 @@ void linecopylen(
|
|||||||
#define ERROR_BUFFER_LEN 256
|
#define ERROR_BUFFER_LEN 256
|
||||||
|
|
||||||
/* C specific */
|
/* C specific */
|
||||||
#ifndef __cplusplus
|
/* VC needs these in C++ mode too (do other compilers?) */
|
||||||
|
#if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#ifndef S_ISREG
|
#ifndef S_ISREG
|
||||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||||
@ -130,7 +131,7 @@ void linecopylen(
|
|||||||
#define max(a, b) (((a)>(b))? (a):(b))
|
#define max(a, b) (((a)>(b))? (a):(b))
|
||||||
#define min(a, b) (((a)<(b))? (a):(b))
|
#define min(a, b) (((a)<(b))? (a):(b))
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
#endif /* __cplusplus */
|
#endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
|
||||||
|
|
||||||
#endif /* UTIL_H */
|
#endif /* UTIL_H */
|
||||||
|
|
||||||
|
@ -52,7 +52,10 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
#ifndef UPNP_USE_MSVCPP
|
||||||
|
/* VC Winsocks2 includes these functions */
|
||||||
#include "inet_pton.h"
|
#include "inet_pton.h"
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <netdb.h> /* for struct addrinfo */
|
#include <netdb.h> /* for struct addrinfo */
|
||||||
#endif
|
#endif
|
||||||
|
@ -379,7 +379,7 @@ get_response_value( IN http_message_t * hmsg,
|
|||||||
char *node_str = NULL;
|
char *node_str = NULL;
|
||||||
const char *temp_str = NULL;
|
const char *temp_str = NULL;
|
||||||
DOMString error_node_str = NULL;
|
DOMString error_node_str = NULL;
|
||||||
int err_code = UPNP_E_BAD_RESPONSE; /* default error */ ;
|
int err_code = UPNP_E_BAD_RESPONSE; /* default error */
|
||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
const char *names[5];
|
const char *names[5];
|
||||||
const DOMString nodeValue;
|
const DOMString nodeValue;
|
||||||
|
@ -106,7 +106,7 @@ void get_random_info(unsigned char seed[16])
|
|||||||
GetComputerName( r.hostname, &r.l );
|
GetComputerName( r.hostname, &r.l );
|
||||||
/* MD5 it */
|
/* MD5 it */
|
||||||
MD5Init(&c);
|
MD5Init(&c);
|
||||||
MD5Update(&c, &r, sizeof r);
|
MD5Update(&c, (unsigned char *)(&r), sizeof r);
|
||||||
MD5Final(seed, &c);
|
MD5Final(seed, &c);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user