mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-12-21 09:19:31 +08:00
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:
parent
6503051dcc
commit
55e51d9534
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user