Move fseeko/ftello/off_t handling from compiler.h into lib/file.c

This should only matter in this very specific file, so let's not make
*everything* depend on it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-03-08 02:23:23 -08:00
parent 2bc0ab38a2
commit 7ab5595347
2 changed files with 25 additions and 24 deletions

View File

@ -93,20 +93,6 @@ int vsnprintf(char *, size_t, const char *, va_list);
# endif
#endif
/* Missing fseeko/ftello */
#ifndef HAVE_FSEEKO
# undef off_t /* Just in case it is a macro */
# ifdef HAVE__FSEEKI64
# define fseeko _fseeki64
# define ftello _ftelli64
# define off_t int64_t
# else
# define fseeko fseek
# define ftello ftell
# define off_t long
# endif
#endif
#if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY
size_t strlcpy(char *, const char *, size_t);
#endif

View File

@ -43,6 +43,31 @@
# include <unistd.h>
#endif
/* Missing fseeko/ftello */
#ifndef HAVE_FSEEKO
# undef off_t /* Just in case it is a macro */
# ifdef HAVE__FSEEKI64
# define fseeko _fseeki64
# define ftello _ftelli64
# define off_t int64_t
# else
# define fseeko fseek
# define ftello ftell
# define off_t long
# endif
#endif
/* 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)
# elif defined(HAVE__CHSIZE)
# define nasm_ftruncate(fd,size) _chsize(fd,size)
# elif defined(HAVE_FTRUNCATE)
# define nasm_ftruncate(fd,size) ftruncate(fd,size)
# endif
#endif
void nasm_write(const void *ptr, size_t size, FILE *f)
{
size_t n = fwrite(ptr, 1, size, f);
@ -105,16 +130,6 @@ void fwriteaddr(uint64_t data, int size, FILE * fp)
#endif
#ifdef HAVE_FILENO /* Useless without fileno() */
# ifdef HAVE__CHSIZE_S
# define nasm_ftruncate(fd,size) _chsize_s(fd,size)
# elif defined(HAVE__CHSIZE)
# define nasm_ftruncate(fd,size) _chsize(fd,size)
# elif defined(HAVE_FTRUNCATE)
# define nasm_ftruncate(fd,size) ftruncate(fd,size)
# endif
#endif
void fwritezero(size_t bytes, FILE *fp)
{
size_t blksize;