nasmlib/file.c: Windows _chsize_s() *returns* errno

_chsize_s(), but not _chsize(), actually *returns* errno rather than
setting errno; create a wrapper routine to make it match the other
nasm_ftruncate() varieties.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2016-05-10 15:14:30 -07:00
parent 6503051dcc
commit 55e51d9534

View File

@ -60,7 +60,17 @@
/* Can we adjust the file size without actually writing all the bytes? */
#ifdef HAVE_FILENO /* Useless without fileno() */
# ifdef HAVE__CHSIZE_S
# define nasm_ftruncate(fd,size) _chsize_s(fd,size)
static int nasm_ftruncate(int fd, int64_t size)
{
int err = _chsize_s(fd, size);
if (!err)
return 0;
errno = err;
return -1;
}
# define nasm_ftruncate(fd,size) nasm_ftruncate(fd,size)
# elif defined(HAVE__CHSIZE)
# define nasm_ftruncate(fd,size) _chsize(fd,size)
# elif defined(HAVE_FTRUNCATE)