diff --git a/ChangeLog b/ChangeLog index 71cf6fc..17a8392 100644 --- a/ChangeLog +++ b/ChangeLog @@ -255,6 +255,11 @@ Version 1.8.0 Version 1.6.14 ******************************************************************************* +2011-03-18 Iain Denniston + + Fixes for compilation under Windows (specifically MSVC). Also added + MSVC supported "_inline", and fixed some WIN32 specific warnings. + 2011-03-08 Iain Denniston Several fixes to correctly use SOCKET (and related) types instead of diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index d040067..69bcff9 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -922,7 +922,8 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { #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 */ EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind); #endif diff --git a/threadutil/src/ThreadPool.c b/threadutil/src/ThreadPool.c index a487e1f..a2bda45 100644 --- a/threadutil/src/ThreadPool.c +++ b/threadutil/src/ThreadPool.c @@ -292,8 +292,8 @@ static int SetPriority( /*! . */ ThreadPriority priority) { - int retVal = 0; #if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0 + int retVal = 0; int currentPolicy; int minPriority = 0; int maxPriority = 0; @@ -325,11 +325,12 @@ static int SetPriority( sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority); retVal = (sched_result == 0 || errno == EPERM) ? 0 : sched_result; -#else - retVal = 0; -#endif exit_function: return retVal; +#else + return 0; + priority = priority; +#endif } /*! diff --git a/upnp/inc/UpnpGlobal.h b/upnp/inc/UpnpGlobal.h index f1bb457..a2872f3 100644 --- a/upnp/inc/UpnpGlobal.h +++ b/upnp/inc/UpnpGlobal.h @@ -40,7 +40,7 @@ */ #ifdef UPNP_USE_MSVCPP /* define some things the M$ VC++ doesn't know */ - #define UPNP_INLINE + #define UPNP_INLINE _inline typedef __int64 int64_t; #define PRId64 "I64d" #define PRIzd "ld" diff --git a/upnp/inc/UpnpInet.h b/upnp/inc/UpnpInet.h index 021e986..6269c4a 100644 --- a/upnp/inc/UpnpInet.h +++ b/upnp/inc/UpnpInet.h @@ -15,8 +15,11 @@ #ifdef WIN32 #include - #include - #include + #ifndef UPNP_USE_MSVCPP + /* Removed: not required (and cause compilation issues) */ + #include + #include + #endif #include #include #include diff --git a/upnp/inc/UpnpIntTypes.h b/upnp/inc/UpnpIntTypes.h index 056ad97..4575960 100644 --- a/upnp/inc/UpnpIntTypes.h +++ b/upnp/inc/UpnpIntTypes.h @@ -1,11 +1,11 @@ #ifndef UPNPINTTYPES_H #define UPNPINTTYPES_H -#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) +#if !defined(UPNP_USE_BCBPP) /* Printf format for integers. */ #include -#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */ +#endif /* !defined(UPNP_USE_BCBPP) */ #endif /* UPNPINTTYPES_H */ diff --git a/upnp/inc/UpnpStdInt.h b/upnp/inc/UpnpStdInt.h index 1e3e31d..9256f57 100644 --- a/upnp/inc/UpnpStdInt.h +++ b/upnp/inc/UpnpStdInt.h @@ -1,11 +1,20 @@ #ifndef UPNPSTDINT_H #define UPNPSTDINT_H -#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) +#if !defined(UPNP_USE_BCBPP) /* Sized integer types. */ #include -#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 */ diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 4f57a30..5ddb003 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -51,6 +51,9 @@ */ #ifdef WIN32 #include + #ifdef UPNP_USE_MSVCPP + #include /* needed for off_t */ + #endif #elif (defined(BSD) && BSD >= 199306) #include #else diff --git a/upnp/src/api/UpnpString.c b/upnp/src/api/UpnpString.c index 25f3659..a5d43cb 100644 --- a/upnp/src/api/UpnpString.c +++ b/upnp/src/api/UpnpString.c @@ -28,16 +28,19 @@ /* Other systems have strncasecmp */ #endif -/* strnlen() is a GNU extension. */ -#if HAVE_STRNLEN - extern size_t strnlen(const char *s, size_t maxlen); -#else /* HAVE_STRNLEN */ - static size_t strnlen(const char *s, size_t n) - { - const char *p = (const char *)memchr(s, 0, n); - return p ? p - s : n; - } -#endif /* HAVE_STRNLEN */ +#ifndef UPNP_USE_MSVCPP + /* VC has strnlen which is already included but with (potentially) different linkage */ + /* strnlen() is a GNU extension. */ + #if HAVE_STRNLEN + extern size_t strnlen(const char *s, size_t maxlen); + #else /* HAVE_STRNLEN */ + static size_t strnlen(const char *s, size_t n) + { + const char *p = (const char *)memchr(s, 0, n); + return p ? p - s : n; + } + #endif /* HAVE_STRNLEN */ +#endif /* WIN32 */ /* strndup() is a GNU extension. */ #if HAVE_STRNDUP && !defined(WIN32) diff --git a/upnp/src/api/upnpdebug.c b/upnp/src/api/upnpdebug.c index 3cf8d90..0dad9e2 100644 --- a/upnp/src/api/upnpdebug.c +++ b/upnp/src/api/upnpdebug.c @@ -118,6 +118,7 @@ int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module) (Module == DOM && DEBUG_DOM) || (Module == HTTP && DEBUG_HTTP); return ret; + Module = Module; /* VC complains about this being unreferenced */ } void UpnpPrintf(Upnp_LogLevel DLevel, diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 8ffa8ce..22d7570 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -493,7 +493,8 @@ Cleanup_File: num_written = (size_t)nw; UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__, ">>> (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); if (num_written != buf_length) { RetVal = 0; diff --git a/upnp/src/inc/upnputil.h b/upnp/src/inc/upnputil.h index 2cc4488..5dc7d37 100644 --- a/upnp/src/inc/upnputil.h +++ b/upnp/src/inc/upnputil.h @@ -112,7 +112,8 @@ void linecopylen( #define ERROR_BUFFER_LEN 256 /* C specific */ -#ifndef __cplusplus +/* VC needs these in C++ mode too (do other compilers?) */ +#if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) #ifdef WIN32 #ifndef S_ISREG #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) @@ -130,7 +131,7 @@ void linecopylen( #define max(a, b) (((a)>(b))? (a):(b)) #define min(a, b) (((a)<(b))? (a):(b)) #endif /* WIN32 */ -#endif /* __cplusplus */ +#endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */ #endif /* UTIL_H */ diff --git a/upnp/src/inc/uri.h b/upnp/src/inc/uri.h index 64e415a..a870ca4 100644 --- a/upnp/src/inc/uri.h +++ b/upnp/src/inc/uri.h @@ -52,7 +52,10 @@ #include #ifdef WIN32 - #include "inet_pton.h" + #ifndef UPNP_USE_MSVCPP + /* VC Winsocks2 includes these functions */ + #include "inet_pton.h" + #endif #else #include /* for struct addrinfo */ #endif diff --git a/upnp/src/soap/soap_ctrlpt.c b/upnp/src/soap/soap_ctrlpt.c index 212ddf4..da4aa7b 100644 --- a/upnp/src/soap/soap_ctrlpt.c +++ b/upnp/src/soap/soap_ctrlpt.c @@ -379,7 +379,7 @@ get_response_value( IN http_message_t * hmsg, char *node_str = NULL; const char *temp_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; const char *names[5]; const DOMString nodeValue; diff --git a/upnp/src/uuid/sysdep.c b/upnp/src/uuid/sysdep.c index 037969b..ea5b200 100644 --- a/upnp/src/uuid/sysdep.c +++ b/upnp/src/uuid/sysdep.c @@ -106,7 +106,7 @@ void get_random_info(unsigned char seed[16]) GetComputerName( r.hostname, &r.l ); /* MD5 it */ MD5Init(&c); - MD5Update(&c, &r, sizeof r); + MD5Update(&c, (unsigned char *)(&r), sizeof r); MD5Final(seed, &c); };