Skip to content

Commit db64a96

Browse files
committed
- updated ax_pthread.m4 to version 21 with clang support, this
removes a warning from compilation. git-svn-id: file:///svn/unbound/trunk@3581 be551aaa-1e26-0410-a405-d3ace91eadb9
1 parent 72a5931 commit db64a96

File tree

3 files changed

+70
-22
lines changed

3 files changed

+70
-22
lines changed

ax_pthread.m4

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
# modified version of the Autoconf Macro, you may extend this special
8383
# exception to the GPL to apply to your modified version as well.
8484

85-
#serial 20
85+
#serial 21
8686

8787
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
8888
AC_DEFUN([AX_PTHREAD], [
@@ -103,8 +103,8 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
103103
save_LIBS="$LIBS"
104104
LIBS="$PTHREAD_LIBS $LIBS"
105105
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
106-
AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
107-
AC_MSG_RESULT($ax_pthread_ok)
106+
AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
107+
AC_MSG_RESULT([$ax_pthread_ok])
108108
if test x"$ax_pthread_ok" = xno; then
109109
PTHREAD_LIBS=""
110110
PTHREAD_CFLAGS=""
@@ -164,6 +164,20 @@ case ${host_os} in
164164
;;
165165
esac
166166
167+
# Clang doesn't consider unrecognized options an error unless we specify
168+
# -Werror. We throw in some extra Clang-specific options to ensure that
169+
# this doesn't happen for GCC, which also accepts -Werror.
170+
171+
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
172+
save_CFLAGS="$CFLAGS"
173+
ax_pthread_extra_flags="-Werror"
174+
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
175+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
176+
[AC_MSG_RESULT([yes])],
177+
[ax_pthread_extra_flags=
178+
AC_MSG_RESULT([no])])
179+
CFLAGS="$save_CFLAGS"
180+
167181
if test x"$ax_pthread_ok" = xno; then
168182
for flag in $ax_pthread_flags; do
169183
@@ -178,7 +192,7 @@ for flag in $ax_pthread_flags; do
178192
;;
179193
180194
pthread-config)
181-
AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
195+
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
182196
if test x"$ax_pthread_config" = xno; then continue; fi
183197
PTHREAD_CFLAGS="`pthread-config --cflags`"
184198
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
@@ -193,7 +207,7 @@ for flag in $ax_pthread_flags; do
193207
save_LIBS="$LIBS"
194208
save_CFLAGS="$CFLAGS"
195209
LIBS="$PTHREAD_LIBS $LIBS"
196-
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
210+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
197211
198212
# Check for various functions. We must include pthread.h,
199213
# since some functions may be macros. (On the Sequent, we
@@ -219,7 +233,7 @@ for flag in $ax_pthread_flags; do
219233
LIBS="$save_LIBS"
220234
CFLAGS="$save_CFLAGS"
221235
222-
AC_MSG_RESULT($ax_pthread_ok)
236+
AC_MSG_RESULT([$ax_pthread_ok])
223237
if test "x$ax_pthread_ok" = xyes; then
224238
break;
225239
fi
@@ -245,9 +259,9 @@ if test "x$ax_pthread_ok" = xyes; then
245259
[attr_name=$attr; break],
246260
[])
247261
done
248-
AC_MSG_RESULT($attr_name)
262+
AC_MSG_RESULT([$attr_name])
249263
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
250-
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
264+
AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
251265
[Define to necessary symbol if this constant
252266
uses a non-standard name on your system.])
253267
fi
@@ -261,24 +275,25 @@ if test "x$ax_pthread_ok" = xyes; then
261275
if test "$GCC" = "yes"; then
262276
flag="-D_REENTRANT"
263277
else
278+
# TODO: What about Clang on Solaris?
264279
flag="-mt -D_REENTRANT"
265280
fi
266281
;;
267282
esac
268-
AC_MSG_RESULT(${flag})
283+
AC_MSG_RESULT([$flag])
269284
if test "x$flag" != xno; then
270285
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
271286
fi
272287
273288
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
274-
ax_cv_PTHREAD_PRIO_INHERIT, [
275-
AC_LINK_IFELSE([
276-
AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
289+
[ax_cv_PTHREAD_PRIO_INHERIT], [
290+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
291+
[[int i = PTHREAD_PRIO_INHERIT;]])],
277292
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
278293
[ax_cv_PTHREAD_PRIO_INHERIT=no])
279294
])
280295
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
281-
AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
296+
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
282297
283298
LIBS="$save_LIBS"
284299
CFLAGS="$save_CFLAGS"
@@ -301,13 +316,13 @@ fi
301316
302317
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
303318
304-
AC_SUBST(PTHREAD_LIBS)
305-
AC_SUBST(PTHREAD_CFLAGS)
306-
AC_SUBST(PTHREAD_CC)
319+
AC_SUBST([PTHREAD_LIBS])
320+
AC_SUBST([PTHREAD_CFLAGS])
321+
AC_SUBST([PTHREAD_CC])
307322
308323
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
309324
if test x"$ax_pthread_ok" = xyes; then
310-
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
325+
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
311326
:
312327
else
313328
ax_pthread_ok=no

