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: https://svn.pjsip.org/repos/pjproject/trunk@1783 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2008-02-07 13:11:39 +00:00
parent 1b911ba805
commit 1c5f4e479e
7 changed files with 407 additions and 28 deletions

View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for pjproject 0.7.
# Generated by GNU Autoconf 2.61 for pjproject 0.8.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='pjproject'
PACKAGE_TARNAME='pjproject'
PACKAGE_VERSION='0.7'
PACKAGE_STRING='pjproject 0.7'
PACKAGE_VERSION='0.8'
PACKAGE_STRING='pjproject 0.8'
PACKAGE_BUGREPORT=''
# Factoring default headers for most tests.
@ -1212,7 +1212,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures pjproject 0.7 to adapt to many kinds of systems.
\`configure' configures pjproject 0.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1278,7 +1278,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of pjproject 0.7:";;
short | recursive ) echo "Configuration of pjproject 0.8:";;
esac
cat <<\_ACEOF
@ -1376,7 +1376,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
pjproject configure 0.7
pjproject configure 0.8
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@ -1390,7 +1390,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by pjproject $as_me 0.7, which was
It was created by pjproject $as_me 0.8, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@ -6573,6 +6573,139 @@ _ACEOF
fi
if test "${ac_cv_header_semaphore_h+set}" = set; then
{ echo "$as_me:$LINENO: checking for semaphore.h" >&5
echo $ECHO_N "checking for semaphore.h... $ECHO_C" >&6; }
if test "${ac_cv_header_semaphore_h+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
{ echo "$as_me:$LINENO: result: $ac_cv_header_semaphore_h" >&5
echo "${ECHO_T}$ac_cv_header_semaphore_h" >&6; }
else
# Is the header compilable?
{ echo "$as_me:$LINENO: checking semaphore.h usability" >&5
echo $ECHO_N "checking semaphore.h usability... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <semaphore.h>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6; }
# Is the header present?
{ echo "$as_me:$LINENO: checking semaphore.h presence" >&5
echo $ECHO_N "checking semaphore.h presence... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <semaphore.h>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: semaphore.h: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: semaphore.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: semaphore.h: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: semaphore.h: present but cannot be compiled" >&5
echo "$as_me: WARNING: semaphore.h: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: semaphore.h: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: see the Autoconf documentation" >&5
echo "$as_me: WARNING: semaphore.h: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: semaphore.h: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: semaphore.h: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: semaphore.h: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: semaphore.h: in the future, the compiler will take precedence" >&2;}
;;
esac
{ echo "$as_me:$LINENO: checking for semaphore.h" >&5
echo $ECHO_N "checking for semaphore.h... $ECHO_C" >&6; }
if test "${ac_cv_header_semaphore_h+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_header_semaphore_h=$ac_header_preproc
fi
{ echo "$as_me:$LINENO: result: $ac_cv_header_semaphore_h" >&5
echo "${ECHO_T}$ac_cv_header_semaphore_h" >&6; }
fi
if test $ac_cv_header_semaphore_h = yes; then
cat >>confdefs.h <<\_ACEOF
#define PJ_HAS_SEMAPHORE_H 1
_ACEOF
fi
if test "${ac_cv_header_setjmp_h+set}" = set; then
{ echo "$as_me:$LINENO: checking for setjmp.h" >&5
echo $ECHO_N "checking for setjmp.h... $ECHO_C" >&6; }
@ -9555,6 +9688,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
#define PJ_EMULATE_RWMUTEX 0
_ACEOF
ac_rwmutex="yes"
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
@ -9565,12 +9699,172 @@ sed 's/^/| /' conftest.$ac_ext >&5
#define PJ_EMULATE_RWMUTEX 1
_ACEOF
ac_rwmutex="no"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$ac_rwmutex" = "no"; then
{ echo "$as_me:$LINENO: checking if pthread_rwlock_t is available with _POSIX_READER_WRITER_LOCKS" >&5
echo $ECHO_N "checking if pthread_rwlock_t is available with _POSIX_READER_WRITER_LOCKS... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _POSIX_READER_WRITER_LOCKS
#include <pthread.h>
int
main ()
{
pthread_rwlock_t *x;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
#define PJ_EMULATE_RWMUTEX 0
_ACEOF
CFLAGS="$CFLAGS -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS"
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >>confdefs.h <<\_ACEOF
#define PJ_EMULATE_RWMUTEX 1
_ACEOF
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: checking if pthread_mutexattr_settype() is available" >&5
echo $ECHO_N "checking if pthread_mutexattr_settype() is available... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <pthread.h>
int
main ()
{
pthread_mutexattr_settype(0,PTHREAD_MUTEX_FAST_NP);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
#define PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE 1
_ACEOF
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: checking if pthread_mutexattr_t has recursive member" >&5
echo $ECHO_N "checking if pthread_mutexattr_t has recursive member... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <pthread.h>
int
main ()
{
pthread_mutexattr_t attr;
attr.recursive=1;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
#define PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE 1
_ACEOF
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
case $target in
*mingw* | *cygw* | *win32* | *w32* )
@ -11192,7 +11486,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by pjproject $as_me 0.7, which was
This file was extended by pjproject $as_me 0.8, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -11241,7 +11535,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
pjproject config.status 0.7
pjproject config.status 0.8
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"

View File

@ -1,4 +1,4 @@
AC_INIT(pjproject,0.7)
AC_INIT(pjproject,0.8)
host_orig="$host"
@ -146,6 +146,7 @@ AC_CHECK_HEADER(netinet/in.h,[AC_DEFINE(PJ_HAS_NETINET_IN_H,1)])
AC_CHECK_HEADER(netinet/ip.h,[AC_DEFINE(PJ_HAS_NETINET_IP_H,1)])
AC_CHECK_HEADER(net/if.h,[AC_DEFINE(PJ_HAS_NET_IF_H,1)])
AC_CHECK_HEADER(ifaddrs.h,[AC_DEFINE(PJ_HAS_IFADDRS_H,1)])
AC_CHECK_HEADER(semaphore.h,[AC_DEFINE(PJ_HAS_SEMAPHORE_H,1)])
AC_CHECK_HEADER(setjmp.h,[AC_DEFINE(PJ_HAS_SETJMP_H,1)])
AC_CHECK_HEADER(stdarg.h,[AC_DEFINE(PJ_HAS_STDARG_H,1)])
AC_CHECK_HEADER(stddef.h,[AC_DEFINE(PJ_HAS_STDDEF_H,1)])
@ -268,10 +269,43 @@ AC_MSG_CHECKING([if pthread_rwlock_t is available])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[pthread_rwlock_t *x;])],
[AC_DEFINE(PJ_EMULATE_RWMUTEX,0)
ac_rwmutex="yes"
AC_MSG_RESULT(yes)],
[AC_DEFINE(PJ_EMULATE_RWMUTEX,1)
ac_rwmutex="no"
AC_MSG_RESULT(no)])
dnl # If rwmutex is not detected, check again but this time
dnl # with _POSIX_READER_WRITER_LOCKS defined (newlib needs this)
if test "$ac_rwmutex" = "no"; then
AC_MSG_CHECKING([if pthread_rwlock_t is available with _POSIX_READER_WRITER_LOCKS])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _POSIX_READER_WRITER_LOCKS
#include <pthread.h>]],
[pthread_rwlock_t *x;])],
[AC_DEFINE(PJ_EMULATE_RWMUTEX,0)
CFLAGS="$CFLAGS -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS"
AC_MSG_RESULT(yes)],
[AC_DEFINE(PJ_EMULATE_RWMUTEX,1)
AC_MSG_RESULT(no)])
fi
dnl # Do we have pthread_mutexattr_settype()?
AC_MSG_CHECKING([if pthread_mutexattr_settype() is available])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[pthread_mutexattr_settype(0,PTHREAD_MUTEX_FAST_NP);])],
[AC_DEFINE(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE,1)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
dnl # Does pthread_mutexattr_t has "recursive" member?
AC_MSG_CHECKING([if pthread_mutexattr_t has recursive member])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[[pthread_mutexattr_t attr;
attr.recursive=1;]])],
[AC_DEFINE(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE,1)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
AC_SUBST(ac_os_objs)
case $target in
*mingw* | *cygw* | *win32* | *w32* )

View File

@ -54,6 +54,7 @@
#undef PJ_HAS_NETINET_IP_H
#undef PJ_HAS_NET_IF_H
#undef PJ_HAS_IFADDRS_H
#undef PJ_HAS_SEMAPHORE_H
#undef PJ_HAS_SETJMP_H
#undef PJ_HAS_STDARG_H
#undef PJ_HAS_STDDEF_H
@ -79,6 +80,19 @@
#undef PJ_SOCK_HAS_INET_NTOP
#undef PJ_SOCK_HAS_GETADDRINFO
/* On these OSes, semaphore feature depends on semaphore.h */
#if defined(PJ_HAS_SEMAPHORE_H) && PJ_HAS_SEMAPHORE_H!=0
# define PJ_HAS_SEMAPHORE 1
#else
# define PJ_HAS_SEMAPHORE 0
#endif
/* Do we have pthread_mutexattr_settype()? */
#undef PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE
/* Does pthread_mutexattr_t has "recursive" member? */
#undef PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE
/* Set 1 if native sockaddr_in has sin_len member.
* Default: 0
*/

View File

@ -485,13 +485,6 @@
* underlying I/O queue impelementation, but still, developers should be
* aware of this constant, to make sure that the program will not break when
* the underlying implementation changes.
*
* For implementation based on select(), the value here will be used as the
* maximum number of socket handles passed to select() (i.e. FD_SETSIZE will
* be set to this value).
*
* Default: if FD_SETSIZE is defined and the value is greather than 256,
* then it will be used. Otherwise 256 (64 for WinCE).
*/
#ifndef PJ_IOQUEUE_MAX_HANDLES
# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
@ -537,17 +530,42 @@
#endif
/**
* Determine if FD_SETSIZE is changeable/set-able. If so, then we will
* set it to PJ_IOQUEUE_MAX_HANDLES.
*/
/* This is awful, as we should actually check for __GLIBC__ rather than
* __GNUC__. But alas! Libc headers are not included yet at this stage.
*/
#ifdef __GNUC__
# define PJ_FD_SETSIZE_SETABLE 0
#else
# define PJ_FD_SETSIZE_SETABLE 1
#endif
/**
* Overrides FD_SETSIZE so it is consistent throughout the library.
* OS specific configuration header (compat/os_*) might have declared
* FD_SETSIZE, thus we only set if it hasn't been declared.
* We only do this if we detected that FD_SETSIZE is changeable.
*
* Default: #PJ_IOQUEUE_MAX_HANDLES
*/
#ifndef FD_SETSIZE
# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
#if PJ_FD_SETSIZE_SETABLE
/* Only override FD_SETSIZE if the value has not been set */
# ifndef FD_SETSIZE
# define FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
# endif
#else
/* When FD_SETSIZE is not changeable, check if PJ_IOQUEUE_MAX_HANDLES
* is lower than FD_SETSIZE value.
*/
# ifdef FD_SETSIZE
# if PJ_IOQUEUE_MAX_HANDLES > FD_SETSIZE
# error "PJ_IOQUEUE_MAX_HANDLES is greater than FD_SETSIZE"
# endif
# endif
#endif
/**
* Has semaphore functionality?
*

View File

@ -54,7 +54,7 @@ PJ_BEGIN_DECL
*/
typedef struct pj_fd_set_t
{
pj_sock_t data[FD_SETSIZE + 4]; /**< Opaque buffer for fd_set */
pj_sock_t data[PJ_IOQUEUE_MAX_HANDLES+ 4]; /**< Opaque buffer for fd_set */
} pj_fd_set_t;

View File

@ -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
{

View File

@ -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])