configure script will now define HAVE_CLOCK_GETTIME_MONOTONIC symbol only
when function clock_gettime() is available and the monotonic timer is also available. Otherwise, in some cases, librt or libposix4 could be used for linking even when finally not using the clock_gettime() function due to lack of the monotonic clock.
This commit is contained in:
parent
60dd765b3d
commit
ed80eb5b0f
144
acinclude.m4
144
acinclude.m4
@ -1814,29 +1814,16 @@ AC_DEFUN([TYPE_IN_ADDR_T],
|
|||||||
]) dnl AC_CHECK_TYPE
|
]) dnl AC_CHECK_TYPE
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
dnl CURL_CHECK_LIBS_CLOCK_GETTIME
|
dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for libraries needed for clock_gettime,
|
dnl Check if monotonic clock_gettime is available.
|
||||||
dnl and prepended to LIBS any needed libraries.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME], [
|
AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
|
||||||
AC_REQUIRE([AC_HEADER_TIME])dnl
|
AC_REQUIRE([AC_HEADER_TIME])dnl
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
||||||
#
|
AC_MSG_CHECKING([for monotonic clock_gettime])
|
||||||
AC_MSG_CHECKING([for clock_gettime in libraries])
|
AC_COMPILE_IFELSE([
|
||||||
#
|
AC_LANG_PROGRAM([
|
||||||
curl_cv_save_LIBS="$LIBS"
|
|
||||||
curl_cv_gclk_LIBS="unknown"
|
|
||||||
#
|
|
||||||
for x_xlibs in '' '-lrt' '-lposix4' ; do
|
|
||||||
if test -z "$x_xlibs"; then
|
|
||||||
LIBS="$curl_cv_save_LIBS"
|
|
||||||
else
|
|
||||||
LIBS="$x_xlibs $curl_cv_save_LIBS"
|
|
||||||
fi
|
|
||||||
AC_LINK_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([
|
|
||||||
#undef inline
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1850,43 +1837,98 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME], [
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
],[
|
|
||||||
(void)clock_gettime(0, 0);
|
|
||||||
])
|
|
||||||
],[
|
],[
|
||||||
curl_cv_gclk_LIBS="$x_xlibs"
|
struct timespec ts;
|
||||||
break
|
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
])
|
])
|
||||||
done
|
],[
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
ac_cv_func_clock_gettime="no"
|
||||||
|
])
|
||||||
|
dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
|
||||||
|
dnl postponed until library linking checks for clock_gettime pass.
|
||||||
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl If monotonic clock_gettime is available then,
|
||||||
|
dnl check and prepended to LIBS any needed libraries.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
|
||||||
|
AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
|
||||||
#
|
#
|
||||||
LIBS="$curl_cv_save_LIBS"
|
if test "$ac_cv_func_clock_gettime" = "yes"; then
|
||||||
#
|
#
|
||||||
case X-"$curl_cv_gclk_LIBS" in
|
AC_MSG_CHECKING([for clock_gettime in libraries])
|
||||||
X-unknown)
|
#
|
||||||
AC_MSG_RESULT([cannot find clock_gettime])
|
curl_cv_save_LIBS="$LIBS"
|
||||||
ac_cv_func_clock_gettime="no"
|
curl_cv_gclk_LIBS="unknown"
|
||||||
;;
|
#
|
||||||
X-)
|
for x_xlibs in '' '-lrt' '-lposix4' ; do
|
||||||
AC_MSG_RESULT([no additional lib required])
|
if test -z "$x_xlibs"; then
|
||||||
ac_cv_func_clock_gettime="yes"
|
LIBS="$curl_cv_save_LIBS"
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test -z "$curl_cv_save_LIBS"; then
|
|
||||||
LIBS="$curl_cv_gclk_LIBS"
|
|
||||||
else
|
else
|
||||||
LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
|
LIBS="$x_xlibs $curl_cv_save_LIBS"
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$curl_cv_gclk_LIBS])
|
AC_LINK_IFELSE([
|
||||||
ac_cv_func_clock_gettime="yes"
|
AC_LANG_PROGRAM([
|
||||||
;;
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
esac
|
#include <sys/types.h>
|
||||||
#
|
#endif
|
||||||
case "$ac_cv_func_clock_gettime" in
|
#ifdef HAVE_SYS_TIME_H
|
||||||
yes)
|
#include <sys/time.h>
|
||||||
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME, 1,
|
#ifdef TIME_WITH_SYS_TIME
|
||||||
[Define to 1 if you have the clock_gettime function.])
|
#include <time.h>
|
||||||
;;
|
#endif
|
||||||
esac
|
#else
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
],[
|
||||||
|
struct timespec ts;
|
||||||
|
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
])
|
||||||
|
],[
|
||||||
|
curl_cv_gclk_LIBS="$x_xlibs"
|
||||||
|
break
|
||||||
|
])
|
||||||
|
done
|
||||||
|
#
|
||||||
|
LIBS="$curl_cv_save_LIBS"
|
||||||
|
#
|
||||||
|
case X-"$curl_cv_gclk_LIBS" in
|
||||||
|
X-unknown)
|
||||||
|
AC_MSG_RESULT([cannot find clock_gettime])
|
||||||
|
AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
|
||||||
|
ac_cv_func_clock_gettime="no"
|
||||||
|
;;
|
||||||
|
X-)
|
||||||
|
AC_MSG_RESULT([no additional lib required])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if test -z "$curl_cv_save_LIBS"; then
|
||||||
|
LIBS="$curl_cv_gclk_LIBS"
|
||||||
|
else
|
||||||
|
LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([$curl_cv_gclk_LIBS])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#
|
||||||
|
case "$ac_cv_func_clock_gettime" in
|
||||||
|
yes)
|
||||||
|
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
|
||||||
|
[Define to 1 if you have the clock_gettime function and monotonic timer.])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#
|
||||||
|
fi
|
||||||
#
|
#
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
@ -1283,29 +1283,16 @@ AC_DEFUN([TYPE_IN_ADDR_T],
|
|||||||
]) dnl AC_CHECK_TYPE
|
]) dnl AC_CHECK_TYPE
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
dnl CURL_CHECK_LIBS_CLOCK_GETTIME
|
dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for libraries needed for clock_gettime,
|
dnl Check if monotonic clock_gettime is available.
|
||||||
dnl and prepended to LIBS any needed libraries.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME], [
|
AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
|
||||||
AC_REQUIRE([AC_HEADER_TIME])dnl
|
AC_REQUIRE([AC_HEADER_TIME])dnl
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
||||||
#
|
AC_MSG_CHECKING([for monotonic clock_gettime])
|
||||||
AC_MSG_CHECKING([for clock_gettime in libraries])
|
AC_COMPILE_IFELSE([
|
||||||
#
|
AC_LANG_PROGRAM([
|
||||||
curl_cv_save_LIBS="$LIBS"
|
|
||||||
curl_cv_gclk_LIBS="unknown"
|
|
||||||
#
|
|
||||||
for x_xlibs in '' '-lrt' '-lposix4' ; do
|
|
||||||
if test -z "$x_xlibs"; then
|
|
||||||
LIBS="$curl_cv_save_LIBS"
|
|
||||||
else
|
|
||||||
LIBS="$x_xlibs $curl_cv_save_LIBS"
|
|
||||||
fi
|
|
||||||
AC_LINK_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([
|
|
||||||
#undef inline
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1319,43 +1306,98 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME], [
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
],[
|
|
||||||
(void)clock_gettime(0, 0);
|
|
||||||
])
|
|
||||||
],[
|
],[
|
||||||
curl_cv_gclk_LIBS="$x_xlibs"
|
struct timespec ts;
|
||||||
break
|
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
])
|
])
|
||||||
done
|
],[
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
ac_cv_func_clock_gettime="no"
|
||||||
|
])
|
||||||
|
dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
|
||||||
|
dnl postponed until library linking checks for clock_gettime pass.
|
||||||
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl If monotonic clock_gettime is available then,
|
||||||
|
dnl check and prepended to LIBS any needed libraries.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
|
||||||
|
AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
|
||||||
#
|
#
|
||||||
LIBS="$curl_cv_save_LIBS"
|
if test "$ac_cv_func_clock_gettime" = "yes"; then
|
||||||
#
|
#
|
||||||
case X-"$curl_cv_gclk_LIBS" in
|
AC_MSG_CHECKING([for clock_gettime in libraries])
|
||||||
X-unknown)
|
#
|
||||||
AC_MSG_RESULT([cannot find clock_gettime])
|
curl_cv_save_LIBS="$LIBS"
|
||||||
ac_cv_func_clock_gettime="no"
|
curl_cv_gclk_LIBS="unknown"
|
||||||
;;
|
#
|
||||||
X-)
|
for x_xlibs in '' '-lrt' '-lposix4' ; do
|
||||||
AC_MSG_RESULT([no additional lib required])
|
if test -z "$x_xlibs"; then
|
||||||
ac_cv_func_clock_gettime="yes"
|
LIBS="$curl_cv_save_LIBS"
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test -z "$curl_cv_save_LIBS"; then
|
|
||||||
LIBS="$curl_cv_gclk_LIBS"
|
|
||||||
else
|
else
|
||||||
LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
|
LIBS="$x_xlibs $curl_cv_save_LIBS"
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$curl_cv_gclk_LIBS])
|
AC_LINK_IFELSE([
|
||||||
ac_cv_func_clock_gettime="yes"
|
AC_LANG_PROGRAM([
|
||||||
;;
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
esac
|
#include <sys/types.h>
|
||||||
#
|
#endif
|
||||||
case "$ac_cv_func_clock_gettime" in
|
#ifdef HAVE_SYS_TIME_H
|
||||||
yes)
|
#include <sys/time.h>
|
||||||
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME, 1,
|
#ifdef TIME_WITH_SYS_TIME
|
||||||
[Define to 1 if you have the clock_gettime function.])
|
#include <time.h>
|
||||||
;;
|
#endif
|
||||||
esac
|
#else
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
],[
|
||||||
|
struct timespec ts;
|
||||||
|
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
])
|
||||||
|
],[
|
||||||
|
curl_cv_gclk_LIBS="$x_xlibs"
|
||||||
|
break
|
||||||
|
])
|
||||||
|
done
|
||||||
|
#
|
||||||
|
LIBS="$curl_cv_save_LIBS"
|
||||||
|
#
|
||||||
|
case X-"$curl_cv_gclk_LIBS" in
|
||||||
|
X-unknown)
|
||||||
|
AC_MSG_RESULT([cannot find clock_gettime])
|
||||||
|
AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
|
||||||
|
ac_cv_func_clock_gettime="no"
|
||||||
|
;;
|
||||||
|
X-)
|
||||||
|
AC_MSG_RESULT([no additional lib required])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if test -z "$curl_cv_save_LIBS"; then
|
||||||
|
LIBS="$curl_cv_gclk_LIBS"
|
||||||
|
else
|
||||||
|
LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([$curl_cv_gclk_LIBS])
|
||||||
|
ac_cv_func_clock_gettime="yes"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#
|
||||||
|
case "$ac_cv_func_clock_gettime" in
|
||||||
|
yes)
|
||||||
|
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
|
||||||
|
[Define to 1 if you have the clock_gettime function and monotonic timer.])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#
|
||||||
|
fi
|
||||||
#
|
#
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ struct timeval ares__tvnow(void)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
||||||
|
|
||||||
struct timeval ares__tvnow(void)
|
struct timeval ares__tvnow(void)
|
||||||
{
|
{
|
||||||
|
@ -261,9 +261,10 @@ dnl socket lib?
|
|||||||
AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
|
AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
|
||||||
|
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
dnl Check for libraries needed for function clock_gettime
|
dnl In case that function clock_gettime with monotonic timer is available,
|
||||||
|
dnl check for additional required libraries.
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
CURL_CHECK_LIBS_CLOCK_GETTIME
|
CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether to use libgcc])
|
AC_MSG_CHECKING([whether to use libgcc])
|
||||||
AC_ARG_ENABLE(libgcc,
|
AC_ARG_ENABLE(libgcc,
|
||||||
|
@ -568,9 +568,10 @@ dnl socket lib?
|
|||||||
AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
|
AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
|
||||||
|
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
dnl Check for libraries needed for function clock_gettime
|
dnl In case that function clock_gettime with monotonic timer is available,
|
||||||
|
dnl check for additional required libraries.
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
CURL_CHECK_LIBS_CLOCK_GETTIME
|
CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
|
||||||
|
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
dnl The preceding library checks are all potentially useful for test
|
dnl The preceding library checks are all potentially useful for test
|
||||||
|
@ -39,7 +39,7 @@ struct timeval curlx_tvnow(void)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
||||||
|
|
||||||
struct timeval curlx_tvnow(void)
|
struct timeval curlx_tvnow(void)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ struct timeval cutil_tvnow(void)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
||||||
|
|
||||||
struct timeval cutil_tvnow(void)
|
struct timeval cutil_tvnow(void)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ struct timeval tutil_tvnow(void)
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
||||||
|
|
||||||
struct timeval tutil_tvnow(void)
|
struct timeval tutil_tvnow(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user