summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-01-27 22:03:14 +0100
committerBruno Haible <bruno@clisp.org>2019-01-27 22:06:30 +0100
commitabdbeff397c2176b130367d6f0d47fdc160df30c (patch)
tree73aab1e8c0605d7bb3a7b6d9d11b9f4246e9833f /m4
parent954d1e36aa815994f7f5b1fcd46ebc96a63b8df4 (diff)
downloadgnulib-abdbeff397c2176b130367d6f0d47fdc160df30c.tar.gz
tmpfile: Add support for Android.
* m4/tmpfile.m4 (gl_FUNC_TMPFILE): Add a runtime test whether tmpfile() works. * lib/tmpfile.c (tmpfile): Add an alternative implementation for Android. * modules/tmpfile (Depends-on): Add 'stdbool'. * doc/posix-functions/tmpfile.texi: Mention the Android bug. * modules/argv-iter-tests (Depends-on): Add 'tmpfile'.
Diffstat (limited to 'm4')
-rw-r--r--m4/tmpfile.m440
1 files changed, 32 insertions, 8 deletions
diff --git a/m4/tmpfile.m4 b/m4/tmpfile.m4
index faef23ee22..e648d37986 100644
--- a/m4/tmpfile.m4
+++ b/m4/tmpfile.m4
@@ -1,4 +1,4 @@
-# tmpfile.m4 serial 3
+# tmpfile.m4 serial 4
# Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -18,20 +18,44 @@
# directory, even though tmpfile wouldn't work in general. Instead,
# just test for a Windows platform (excluding Cygwin).
+# On Android 4.3, tmpfile() always returns NULL, even if TMPDIR is set
+# to a writable directory.
+
AC_DEFUN([gl_FUNC_TMPFILE], [
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
- AC_CACHE_CHECK([whether tmpfile should be overridden],
- [gl_cv_func_tmpfile_unusable],
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether tmpfile works],
+ [gl_cv_func_tmpfile_works],
[AC_EGREP_CPP([choke me], [
#if defined _WIN32 && !defined __CYGWIN__
choke me
#endif
],
- [gl_cv_func_tmpfile_unusable=yes],
- [gl_cv_func_tmpfile_unusable=no])])
- if test $gl_cv_func_tmpfile_unusable = yes; then
- REPLACE_TMPFILE=1
- fi
+ [gl_cv_func_tmpfile_works=no],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <stdlib.h>
+int
+main (void)
+{
+ return tmpfile () == NULL;
+}]])],
+ [gl_cv_func_tmpfile_works=yes],
+ [gl_cv_func_tmpfile_works=no],
+ [case "$host_os" in
+ # Guess no on Android.
+ linux*-android*) gl_cv_func_tmpfile_works="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_tmpfile_works="guessing yes" ;;
+ esac
+ ])
+ ])
+ ])
+ case "$gl_cv_func_tmpfile_works" in
+ *yes) ;;
+ *) REPLACE_TMPFILE=1 ;;
+ esac
])
# Prerequisites of lib/tmpfile.c.