summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-08-09 22:59:26 +0200
committerBruno Haible <bruno@clisp.org>2020-08-09 22:59:26 +0200
commit444acd314f6c4a1fb7ea7412a54b8ea5fc0ad7c2 (patch)
tree7e9a1f46c8699b65b69facd6f3270d6c8a5fcad4
parentd371c5765e07730b544c5b560f2abd40fb4e64b8 (diff)
downloadgnulib-444acd314f6c4a1fb7ea7412a54b8ea5fc0ad7c2.tar.gz
ftruncate: Use _chsize, not chsize.
* m4/ftruncate.m4 (gl_PREREQ_FTRUNCATE): Test for _chsize, not chsize. * lib/ftruncate.c: Test HAVE__CHSIZE. (chsize_nothrow): Use _chsize, not chsize.
-rw-r--r--ChangeLog7
-rw-r--r--lib/ftruncate.c8
-rw-r--r--m4/ftruncate.m46
3 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 10697a729f..cced35ba8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2020-08-09 Bruno Haible <bruno@clisp.org>
+ ftruncate: Use _chsize, not chsize.
+ * m4/ftruncate.m4 (gl_PREREQ_FTRUNCATE): Test for _chsize, not chsize.
+ * lib/ftruncate.c: Test HAVE__CHSIZE.
+ (chsize_nothrow): Use _chsize, not chsize.
+
+2020-08-09 Bruno Haible <bruno@clisp.org>
+
Silence warnings from clang 10 with -Wimplicit-fallthrough.
* lib/dfa.c (FALLTHROUGH): Use __attribute__ __fallthrough__ also on
clang >= 10.
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 2514075e51..a9b9185f4a 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -19,14 +19,14 @@
/* Specification. */
#include <unistd.h>
-#if HAVE_CHSIZE
+#if HAVE__CHSIZE
/* A native Windows platform. */
# include <errno.h>
# if _GL_WINDOWS_64_BIT_OFF_T
-/* Large File Support: off_t is 64-bit, but chsize() takes only a 32-bit
+/* Large File Support: off_t is 64-bit, but _chsize() takes only a 32-bit
argument. So, define a 64-bit safe SetFileSize function ourselves. */
/* Ensure that <windows.h> declares GetFileSizeEx. */
@@ -170,7 +170,7 @@ chsize_nothrow (int fd, long length)
TRY_MSVC_INVAL
{
- result = chsize (fd, length);
+ result = _chsize (fd, length);
}
CATCH_MSVC_INVAL
{
@@ -182,7 +182,7 @@ chsize_nothrow (int fd, long length)
return result;
}
# else
-# define chsize_nothrow chsize
+# define chsize_nothrow _chsize
# endif
int
diff --git a/m4/ftruncate.m4 b/m4/ftruncate.m4
index 041f542b8e..752b0dd4eb 100644
--- a/m4/ftruncate.m4
+++ b/m4/ftruncate.m4
@@ -1,6 +1,6 @@
-# serial 20
+# serial 21
-# See if we need to emulate a missing ftruncate function using chsize.
+# See if we need to emulate a missing ftruncate function using _chsize.
# Copyright (C) 2000-2001, 2003-2007, 2009-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -36,5 +36,5 @@ AC_DEFUN([gl_FUNC_FTRUNCATE],
# Prerequisites of lib/ftruncate.c.
AC_DEFUN([gl_PREREQ_FTRUNCATE],
[
- AC_CHECK_FUNCS([chsize])
+ AC_CHECK_FUNCS([_chsize])
])