]> Savannah Git Hosting - gnulib.git/commitdiff
ftruncate: Support for MSVC 9.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Sep 2011 12:10:58 +0000 (14:10 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Sep 2011 12:10:58 +0000 (14:10 +0200)
* lib/ftruncate.c: Include errno.h, msvc-inval.h.
(chsize_nothrow): New function.
(chsize): Redefine as a macro.
* m4/ftruncate.m4 (gl_PREREQ_FTRUNCATE): Require AC_C_INLINE.
* modules/ftruncate (Depends-on): Add msvc-inval.

ChangeLog
lib/ftruncate.c
m4/ftruncate.m4
modules/ftruncate

index c7bc060ee7047e50b9df9401ff5e55c0c3d1d7ea..12ef00a68b9e7411db4a49372fbec4ade6e5432d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-09-25  Bruno Haible  <bruno@clisp.org>
+
+       ftruncate: Support for MSVC 9.
+       * lib/ftruncate.c: Include errno.h, msvc-inval.h.
+       (chsize_nothrow): New function.
+       (chsize): Redefine as a macro.
+       * m4/ftruncate.m4 (gl_PREREQ_FTRUNCATE): Require AC_C_INLINE.
+       * modules/ftruncate (Depends-on): Add msvc-inval.
+
 2011-09-25  Bruno Haible  <bruno@clisp.org>
 
        New module 'fstat'.
index d5a3be144c6393e5c250f48b1a2ed89f78bf15eb..ae1e85890c23956f2aab5a2362665599b8fdea5d 100644 (file)
@@ -8,8 +8,32 @@
 
 #if HAVE_CHSIZE
 
+# include <errno.h>
 # include <io.h>
 
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+#  include "msvc-inval.h"
+static inline int
+chsize_nothrow (int fd, long length)
+{
+  int result;
+
+  TRY_MSVC_INVAL
+    {
+      result = chsize (fd, length);
+    }
+  CATCH_MSVC_INVAL
+    {
+      result = -1;
+      errno = EBADF;
+    }
+  DONE_MSVC_INVAL;
+
+  return result;
+}
+#  define chsize chsize_nothrow
+# endif
+
 int
 ftruncate (int fd, off_t length)
 {
index 42730907a66115906022a6123ebeebcca8202ac8..4a47ba4297a1f020c97392f9deef233e357f1cc0 100644 (file)
@@ -1,4 +1,4 @@
-# serial 17
+# serial 18
 
 # See if we need to emulate a missing ftruncate function using chsize.
 
@@ -19,5 +19,6 @@ AC_DEFUN([gl_FUNC_FTRUNCATE],
 # Prerequisites of lib/ftruncate.c.
 AC_DEFUN([gl_PREREQ_FTRUNCATE],
 [
+  AC_REQUIRE([AC_C_INLINE])
   AC_CHECK_FUNCS([chsize])
 ])
index 3bea20be3b06edd5a0fbfa8cc60371e305e780fd..097ed9c770817c18f4ab8389a3f49c5e4ffeb07b 100644 (file)
@@ -8,6 +8,7 @@ m4/ftruncate.m4
 Depends-on:
 unistd
 largefile
+msvc-inval      [test $HAVE_FTRUNCATE = 0]
 
 configure.ac:
 gl_FUNC_FTRUNCATE