Commit Graph

25 Commits

Author SHA1 Message Date
H. Peter Anvin
740ec3572b malloc: simplify nasm_malloc code, add nasm_strcatn()
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>
2018-05-30 11:40:42 -07:00
Cyrill Gorcunov
dd6a2cdcf4 Revert "compiler: Add fallthrough() helper"
This reverts commit 8ba28e13ea.
2018-02-25 22:25:57 +03:00
Cyrill Gorcunov
5829bbd9ed Revert "aclocal.m4: Use Werror in PA_CHECK_FALLTHROUGH_ATTRIBUTE"
This reverts commit 8b211a0a3b.
2018-02-25 22:24:53 +03:00
Cyrill Gorcunov
8b211a0a3b aclocal.m4: Use Werror in PA_CHECK_FALLTHROUGH_ATTRIBUTE
In sake of https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Suggested-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 22:01:20 +03:00
Cyrill Gorcunov
8ba28e13ea compiler: Add fallthrough() helper
https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:09:11 +03:00
H. Peter Anvin
99d45c850e Fix problem with C99 inlines and -Werror=missing-prototypes
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>
2018-02-20 12:34:17 -08:00
H. Peter Anvin
2dbfdee780 aclocal.m4: correct and update PA_HAVE_FUNC()
PA_HAVE_FUNC() would fail on some systems for inline functions or
macros due to missing #includes.  Also modernize to current autoconf
style.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:02:52 -08:00
H. Peter Anvin
d428e983fe aclocal.m4: remove dnl which made autoconf complain
autoconf complained about this dnl, and it's not necessary anyway (and
perhaps even potentially harmful?

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 13:31:22 -07:00
H. Peter Anvin
27854e67ac aclocal.m4: add defines for added CFLAGS, cleanups, PA_SYM()
Add defines for added CFLAGS.  This can be useful, for example, for
LTO or sanitizers being enabled.

Various cleanups for readability and documentation; use macros
available in current autoconf.

Add new utility function PA_SYM(), similar to AS_TR_CPP() except
collapses sequential underscores.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 10:45:50 -07:00
H. Peter Anvin
e0172d5870 Merge branch 'master' into elf 2017-04-23 23:52:32 -07:00
H. Peter Anvin
d2b7aa8edf aclocal.m4: fix underquoted strings
Some strings were underquoted, causing failures.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 21:42:08 -07:00
H. Peter Anvin
c4d75ddcbf Merge branch 'master' into elf
Resolved Conflicts:
	aclocal.m4
	output/outelf.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 16:08:54 -07:00
H. Peter Anvin
96b2895ac0 aclocal.m4: make it possible to request a header file to be further used
Make it possible to request testing for a header file, which if found,
will be always included for futher tests.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 15:48:31 -07:00
H. Peter Anvin
0da1549b73 autoconf: fix handling of --enable/--disable options, WINE fix
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>
2017-04-06 15:48:45 -07:00
H. Peter Anvin
5fe847e590 Makefile: make it possible to compile with gcc link-time optimization
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>
2017-02-28 18:48:01 -08:00
H. Peter Anvin
bc18af18f0 configure: make sure we flag invalid attributes
Use -Werror=attributes so we can actually test for non-supported
attributes without spewing warnings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 19:22:27 -08:00
H. Peter Anvin
abd28c9ab9 If we have new features introduced by C11, use them
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>
2016-12-20 02:29:58 -08:00
H. Peter Anvin
8b19083483 Better support for function attributes, autoconf cleanups
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>
2016-11-15 14:01:37 -08:00
H. Peter Anvin
89c1770e14 autoconf improvements: @SET_MAKE@, library extension
Minor autoconf corner cases.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-03-09 14:11:40 -08:00
H. Peter Anvin
cc147f79e4 Makefiles: use actual archive managers
There is no reason to not use an archive manager to build our
executables.  If there really are systems which don't have any kind of
archive manager, we can simply link all the objects.

This also drops any use of configure to detect library objects.
Instead just use HAVE_* and let the archive manager delete them.

A lot of additional functions could be declared library functions and
reorganized.

***FIX*** Mkfiles/*.mak have not yet been updated.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-08 02:08:44 -08:00
H. Peter Anvin
25da6eaf43 configure: enable additional code cleanliness warnings
We are supposed to handle compiling on a "C90 plus long long"
compiler, so make gcc (our most common development platform compiler)
complain when we don't.

However, suppress the complaints about the Microsoft definitions of
the <inttypes.h> strings.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-01 22:20:10 -08:00
H. Peter Anvin
d338b376df Portability improvements and autoconf modernization
Improve the portability of the code and modernize our use of
autoconf.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 01:03:51 -08:00
Victor van den Elzen
db6b9cfa62 Fix autoconf 2.68 warning.
The first argument of AC_COMPILE_IFELSE needs to be wrapped with
AC_LANG_SOURCE.
2010-11-07 17:31:27 +01:00
H. Peter Anvin
1fb908c0db autoconf: detect the broken bool in OpenWatcom 1.8
OpenWatcom 1.8 has a C99 mode, which implements _Bool and
<stdbool.h>.  Unfortunately the implementation is broken, and doesn't
let _Bool be implicitly converted to integer (as required by the C99
spec).  Detect this case in autoconf.
2009-03-01 13:57:40 -08:00
H. Peter Anvin
1ed0387476 Cleaner way to add gcc options
We can actually test for the options being accepted, rather than try
to test for gcc; this handles differences between gcc versions as well
as compilers with a similar command line set.
2007-04-15 22:45:25 +00:00