The binary mode has no difference from text mode in
POSIX-compliant operating systems. The two modes are
distinguishable from each other on Windows, and perhaps
on other systems as well.
The binary stream has scalability and other advantages.
Windows treats the standard input stream as text mode by
default. So the code changes it to binary mode.
Also, add a helper function, nasm_set_binary_mode(),
that is OS-agnostic, in the library.
Reported-by: Didier Stevens <didier.stevens@gmail.com>
Suggested-by: Didier Stevens <didier.stevens@gmail.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392649
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Windows supports pathnames up to 32767 UTF-16 characters, but using
the standard interfaces only up to 260 characters. Wrap the functions
that take filenames on Windows.
Clean up the compatiblity layers some more for reduced #ifdefs.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
"compiler.h" already includes a bunch of common include files. There
is absolutely no reason to duplicate them in individual files, and in
fact it robs us of central control of how these files are used.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[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>
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>
Move directive processing to its own file, and move nasmlib/error.c to
asm/error.c (it was not used by the disassembler); remove some extern
declarations from .c files, and do some general code cleanups.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
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>