acinclude.m4 ([GLIBCXX_CHECK_GETTIMEOFDAY]): Change to use GCC_TRY_COMPILE_OR_LINK.

2008-08-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* acinclude.m4 ([GLIBCXX_CHECK_GETTIMEOFDAY]): Change to use
	GCC_TRY_COMPILE_OR_LINK.
	([GLIBCXX_CHECK_CLOCK_GETTIME]): Rename to
	[GLIBCXX_ENABLE_CLOCK_GETTIME], a versatile configure-time option,
	[no] by default, since it includes TRY_LINK checks.  librt is also
	searched, if requested.
	* doc/xml/manual/configure.xml: Document the latter.
	* configure.ac: Move the above checks outside native-only.
	* configure: Regenerate.

From-SVN: r139530
This commit is contained in:
Paolo Carlini 2008-08-24 00:25:22 +00:00 committed by Paolo Carlini
parent 033f28dc65
commit 610870b25a
5 changed files with 1062 additions and 786 deletions

View File

@ -1,3 +1,15 @@
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* acinclude.m4 ([GLIBCXX_CHECK_GETTIMEOFDAY]): Change to use
GCC_TRY_COMPILE_OR_LINK.
([GLIBCXX_CHECK_CLOCK_GETTIME]): Rename to
[GLIBCXX_ENABLE_CLOCK_GETTIME], a versatile configure-time option,
[no] by default, since it includes TRY_LINK checks. librt is also
searched, if requested.
* doc/xml/manual/configure.xml: Document the latter.
* configure.ac: Move the above checks outside native-only.
* configure: Regenerate.
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.

View File

