]> jfr.im git - solanum.git/blame - librb/acinclude.m4
librb: Fix GCC 8 warning; 640 bytes should be enough
[solanum.git] / librb / acinclude.m4
CommitLineData
db137867
AC
1AC_DEFUN([AC_DEFINE_DIR], [
2 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
3 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
c74836dc
NPB
4 last_ac_define_dir=`eval echo [$]$2`
5 ac_define_dir=`eval echo [$]last_ac_define_dir`
422cf3bb 6 ac_define_dir_counter=0
c74836dc
NPB
7 while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do
8 last_ac_define_dir="[$]ac_define_dir"
9 ac_define_dir=`eval echo [$]last_ac_define_dir`
422cf3bb
NPB
10 AS_VAR_ARITH([ac_define_dir_counter], [$ac_define_dir_counter + 1])
11 AS_VAR_IF([ac_define_dir_counter], [128],
12 [AC_MSG_ERROR([detected recusive directory expansion when expanding $1=[$]$2: [$]ac_define_dir])
13 break])
c74836dc 14 done
db137867
AC
15 $1="$ac_define_dir"
16 AC_SUBST($1)
17 ifelse($3, ,
18 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
19 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
20])
21
22AC_DEFUN([AC_SUBST_DIR], [
23 ifelse($2,,,$1="[$]$2")
24 $1=`(
25 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
26 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
27 eval echo \""[$]$1"\"
28 )`
29 AC_SUBST($1)
30])
31
32
db137867
AC
33dnl IPv6 support macros..pretty much swiped from wget
34
35dnl RB_PROTO_INET6
c056dba2 36
db137867
AC
37AC_DEFUN([RB_PROTO_INET6],[
38 AC_CACHE_CHECK([for INET6 protocol support], [rb_cv_proto_inet6],[
39 AC_TRY_CPP([
ea83b018 40#ifndef _WIN32
db137867
AC
41#include <sys/types.h>
42#include <sys/socket.h>
ea83b018
AC
43#else
44#include <winsock2.h>
45#include <ws2tcpip.h>
46#endif
db137867
AC
47
48#ifndef PF_INET6
49#error Missing PF_INET6
50#endif
51#ifndef AF_INET6
52#error Mlssing AF_INET6
53#endif
54 ],[
55 rb_cv_proto_inet6=yes
56 ],[
57 rb_cv_proto_inet6=no
58 ])
c056dba2 59 ])
db137867
AC
60
61 if test "X$rb_cv_proto_inet6" = "Xyes"; then :
62 $1
63 else :
c056dba2
MU
64 $2
65 fi
66])
db137867
AC
67
68
69AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[
70 rb_have_sockaddr_in6=
71 AC_CHECK_TYPES([struct sockaddr_in6],[
72 rb_have_sockaddr_in6=yes
73 ],[
74 rb_have_sockaddr_in6=no
75 ],[
71b2af06 76#ifndef _WIN32
db137867
AC
77#include <sys/types.h>
78#include <sys/socket.h>
79#include <netinet/in.h>
71b2af06
AC
80#else
81#include <winsock2.h>
82#include <ws2tcpip.h>
83#endif
db137867
AC
84 ])
85
86 if test "X$rb_have_sockaddr_in6" = "Xyes"; then :
87 $1
88 else :
89 $2
90 fi
91])
92
93
94AC_DEFUN([RB_CHECK_TIMER_CREATE],
c056dba2 95 [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
db137867
AC
96 [rb__cv_timer_create_works],
97 [AC_TRY_RUN([
98#ifdef HAVE_TIME_H
99#include <time.h>
100#endif
101#ifdef HAVE_SIGNAL_H
102#include <signal.h>
103#endif
104#ifdef HAVE_UNISTD_H
105#include <unistd.h>
106#endif
107int main(int argc, char *argv[])
108{
109#if HAVE_TIMER_CREATE
110 struct sigevent ev;
111 timer_t timer;
112 ev.sigev_notify = SIGEV_SIGNAL;
113 ev.sigev_signo = SIGVTALRM;
114 if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
115 return 1;
116 }
117#else
118 return 1;
119#endif
120 return 0;
121}
122 ],
123 [rb__cv_timer_create_works=yes],
498b1893 124 [rb__cv_timer_create_works=no],
db137867
AC
125 [rb__cv_timer_create_works=no])
126 ])
127case $rb__cv_timer_create_works in
c056dba2 128 yes) AC_DEFINE([USE_TIMER_CREATE], 1,
db137867
AC
129 [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
130esac
131])
132
3202e249
VY
133
134
135AC_DEFUN([RB_CHECK_TIMERFD_CREATE],
c056dba2 136 [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)],
3202e249
VY
137 [rb__cv_timerfd_create_works],
138 [AC_TRY_RUN([
139#ifdef HAVE_TIME_H
140#include <time.h>
141#endif
142#ifdef HAVE_SIGNAL_H
143#include <signal.h>
144#endif
145#ifdef HAVE_UNISTD_H
146#include <unistd.h>
147#endif
148#ifdef HAVE_SYS_TIMERFD_H
149#include <sys/timerfd.h>
150#endif
151int main(int argc, char *argv[])
152{
153#if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
154 if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
155 return 1;
156 }
157#else
158 return 1;
159#endif
160 return 0;
161}
162 ],
163 [rb__cv_timerfd_create_works=yes],
498b1893 164 [rb__cv_timerfd_create_works=no],
3202e249
VY
165 [rb__cv_timerfd_create_works=no])
166 ])
167case $rb__cv_timerfd_create_works in
c056dba2 168 yes) AC_DEFINE([USE_TIMERFD_CREATE], 1,
3202e249
VY
169 [Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);;
170esac
171])
172