1290001Sglebiusdnl ######################################################################
2290001Sglebiusdnl rlimit capabilities checks
3290001SglebiusAC_DEFUN([NTP_RLIMIT_ITEMS], [
4290001Sglebius
5290001SglebiusAC_CACHE_CHECK(
6290001Sglebius    [for RLIMIT_MEMLOCK],
7290001Sglebius    [ntp_cv_rlimit_memlock],
8290001Sglebius    [AC_COMPILE_IFELSE(
9290001Sglebius	[AC_LANG_PROGRAM(
10290001Sglebius	    [[
11290001Sglebius		#ifdef HAVE_SYS_TYPES_H
12290001Sglebius		# include <sys/types.h>
13290001Sglebius		#endif
14290001Sglebius		#ifdef HAVE_SYS_TIME_H
15290001Sglebius		# include <sys/time.h>
16290001Sglebius		#endif
17290001Sglebius		#ifdef HAVE_SYS_RESOURCE_H
18290001Sglebius		# include <sys/resource.h>
19290001Sglebius		#endif
20290001Sglebius	    ]],
21290001Sglebius	    [[
22290001Sglebius		getrlimit(RLIMIT_MEMLOCK, 0);
23290001Sglebius	    ]]
24290001Sglebius	)],
25290001Sglebius	[ntp_cv_rlimit_memlock=yes],
26290001Sglebius	[ntp_cv_rlimit_memlock=no]
27290001Sglebius    )]
28290001Sglebius)
29290001Sglebiuscase "$host" in
30290001Sglebius *-*-*linux*)
31290001Sglebius    ntp_dflt_rlimit_memlock="-1" ;;
32290001Sglebius *) ntp_dflt_rlimit_memlock="32" ;;
33290001Sglebiusesac
34290001Sglebiuscase "$ntp_cv_rlimit_memlock" in
35290001Sglebius yes)
36290001Sglebius    AC_SUBST([HAVE_RLIMIT_MEMLOCK])
37290001Sglebius    HAVE_RLIMIT_MEMLOCK=" memlock $ntp_dflt_rlimit_memlock"  ;;
38290001Sglebiusesac
39290001Sglebius
40290001SglebiusAC_CACHE_CHECK(
41290001Sglebius    [for RLIMIT_STACK],
42290001Sglebius    [ntp_cv_rlimit_stack],
43290001Sglebius    [AC_COMPILE_IFELSE(
44290001Sglebius	[AC_LANG_PROGRAM(
45290001Sglebius	    [[
46290001Sglebius		#ifdef HAVE_SYS_TYPES_H
47290001Sglebius		# include <sys/types.h>
48290001Sglebius		#endif
49290001Sglebius		#ifdef HAVE_SYS_TIME_H
50290001Sglebius		# include <sys/time.h>
51290001Sglebius		#endif
52290001Sglebius		#ifdef HAVE_SYS_RESOURCE_H
53290001Sglebius		# include <sys/resource.h>
54290001Sglebius		#endif
55290001Sglebius	    ]],
56290001Sglebius	    [[
57290001Sglebius		getrlimit(RLIMIT_STACK, 0);
58290001Sglebius	    ]]
59290001Sglebius	)],
60290001Sglebius	[ntp_cv_rlimit_stack=yes],
61290001Sglebius	[ntp_cv_rlimit_stack=no]
62290001Sglebius    )]
63290001Sglebius)
64290001Sglebiuscase "$ntp_cv_rlimit_stack" in
65290001Sglebius yes)
66290001Sglebius    AC_SUBST([HAVE_RLIMIT_STACK])
67290001Sglebius    HAVE_RLIMIT_STACK=" stacksize 50"
68290001Sglebiusesac
69290001Sglebius
70290001Sglebius# HMS: Only if we are doing the MLOCKALL stuff...
71290001SglebiusAC_MSG_CHECKING([for the default number of 4k stack pages])
72290001SglebiusAC_ARG_WITH(
73290001Sglebius    [stack-limit],
74290001Sglebius    [AS_HELP_STRING(
75290001Sglebius	[--with-stack-limit],
76290001Sglebius	[? =50 (200 for openbsd) 4k pages]
77290001Sglebius    )],
78290001Sglebius    [ans=$withval],
79290001Sglebius    [ans=yes]
80290001Sglebius)
81290001Sglebiuscase "$ans" in
82290001Sglebius yes | no)
83290001Sglebius    case "$host" in
84290001Sglebius     *-*-openbsd*)
85290001Sglebius	ans=200
86290001Sglebius	;;
87290001Sglebius     *) ans=50
88290001Sglebius        ;;
89290001Sglebius    esac
90290001Sglebius    ;;
91290001Sglebius [[1-9]][[0-9]]*)
92290001Sglebius    ;;
93290001Sglebius *) AC_MSG_ERROR(["--with-stack-limit requires an integer argument."])
94290001Sglebius    ;;
95290001Sglebiusesac
96290001SglebiusAC_MSG_RESULT([$ans])
97290001SglebiusAC_DEFINE_UNQUOTED([DFLT_RLIMIT_STACK], [$ans],
98290001Sglebius    [Default number of 4k pages for RLIMIT_STACK])
99290001Sglebius
100290001Sglebius# HMS: only if we have RLIMIT_MEMLOCK
101290001SglebiusAC_MSG_CHECKING([for the default number of megabytes to MEMLOCK])
102290001SglebiusAC_ARG_WITH(
103290001Sglebius    [memlock],
104290001Sglebius    [AS_HELP_STRING(
105290001Sglebius	[--with-memlock],
106290001Sglebius	[? =32 (-1 on linux) megabytes]
107290001Sglebius    )],
108290001Sglebius    [ans=$withval],
109290001Sglebius    [ans=yes]
110290001Sglebius)
111290001Sglebiuscase "$ans" in
112290001Sglebius yes | no)
113290001Sglebius    ans=$ntp_dflt_rlimit_memlock
114290001Sglebius    ;;
115290001Sglebius [[1-9]][[0-9]]*) ;;
116290001Sglebius *) AC_MSG_ERROR(["--with-memlock requires an integer argument."])
117290001Sglebius     ;;
118290001Sglebiusesac
119290001SglebiusAC_MSG_RESULT([$ans])
120290001SglebiusAC_DEFINE_UNQUOTED([DFLT_RLIMIT_MEMLOCK], [$ans],
121290001Sglebius    [Default number of megabytes for RLIMIT_MEMLOCK])
122290001Sglebius
123290001Sglebius])dnl
124290001Sglebius
125290001Sglebiusdnl ======================================================================
126