You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB

  1. dnl -*- Autoconf -*-
  2. dnl Copyright (C) 1993-2006 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License. As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
  9. AC_PREREQ(2.57)
  10. AC_DEFUN([CL_TIMES_CLOCK],
  11. [AC_REQUIRE([CL_GETTIMEOFDAY])dnl
  12. if test $ac_cv_func_gettimeofday = no -a $ac_cv_func_ftime = no; then
  13. AC_CHECK_FUNC(times, , no_times=1)dnl
  14. if test -z "$no_times"; then
  15. AC_CACHE_CHECK(for times return value, cl_cv_func_times_return, [
  16. AC_TRY_RUN([
  17. #include <stdlib.h> /* needed for exit() */
  18. #include <sys/types.h>
  19. #include <time.h> /* needed for CLK_TCK */
  20. #ifndef CLK_TCK
  21. #include <sys/time.h> /* needed for CLK_TCK on SYSV PTX */
  22. #endif
  23. #include <sys/times.h>
  24. int main ()
  25. { struct tms buffer;
  26. clock_t result1;
  27. clock_t result2;
  28. int ticks;
  29. result1 = times(&buffer);
  30. if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) exit(1);
  31. sleep(1);
  32. result2 = times(&buffer);
  33. if ((result2 == (clock_t)0) || (result2 == (clock_t)(-1))) exit(1);
  34. ticks = result2 - result1;
  35. exit(!((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2)));
  36. }], cl_cv_func_times_return=yes, cl_cv_func_times_return=no,
  37. dnl When cross-compiling, don't assume anything.
  38. cl_cv_func_times_return="guessing no")
  39. ])
  40. case "$cl_cv_func_times_return" in
  41. *yes) AC_DEFINE(HAVE_TIMES_CLOCK,,[have the times() function and it returns the real time, but do not have the gettimeofday() or ftime() function]) ;;
  42. *no) ;;
  43. esac
  44. fi
  45. fi
  46. ])