Hash :
5d91e956
Author :
Date :
2011-09-25T14:10:58
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/* ftruncate emulations for native Windows.
This file is in the public domain. */
#include <config.h>
/* Specification. */
#include <unistd.h>
#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)
{
return chsize (fd, length);
}
#endif