SF Tracker [ 1663004 ] Compile on Cygwin
Submitted By: Jon Foster - jongfoster This patch gives basic support for building under Cygwin - it compiles, links, and a simple UPnP device application can initialise. I'm not sure if it actually works yet, but this is definitely a step in the right direction. Patch is against the 1.4.1 release. Changes are: * threadutil/inc/ithread.h: Fix the ithread mutex support to use documented, portable APIs (if present) rather than the Non-Portable (_NP) ones it uses now. This is required because Cygwin implements only the portable API. * threadutil/src/ThreadPool.c: Fake SetPolicyType() to do nothing on Cygwin because otherwise it fails. Should probably investigate why it fails and add a proper implementation later. * upnp/src/api/upnpapi.c: On Cygwin, zero out the GlobalHndMutex structure before initialising it. Without this, the initialisation fails. This appears to be a bug in Cygwin. * upnp/src/genlib/net/uri/uri.c: Use gethostbyname() on Cygwin. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@151 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
@@ -47,11 +47,21 @@ extern "C" {
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
/* This system has SuS2-compliant mutex attributes.
|
||||
* E.g. on Cygwin, where we don't have the old nonportable (NP) symbols
|
||||
*/
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_NORMAL
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK
|
||||
#else
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_FAST_NP
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP
|
||||
#endif
|
||||
|
||||
#define ITHREAD_CANCELED PTHREAD_CANCELED
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Name: ithread_t
|
||||
@@ -181,8 +191,11 @@ extern "C" {
|
||||
* Returns EINVAL if the kind is not supported.
|
||||
* See man page for pthread_mutexattr_setkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
|
||||
#else
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ithread_mutexattr_getkind_np
|
||||
@@ -203,7 +216,11 @@ extern "C" {
|
||||
* Always returns 0.
|
||||
* See man page for pthread_mutexattr_getkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
|
||||
#else
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@@ -542,8 +559,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE
|
||||
//NK: Added for satisfying the gcc compiler
|
||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -90,6 +90,10 @@ FreeThreadPoolJob( ThreadPool * tp,
|
||||
static int
|
||||
SetPolicyType( PolicyType in )
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
/* TODO not currently working... */
|
||||
return 0;
|
||||
#else
|
||||
#ifdef WIN32
|
||||
return sched_setscheduler( 0, in);
|
||||
#else
|
||||
@@ -99,6 +103,7 @@ SetPolicyType( PolicyType in )
|
||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||
return sched_setscheduler( 0, in, ¤t );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Reference in New Issue
Block a user