get rid of the grey grid when Xorg starts up
[openwrt/svn-archive/archive.git] / net / asterisk-1.6.x / patches / 300-bug14930.patch
1 diff -Nru asterisk-1.6.1.0.org/configure asterisk-1.6.1.0/configure
2 --- asterisk-1.6.1.0.org/configure 2009-03-19 19:14:55.000000000 +0100
3 +++ asterisk-1.6.1.0/configure 2009-05-01 16:20:40.000000000 +0200
4 @@ -16790,6 +16790,70 @@
5 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
6 conftest$ac_exeext conftest.$ac_ext
7
8 +{ echo "$as_me:$LINENO: checking for pthread_rwlock_timedwrlock() in pthread.h" >&5
9 +echo $ECHO_N "checking for pthread_rwlock_timedwrlock() in pthread.h... $ECHO_C" >&6; }
10 +cat >conftest.$ac_ext <<_ACEOF
11 +/* confdefs.h. */
12 +_ACEOF
13 +cat confdefs.h >>conftest.$ac_ext
14 +cat >>conftest.$ac_ext <<_ACEOF
15 +/* end confdefs.h. */
16 +#include <pthread.h>
17 + #include <time.h>
18 +int
19 +main ()
20 +{
21 +pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)
22 + ;
23 + return 0;
24 +}
25 +
26 +_ACEOF
27 +rm -f conftest.$ac_objext conftest$ac_exeext
28 +if { (ac_try="$ac_link"
29 +case "(($ac_try" in
30 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
31 + *) ac_try_echo=$ac_try;;
32 +esac
33 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
34 + (eval "$ac_link") 2>conftest.er1
35 + ac_status=$?
36 + grep -v '^ *+' conftest.er1 >conftest.err
37 + rm -f conftest.er1
38 + cat conftest.err >&5
39 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
40 + (exit $ac_status); } && {
41 + test -z "$ac_c_werror_flag" ||
42 + test ! -s conftest.err
43 + } && test -s conftest$ac_exeext &&
44 + $as_test_x conftest$ac_exeext; then
45 +
46 + { echo "$as_me:$LINENO: result: yes" >&5
47 +echo "${ECHO_T}yes" >&6; }
48 + ac_cv_pthread_rwlock_timedwrlock="yes"
49 +
50 +else
51 + echo "$as_me: failed program was:" >&5
52 +sed 's/^/| /' conftest.$ac_ext >&5
53 +
54 +
55 + { echo "$as_me:$LINENO: result: no" >&5
56 +echo "${ECHO_T}no" >&6; }
57 + ac_cv_pthread_rwlock_timedwrlock="no"
58 +
59 +
60 +fi
61 +
62 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
63 + conftest$ac_exeext conftest.$ac_ext
64 +if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then
65 +
66 +cat >>confdefs.h <<\_ACEOF
67 +#define HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 1
68 +_ACEOF
69 +
70 +fi
71 +
72
73 if test "x${PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}" != "x1"; then
74 { echo "$as_me:$LINENO: checking for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP in pthread.h" >&5
75 diff -Nru asterisk-1.6.1.0.org/configure.ac asterisk-1.6.1.0/configure.ac
76 --- asterisk-1.6.1.0.org/configure.ac 2009-03-19 19:14:55.000000000 +0100
77 +++ asterisk-1.6.1.0/configure.ac 2009-05-01 16:20:40.000000000 +0200
78 @@ -437,6 +437,24 @@
79 AC_MSG_RESULT(no)
80 )
81
82 +AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h)
83 +AC_LINK_IFELSE(
84 + [AC_LANG_PROGRAM(
85 + [#include <pthread.h>
86 + #include <time.h>],
87 + [pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)])
88 + ],[
89 + AC_MSG_RESULT(yes)
90 + ac_cv_pthread_rwlock_timedwrlock="yes"
91 + ],[
92 + AC_MSG_RESULT(no)
93 + ac_cv_pthread_rwlock_timedwrlock="no"
94 + ]
95 +)
96 +if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then
97 + AC_DEFINE([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK], 1, [Define if your system has pthread_rwlock_timedwrlock()])
98 +fi
99 +
100 AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
101
102 #if test "${cross_compiling}" = "no";
103 diff -Nru asterisk-1.6.1.0.org/include/asterisk/autoconfig.h.in asterisk-1.6.1.0/include/asterisk/autoconfig.h.in
104 --- asterisk-1.6.1.0.org/include/asterisk/autoconfig.h.in 2009-03-19 19:14:55.000000000 +0100
105 +++ asterisk-1.6.1.0/include/asterisk/autoconfig.h.in 2009-05-01 16:20:40.000000000 +0200
106 @@ -647,6 +647,9 @@
107 pthread.h */
108 #undef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
109
110 +/* Define if your system has pthread_rwlock_timedwrlock() */
111 +#undef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
112 +
113 /* Define to 1 if the system has the type `ptrdiff_t'. */
114 #undef HAVE_PTRDIFF_T
115
116 diff -Nru asterisk-1.6.1.0.org/include/asterisk/lock.h asterisk-1.6.1.0/include/asterisk/lock.h
117 --- asterisk-1.6.1.0.org/include/asterisk/lock.h 2009-04-10 05:56:37.000000000 +0200
118 +++ asterisk-1.6.1.0/include/asterisk/lock.h 2009-05-01 16:20:40.000000000 +0200
119 @@ -49,10 +49,15 @@
120 #define _ASTERISK_LOCK_H
121
122 #include <pthread.h>
123 +#include <time.h>
124 #include <sys/param.h>
125 #ifdef HAVE_BKTR
126 #include <execinfo.h>
127 #endif
128 +
129 +#ifndef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
130 +#include "asterisk/time.h"
131 +#endif
132 #include "asterisk/logger.h"
133
134 /* internal macro to profile mutexes. Only computes the delay on
135 @@ -1395,7 +1400,23 @@
136 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
137 #endif
138 }
139 +#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
140 res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout);
141 +#else
142 + do {
143 + struct timeval _start = ast_tvnow(), _diff;
144 + for (;;) {
145 + if (!(res = pthread_rwlock_tryrdlock(&t->lock))) {
146 + break;
147 + }
148 + _diff = ast_tvsub(ast_tvnow(), _start);
149 + if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
150 + break;
151 + }
152 + usleep(1);
153 + }
154 + } while (0);
155 +#endif
156 if (!res) {
157 ast_reentrancy_lock(lt);
158 if (lt->reentrancy < AST_MAX_REENTRANCY) {
159 @@ -1474,7 +1495,23 @@
160 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
161 #endif
162 }
163 +#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
164 res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout);
165 +#else
166 + do {
167 + struct timeval _start = ast_tvnow(), _diff;
168 + for (;;) {
169 + if (!(res = pthread_rwlock_trywrlock(&t->lock))) {
170 + break;
171 + }
172 + _diff = ast_tvsub(ast_tvnow(), _start);
173 + if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
174 + break;
175 + }
176 + usleep(1);
177 + }
178 + } while (0);
179 +#endif
180 if (!res) {
181 ast_reentrancy_lock(lt);
182 if (lt->reentrancy < AST_MAX_REENTRANCY) {
183 @@ -1762,7 +1799,23 @@
184
185 static inline int ast_rwlock_timedrdlock(ast_rwlock_t *prwlock, const struct timespec *abs_timeout)
186 {
187 - return pthread_rwlock_timedrdlock(prwlock, abs_timeout);
188 + int res;
189 +#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
190 + res = pthread_rwlock_timedrdlock(prwlock, abs_timeout);
191 +#else
192 + struct timeval _start = ast_tvnow(), _diff;
193 + for (;;) {
194 + if (!(res = pthread_rwlock_tryrdlock(prwlock))) {
195 + break;
196 + }
197 + _diff = ast_tvsub(ast_tvnow(), _start);
198 + if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
199 + break;
200 + }
201 + usleep(1);
202 + }
203 +#endif
204 + return res;
205 }
206
207 static inline int ast_rwlock_tryrdlock(ast_rwlock_t *prwlock)
208 @@ -1777,7 +1830,25 @@
209
210 static inline int ast_rwlock_timedwrlock(ast_rwlock_t *prwlock, const struct timespec *abs_timeout)
211 {
212 - return pthread_rwlock_timedwrlock(prwlock, abs_timeout);
213 + int res;
214 +#ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
215 + res = pthread_rwlock_timedwrlock(prwlock, abs_timeout);
216 +#else
217 + do {
218 + struct timeval _start = ast_tvnow(), _diff;
219 + for (;;) {
220 + if (!(res = pthread_rwlock_trywrlock(prwlock))) {
221 + break;
222 + }
223 + _diff = ast_tvsub(ast_tvnow(), _start);
224 + if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
225 + break;
226 + }
227 + usleep(1);
228 + }
229 + } while (0);
230 +#endif
231 + return res;
232 }
233
234 static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock)