MSVC compatibility: clean up the handling of _stati64/_fstati64

On Windows we need to use _stati64/_fstati64 in order to handle large
file sizes, but the handling was broken in the canned MSVC++
configuration.  Clean it up and fix it.

This addresses BR 3392398.

Reported-by: Nikolai Saoukh <nms@otdel-1.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2017-04-05 21:19:03 -07:00
parent 9546507861
commit 675e7b7d79
5 changed files with 19 additions and 15 deletions

View file

@ -12,7 +12,7 @@
top_srcdir = .
srcdir = .
VPATH = .
prefix = C:\Program Files\NASM
prefix = "C:\Program Files\NASM"
exec_prefix = $(prefix)
bindir = $(prefix)/bin
mandir = $(prefix)/man

View file

@ -49,6 +49,7 @@
* 1700 - Visual Studio 2012
* 1800 - Visual Studio 2013
* 1900 - Visual Studio 2015
* 1910 - Visual Studio 2017
*/
#ifndef NASM_CONFIG_MSVC_H
@ -112,9 +113,11 @@
/* Define to 1 if you have the `_fullpath' function. */
#define HAVE__FULLPATH 1
/* Define to 1 if you have the `stat' function. */
#define HAVE_STAT 1
#define stat _stati64
/* Define to 1 if you have the `_stati64' function. */
#define HAVE__STATI64 1
/* Define to 1 if you have the `_fstati64' function. */
#define HAVE__FSTATI64 1
/* Define to 1 if stdbool.h conforms to C99. */
#if _MSC_VER >= 1800

View file

@ -84,8 +84,8 @@ AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/stat.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/stat.h)
dnl Checks for library functions.
AC_CHECK_FUNCS(strcasecmp stricmp)
@ -108,7 +108,7 @@ AC_CHECK_FUNCS([fileno _fileno])
AC_CHECK_FUNCS(_filelengthi64)
AC_CHECK_FUNCS([stat _stati64])
AC_CHECK_FUNCS(fstat)
AC_CHECK_FUNCS([fstat _fstati64])
AC_FUNC_MMAP
AC_CHECK_FUNCS(getpagesize)
AC_CHECK_FUNCS(sysconf)

View file

@ -208,10 +208,10 @@ off_t nasm_file_size(FILE *f)
*/
off_t nasm_file_size_by_path(const char *pathname)
{
#ifdef HAVE_STAT
struct stat st;
#ifdef nasm_stat
struct nasm_stat st;
if (stat(pathname, &st))
if (nasm_stat(pathname, &st))
return (off_t)-1;
return st.st_size;

View file

@ -43,6 +43,9 @@
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
@ -87,14 +90,12 @@
*/
#ifdef HAVE__STATI64
# define nasm_stat _stati64
# if defined(HAVE_FILENO) && defined(HAVE__FSTATI64)
# define nasm_fstat _fstati64
# endif
#elif defined(HAVE_STAT)
# define nasm_stat stat
#endif
#ifdef HAVE_FILENO
# ifdef HAVE__FSTATI64
# define nasm_fstat _fstati64
# elif defined(HAVE_FSTAT)
# if defined(HAVE_FILENO) && defined(HAVE_FSTAT)
# define nasm_fstat fstat
# endif
#endif