Commit a0f15cb0 authored by Bruno Haible's avatar Bruno Haible

truncate: Fix compilation error on Android.

* m4/truncate.m4 (gl_FUNC_TRUNCATE): Test also whether 'truncate' is
declared. Set HAVE_DECL_TRUNCATE, not HAVE_TRUNCATE.
* lib/unistd.in.h (truncate): Test HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* modules/truncate: Likewise.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_TRUNCATE,
not HAVE_TRUNCATE.
* modules/unistd (Makefile.am): Substitute HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* doc/posix-functions/truncate.texi: Mention the issue.
parent d1c1f3ae
2018-05-13 Bruno Haible <bruno@clisp.org>
truncate: Fix compilation error on Android.
* m4/truncate.m4 (gl_FUNC_TRUNCATE): Test also whether 'truncate' is
declared. Set HAVE_DECL_TRUNCATE, not HAVE_TRUNCATE.
* lib/unistd.in.h (truncate): Test HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* modules/truncate: Likewise.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_TRUNCATE,
not HAVE_TRUNCATE.
* modules/unistd (Makefile.am): Substitute HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* doc/posix-functions/truncate.texi: Mention the issue.
2018-05-13 Bruno Haible <bruno@clisp.org>
pthread: Fix compilation error on Android.
......@@ -10,7 +10,7 @@ Portability problems fixed by Gnulib:
@itemize
@item
This function is missing on some platforms:
mingw, MSVC 14.
mingw, MSVC 14, Android 4.4 with @code{AC_SYS_LARGEFILE} in effect.
@item
On platforms where @code{off_t} is a 32-bit type, this function is not
applicable to arbitrary lengths for files larger than 2 GB. The fix is to
......
......@@ -1489,7 +1489,7 @@ _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
# else
# if !@HAVE_TRUNCATE@
# if !@HAVE_DECL_TRUNCATE@
_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
_GL_ARG_NONNULL ((1)));
# endif
......
# truncate.m4 serial 1 -*- Autoconf -*-
# truncate.m4 serial 2 -*- Autoconf -*-
dnl Copyright (C) 2017-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -8,7 +8,12 @@ AC_DEFUN([gl_FUNC_TRUNCATE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([truncate])
if test $ac_cv_func_truncate = yes; then
dnl AC_CHECK_FUNC is not enough here, because when compiling for Android 4.4
dnl or older with _FILE_OFFSET_BITS=64, truncate() is not declared. There
dnl is a function 'truncate' in libc, but it is unsuitable, because it takes
dnl only a 32-bit offset argument.
AC_CHECK_DECL([truncate], , , [[#include <unistd.h>]])
if test $ac_cv_have_decl_truncate = yes; then
m4_ifdef([gl_LARGEFILE], [
AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
......@@ -25,7 +30,11 @@ AC_DEFUN([gl_FUNC_TRUNCATE],
:
])
else
HAVE_TRUNCATE=0
HAVE_DECL_TRUNCATE=0
if test $ac_cv_func_truncate = yes; then
dnl Avoid a conflict with the 'truncate' in libc.
REPLACE_TRUNCATE=1
fi
fi
])
......
# unistd_h.m4 serial 72
# unistd_h.m4 serial 73
dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -140,7 +140,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
HAVE_TRUNCATE=1; AC_SUBST([HAVE_TRUNCATE])
HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
......@@ -152,6 +151,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE])
HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
......
......@@ -9,12 +9,12 @@ Depends-on:
unistd
sys_types
largefile
open [test $HAVE_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1]
ftruncate [test $HAVE_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1]
open [test $HAVE_DECL_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1]
ftruncate [test $HAVE_DECL_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1]
configure.ac:
gl_FUNC_TRUNCATE
if test $HAVE_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1; then
if test $HAVE_DECL_TRUNCATE = 0 || test $REPLACE_TRUNCATE = 1; then
AC_LIBOBJ([truncate])
gl_PREREQ_TRUNCATE
fi
......
......@@ -115,7 +115,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
-e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
-e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
-e 's|@''HAVE_TRUNCATE''@|$(HAVE_TRUNCATE)|g' \
-e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
-e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
......@@ -127,6 +126,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
-e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
-e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
-e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment