bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ftruncate: Use _chsize, not chsize


From: Bruno Haible
Subject: ftruncate: Use _chsize, not chsize
Date: Sun, 09 Aug 2020 23:00:04 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

With clang, on native Windows, the function 'chsize' is not present any more.
This matches the deprecation of this spelling by Microsoft
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-chsize>.


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.

diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 2514075..a9b9185 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 041f542..752b0dd 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])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]