xref: /freebsd/contrib/ntp/sntp/m4/ntp_rlimit.m4 (revision 4436b51dff5736e74da464946049ea6899a88938)
1dnl ######################################################################
2dnl rlimit capabilities checks
3AC_DEFUN([NTP_RLIMIT_ITEMS], [
4
5AC_CACHE_CHECK(
6    [for RLIMIT_MEMLOCK],
7    [ntp_cv_rlimit_memlock],
8    [AC_COMPILE_IFELSE(
9	[AC_LANG_PROGRAM(
10	    [[
11		#ifdef HAVE_SYS_TYPES_H
12		# include <sys/types.h>
13		#endif
14		#ifdef HAVE_SYS_TIME_H
15		# include <sys/time.h>
16		#endif
17		#ifdef HAVE_SYS_RESOURCE_H
18		# include <sys/resource.h>
19		#endif
20	    ]],
21	    [[
22		getrlimit(RLIMIT_MEMLOCK, 0);
23	    ]]
24	)],
25	[ntp_cv_rlimit_memlock=yes],
26	[ntp_cv_rlimit_memlock=no]
27    )]
28)
29case "$ntp_cv_rlimit_memlock" in
30 yes)
31    AC_SUBST([HAVE_RLIMIT_MEMLOCK])
32    HAVE_RLIMIT_MEMLOCK=" memlock 32"
33esac
34
35AC_CACHE_CHECK(
36    [for RLIMIT_STACK],
37    [ntp_cv_rlimit_stack],
38    [AC_COMPILE_IFELSE(
39	[AC_LANG_PROGRAM(
40	    [[
41		#ifdef HAVE_SYS_TYPES_H
42		# include <sys/types.h>
43		#endif
44		#ifdef HAVE_SYS_TIME_H
45		# include <sys/time.h>
46		#endif
47		#ifdef HAVE_SYS_RESOURCE_H
48		# include <sys/resource.h>
49		#endif
50	    ]],
51	    [[
52		getrlimit(RLIMIT_STACK, 0);
53	    ]]
54	)],
55	[ntp_cv_rlimit_stack=yes],
56	[ntp_cv_rlimit_stack=no]
57    )]
58)
59case "$ntp_cv_rlimit_stack" in
60 yes)
61    AC_SUBST([HAVE_RLIMIT_STACK])
62    HAVE_RLIMIT_STACK=" stacksize 50"
63esac
64
65])dnl
66dnl ======================================================================
67