mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Create MOZ_CHECK_PTHREADS() macro that compiles a small test case using <pthread.h> so that systems like hpux & osf/1 will properly detect pthreads.
This commit is contained in:
parent
f6bd43f5f5
commit
bf562c2475
@ -34,6 +34,7 @@ dnl MOZ_ARG_WITH_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE])
|
||||
dnl MOZ_ARG_WITHOUT_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE])
|
||||
dnl MOZ_ARG_WITH_STRING( NAME, HELP, IF-SET [, ELSE])
|
||||
dnl MOZ_ARG_HEADER(Comment)
|
||||
dnl MOZ_CHECK_PTHREADS( NAME, IF-YES [, ELSE ])
|
||||
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
|
||||
|
||||
|
||||
@ -95,6 +96,38 @@ dnl MOZ_ARG_HEADER(Comment)
|
||||
dnl This is used by webconfig to group options
|
||||
define(MOZ_ARG_HEADER, [# $1])
|
||||
|
||||
dnl
|
||||
dnl Apparently, some systems cannot properly check for the pthread
|
||||
dnl library unless <pthread.h> is included so we need to test
|
||||
dnl using it
|
||||
dnl
|
||||
dnl MOZ_CHECK_PTHREADS(lib, success, failure)
|
||||
AC_DEFUN(MOZ_CHECK_PTHREADS,
|
||||
[
|
||||
AC_MSG_CHECKING([for pthread_create in -l$1])
|
||||
echo "
|
||||
#include <pthread.h>
|
||||
void *foo(void *v) { int a = 1; }
|
||||
int main() {
|
||||
pthread_t t;
|
||||
if (!pthread_create(&t, 0, &foo, 0)) {
|
||||
pthread_join(t, 0);
|
||||
}
|
||||
exit(0);
|
||||
}" > dummy.c ;
|
||||
echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
|
||||
${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
|
||||
_res=$? ;
|
||||
rm -f dummy.c dummy${ac_exeext} ;
|
||||
if test "$_res" = "0"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
[$2]
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
[$3]
|
||||
fi
|
||||
])
|
||||
|
||||
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
|
||||
AC_DEFUN(MOZ_READ_MOZCONFIG,
|
||||
[AC_REQUIRE([AC_INIT_BINSH])dnl
|
||||
|
19
configure.in
19
configure.in
@ -2020,17 +2020,18 @@ dnl Start by checking whether the system support pthreads
|
||||
dnl
|
||||
|
||||
|
||||
dnl
|
||||
dnl Try lib pthread
|
||||
dnl
|
||||
AC_CHECK_LIB(pthread, pthread_attr_init,
|
||||
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
|
||||
AC_CHECK_LIB(c_r, pthread_attr_init,
|
||||
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
|
||||
AC_CHECK_LIB(c, pthread_attr_init,
|
||||
USE_PTHREADS=1 )
|
||||
MOZ_CHECK_PTHREADS(pthreads,
|
||||
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
|
||||
MOZ_CHECK_PTHREADS(pthread,
|
||||
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
|
||||
MOZ_CHECK_PTHREADS(c_r,
|
||||
USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
|
||||
MOZ_CHECK_PTHREADS(c,
|
||||
USE_PTHREADS=1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
dnl
|
||||
dnl Check the command line for --with-pthreads
|
||||
|
Loading…
Reference in New Issue
Block a user