summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-03-08 02:23:23 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-03-08 02:23:23 -0800
commit7ab5595347d70ec9da736a0cedc9675a63356da3 (patch)
treed438905e0c30cc8916b847e6280b95b65f05d69e
parent2bc0ab38a22ecbaa56ef20e4037084b3ac6d3d45 (diff)
downloadnasm-7ab5595347d70ec9da736a0cedc9675a63356da3.tar.gz
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>
-rw-r--r--compiler.h14
-rw-r--r--lib/file.c35
2 files changed, 25 insertions, 24 deletions
diff --git a/compiler.h b/compiler.h
index baa8d197..df19aa58 100644
--- a/compiler.h
+++ b/compiler.h
@@ -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
diff --git a/lib/file.c b/lib/file.c
index a5a97a00..6ba38444 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -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;