Debian Codegraph @

m4/librt_timers.m4

raw
1 # HW_HEADER_TIME_H
2 # ------------------
3 # Define HAVE_TIME_H to 1 if <time.h> is available.
4 AC_DEFUN([HW_HEADER_TIME_H],
5 [
6 AC_PREREQ([2.60])dnl Older releases should work if AC_CHECK_HEADERS is used.
7 AC_CHECK_HEADERS_ONCE([time.h])
8 ])# HW_HEADER_TIME_H
9
10 # HW_LIBRT_TIMERS
11 # -----------------
12 # Set $hw_cv_librt_timers and $hw_cv_librt_timers_posix to "yes" or "no",
13 # respectively. If the timer_create() function is available and
14 # POSIX compliant, then the system's timer_create(), timer_settime(),
15 # and timer_delete() functions are used. Otherwise, make sure
16 # the replacement functions will be built.
17 #
18 # In the case where we are cross compiling, the POSIX detection of
19 # the timer_create() function is skipped, and instead the usual check
20 # for the existence of all the timer_* functions is done using
21 # AC_REPLACE_FUNCS.
22 #
23 # If enable_timer_replacement=true, the replacements is forced to be built.
24 AC_DEFUN([HW_LIBRT_TIMERS],
25 [
26 AC_PREREQ([2.60])dnl 2.59 should work if some AC_TYPE_* macros are replaced.
27 AC_REQUIRE([HW_HEADER_TIME_H])dnl Our check evaluates HAVE_TIME_H.
28
29 if test "xtrue" != x"$enable_timer_replacement"; then
30 AC_CHECK_FUNC([timer_create],
31 [hw_cv_librt_timers=yes],
32 [hw_cv_librt_timers=no])
33 AS_IF([test "$hw_cv_librt_timers" = yes],
34 [AC_CACHE_CHECK([if timer_create is supported on the system],
35 [hw_cv_librt_timers_posix],
36 [AC_RUN_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#if HAVE_TIME_H
39 #include <time.h>
40 #endif
41 #include <errno.h>
42 static int test_timer_create()
43 {
44 timer_t timerid;
45 if(timer_create(CLOCK_REALTIME, NULL, &timerid) != 0)
46 {
47 /*
48 On this system, although the function is available,
49 no meaningful implementation is provided.
50 */
51 if(errno == ENOSYS)
52 {
53 return 1;
54 }
55 }
56 return 0;
57 }]],
58 [[return test_timer_create();]])],
59 [hw_cv_librt_timers_posix=yes],
60 [hw_cv_librt_timers_posix=no],
61 [hw_cv_librt_timers_posix=autodetect])])],
62 [hw_cv_librt_timers_posix=no])
63 else
64 hw_cv_librt_timers_posix=no
65 fi
66
67 # If the system does not have a POSIX timer_create(), then use
68 # Check's reimplementation of the timer_* calls
69 AS_IF([test "$hw_cv_librt_timers_posix" = no],
70 [_HW_LIBRT_TIMERS_REPLACE])
71
72 # If we are cross compiling, do the normal check for the
73 # timer_* calls.
74 AS_IF([test "$hw_cv_librt_timers_posix" = autodetect],
75 [AC_REPLACE_FUNCS([timer_create timer_settime timer_delete])
76 AC_CHECK_DECLS([timer_create, timer_settime, timer_delete])])
77 ])# HW_LIBRT_TIMERS
78
79 # _HW_LIBRT_TIMERS_REPLACE
80 # ------------------------
81 # Arrange for building timer_create.c, timer_settime.c, and
82 # timer_delete.c.
83 AC_DEFUN([_HW_LIBRT_TIMERS_REPLACE],
84 [
85 AS_IF([test "x$_hw_cv_librt_timers_replace_done" != xyes],
86 [AC_LIBOBJ([timer_create])
87 AC_LIBOBJ([timer_settime])
88 AC_LIBOBJ([timer_delete])
89 _hw_cv_librt_timers_replace_done=yes])
90 ])# _HW_LIBRT_TIMERS_REPLACE