1 # getdtablesize.m4 serial 6
2 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_GETDTABLESIZE],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
12 AC_CHECK_DECLS_ONCE([getdtablesize])
13 if test $ac_cv_func_getdtablesize = yes &&
14 test $ac_cv_have_decl_getdtablesize = yes; then
15 # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
16 # up to an unchangeable hard limit; all other platforms correctly
17 # require setrlimit before getdtablesize() can report a larger value.
18 AC_CACHE_CHECK([whether getdtablesize works],
19 [gl_cv_func_getdtablesize_works],
21 AC_LANG_PROGRAM([[#include <unistd.h>]],
22 [int size = getdtablesize();
23 if (dup2 (0, getdtablesize()) != -1)
25 if (size != getdtablesize())
28 [gl_cv_func_getdtablesize_works=yes],
29 [gl_cv_func_getdtablesize_works=no],
31 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
32 gl_cv_func_getdtablesize_works="guessing no" ;;
33 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
36 case "$gl_cv_func_getdtablesize_works" in
38 *) REPLACE_GETDTABLESIZE=1 ;;
45 # Prerequisites of lib/getdtablesize.c.
46 AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])