diff options
| author | Paul Eggert | 2015-03-19 14:14:07 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-03-19 14:18:30 -0700 |
| commit | a68aa2e15be21297d6e8dccb2bcd86422fdebe15 (patch) | |
| tree | fa74a9e62d303f7f8fbb713241e884e4b967be25 | |
| parent | 3ffcf0e3dedb94e065733dc0a5923d7fef42de49 (diff) | |
| download | emacs-a68aa2e15be21297d6e8dccb2bcd86422fdebe15.tar.gz emacs-a68aa2e15be21297d6e8dccb2bcd86422fdebe15.zip | |
Better port of pthread usage to FreeBSD
* configure.ac (ac_func_list): Omit pthread_sigmask, since
we check for that ourselves rather than relying on gnulib.
(HAVE_PTHREAD, LIB_PTHREAD, _THREAD_SAFE): Port better to FreeBSD,
by also checking for pthread_create, pthread_self, pthread_sigmask.
Tighten the test for pthread_atfork while we're at it.
Fixes: bug#20136
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | configure.ac | 87 |
2 files changed, 66 insertions, 29 deletions
| @@ -1,5 +1,13 @@ | |||
| 1 | 2015-03-19 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2015-03-19 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Better port of pthread usage to FreeBSD | ||
| 4 | * configure.ac (ac_func_list): Omit pthread_sigmask, since | ||
| 5 | we check for that ourselves rather than relying on gnulib. | ||
| 6 | (HAVE_PTHREAD, LIB_PTHREAD, _THREAD_SAFE): Port better to FreeBSD, | ||
| 7 | by also checking for pthread_create, pthread_self, pthread_sigmask. | ||
| 8 | Tighten the test for pthread_atfork while we're at it. | ||
| 9 | Fixes: bug#20136 | ||
| 10 | |||
| 3 | Merge from gnulib | 11 | Merge from gnulib |
| 4 | This incorporates: | 12 | This incorporates: |
| 5 | 2015-03-19 fdopendir: port better to MinGW | 13 | 2015-03-19 fdopendir: port better to MinGW |
diff --git a/configure.ac b/configure.ac index d65494ac675..520816b1a61 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -780,6 +780,12 @@ AC_DEFUN([gl_CRYPTO_CHECK]) | |||
| 780 | # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW, | 780 | # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW, |
| 781 | # as we don't use them. | 781 | # as we don't use them. |
| 782 | AC_DEFUN([gl_FCNTL_O_FLAGS]) | 782 | AC_DEFUN([gl_FCNTL_O_FLAGS]) |
| 783 | # Avoid gnulib's test for pthread_sigmask. | ||
| 784 | funcs= | ||
| 785 | for func in $ac_func_list; do | ||
| 786 | test $func = pthread_sigmask || AS_VAR_APPEND([funcs], [" $func"]) | ||
| 787 | done | ||
| 788 | ac_func_list=$funcs | ||
| 783 | # Use the system putenv even if it lacks GNU features, as we don't need them, | 789 | # Use the system putenv even if it lacks GNU features, as we don't need them, |
| 784 | # and the gnulib replacement runs afoul of a FreeBSD 10.1 bug; see Bug#19874. | 790 | # and the gnulib replacement runs afoul of a FreeBSD 10.1 bug; see Bug#19874. |
| 785 | AC_CHECK_FUNCS_ONCE([putenv]) | 791 | AC_CHECK_FUNCS_ONCE([putenv]) |
| @@ -2179,39 +2185,62 @@ AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd") | |||
| 2179 | 2185 | ||
| 2180 | dnl Check for the POSIX thread library. | 2186 | dnl Check for the POSIX thread library. |
| 2181 | LIB_PTHREAD= | 2187 | LIB_PTHREAD= |
| 2182 | if test "$opsys" != "mingw32"; then | ||
| 2183 | AC_CHECK_HEADERS_ONCE(pthread.h) | 2188 | AC_CHECK_HEADERS_ONCE(pthread.h) |
| 2184 | if test "$ac_cv_header_pthread_h"; then | 2189 | if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then |
| 2185 | dnl gmalloc.c uses pthread_atfork, which is not available on older-style | 2190 | AC_CACHE_CHECK([for pthread library], |
| 2186 | dnl hosts such as MirBSD 10, so test for pthread_atfork instead of merely | 2191 | [emacs_cv_pthread_lib], |
| 2187 | dnl testing for pthread_kill if Emacs uses gmalloc.c. | 2192 | [emacs_cv_pthread_lib=no |
| 2188 | if test "$GMALLOC_OBJ" = gmalloc.o; then | 2193 | OLD_CPPFLAGS=$CPPFLAGS |
| 2189 | emacs_pthread_function=pthread_atfork | 2194 | OLD_LIBS=$LIBS |
| 2190 | else | 2195 | for emacs_pthread_lib in 'none needed' -lpthread; do |
| 2191 | emacs_pthread_function=pthread_kill | 2196 | case $emacs_pthread_lib in |
| 2192 | fi | 2197 | -*) LIBS="$OLD_LIBS $emacs_pthread_lib";; |
| 2193 | OLD_LIBS=$LIBS | 2198 | esac |
| 2194 | AC_SEARCH_LIBS([$emacs_pthread_function], [pthread], | 2199 | AC_LINK_IFELSE( |
| 2195 | [AC_DEFINE([HAVE_PTHREAD], [1], | 2200 | [AC_LANG_PROGRAM( |
| 2196 | [Define to 1 if you have pthread (-lpthread).]) | 2201 | [[#include <pthread.h> |
| 2197 | # Some systems optimize for single-threaded programs by default, and | 2202 | #include <signal.h> |
| 2198 | # need special flags to disable these optimizations. For example, the | 2203 | sigset_t old_mask, new_mask; |
| 2199 | # definition of 'errno' in <errno.h>. | 2204 | void noop (void) {}]], |
| 2200 | case $opsys in | 2205 | [[pthread_t th = pthread_self (); |
| 2201 | sol*) | 2206 | int status = 0; |
| 2202 | AC_DEFINE([_REENTRANT], 1, | 2207 | status += pthread_create (&th, 0, 0, 0); |
| 2203 | [Define to 1 if your system requires this in multithreaded code.]);; | 2208 | status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); |
| 2204 | aix4-2) | 2209 | status += pthread_kill (th, 0); |
| 2205 | AC_DEFINE([_THREAD_SAFE], 1, | 2210 | #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \ |
| 2206 | [Define to 1 if your system requires this in multithreaded code.]);; | 2211 | || defined DOUG_LEA_MALLOC) |
| 2207 | esac]) | 2212 | /* Test for pthread_atfork only if gmalloc uses it, |
| 2208 | if test "X$LIBS" != "X$OLD_LIBS"; then | 2213 | as older-style hosts like MirBSD 10 lack it. */ |
| 2209 | eval LIB_PTHREAD=\$ac_cv_search_$emacs_pthread_function | 2214 | status += pthread_atfork (noop, noop, noop); |
| 2215 | #endif | ||
| 2216 | return status;]])], | ||
| 2217 | [emacs_cv_pthread_lib=$emacs_pthread_lib]) | ||
| 2218 | LIBS=$OLD_LIBS | ||
| 2219 | if test "$emacs_cv_pthread_lib" != no; then | ||
| 2220 | break | ||
| 2221 | fi | ||
| 2222 | done | ||
| 2223 | CPPFLAGS=$OLD_CPPFLAGS]) | ||
| 2224 | if test "$emacs_cv_pthread_lib" != no; then | ||
| 2225 | AC_DEFINE([HAVE_PTHREAD], 1, [Define to 1 if you have POSIX threads.]) | ||
| 2226 | case $emacs_cv_pthread_lib in | ||
| 2227 | -*) LIB_PTHREAD=$emacs_cv_pthread_lib;; | ||
| 2228 | esac | ||
| 2229 | ac_cv_func_pthread_sigmask=yes | ||
| 2230 | # Some systems optimize for single-threaded programs by default, and | ||
| 2231 | # need special flags to disable these optimizations. For example, the | ||
| 2232 | # definition of 'errno' in <errno.h>. | ||
| 2233 | case $opsys in | ||
| 2234 | hpux* | sol*) | ||
| 2235 | AC_DEFINE([_REENTRANT], 1, | ||
| 2236 | [Define to 1 if your system requires this in multithreaded code.]);; | ||
| 2237 | aix4-2 | darwin | freebsd) | ||
| 2238 | AC_DEFINE([_THREAD_SAFE], 1, | ||
| 2239 | [Define to 1 if your system requires this in multithreaded code.]);; | ||
| 2240 | esac | ||
| 2210 | fi | 2241 | fi |
| 2211 | LIBS=$OLD_LIBS | ||
| 2212 | fi | 2242 | fi |
| 2213 | AC_SUBST([LIB_PTHREAD]) | 2243 | AC_SUBST([LIB_PTHREAD]) |
| 2214 | fi | ||
| 2215 | 2244 | ||
| 2216 | dnl Check for need for bigtoc support on IBM AIX | 2245 | dnl Check for need for bigtoc support on IBM AIX |
| 2217 | 2246 | ||