summaryrefslogtreecommitdiff
path: root/pjlib/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-02-07 13:11:39 +0000
committerBenny Prijono <bennylp@teluu.com>2008-02-07 13:11:39 +0000
commit56886ef4b648760667743506f4f7bed9830798e8 (patch)
tree33d43a16fe1cf5c26afae53de0dc0bf8e8478bba /pjlib/src
parenta50cf4e4adc531db5edd98ec99bb358b397c8557 (diff)
Ticket #470, #471, and #472: Compile error when semaphore.h is not present, Compilation error if pthread_mutexattr_set_type() is not present, and Problem with setting up FD_SETSIZE
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1783 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src')
-rw-r--r--pjlib/src/pj/os_core_unix.c24
-rw-r--r--pjlib/src/pj/sock_select.c7
2 files changed, 25 insertions, 6 deletions
diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c
index 5a246df5..1fe5253b 100644
--- a/pjlib/src/pj/os_core_unix.c
+++ b/pjlib/src/pj/os_core_unix.c
@@ -34,7 +34,7 @@
#include <pj/except.h>
#include <pj/errno.h>
-#if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0
+#if defined(PJ_HAS_SEMAPHORE_H) && PJ_HAS_SEMAPHORE_H != 0
# include <semaphore.h>
#endif
@@ -948,21 +948,29 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type)
return PJ_RETURN_OS_ERROR(rc);
if (type == PJ_MUTEX_SIMPLE) {
-#if defined(PJ_LINUX) && PJ_LINUX!=0
+#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
+ defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP);
-#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
+#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
+ defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
/* Nothing to do, default is simple */
#else
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
#endif
} else {
-#if defined(PJ_LINUX) && PJ_LINUX!=0
+#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
+ defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
-#elif defined(PJ_RTEMS) && PJ_RTEMS!=0
+#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
+ defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
// Phil Torre <ptorre@zetron.com>:
// The RTEMS implementation of POSIX mutexes doesn't include
// pthread_mutexattr_settype(), so what follows is a hack
// until I get RTEMS patched to support the set/get functions.
+ //
+ // More info:
+ // newlib's pthread also lacks pthread_mutexattr_settype(),
+ // but it seems to have mutexattr.recursive.
PJ_TODO(FIX_RTEMS_RECURSIVE_MUTEX_TYPE)
attr.recursive = 1;
#else
@@ -1239,7 +1247,11 @@ PJ_DEF(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex)
* RTEMS). Otherwise use POSIX rwlock.
*/
#if defined(PJ_EMULATE_RWMUTEX) && PJ_EMULATE_RWMUTEX!=0
-# include "os_rwmutex.c"
+ /* We need semaphore functionality to emulate rwmutex */
+# if !defined(PJ_HAS_SEMAPHORE) || PJ_HAS_SEMAPHORE==0
+# error "Semaphore support needs to be enabled to emulate rwmutex"
+# endif
+# include "os_rwmutex.c"
#else
struct pj_rwmutex_t
{
diff --git a/pjlib/src/pj/sock_select.c b/pjlib/src/pj/sock_select.c
index 566050ef..b3743b93 100644
--- a/pjlib/src/pj/sock_select.c
+++ b/pjlib/src/pj/sock_select.c
@@ -35,6 +35,13 @@
# pragma warning(disable: 4389) // Signed/unsigned mismatch in FD_*
#endif
+/* Now that we have access to OS'es <sys/select>, lets check again that
+ * PJ_IOQUEUE_MAX_HANDLES is not greater than FD_SETSIZE
+ */
+#if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
+# error "PJ_IOQUEUE_MAX_HANDLES cannot be greater than FD_SETSIZE"
+#endif
+
#define PART_FDSET(ps) ((fd_set*)&ps->data[1])
#define PART_FDSET_OR_NULL(ps) (ps ? PART_FDSET(ps) : NULL)
#define PART_COUNT(ps) (ps->data[0])