Create our own ctype table where we can do the tests we want to do
cheaply, instead of calling ctype functions and then adding additional
tests all over the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is no reason to use -O3; it causes code to be insanely
duplicated. Simplify the configure.ac file too.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
strncpy() is correctly used to fill in a zero-*padded* (not
zero-terminated) field in several places. Make gcc not complain about
those uses.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
None of our symbols are available for a dynamic library, and if they
were, there would be no point in allowing them to be overridden. This
optimizes code generation for global symbols.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Simplify the nasm_malloc() code by moving the pointer check into a
common subroutine.
We can now issue a filename error even for failures like malloc().
Add support for the gcc sentinel attribute (verify that a list ends
with NULL).
Add a handful of safe_alloc attributes.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Some older versions of gcc (gcc 4.2.1 at least) produce a warning,
promoted to error, on C99 inlines. Do some work to figure out if we
need to fall back to GNU inline syntax.
Fix some issues with GNU inline syntax.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Get rid of remaining dependencies on FILENAME_MAX, which ought to have
been removed a long time ago.
Remove ofmt->filename(); all implementations pretty much do the same
thing and there is absolutely no reason to duplicate that
functionality all over the place.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make further autoconf rule improvements and update the required
version of autoconf to 2.69. That version is now 5+ years old and
although there might be older versions which have the prerequisite
macros they are known to have lots of bugs, and we can't really test
them.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make -O0 imply -fno-omit-frame-pointer
Add options to compile/link with AddressSanitizer and
UndefinedSanitizer.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Move byte order handling functions to their own header file, and try
to be more specific about how exactly to handle things.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The --enable-sections option isn't too useful without
-Wl,--gc-sections. It's unclear if gcc will provide that option by
default.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
An uncompressed PDF is about twice as big, but if one is using an
external compression program (e.g. .pdf.xz) it compresses far better.
Use it for the RPM specfile.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We have separate invocations for the various PDF tools anyway. It
generates a slightly annoying error message, but makes some other
things a little easier.
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>
AC_ARG_ENABLE() doesn't really work the way you expect: one argument
is called on *any* invocation. Create simple helper wrappers to get
the effect we really want for boolean options.
Define WINELOADER=/dev/null to prevent autoconf from inadvertently
running Wine and think we are not cross-compiling even if we are. It
is at the very best slow and buys us absolutely nothing.
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>
The -ffunction-sections and -fdata-sections, if supported, can enable
the linker to do some amount of dead code elimination. Basically a
very basic form of LTO.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Default to -O3 instead of -O2. The code gets somewhat bigger, but
nasm is full of tiny functions called from all over the place.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Put in the necessary machinery to compile with gcc link-time
optimization. This means compiling and linking with -flto, as well as
using gcc-ar and gcc-ranlib instead of the normal tools.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Instead of using hacks or compiler-specific features, if we have
standard features as defined in ISO C11, use them.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Use autoconf to detect function attributes; some compilers like Sun CC
do support some gcc-style attributes, but don't define __GNUC__. Also
-U__STRICT_ANSI__ already in configure.ac so our tests match what we
might eventually encounter.
Add const_func and pure_func attributes.
Decorate functions in nasmlib.h with const_func and pure_func.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
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>
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>
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>
Disable common data to:
a) discover problems with common data as quickly as possible (we
should not use common data as some compilers may not handle it);
b) work around a problem with the OSX linker causing it to not find
zero_buffer even though it is defined in nasmlib/zerobuf.c.
Reported-by: anonymous coward <nasm64developer@users.sf.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasmlib.c had basically turned into a garbage bin of various functions
with very little in common. Break it up into logical components for
isolation and manageability.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>