configure

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15524,6 +15524,37 @@ case ${host_os} in
1552415524
;;
1552515525
esac
1552615526

15527+
# Clang doesn't consider unrecognized options an error unless we specify
15528+
# -Werror. We throw in some extra Clang-specific options to ensure that
15529+
# this doesn't happen for GCC, which also accepts -Werror.
15530+
15531+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler needs -Werror to reject unknown flags" >&5
15532+
$as_echo_n "checking if compiler needs -Werror to reject unknown flags... " >&6; }
15533+
save_CFLAGS="$CFLAGS"
15534+
ax_pthread_extra_flags="-Werror"
15535+
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
15536+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15537+
/* end confdefs.h. */
15538+
int foo(void);
15539+
int
15540+
main ()
15541+
{
15542+
foo()
15543+
;
15544+
return 0;
15545+
}
15546+
_ACEOF
15547+
if ac_fn_c_try_compile "$LINENO"; then :
15548+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15549+
$as_echo "yes" >&6; }
15550+
else
15551+
ax_pthread_extra_flags=
15552+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15553+
$as_echo "no" >&6; }
15554+
fi
15555+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15556+
CFLAGS="$save_CFLAGS"
15557+
1552715558
if test x"$ax_pthread_ok" = xno; then
1552815559
for flag in $ax_pthread_flags; do
1552915560

@@ -15593,7 +15624,7 @@ $as_echo_n "checking for the pthreads library -l$flag... " >&6; }
1559315624
save_LIBS="$LIBS"
1559415625
save_CFLAGS="$CFLAGS"
1559515626
LIBS="$PTHREAD_LIBS $LIBS"
15596-
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
15627+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
1559715628

1559815629
# Check for various functions. We must include pthread.h,
1559915630
# since some functions may be macros. (On the Sequent, we
@@ -15691,12 +15722,13 @@ $as_echo_n "checking if more special flags are required for pthreads... " >&6; }
1569115722
if test "$GCC" = "yes"; then
1569215723
flag="-D_REENTRANT"
1569315724
else
15725+
# TODO: What about Clang on Solaris?
1569415726
flag="-mt -D_REENTRANT"
1569515727
fi
1569615728
;;
1569715729
esac
15698-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
15699-
$as_echo "${flag}" >&6; }
15730+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flag" >&5
15731+
$as_echo "$flag" >&6; }
1570015732
if test "x$flag" != xno; then
1570115733
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1570215734
fi
@@ -15709,8 +15741,7 @@ else
1570915741

1571015742
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1571115743
/* end confdefs.h. */
15712-
15713-
#include <pthread.h>
15744+
#include <pthread.h>
1571415745
int
1571515746
main ()
1571615747
{

doc/Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
11 December 2015: Wouter
22
- remove NULL-checks before free, patch from Michael McConville.
3+
- updated ax_pthread.m4 to version 21 with clang support, this
4+
removes a warning from compilation.
35

46
10 December 2015: Wouter
57
- 1.5.7 release

0 commit comments

Comments
 (0)