summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2017-02-20 11:18:58 +0000
committerUli Schlachter <psychon@znc.in>2017-03-01 17:42:40 +0100
commit8340ebd656c7e1a5b6d31170c1f3c87df043e793 (patch)
tree0da84379a074c2e047c9c7cf2ea3c8331223d6a6 /configure.ac
parent816ca2affbd5a9d2e551851de4d0a26ec080d948 (diff)
downloadxcb-pthread-stubs-8340ebd656c7e1a5b6d31170c1f3c87df043e793.tar.gz
Rework the pthread-stub design
The current design handles the most common use-cases, although it causes breakage on others (when a pthreads liked library is dlopened). Refer to the README for further details. The new design, makes pthread-stubs a "meta" package which _never_ provides a library but only a .pc file. pthread-stubs checks if the run-time (libc or otherwise) expose lightweight pthread symbols to link against and defaults to a full blown pthread. This way projects can use the Cflags/Libs without having to know the details. Alternatively they can directly link against the pthread implementation, although that might bring unwarranted overhead. v2: - Remove m4 macro, always use -pthread and document why. - Sort the symbol list, document how it's derived what is allowed and what not. - Rework the README to start from current state of afairs to past ones. - Document platforms that are 'safe' and ones that are not. v3: - Add SVN note about -pthread + Cygwin/mingw/mingw-w64 Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Acked-by: Eric Anholt <eric@anholt.net> Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac60
1 files changed, 30 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac
index ef300ad..09d3b78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,39 +9,39 @@ AC_CONFIG_HEADERS([config.h])
AC_PROG_LIBTOOL
AC_PROG_CC
-
-dnl Detection code for compilers supporting the __attribute__((weak, alias))
-dnl feature. Original code present in unieject's repository
-dnl Diego Pettenò <flameeyes@gentoo.org>
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-AC_CACHE_CHECK([if compiler supports __attribute__((weak, alias))],
- [cc_cv_attribute_alias],
- [AC_COMPILE_IFELSE([
- void other_function(void *foo) { }
- void some_function(void *foo) __attribute__((weak, alias("other_function")));
- ],
- [cc_cv_attribute_alias=yes],
- [cc_cv_attribute_alias=no])
- ])
-CFLAGS="$ac_save_CFLAGS"
-if test "x$cc_cv_attribute_alias" = "xyes"; then
- AC_DEFINE([SUPPORT_ATTRIBUTE_ALIAS], 1, [Define this if the compiler supports the alias attribute])
+dnl Check if the following functions have stubs.
+dnl See the README for specifics about the list.
+funclist="\
+pthread_condattr_destroy \
+pthread_condattr_init \
+pthread_cond_broadcast \
+pthread_cond_destroy \
+pthread_cond_init \
+pthread_cond_signal \
+pthread_cond_timedwait \
+pthread_cond_wait \
+pthread_equal \
+pthread_exit \
+pthread_mutex_destroy \
+pthread_mutex_init \
+pthread_mutex_lock \
+pthread_mutex_unlock \
+pthread_self"
+
+AC_CHECK_FUNCS($funclist, [], [HAVE_STUBS=no])
+
+
+if test "x$HAVE_STUBS" != xno; then
+ PKG_CONFIG_CFLAGS=
+ PKG_CONFIG_LIBS=
+else
+ dnl See the README why '-pthread' is deemed sufficient.
+ PKG_CONFIG_CFLAGS="-pthread"
+ PKG_CONFIG_LIBS="-pthread"
fi
-dnl Grab the list of functions to test for from our template file.
-m4_define([funclist], [])
-m4_define([alias], [m4_if([$1],[na],[], [m4_append([funclist], [$3 ])])])
-m4_divert_push([KILL])
-m4_include([list.m4])
-m4_divert_pop([KILL])
-
-dnl Check which functions we need to provide aliases for.
-PKG_CONFIG_LIBS=
-AC_CHECK_FUNCS(funclist, [], [PKG_CONFIG_LIBS='-L${libdir} -lpthread-stubs'])
-
+AC_SUBST([PKG_CONFIG_CFLAGS])
AC_SUBST([PKG_CONFIG_LIBS])
-AM_CONDITIONAL(BUILD_LIB, test "x$PKG_CONFIG_LIBS" != x)
AC_CONFIG_FILES([Makefile pthread-stubs.pc])
AC_OUTPUT