Commit graph

16 commits

Author SHA1 Message Date
H. Peter Anvin
82025ea0e9 nasmlib/file.c: simplify and unify fwriteint*/addr()
The fwriteint*() and fwriteaddr() functions can be trivially unified
by using cpu_to_le*().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:53:52 -08:00
H. Peter Anvin
a771be85f4 outobj: emit file dependency information
Some OMF toolchain can make use of file dependency information
embedded in the object files.  As implemented here, we don't try to
absolutize the filenames, as that prevents moving around trees and is
OS-dependent.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 15:00:38 -07:00
Chang S. Bae
5431732560 Fix errors uncovered by clang warnings
1. One incorrect variable use(!)
2. One possibly uninitialized variable.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:01:33 -07:00
H. Peter Anvin
8dc965347d rdoff: use nasm-provided safe memory allocation and I/O
We already have abort-on-error memory allocation and I/O operations in
nasmlib, so use them for rdoff as well.

Delete long-since-obsolete rdoff Mkfiles directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 13:56:50 -07:00
H. Peter Anvin
3118429089 Windows: clean up the handling of stat on Windows
[f]stat on Windows is messy: we need to use _stati64 for maximum
compatibility, but because there is a bunch of stuff wrapped in
macros, autoconf sometimes gets the wrong answers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 15:48:51 -07:00
H. Peter Anvin
675e7b7d79 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>
2017-04-05 21:19:03 -07:00
H. Peter Anvin
9222364607 nasmlib/file: move memory-mapping functions out of file.c
Move memory-mapping functions from file.c into a separate mmap.c.
This will be cleaner especially once (if) we end up doing a Windows
implementation, which is likely to look entirely different.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:39:00 -08:00
H. Peter Anvin
cbd72b68fc nasmlib/file.c: fix various portability problems
Fix portability problems which prevented this code from building on
Win32 with MinGW-W64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:19:25 -08:00
H. Peter Anvin
4c9132e3a0 compiler.h: include <sys/types.h>
Apparently, at least on some OS/2 compilers, <sys/types.h> needs to be
included for off_t to be defined.  This seems like a generically good
idea to include this header whenever it is available.

Remove reference to <types.h>.  This was supposedly for MSVC, but
there is no actual evidence that it is useful beyond <sys/types.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-19 13:13:38 -07:00
H. Peter Anvin
397c169736 Move config.h to a subdirectory, add MSVC-specific config file
Instead of trying to do hacks in the Makefiles, define header files
for specific compilers if they can't use autoconf.  Currently defined
for Microsoft Visual Studio, based on MSDN documentation.  It is
currently untested.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:01:59 -07:00
H. Peter Anvin
d81a235f33 file: improve the file access interface
A number of fairly common operations are invoked way too many times,
especially when using incbin.  Drastically reduce the number of system
calls that need to be executed, and use memory mapping to reduce
unnecessary double buffering.

We could improve this further by leaving files open once used;
however, that might run into file count problems on some systems.

Still unclear is why we seem to invoke nasm_file_size() twice per pass
for incbin.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-21 14:07:17 -07:00
H. Peter Anvin
c170089e7c nasmlib: move fseeko/ftello/off_t replacements to nasmlib.h
Move fseeko, ftello, and off_t definitions to nasmlib.h so that files
other than nasmlib/file.c can use them (already added to
asm/assemble.c).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-09-20 18:26:42 -07:00
H. Peter Anvin
3e83cec90e Add wrappers around fopen(), use mmap on glibc
Add wrappers to fopen().  The intent is to replace references to
FILE * with an internal structure which can also cache things like the
filename and, when needed, the full pathname and checksums.

Also, add the "m" flag if we are compiling for glibc, for speed.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 04:34:00 -07:00
H. Peter Anvin
c0aaf9750f Revert "nasmlib/file.c: Windows _chsize_s() *returns* errno"
This reverts commit 55e51d9534.

First of all, _chsize_s() *does* set errno, even though it returns the
same value.  Second of all, all we look for is a zero return value
anyway, so there is no need for this wrapper.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 15:18:00 -07:00
H. Peter Anvin
55e51d9534 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>
2016-05-10 15:14:30 -07:00
H. Peter Anvin
3ef4f00d5a lib: split library into stdlib and nasmlib; header handling fixes
Split lib/ into nasmlib/ (for nasm-specific functions) and stdlib/
(for replacements for C library functions which may be missing.)

Rename the ersatz inttypes.h to nasmint.h so we can use a simple test
in compiler.h instead of dealing with include path magic.

Remove tests in configure.in for ancient missing functions (which will
break the build anyway.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-08 12:20:02 -08:00
Renamed from lib/file.c (Browse further)