Skip to content

Commit 363d464

Browse files
committed
Merge branch 'stable-3.2'
2 parents c5d608d + 9bc4c68 commit 363d464

File tree

1 file changed

+64
-111
lines changed

1 file changed

+64
-111
lines changed

build-aux/lock.m4

Lines changed: 64 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -22,124 +22,77 @@ AC_DEFUN([GST_LOCK],
2222
# Prerequisites of lib-src/lock.c.
2323
AC_REQUIRE([AC_C_INLINE])
2424
25-
dnl Check for multithreading.
26-
AC_ARG_ENABLE(threads,
27-
AC_HELP_STRING([--enable-threads={posix|solaris|win32}], [specify multithreading API])
28-
AC_HELP_STRING([--disable-threads], [build without multithread safety]),
29-
[gst_use_threads=$enableval],
30-
[case "$host_os" in
31-
dnl Disable multithreading by default on OSF/1, because it interferes
32-
dnl with fork()/exec(): When msgexec is linked with -lpthread, its
33-
dnl child process gets an endless segmentation fault inside execvp().
34-
osf*) gst_use_threads=no ;;
35-
*) gst_use_threads=yes ;;
36-
esac])
37-
if test "$gst_use_threads" = yes || test "$gst_use_threads" = posix; then
38-
# For using <pthread.h>:
39-
case "$host_os" in
40-
osf*)
41-
# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
42-
# groks <pthread.h>. cc also understands the flag -pthread, but
43-
# we don't use it because 1. gcc-2.95 doesn't understand -pthread,
44-
# 2. putting a flag into CPPFLAGS that has an effect on the linker
45-
# causes the AC_TRY_LINK test below to succeed unexpectedly,
46-
# leading to wrong values of LIBTHREAD.
47-
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
48-
;;
49-
esac
50-
# Some systems optimize for single-threaded programs by default, and
51-
# need special flags to disable these optimizations. For example, the
52-
# definition of 'errno' in <errno.h>.
53-
case "$host_os" in
54-
aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
55-
solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
56-
esac
57-
fi
58-
5925
gst_threads_api=none
6026
LIBTHREAD=
61-
if test "$gst_use_threads" != no; then
62-
if test "$gst_use_threads" = yes || test "$gst_use_threads" = posix; then
63-
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
64-
# it groks <pthread.h>. It's added above.
65-
AC_CHECK_HEADER(pthread.h, gst_have_pthread_h=yes, gst_have_pthread_h=no)
66-
if test "$gst_have_pthread_h" = yes; then
67-
# Other possible tests:
68-
# -lpthreads (FSU threads, PCthreads)
69-
# -lgthreads
70-
gst_have_pthread=
71-
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
72-
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but
73-
# the second one only in libpthread, and lock.c needs it.
74-
AC_TRY_LINK([#include <pthread.h>],
75-
[pthread_mutex_lock((pthread_mutex_t*)0);
76-
pthread_mutexattr_init((pthread_mutexattr_t*)0);],
77-
[gst_have_pthread=yes])
78-
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
79-
# since it is defined as a macro on OSF/1.)
80-
if test -n "$gst_have_pthread"; then
81-
# The program links fine without libpthread. But it may actually
82-
# need to link with libpthread in order to create multiple threads.
83-
AC_CHECK_LIB(pthread, pthread_kill,
84-
[LIBTHREAD=
85-
# On Solaris and HP-UX, most pthread functions exist also in libc.
86-
# Therefore pthread_in_use() needs to actually try to create a
87-
# thread: pthread_create from libc will fail, whereas
88-
# pthread_create will actually create a thread.
89-
case "$host_os" in
90-
solaris* | hpux*)
91-
AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1,
92-
[Define if the pthread_in_use() detection is hard.])
93-
esac
94-
])
95-
else
96-
# Some library is needed. Try libpthread and libc_r.
97-
AC_CHECK_LIB(pthread, pthread_kill,
98-
[gst_have_pthread=yes
99-
LIBTHREAD=-lpthread])
100-
if test -z "$gst_have_pthread"; then
101-
# For FreeBSD 4.
102-
AC_CHECK_LIB(c_r, pthread_kill,
103-
[gst_have_pthread=yes
104-
LIBTHREAD=-lc_r])
105-
fi
106-
fi
107-
if test -n "$gst_have_pthread"; then
108-
gst_threads_api=posix
109-
AC_DEFINE([USE_POSIX_THREADS], 1,
110-
[Define if the POSIX multithreading library can be used.])
111-
# OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
112-
# pthread_rwlock_* functions.
113-
AC_CHECK_TYPE([pthread_rwlock_t],
114-
[AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,
115-
[Define if the POSIX multithreading library has read/write locks.])],
116-
[],
117-
[#include <pthread.h>])
118-
# glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
119-
AC_TRY_COMPILE([#include <pthread.h>],
120-
[#if __FreeBSD__ == 4
27+
28+
dnl Check for multithreading.
29+
# Some systems optimize for single-threaded programs by default, and
30+
# need special flags to disable these optimizations. For example, the
31+
# definition of 'errno' in <errno.h>.
32+
# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
33+
# groks <pthread.h>. cc also understands the flag -pthread, but
34+
# we don't use it because 1. gcc-2.95 doesn't understand -pthread,
35+
# 2. putting a flag into CPPFLAGS that has an effect on the linker
36+
# causes the AC_TRY_LINK test below to succeed unexpectedly,
37+
# leading to wrong values of LIBTHREAD.
38+
# On Solaris and HP-UX, most pthread functions exist also in libc.
39+
# However, pthread_create from libc will fail.
40+
case "$host_os" in
41+
osf*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
42+
aix*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
43+
freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" LIBTHREAD=-pthread ;;
44+
solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" LIBTHREAD=-lpthread ;;
45+
hpux*) LIBTHREAD=-lpthread ;;
46+
esac
47+
48+
AC_CHECK_HEADER(pthread.h, gst_have_pthread_h=yes, gst_have_pthread_h=no)
49+
50+
if { case "$host_os" in
51+
mingw*) true;;
52+
*) false;;
53+
esac
54+
}; then
55+
gst_threads_api=win32
56+
AC_DEFINE([USE_WIN32_THREADS], 1,
57+
[Define if the Win32 multithreading API can be used.])
58+
elif test "$gst_have_pthread_h" = yes; then
59+
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
60+
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but
61+
# the second one only in libpthread. FreeBSD has libc_r.
62+
gst_save_CFLAGS=$CFLAGS
63+
gst_save_LIBS=$LIBS
64+
CFLAGS="$CFLAGS $LIBTHREAD"
65+
gst_have_pthread=yes
66+
AC_SEARCH_LIBS([pthread_mutexattr_init], [pthread pthreads c_r], ,
67+
[gst_have_pthread=no])
68+
AC_SEARCH_LIBS([pthread_mutex_lock], [pthread pthreads c_r], ,
69+
[gst_have_pthread=no])
70+
CFLAGS=$gst_save_CFLAGS
71+
LIBS=$gst_save_LIBS
72+
if test "$gst_have_pthread" = yes; then
73+
if test "$ac_cv_search_pthread_mutex_lock" != "none required"; then
74+
LIBTHREAD="$LIBTHREAD $ac_cv_search_pthread_mutex_lock"
75+
fi
76+
gst_threads_api=posix
77+
AC_DEFINE([USE_POSIX_THREADS], 1,
78+
[Define if the POSIX multithreading library can be used.])
79+
# OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
80+
# pthread_rwlock_* functions.
81+
AC_CHECK_TYPE([pthread_rwlock_t],
82+
[AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,
83+
[Define if the POSIX multithreading library has read/write locks.])],
84+
[],
85+
[#include <pthread.h>])
86+
# glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
87+
AC_TRY_COMPILE([#include <pthread.h>],
88+
[#if __FreeBSD__ == 4
12189
error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
12290
#else
12391
int x = (int)PTHREAD_MUTEX_RECURSIVE;
12492
return !x;
12593
#endif],
126-
[AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1,
127-
[Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
128-
fi
129-
fi
130-
fi
131-
if test -z "$gst_have_pthread"; then
132-
if test "$gst_use_threads" = yes || test "$gst_use_threads" = win32; then
133-
if { case "$host_os" in
134-
mingw*) true;;
135-
*) false;;
136-
esac
137-
}; then
138-
gst_threads_api=win32
139-
AC_DEFINE([USE_WIN32_THREADS], 1,
140-
[Define if the Win32 multithreading API can be used.])
141-
fi
142-
fi
94+
[AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1,
95+
[Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
14396
fi
14497
fi
14598
AC_MSG_CHECKING([for multithread API to use])

0 commit comments

Comments
 (0)