[libvirt] [PATCH 2/5] build: replace redundant header check with function check

Jim Meyering jim at meyering.net
Thu Apr 29 09:23:39 UTC 2010


Eric Blake wrote:
> Gnulib guarantees that pthread.h exists, but for now, it is a dummy
> header with no support for most pthread_* functions.  Modify our
> use of pthread to use function checks, rather than header checks,
> to determine how much pthread support is present.
>
> * configure.ac: Optimize function checks.  Add check for pthread
> functions.
> * src/remote/remote_driver.c (remoteIOEventLoop): Depend on
> pthread_sigmask, now that gnulib guarantees pthread.h.
> * src/util/util.c (virFork): Likewise.
> * src/util/threads.c (threads-pthread.c): Depend on
> pthread_mutexattr_init, as a witness of full pthread support.
> * src/util/threads.h (threads-pthread.h): Likewise.
> ---
>  configure.ac               |   13 +++++++++++--
>  src/remote/remote_driver.c |    6 +++---
>  src/util/threads.c         |    4 ++--
>  src/util/threads.h         |    4 ++--
>  src/util/util.c            |   10 +++++-----
>  5 files changed, 23 insertions(+), 14 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index cfefc02..b5ff348 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -107,10 +107,19 @@ dnl Use --disable-largefile if you don't want this.
>  AC_SYS_LARGEFILE
>
>  dnl Availability of various common functions (non-fatal if missing).
> -AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid posix_fallocate mmap])
> +AC_CHECK_FUNCS_ONCE([cfmakeraw regexec uname sched_getaffinity getuid getgid \
> + posix_fallocate mmap])
>
>  dnl Availability of various not common threadsafe functions
> -AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r])
> +AC_CHECK_FUNCS_ONCE([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r])
> +
> +dnl Availability of pthread functions (if missing, win32 threading is
> +dnl assumed).  Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
> +dnl LIB_PTHREAD was set during gl_INIT by gnulib.
> +old_LIBS=$LIBS
> +LIBS="$LIBS $LIB_PTHREAD"
> +AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
> +LIBS=$old_libs
>
>  dnl Availability of various common headers (non-fatal if missing).
>  AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h \
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 1917f26..b798cdf 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -9487,7 +9487,7 @@ remoteIOEventLoop(virConnectPtr conn,
>          struct remote_thread_call *tmp = priv->waitDispatch;
>          struct remote_thread_call *prev;
>          char ignore;
> -#ifdef HAVE_PTHREAD_H
> +#ifdef HAVE_PTHREAD_SIGMASK

Good change.
This more in the spirit of the Autoconf Way.

ACK.




More information about the libvir-list mailing list