@ -1074,10 +1074,29 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
dnl
dnl Check for IEEE Std 1003.1-2001 clock_gettime required for
dnl 20.8.5 [time.clock] in the current C++0X working draft.
dnl Check for clock_gettime clocks, used in the implementation of 20.8.5
dnl [time.clock] in the current C++0x working draft.
dnl
AC_DEFUN([GLIBCXX_CHECK_CLOCK_GETTIME], [
dnl --enable-clock-gettime
dnl --enable-clock-gettime=yes
dnl checks for the availability of monotonic or realtime clocks
dnl in libc and libposix4
dnl --enable-clock-gettime=rt
dnl searches librt too, and in case of success enables its linking
dnl to libstdc++ as part of the build process. Note that this is
dnl not always desirable because, in glibc, for example, in turn it
dnl triggers automatically the linking of libpthread too, which
dnl activates locking, a large overhead for single-thread programs.
dnl --enable-clock-gettime=no
dnl --disable-clock-gettime
dnl disables the checks completely
dnl
AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
AC_MSG_CHECKING([for clock_gettime clocks])
GLIBCXX_ENABLE(clock-gettime,$1,,
[use KIND for check type],
[permit yes|no|rt])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
@ -1085,45 +1104,53 @@ AC_DEFUN([GLIBCXX_CHECK_CLOCK_GETTIME], [
CXXFLAGS="$CXXFLAGS -fno-exceptions"
ac_save_LIBS="$LIBS"
AC_SEARCH_LIBS(clock_gettime, [posix4])
# Link to -lposix4.
case "$ac_cv_search_clock_gettime" in
-lposix4*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
esac
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
ac_has_clock_monotonic=no;
ac_has_clock_realtime=no;
if test x"$ac_has_unistd_h" = x"yes"; then
AC_MSG_CHECKING([for monotonic clock])
AC_TRY_LINK(
[#include <unistd.h>
#include <time.h>
],
[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
timespec tp;
#endif
clock_gettime(CLOCK_MONOTONIC, &tp);
], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
ac_has_clock_realtime=no;
if test x"$enable_clock_gettime" != x"no"; then
if test x"$enable_clock_gettime" = x"rt"; then
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
else
AC_SEARCH_LIBS(clock_gettime, [posix4])
fi
case "$ac_cv_search_clock_gettime" in
-l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
esac
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
if test x"$ac_has_unistd_h" = x"yes"; then
AC_MSG_CHECKING([for monotonic clock])
AC_TRY_LINK(
[#include <unistd.h>
#include <time.h>
],
[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
timespec tp;
#endif
clock_gettime(CLOCK_MONOTONIC, &tp);
], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
AC_MSG_RESULT($ac_has_clock_monotonic)
AC_MSG_RESULT($ac_has_clock_monotonic)
AC_MSG_CHECKING([for realtime clock])
AC_TRY_LINK(
[#include <unistd.h>
#include <time.h>
],
[#if _POSIX_TIMERS > 0
timespec tp;
#endif
clock_gettime(CLOCK_REALTIME, &tp);
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
AC_MSG_RESULT($ac_has_clock_realtime)
fi
AC_MSG_CHECKING([for realtime clock])
AC_TRY_LINK(
[#include <unistd.h>
#include <time.h>
],
[#if _POSIX_TIMERS > 0
timespec tp;
#endif
clock_gettime(CLOCK_REALTIME, &tp);
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
AC_MSG_RESULT($ac_has_clock_realtime)
fi
fi
if test x"$ac_has_clock_monotonic" = x"yes"; then
AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
[ Defined if clock_gettime has monotonic clock support. ])
@ -1142,11 +1169,13 @@ AC_DEFUN([GLIBCXX_CHECK_CLOCK_GETTIME], [
])
dnl
dnl Check for IEEE Std 1003.1-2001 gettimeofday required for
dnl 20.8.5 [time.clock] in the current C++0X working draft.
dnl Check for gettimeofday, used in the implementation of 20.8.5
dnl [time.clock] in the current C++0x working draft.
dnl
AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
AC_MSG_CHECKING([for gettimeofday])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
@ -1156,7 +1185,7 @@ AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
if test x"$ac_has_sys_time_h" = x"yes"; then
AC_MSG_CHECKING([for gettimeofday])
AC_TRY_LINK([#include <sys/time.h>],
GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
[timeval tv; gettimeofday(&tv, 0);],
[ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])

1686
libstdc++-v3/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -143,6 +143,13 @@ GLIBCXX_CHECK_C99_TR1
# For common values of EOF, SEEK_CUR, SEEK_END.
GLIBCXX_CHECK_STDIO_MACROS
# For gettimeofday support.
GLIBCXX_CHECK_GETTIMEOFDAY
# For clock_gettime support.
# NB: The default is [no], because otherwise it requires linking.
GLIBCXX_ENABLE_CLOCK_GETTIME([no])
AC_LC_MESSAGES
# Check for available headers.
@ -167,12 +174,6 @@ if $GLIBCXX_IS_NATIVE; then
# For dev/random and dev/urandom for TR1.
GLIBCXX_CHECK_RANDOM_TR1
# For clock_gettime support.
GLIBCXX_CHECK_CLOCK_GETTIME
# For gettimeofday support.
GLIBCXX_CHECK_GETTIMEOFDAY
# For TLS support.
GCC_CHECK_TLS

View File

@ -312,7 +312,27 @@
environment.
</para>
</listitem></varlistentry>
<varlistentry><term><code>--enable-clock-gettime</code></term>
<listitem><para>This is an abbreviated form of
<code>'--enable-clock-gettime=yes'</code>(described next).
</para>
</listitem></varlistentry>
<varlistentry><term><code>--enable-clock-gettime=OPTION</code></term>
<listitem><para>Enables checks (link-type too) for the clock_gettime clocks,
used in the implementation [time.clock] in the current C++0x draft.
The choice OPTION=yes checks for the availability of the monotonic and
realtime clocks in libc and libposix4. OPTION=rt searches librt too,
and in case of success enables its linking to libstdc++ as part of the
build process. Note that this is not always desirable because, in
glibc, for example, in turn it triggers automatically the linking of
libpthread too, which activates locking, a large overhead for
single-thread programs. OPTION=no skips the tests completely. The
default is OPTION=no.
</para>
</listitem></varlistentry>
</variablelist>
</sect1>