Blame m4/librt_timers.m4

Packit 0b5880
# HW_HEADER_TIME_H
Packit 0b5880
# ------------------
Packit 0b5880
# Define HAVE_TIME_H to 1 if <time.h> is available.
Packit 0b5880
AC_DEFUN([HW_HEADER_TIME_H],
Packit 0b5880
[
Packit 0b5880
  AC_PREREQ([2.60])dnl Older releases should work if AC_CHECK_HEADERS is used.
Packit 0b5880
  AC_CHECK_HEADERS_ONCE([time.h])
Packit 0b5880
])# HW_HEADER_TIME_H
Packit 0b5880
Packit 0b5880
# HW_LIBRT_TIMERS
Packit 0b5880
# -----------------
Packit 0b5880
# Set $hw_cv_librt_timers and $hw_cv_librt_timers_posix to "yes" or "no",
Packit 0b5880
# respectively.  If the timer_create() function is available and
Packit 0b5880
# POSIX compliant, then the system's timer_create(), timer_settime(),
Packit 0b5880
# and timer_delete() functions are used. Otherwise, make sure
Packit 0b5880
# the replacement functions will be built.
Packit 0b5880
#
Packit 0b5880
# In the case where we are cross compiling, the POSIX detection of
Packit 0b5880
# the timer_create() function is skipped, and instead the usual check
Packit 0b5880
# for the existence of all the timer_* functions is done using
Packit 0b5880
# AC_REPLACE_FUNCS.
Packit 0b5880
#
Packit 0b5880
# If enable_timer_replacement=true, the replacements is forced to be built.
Packit 0b5880
AC_DEFUN([HW_LIBRT_TIMERS],
Packit 0b5880
[
Packit 0b5880
  AC_PREREQ([2.60])dnl 2.59 should work if some AC_TYPE_* macros are replaced.
Packit 0b5880
  AC_REQUIRE([HW_HEADER_TIME_H])dnl Our check evaluates HAVE_TIME_H.
Packit 0b5880
Packit 0b5880
  if test "xtrue" != x"$enable_timer_replacement"; then
Packit 0b5880
	  AC_CHECK_FUNC([timer_create],
Packit 0b5880
		[hw_cv_librt_timers=yes],
Packit 0b5880
		[hw_cv_librt_timers=no])
Packit 0b5880
	  AS_IF([test "$hw_cv_librt_timers" = yes],
Packit 0b5880
		[AC_CACHE_CHECK([if timer_create is supported on the system],
Packit 0b5880
		  [hw_cv_librt_timers_posix],
Packit 0b5880
		  [AC_RUN_IFELSE(
Packit 0b5880
			[AC_LANG_PROGRAM(
Packit 0b5880
			  [[#if HAVE_TIME_H
Packit 0b5880
			  #include <time.h>
Packit 0b5880
			  #endif
Packit 0b5880
              #include <errno.h>
Packit 0b5880
			  static int test_timer_create()
Packit 0b5880
			  {
Packit 0b5880
                timer_t timerid;
Packit 0b5880
                if(timer_create(CLOCK_REALTIME, NULL, &timerid) != 0)
Packit 0b5880
                {
Packit 0b5880
                    /* 
Packit 0b5880
                      On this system, although the function is available,
Packit 0b5880
                      no meaningful implementation is provided.
Packit 0b5880
                    */
Packit 0b5880
                    if(errno == ENOSYS)
Packit 0b5880
                    {
Packit 0b5880
                        return 1;
Packit 0b5880
                    }
Packit 0b5880
                }
Packit 0b5880
                return 0;
Packit 0b5880
			  }]],
Packit 0b5880
			  [[return test_timer_create();]])],
Packit 0b5880
			[hw_cv_librt_timers_posix=yes],
Packit 0b5880
			[hw_cv_librt_timers_posix=no],
Packit 0b5880
			[hw_cv_librt_timers_posix=autodetect])])],
Packit 0b5880
		[hw_cv_librt_timers_posix=no])
Packit 0b5880
  else
Packit 0b5880
      hw_cv_librt_timers_posix=no
Packit 0b5880
  fi
Packit 0b5880
Packit 0b5880
  # If the system does not have a POSIX timer_create(), then use
Packit 0b5880
  # Check's reimplementation of the timer_* calls
Packit 0b5880
  AS_IF([test "$hw_cv_librt_timers_posix" = no],
Packit 0b5880
    [_HW_LIBRT_TIMERS_REPLACE])
Packit 0b5880
Packit 0b5880
  # If we are cross compiling, do the normal check for the
Packit 0b5880
  # timer_* calls.
Packit 0b5880
  AS_IF([test "$hw_cv_librt_timers_posix" = autodetect],
Packit 0b5880
    [AC_REPLACE_FUNCS([timer_create timer_settime timer_delete])
Packit 0b5880
     AC_CHECK_DECLS([timer_create, timer_settime, timer_delete])])
Packit 0b5880
])# HW_LIBRT_TIMERS
Packit 0b5880
Packit 0b5880
# _HW_LIBRT_TIMERS_REPLACE
Packit 0b5880
# ------------------------
Packit 0b5880
# Arrange for building timer_create.c, timer_settime.c, and
Packit 0b5880
# timer_delete.c.
Packit 0b5880
AC_DEFUN([_HW_LIBRT_TIMERS_REPLACE],
Packit 0b5880
[
Packit 0b5880
  AS_IF([test "x$_hw_cv_librt_timers_replace_done" != xyes],
Packit 0b5880
    [AC_LIBOBJ([timer_create])
Packit 0b5880
     AC_LIBOBJ([timer_settime])
Packit 0b5880
     AC_LIBOBJ([timer_delete])
Packit 0b5880
    _hw_cv_librt_timers_replace_done=yes])
Packit 0b5880
])# _HW_LIBRT_TIMERS_REPLACE