650.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. From 14b36ee7a300aa47e08df06241bc409e213edff2 Mon Sep 17 00:00:00 2001
  2. From: orbea <orbea@riseup.net>
  3. Date: Fri, 1 Jan 2021 06:28:18 -0800
  4. Subject: [PATCH] Add missing pthread dependency.
  5. ---
  6. Makefile.am | 5 +-
  7. configure.ac | 1 +
  8. m4/ax_pthread.m4 | 507 +++++++++++++++++++++++++++++++++++++++++++++++
  9. 3 files changed, 511 insertions(+), 2 deletions(-)
  10. create mode 100644 m4/ax_pthread.m4
  11. diff --git a/Makefile.am b/Makefile.am
  12. index 123a3488..3844afb7 100644
  13. --- a/Makefile.am
  14. +++ b/Makefile.am
  15. @@ -2,6 +2,7 @@ warningflags = -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-ign
  16. commoncflags = -O3 -fvisibility=hidden $(warningflags) -I$(srcdir)/include $(DEBUGCFLAGS) $(MFLAGS) $(UNICODECFLAGS) $(STACKREALIGN)
  17. AM_CXXFLAGS = -std=c++11 $(commoncflags)
  18. AM_CFLAGS = -std=c99 $(commoncflags)
  19. +ACLOCAL_AMFLAGS = -I m4
  20. @@ -80,8 +81,8 @@ pkginclude_HEADERS = include/VapourSynth.h \
  21. pkgconfig_DATA += pc/vapoursynth.pc
  22. libvapoursynth_la_LDFLAGS = -no-undefined -avoid-version
  23. -libvapoursynth_la_CPPFLAGS = $(ZIMG_CFLAGS) -DVS_PATH_PLUGINDIR='"$(PLUGINDIR)"'
  24. -libvapoursynth_la_LIBADD = $(ZIMG_LIBS) $(DLOPENLIB) libexprfilter.la
  25. +libvapoursynth_la_CPPFLAGS = $(PTHREAD_CFLAGS) $(ZIMG_CFLAGS) -DVS_PATH_PLUGINDIR='"$(PLUGINDIR)"'
  26. +libvapoursynth_la_LIBADD = $(PTHREAD_LIBS) $(ZIMG_LIBS) $(DLOPENLIB) libexprfilter.la
  27. if X86ASM
  28. diff --git a/configure.ac b/configure.ac
  29. index b898d411..1566c6e0 100644
  30. --- a/configure.ac
  31. +++ b/configure.ac
  32. @@ -14,6 +14,7 @@ AC_PROG_CXX
  33. AC_SYS_LARGEFILE
  34. AC_FUNC_FSEEKO
  35. +AX_PTHREAD
  36. AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable compilation options required for debugging. (default=no)]))
  37. diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
  38. new file mode 100644
  39. index 00000000..1598d077
  40. --- /dev/null
  41. +++ b/m4/ax_pthread.m4
  42. @@ -0,0 +1,507 @@
  43. +# ===========================================================================
  44. +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
  45. +# ===========================================================================
  46. +#
  47. +# SYNOPSIS
  48. +#
  49. +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  50. +#
  51. +# DESCRIPTION
  52. +#
  53. +# This macro figures out how to build C programs using POSIX threads. It
  54. +# sets the PTHREAD_LIBS output variable to the threads library and linker
  55. +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
  56. +# flags that are needed. (The user can also force certain compiler
  57. +# flags/libs to be tested by setting these environment variables.)
  58. +#
  59. +# Also sets PTHREAD_CC to any special C compiler that is needed for
  60. +# multi-threaded programs (defaults to the value of CC otherwise). (This
  61. +# is necessary on AIX to use the special cc_r compiler alias.)
  62. +#
  63. +# NOTE: You are assumed to not only compile your program with these flags,
  64. +# but also to link with them as well. For example, you might link with
  65. +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
  66. +#
  67. +# If you are only building threaded programs, you may wish to use these
  68. +# variables in your default LIBS, CFLAGS, and CC:
  69. +#
  70. +# LIBS="$PTHREAD_LIBS $LIBS"
  71. +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  72. +# CC="$PTHREAD_CC"
  73. +#
  74. +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
  75. +# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
  76. +# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
  77. +#
  78. +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
  79. +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
  80. +# PTHREAD_CFLAGS.
  81. +#
  82. +# ACTION-IF-FOUND is a list of shell commands to run if a threads library
  83. +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
  84. +# is not found. If ACTION-IF-FOUND is not specified, the default action
  85. +# will define HAVE_PTHREAD.
  86. +#
  87. +# Please let the authors know if this macro fails on any platform, or if
  88. +# you have any other suggestions or comments. This macro was based on work
  89. +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
  90. +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
  91. +# Alejandro Forero Cuervo to the autoconf macro repository. We are also
  92. +# grateful for the helpful feedback of numerous users.
  93. +#
  94. +# Updated for Autoconf 2.68 by Daniel Richard G.
  95. +#
  96. +# LICENSE
  97. +#
  98. +# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
  99. +# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
  100. +# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
  101. +#
  102. +# This program is free software: you can redistribute it and/or modify it
  103. +# under the terms of the GNU General Public License as published by the
  104. +# Free Software Foundation, either version 3 of the License, or (at your
  105. +# option) any later version.
  106. +#
  107. +# This program is distributed in the hope that it will be useful, but
  108. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  109. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  110. +# Public License for more details.
  111. +#
  112. +# You should have received a copy of the GNU General Public License along
  113. +# with this program. If not, see <https://www.gnu.org/licenses/>.
  114. +#
  115. +# As a special exception, the respective Autoconf Macro's copyright owner
  116. +# gives unlimited permission to copy, distribute and modify the configure
  117. +# scripts that are the output of Autoconf when processing the Macro. You
  118. +# need not follow the terms of the GNU General Public License when using
  119. +# or distributing such scripts, even though portions of the text of the
  120. +# Macro appear in them. The GNU General Public License (GPL) does govern
  121. +# all other use of the material that constitutes the Autoconf Macro.
  122. +#
  123. +# This special exception to the GPL applies to versions of the Autoconf
  124. +# Macro released by the Autoconf Archive. When you make and distribute a
  125. +# modified version of the Autoconf Macro, you may extend this special
  126. +# exception to the GPL to apply to your modified version as well.
  127. +
  128. +#serial 27
  129. +
  130. +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
  131. +AC_DEFUN([AX_PTHREAD], [
  132. +AC_REQUIRE([AC_CANONICAL_HOST])
  133. +AC_REQUIRE([AC_PROG_CC])
  134. +AC_REQUIRE([AC_PROG_SED])
  135. +AC_LANG_PUSH([C])
  136. +ax_pthread_ok=no
  137. +
  138. +# We used to check for pthread.h first, but this fails if pthread.h
  139. +# requires special compiler flags (e.g. on Tru64 or Sequent).
  140. +# It gets checked for in the link test anyway.
  141. +
  142. +# First of all, check if the user has set any of the PTHREAD_LIBS,
  143. +# etcetera environment variables, and if threads linking works using
  144. +# them:
  145. +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
  146. + ax_pthread_save_CC="$CC"
  147. + ax_pthread_save_CFLAGS="$CFLAGS"
  148. + ax_pthread_save_LIBS="$LIBS"
  149. + AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
  150. + CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  151. + LIBS="$PTHREAD_LIBS $LIBS"
  152. + AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
  153. + AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
  154. + AC_MSG_RESULT([$ax_pthread_ok])
  155. + if test "x$ax_pthread_ok" = "xno"; then
  156. + PTHREAD_LIBS=""
  157. + PTHREAD_CFLAGS=""
  158. + fi
  159. + CC="$ax_pthread_save_CC"
  160. + CFLAGS="$ax_pthread_save_CFLAGS"
  161. + LIBS="$ax_pthread_save_LIBS"
  162. +fi
  163. +
  164. +# We must check for the threads library under a number of different
  165. +# names; the ordering is very important because some systems
  166. +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
  167. +# libraries is broken (non-POSIX).
  168. +
  169. +# Create a list of thread flags to try. Items with a "," contain both
  170. +# C compiler flags (before ",") and linker flags (after ","). Other items
  171. +# starting with a "-" are C compiler flags, and remaining items are
  172. +# library names, except for "none" which indicates that we try without
  173. +# any flags at all, and "pthread-config" which is a program returning
  174. +# the flags for the Pth emulation library.
  175. +
  176. +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
  177. +
  178. +# The ordering *is* (sometimes) important. Some notes on the
  179. +# individual items follow:
  180. +
  181. +# pthreads: AIX (must check this before -lpthread)
  182. +# none: in case threads are in libc; should be tried before -Kthread and
  183. +# other compiler flags to prevent continual compiler warnings
  184. +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
  185. +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
  186. +# (Note: HP C rejects this with "bad form for `-t' option")
  187. +# -pthreads: Solaris/gcc (Note: HP C also rejects)
  188. +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
  189. +# doesn't hurt to check since this sometimes defines pthreads and
  190. +# -D_REENTRANT too), HP C (must be checked before -lpthread, which
  191. +# is present but should not be used directly; and before -mthreads,
  192. +# because the compiler interprets this as "-mt" + "-hreads")
  193. +# -mthreads: Mingw32/gcc, Lynx/gcc
  194. +# pthread: Linux, etcetera
  195. +# --thread-safe: KAI C++
  196. +# pthread-config: use pthread-config program (for GNU Pth library)
  197. +
  198. +case $host_os in
  199. +
  200. + freebsd*)
  201. +
  202. + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
  203. + # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
  204. +
  205. + ax_pthread_flags="-kthread lthread $ax_pthread_flags"
  206. + ;;
  207. +
  208. + hpux*)
  209. +
  210. + # From the cc(1) man page: "[-mt] Sets various -D flags to enable
  211. + # multi-threading and also sets -lpthread."
  212. +
  213. + ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
  214. + ;;
  215. +
  216. + openedition*)
  217. +
  218. + # IBM z/OS requires a feature-test macro to be defined in order to
  219. + # enable POSIX threads at all, so give the user a hint if this is
  220. + # not set. (We don't define these ourselves, as they can affect
  221. + # other portions of the system API in unpredictable ways.)
  222. +
  223. + AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
  224. + [
  225. +# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
  226. + AX_PTHREAD_ZOS_MISSING
  227. +# endif
  228. + ],
  229. + [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
  230. + ;;
  231. +
  232. + solaris*)
  233. +
  234. + # On Solaris (at least, for some versions), libc contains stubbed
  235. + # (non-functional) versions of the pthreads routines, so link-based
  236. + # tests will erroneously succeed. (N.B.: The stubs are missing
  237. + # pthread_cleanup_push, or rather a function called by this macro,
  238. + # so we could check for that, but who knows whether they'll stub
  239. + # that too in a future libc.) So we'll check first for the
  240. + # standard Solaris way of linking pthreads (-mt -lpthread).
  241. +
  242. + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
  243. + ;;
  244. +esac
  245. +
  246. +# Are we compiling with Clang?
  247. +
  248. +AC_CACHE_CHECK([whether $CC is Clang],
  249. + [ax_cv_PTHREAD_CLANG],
  250. + [ax_cv_PTHREAD_CLANG=no
  251. + # Note that Autoconf sets GCC=yes for Clang as well as GCC
  252. + if test "x$GCC" = "xyes"; then
  253. + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
  254. + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
  255. +# if defined(__clang__) && defined(__llvm__)
  256. + AX_PTHREAD_CC_IS_CLANG
  257. +# endif
  258. + ],
  259. + [ax_cv_PTHREAD_CLANG=yes])
  260. + fi
  261. + ])
  262. +ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
  263. +
  264. +
  265. +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
  266. +
  267. +# Note that for GCC and Clang -pthread generally implies -lpthread,
  268. +# except when -nostdlib is passed.
  269. +# This is problematic using libtool to build C++ shared libraries with pthread:
  270. +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
  271. +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
  272. +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
  273. +# To solve this, first try -pthread together with -lpthread for GCC
  274. +
  275. +AS_IF([test "x$GCC" = "xyes"],
  276. + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
  277. +
  278. +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
  279. +
  280. +AS_IF([test "x$ax_pthread_clang" = "xyes"],
  281. + [ax_pthread_flags="-pthread,-lpthread -pthread"])
  282. +
  283. +
  284. +# The presence of a feature test macro requesting re-entrant function
  285. +# definitions is, on some systems, a strong hint that pthreads support is
  286. +# correctly enabled
  287. +
  288. +case $host_os in
  289. + darwin* | hpux* | linux* | osf* | solaris*)
  290. + ax_pthread_check_macro="_REENTRANT"
  291. + ;;
  292. +
  293. + aix*)
  294. + ax_pthread_check_macro="_THREAD_SAFE"
  295. + ;;
  296. +
  297. + *)
  298. + ax_pthread_check_macro="--"
  299. + ;;
  300. +esac
  301. +AS_IF([test "x$ax_pthread_check_macro" = "x--"],
  302. + [ax_pthread_check_cond=0],
  303. + [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
  304. +
  305. +
  306. +if test "x$ax_pthread_ok" = "xno"; then
  307. +for ax_pthread_try_flag in $ax_pthread_flags; do
  308. +
  309. + case $ax_pthread_try_flag in
  310. + none)
  311. + AC_MSG_CHECKING([whether pthreads work without any flags])
  312. + ;;
  313. +
  314. + *,*)
  315. + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
  316. + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
  317. + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
  318. + ;;
  319. +
  320. + -*)
  321. + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
  322. + PTHREAD_CFLAGS="$ax_pthread_try_flag"
  323. + ;;
  324. +
  325. + pthread-config)
  326. + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
  327. + AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
  328. + PTHREAD_CFLAGS="`pthread-config --cflags`"
  329. + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
  330. + ;;
  331. +
  332. + *)
  333. + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
  334. + PTHREAD_LIBS="-l$ax_pthread_try_flag"
  335. + ;;
  336. + esac
  337. +
  338. + ax_pthread_save_CFLAGS="$CFLAGS"
  339. + ax_pthread_save_LIBS="$LIBS"
  340. + CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  341. + LIBS="$PTHREAD_LIBS $LIBS"
  342. +
  343. + # Check for various functions. We must include pthread.h,
  344. + # since some functions may be macros. (On the Sequent, we
  345. + # need a special flag -Kthread to make this header compile.)
  346. + # We check for pthread_join because it is in -lpthread on IRIX
  347. + # while pthread_create is in libc. We check for pthread_attr_init
  348. + # due to DEC craziness with -lpthreads. We check for
  349. + # pthread_cleanup_push because it is one of the few pthread
  350. + # functions on Solaris that doesn't have a non-functional libc stub.
  351. + # We try pthread_create on general principles.
  352. +
  353. + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
  354. +# if $ax_pthread_check_cond
  355. +# error "$ax_pthread_check_macro must be defined"
  356. +# endif
  357. + static void *some_global = NULL;
  358. + static void routine(void *a)
  359. + {
  360. + /* To avoid any unused-parameter or
  361. + unused-but-set-parameter warning. */
  362. + some_global = a;
  363. + }
  364. + static void *start_routine(void *a) { return a; }],
  365. + [pthread_t th; pthread_attr_t attr;
  366. + pthread_create(&th, 0, start_routine, 0);
  367. + pthread_join(th, 0);
  368. + pthread_attr_init(&attr);
  369. + pthread_cleanup_push(routine, 0);
  370. + pthread_cleanup_pop(0) /* ; */])],
  371. + [ax_pthread_ok=yes],
  372. + [])
  373. +
  374. + CFLAGS="$ax_pthread_save_CFLAGS"
  375. + LIBS="$ax_pthread_save_LIBS"
  376. +
  377. + AC_MSG_RESULT([$ax_pthread_ok])
  378. + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
  379. +
  380. + PTHREAD_LIBS=""
  381. + PTHREAD_CFLAGS=""
  382. +done
  383. +fi
  384. +
  385. +
  386. +# Clang needs special handling, because older versions handle the -pthread
  387. +# option in a rather... idiosyncratic way
  388. +
  389. +if test "x$ax_pthread_clang" = "xyes"; then
  390. +
  391. + # Clang takes -pthread; it has never supported any other flag
  392. +
  393. + # (Note 1: This will need to be revisited if a system that Clang
  394. + # supports has POSIX threads in a separate library. This tends not
  395. + # to be the way of modern systems, but it's conceivable.)
  396. +
  397. + # (Note 2: On some systems, notably Darwin, -pthread is not needed
  398. + # to get POSIX threads support; the API is always present and
  399. + # active. We could reasonably leave PTHREAD_CFLAGS empty. But
  400. + # -pthread does define _REENTRANT, and while the Darwin headers
  401. + # ignore this macro, third-party headers might not.)
  402. +
  403. + # However, older versions of Clang make a point of warning the user
  404. + # that, in an invocation where only linking and no compilation is
  405. + # taking place, the -pthread option has no effect ("argument unused
  406. + # during compilation"). They expect -pthread to be passed in only
  407. + # when source code is being compiled.
  408. + #
  409. + # Problem is, this is at odds with the way Automake and most other
  410. + # C build frameworks function, which is that the same flags used in
  411. + # compilation (CFLAGS) are also used in linking. Many systems
  412. + # supported by AX_PTHREAD require exactly this for POSIX threads
  413. + # support, and in fact it is often not straightforward to specify a
  414. + # flag that is used only in the compilation phase and not in
  415. + # linking. Such a scenario is extremely rare in practice.
  416. + #
  417. + # Even though use of the -pthread flag in linking would only print
  418. + # a warning, this can be a nuisance for well-run software projects
  419. + # that build with -Werror. So if the active version of Clang has
  420. + # this misfeature, we search for an option to squash it.
  421. +
  422. + AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
  423. + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
  424. + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
  425. + # Create an alternate version of $ac_link that compiles and
  426. + # links in two steps (.c -> .o, .o -> exe) instead of one
  427. + # (.c -> exe), because the warning occurs only in the second
  428. + # step
  429. + ax_pthread_save_ac_link="$ac_link"
  430. + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
  431. + ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
  432. + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
  433. + ax_pthread_save_CFLAGS="$CFLAGS"
  434. + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
  435. + AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
  436. + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
  437. + ac_link="$ax_pthread_save_ac_link"
  438. + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
  439. + [ac_link="$ax_pthread_2step_ac_link"
  440. + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
  441. + [break])
  442. + ])
  443. + done
  444. + ac_link="$ax_pthread_save_ac_link"
  445. + CFLAGS="$ax_pthread_save_CFLAGS"
  446. + AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
  447. + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
  448. + ])
  449. +
  450. + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
  451. + no | unknown) ;;
  452. + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
  453. + esac
  454. +
  455. +fi # $ax_pthread_clang = yes
  456. +
  457. +
  458. +
  459. +# Various other checks:
  460. +if test "x$ax_pthread_ok" = "xyes"; then
  461. + ax_pthread_save_CFLAGS="$CFLAGS"
  462. + ax_pthread_save_LIBS="$LIBS"
  463. + CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  464. + LIBS="$PTHREAD_LIBS $LIBS"
  465. +
  466. + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
  467. + AC_CACHE_CHECK([for joinable pthread attribute],
  468. + [ax_cv_PTHREAD_JOINABLE_ATTR],
  469. + [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
  470. + for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
  471. + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
  472. + [int attr = $ax_pthread_attr; return attr /* ; */])],
  473. + [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
  474. + [])
  475. + done
  476. + ])
  477. + AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
  478. + test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
  479. + test "x$ax_pthread_joinable_attr_defined" != "xyes"],
  480. + [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
  481. + [$ax_cv_PTHREAD_JOINABLE_ATTR],
  482. + [Define to necessary symbol if this constant
  483. + uses a non-standard name on your system.])
  484. + ax_pthread_joinable_attr_defined=yes
  485. + ])
  486. +
  487. + AC_CACHE_CHECK([whether more special flags are required for pthreads],
  488. + [ax_cv_PTHREAD_SPECIAL_FLAGS],
  489. + [ax_cv_PTHREAD_SPECIAL_FLAGS=no
  490. + case $host_os in
  491. + solaris*)
  492. + ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
  493. + ;;
  494. + esac
  495. + ])
  496. + AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
  497. + test "x$ax_pthread_special_flags_added" != "xyes"],
  498. + [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
  499. + ax_pthread_special_flags_added=yes])
  500. +
  501. + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
  502. + [ax_cv_PTHREAD_PRIO_INHERIT],
  503. + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
  504. + [[int i = PTHREAD_PRIO_INHERIT;
  505. + return i;]])],
  506. + [ax_cv_PTHREAD_PRIO_INHERIT=yes],
  507. + [ax_cv_PTHREAD_PRIO_INHERIT=no])
  508. + ])
  509. + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
  510. + test "x$ax_pthread_prio_inherit_defined" != "xyes"],
  511. + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
  512. + ax_pthread_prio_inherit_defined=yes
  513. + ])
  514. +
  515. + CFLAGS="$ax_pthread_save_CFLAGS"
  516. + LIBS="$ax_pthread_save_LIBS"
  517. +
  518. + # More AIX lossage: compile with *_r variant
  519. + if test "x$GCC" != "xyes"; then
  520. + case $host_os in
  521. + aix*)
  522. + AS_CASE(["x/$CC"],
  523. + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
  524. + [#handle absolute path differently from PATH based program lookup
  525. + AS_CASE(["x$CC"],
  526. + [x/*],
  527. + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
  528. + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
  529. + ;;
  530. + esac
  531. + fi
  532. +fi
  533. +
  534. +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
  535. +
  536. +AC_SUBST([PTHREAD_LIBS])
  537. +AC_SUBST([PTHREAD_CFLAGS])
  538. +AC_SUBST([PTHREAD_CC])
  539. +
  540. +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
  541. +if test "x$ax_pthread_ok" = "xyes"; then
  542. + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
  543. + :
  544. +else
  545. + ax_pthread_ok=no
  546. + $2
  547. +fi
  548. +AC_LANG_POP
  549. +])dnl AX_PTHREAD