From 8e846368e0f0e33a5d42bc56b0c6025a8afd5e78 Mon Sep 17 00:00:00 2001 From: Carl Benson Date: Mon, 1 Nov 2010 00:43:20 -0200 Subject: [PATCH] patch for taking notice of UPNP_USE_RWLOCK flag in threadutil By "Carl Benson" : I had to do some modifications myself though, because the Android build system insists on having a file named "util.h" taking precedence in its include path, libupnp gets confused because of the same filename in upnp/src/inc/util.h --- ChangeLog | 8 +++++++ THANKS | 1 + threadutil/inc/ithread.h | 28 +++++++++++++++++++------ upnp/src/api/upnpapi.c | 1 + upnp/src/genlib/miniserver/miniserver.c | 2 +- upnp/src/genlib/net/http/parsetools.c | 2 +- upnp/src/genlib/net/http/statcodes.c | 2 +- upnp/src/genlib/net/http/webserver.c | 2 +- upnp/src/genlib/util/util.c | 2 +- upnp/src/inc/httpparser.h | 2 +- upnp/src/inc/httpreadwrite.h | 2 +- upnp/src/inc/membuffer.h | 2 +- upnp/src/inc/parsetools.h | 2 +- upnp/src/inc/sock.h | 2 +- upnp/src/inc/strintmap.h | 2 +- upnp/src/inc/upnpapi.h | 2 -- upnp/src/inc/{util.h => upnputil.h} | 0 upnp/src/ssdp/ssdp_ctrlpt.c | 2 +- upnp/src/urlconfig/urlconfig.c | 2 +- 19 files changed, 45 insertions(+), 21 deletions(-) rename upnp/src/inc/{util.h => upnputil.h} (100%) diff --git a/ChangeLog b/ChangeLog index cbe7259..40fdc9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,14 @@ Version 1.6.9 ******************************************************************************* +2010-11-01 Carl Benson + + Fix for Android build. + + I had to do some modifications myself though, because the Android + build system insists on having a file named "util.h" taking precedence + in its include path, libupnp gets confused because of the same filename + in upnp/src/inc/util.h ******************************************************************************* Version 1.6.8 diff --git a/THANKS b/THANKS index 0ba9ca2..b90ddb8 100644 --- a/THANKS +++ b/THANKS @@ -13,6 +13,7 @@ exempt of errors. - Arno Willig - Bob Ciora - Carlo Parata +- Carl Benson - Chandra (inactiveneurons) - Chaos - Charles Nepveu (cnepveu) diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index 98e3b83..21876f6 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -188,7 +188,10 @@ typedef pthread_rwlockattr_t ithread_rwlockattr_t; * Internal Use Only ***************************************************************************/ #if UPNP_USE_RWLOCK -typedef pthread_rwlock_t ithread_rwlock_t; + typedef pthread_rwlock_t ithread_rwlock_t; +#else + /* Read-write locks aren't available: use mutex instead. */ + typedef ithread_mutex_t ithread_rwlock_t; #endif /* UPNP_USE_RWLOCK */ @@ -337,7 +340,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { #define ithread_mutexattr_setkind_np pthread_mutexattr_settype #else #define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np -#endif +#endif /* UPNP_USE_RWLOCK */ /**************************************************************************** * Function: ithread_mutexattr_getkind_np @@ -362,7 +365,7 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { #define ithread_mutexattr_getkind_np pthread_mutexattr_gettype #else #define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np -#endif +#endif /* UPNP_USE_RWLOCK */ /**************************************************************************** @@ -536,8 +539,10 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { *****************************************************************************/ #if UPNP_USE_RWLOCK #define ithread_rwlock_init pthread_rwlock_init -#endif /* UPNP_USE_RWLOCK */ - +#else + /* Read-write locks aren't available: use mutex instead. */ + #define ithread_rwlock_init ithread_mutex_init +#endif /**************************************************************************** * Function: ithread_rwlock_rdlock @@ -555,9 +560,11 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { *****************************************************************************/ #if UPNP_USE_RWLOCK #define ithread_rwlock_rdlock pthread_rwlock_rdlock +#else + /* Read-write locks aren't available: use mutex instead. */ + #define ithread_rwlock_rdlock ithread_mutex_lock #endif /* UPNP_USE_RWLOCK */ - /**************************************************************************** * Function: ithread_rwlock_wrlock * @@ -574,6 +581,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { *****************************************************************************/ #if UPNP_USE_RWLOCK #define ithread_rwlock_wrlock pthread_rwlock_wrlock +#else + /* Read-write locks aren't available: use mutex instead. */ + #define ithread_rwlock_wrlock ithread_mutex_lock #endif /* UPNP_USE_RWLOCK */ @@ -594,6 +604,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { *****************************************************************************/ #if UPNP_USE_RWLOCK #define ithread_rwlock_unlock pthread_rwlock_unlock +#else + /* Read-write locks aren't available: use mutex instead. */ + #define ithread_rwlock_unlock ithread_mutex_unlock #endif /* UPNP_USE_RWLOCK */ @@ -615,6 +628,9 @@ static UPNP_INLINE int ithread_cleanup_thread(void) { *****************************************************************************/ #if UPNP_USE_RWLOCK #define ithread_rwlock_destroy pthread_rwlock_destroy +#else + /* Read-write locks aren't available: use mutex instead. */ + #define ithread_rwlock_destroy ithread_mutex_destroy #endif /* UPNP_USE_RWLOCK */ diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 0fc1f96..aa8ca47 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -122,6 +122,7 @@ ithread_mutex_t GlobalClientSubscribeMutex; /*! rwlock to synchronize handles (root device or control point handle). */ ithread_rwlock_t GlobalHndRWLock; + /*! Mutex to synchronize the uuid creation process. */ ithread_mutex_t gUUIDMutex; diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 4561d93..557087d 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -57,7 +57,7 @@ #include "ThreadPool.h" #include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */ #include "upnpapi.h" -#include "util.h" +#include "upnputil.h" #include diff --git a/upnp/src/genlib/net/http/parsetools.c b/upnp/src/genlib/net/http/parsetools.c index b20d4e2..a1dc759 100644 --- a/upnp/src/genlib/net/http/parsetools.c +++ b/upnp/src/genlib/net/http/parsetools.c @@ -36,7 +36,7 @@ #include "config.h" #include -#include "util.h" +#include "upnputil.h" #include "membuffer.h" #include "httpparser.h" #include "statcodes.h" diff --git a/upnp/src/genlib/net/http/statcodes.c b/upnp/src/genlib/net/http/statcodes.c index 92cd62b..f11c3cb 100644 --- a/upnp/src/genlib/net/http/statcodes.c +++ b/upnp/src/genlib/net/http/statcodes.c @@ -37,7 +37,7 @@ #include "config.h" #include #include -#include "util.h" +#include "upnputil.h" #include "statcodes.h" #ifdef WIN32 diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index 57029c3..1e5fdf1 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -51,7 +51,7 @@ #include "unixutil.h" #include "upnp.h" #include "upnpapi.h" -#include "util.h" +#include "upnputil.h" #include "VirtualDir.h" #include diff --git a/upnp/src/genlib/util/util.c b/upnp/src/genlib/util/util.c index 5ccb8b3..694efdd 100644 --- a/upnp/src/genlib/util/util.c +++ b/upnp/src/genlib/util/util.c @@ -37,7 +37,7 @@ #include "config.h" #include "upnp.h" -#include "util.h" +#include "upnputil.h" #include diff --git a/upnp/src/inc/httpparser.h b/upnp/src/inc/httpparser.h index b41a805..d6134e9 100644 --- a/upnp/src/inc/httpparser.h +++ b/upnp/src/inc/httpparser.h @@ -42,7 +42,7 @@ #include "LinkedList.h" #include "membuffer.h" #include "uri.h" -#include "util.h" +#include "upnputil.h" ////// private types //////////// diff --git a/upnp/src/inc/httpreadwrite.h b/upnp/src/inc/httpreadwrite.h index 1f93a9f..cb61994 100644 --- a/upnp/src/inc/httpreadwrite.h +++ b/upnp/src/inc/httpreadwrite.h @@ -33,7 +33,7 @@ #define GENLIB_NET_HTTP_HTTPREADWRITE_H #include "config.h" -#include "util.h" +#include "upnputil.h" #include "sock.h" #include "httpparser.h" diff --git a/upnp/src/inc/membuffer.h b/upnp/src/inc/membuffer.h index ec9987b..24d7c38 100644 --- a/upnp/src/inc/membuffer.h +++ b/upnp/src/inc/membuffer.h @@ -34,7 +34,7 @@ #include -#include "util.h" +#include "upnputil.h" #define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) ) #define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) ) diff --git a/upnp/src/inc/parsetools.h b/upnp/src/inc/parsetools.h index 2f37285..d2faee3 100644 --- a/upnp/src/inc/parsetools.h +++ b/upnp/src/inc/parsetools.h @@ -32,7 +32,7 @@ #ifndef GENLIB_NET_HTTP_PARSETOOLS_H #define GENLIB_NET_HTTP_PARSETOOLS_H -#include "util.h" +#include "upnputil.h" #include "httpparser.h" diff --git a/upnp/src/inc/sock.h b/upnp/src/inc/sock.h index 4e570c5..bbbc8bc 100644 --- a/upnp/src/inc/sock.h +++ b/upnp/src/inc/sock.h @@ -36,7 +36,7 @@ * \file */ -#include "util.h" +#include "upnputil.h" #ifdef WIN32 /* Do not #include */ diff --git a/upnp/src/inc/strintmap.h b/upnp/src/inc/strintmap.h index 6ddcb1c..f5fffa7 100644 --- a/upnp/src/inc/strintmap.h +++ b/upnp/src/inc/strintmap.h @@ -33,7 +33,7 @@ #define GENLIB_UTIL_STRINTMAP_H #include -#include "util.h" +#include "upnputil.h" // Util to map from a string to an integer and vice versa diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h index 4b81cb0..2f5db6c 100644 --- a/upnp/src/inc/upnpapi.h +++ b/upnp/src/inc/upnpapi.h @@ -109,10 +109,8 @@ struct Handle_Info #endif }; - extern ithread_rwlock_t GlobalHndRWLock; - /*! * \brief Get handle information. * diff --git a/upnp/src/inc/util.h b/upnp/src/inc/upnputil.h similarity index 100% rename from upnp/src/inc/util.h rename to upnp/src/inc/upnputil.h diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c index a3c611a..3bb53ad 100644 --- a/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c @@ -33,7 +33,7 @@ #include "config.h" -#include "util.h" +#include "upnputil.h" #ifdef INCLUDE_CLIENT_APIS diff --git a/upnp/src/urlconfig/urlconfig.c b/upnp/src/urlconfig/urlconfig.c index 50d8d24..f30ea60 100644 --- a/upnp/src/urlconfig/urlconfig.c +++ b/upnp/src/urlconfig/urlconfig.c @@ -40,7 +40,7 @@ #include "UpnpInet.h" #include "uri.h" #include "urlconfig.h" -#include "util.h" +#include "upnputil.h" #include "webserver.h"