+2015-02-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ getdtablesize, dup2, fcntl: port to Android
+ Problem reported by Kevin Cernekee in:
+ http://lists.gnu.org/archive/html/bug-gnulib/2015-02/msg00092.html
+ * doc/glibc-functions/getdtablesize.texi (getdtablesize):
+ Mention that getdtablesize doesn't work on Android.
+ * lib/getdtablesize.c: Use getrlimit substitute only if
+ getdtablesize is declared. This should suffice for Cygwin
+ while not breaking Android.
+ * m4/dup2.m4 (gl_FUNC_DUP2):
+ * m4/fcntl.m4 (gl_FUNC_FCNTL):
+ Prefer sysconf (_SC_OPEN_MAX) to getdtablesize, as the former is
+ standardized but the latter is not, and sysconf works on Android.
+ * m4/getdtablesize.m4 (gl_FUNC_GETDTABLESIZE):
+ Also check that getdtablesize is declared.
+ This removes the need for a special case for Android.
+
2015-02-16 Kevin Cernekee <cernekee@google.com>
localename: Implement gl_locale_name_thread_unsafe for Android
@itemize
@item
This function is missing on some platforms:
-mingw, MSVC 9.
+Android LP64, mingw, MSVC 9.
+
+@item
+This function is not declared on some platforms:
+Android LP32.
@item
This function does not represent the true @code{RLIMIT_NOFILE} soft
return dtablesize;
}
-#elif HAVE_GETDTABLESIZE
+#elif HAVE_GETDTABLESIZE && HAVE_DECL_GETDTABLESIZE
# include <sys/resource.h>
# undef getdtablesize
-#serial 20
+#serial 21
dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
- AC_CHECK_FUNCS_ONCE([getdtablesize])
m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
AC_CHECK_FUNCS_ONCE([dup2])
if test $ac_cv_func_dup2 = no; then
[AC_RUN_IFELSE([
AC_LANG_PROGRAM([[#include <unistd.h>
#include <fcntl.h>
+#include <limits.h>
#include <errno.h>]],
[int result = 0;
-#ifdef HAVE_GETDTABLESIZE
- int bad_fd = getdtablesize ();
-#else
- int bad_fd = 1000000;
+ int bad_fd = INT_MAX;
+#ifdef _SC_OPEN_MAX
+ long int open_max = sysconf (_SC_OPEN_MAX);
+ if (0 <= open_max && open_max <= INT_MAX)
+ bad_fd = open_max;
#endif
#ifdef FD_CLOEXEC
if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
-# fcntl.m4 serial 5
+# fcntl.m4 serial 6
dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
- AC_CHECK_FUNCS_ONCE([fcntl getdtablesize])
+ AC_CHECK_FUNCS_ONCE([fcntl])
if test $ac_cv_func_fcntl = no; then
gl_REPLACE_FCNTL
else
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
[gl_cv_func_fcntl_f_dupfd_works],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-#ifdef HAVE_GETDTABLESIZE
-# include <unistd.h>
-#endif
+#include <limits.h>
+#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
]], [[int result = 0;
-#ifdef HAVE_GETDTABLESIZE
- int bad_fd = getdtablesize ();
-#else
- int bad_fd = 1000000;
+ int bad_fd = INT_MAX;
+#ifdef _SC_OPEN_MAX
+ long int open_max = sysconf (_SC_OPEN_MAX);
+ if (0 <= open_max && open_max <= INT_MAX)
+ bad_fd = open_max;
#endif
if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
if (errno != EINVAL) result |= 2;
-# getdtablesize.m4 serial 5
+# getdtablesize.m4 serial 6
dnl Copyright (C) 2008-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_CHECK_FUNCS_ONCE([getdtablesize])
- if test $ac_cv_func_getdtablesize = yes; then
+ AC_CHECK_DECLS_ONCE([getdtablesize])
+ if test $ac_cv_func_getdtablesize = yes &&
+ test $ac_cv_have_decl_getdtablesize = yes; then
# Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
# up to an unchangeable hard limit; all other platforms correctly
# require setrlimit before getdtablesize() can report a larger value.
[gl_cv_func_getdtablesize_works=yes],
[gl_cv_func_getdtablesize_works=no],
[case "$host_os" in
- cygwin*|*-android*)
- # on cygwin 1.5.25, getdtablesize() automatically grows
- # on Android API level >= 21, the declaration is missing from unistd.h
+ cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
gl_cv_func_getdtablesize_works="guessing no" ;;
*) gl_cv_func_getdtablesize_works="guessing yes" ;;
esac])