Commit graph

22 commits

Author SHA1 Message Date
H. Peter Anvin
eaa68f1c85 Add strlcpy() function
Add strlcpy() function and implementation, and use configure to detect
if strlcpy() is natively available on the system.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-10 15:59:34 -07:00
H. Peter Anvin
84280bbf88 Change noreturn macro to no_return to avoid header file problems
Change the "noreturn" macro to "no_return", to avoid problems with
system header files which use __attribute__((noreturn)) rather than
__attribute__((__noreturn__)) as is appropriate for system headers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05 19:22:28 -07:00
H. Peter Anvin
396e6dcc4b compiler.h: new macro for a non-returning function
Add a new macro for a non-returning function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-01 22:01:07 -07:00
H. Peter Anvin
9e6747ccac Add copyright headers to the *.c/*.h files in the main directory
Add copyright headers to the *.c/*.h files in the main directory.  For
files where I'm sure enough that we have all the approvals, I have
given them the 2-BSD license, the others have been given the "LGPL for
now" license header.  Most of them can probably be changed after
auditing.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:13:04 -07: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
9656a581cd compiler.h: add offsetof() and container_of()
offsetof() is a C99 construct; provided here as an ersatz for older
systems.

container_of() is a nonstandard but highly useful construct, which
allows data structure control items like tree structures to be
embedded in larger data structures without the penalty of extra
pointers and allocations.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-30 10:54:55 -07:00
H. Peter Anvin
253a4e7a9f Make it possible to use "inline" and "restrict"
Put the appropriate machinery in place to be able to use the "inline"
and "restrict" keywords with appropriate semantics.
2008-06-10 13:00:27 -07:00
H. Peter Anvin
51997d3d44 Introduce likely/unlikely macros, use them in saa.c
Introduce the likely() and unlikely() macros, as used in Linux.
They are compiler-dependent hints that a particular boolean expression
is likely to be true or false, respectively.

Currently only implemented for gcc.
2008-06-10 09:35:26 -07:00
H. Peter Anvin
2f0f9ea286 Use autoconf to detect WORDS_LITTLEENDIAN
Use autoconf to detect littleendian word order, and use
WORDS_LITTLEENDIAN instead of X86_MEMORY when we don't require
unaligned memory accesses to be permitted.
2008-06-08 20:53:29 -07:00
H. Peter Anvin
714ad04bb8 Some compilers define __386__ instead of __i386__
OpenWatcom, and possibly other compilers from the DOS universe,
defines __386__ rather than __i386__.
2008-02-16 15:28:02 -08:00
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
H. Peter Anvin
d1fb15c154 Address data is int64_t; simplify writing an address object
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)

Create simple "write sized object" macros.
2007-11-13 09:37:59 -08:00
H. Peter Anvin
c13d31a907 Better handling of platforms which hide "extended" functionality
Some platforms apparently feel -std=c99, which defines
__STRICT_ANSI__, should also hide a bunch of function prototypes.
This rather sucks.  At least try to deal with it.

MinGW and DJGPP both have this problem, in particular.
2007-10-26 18:49:29 -07:00
H. Peter Anvin
26573020d8 Cleaner solution for MinGW handling of __STRICT_ANSI__
If MinGW is detected, undefine __STRICT_ANSI__ in compiler.h instead.
2007-10-18 19:14:08 -07:00
H. Peter Anvin
687b363477 Define macros necessary for <inttypes.h> on C++
NASM currently doesn't compile with a C++ compiler, but the error
messages are sometimes useful.  Define macros necessary for
<inttypes.h> to work with a C++ compiler.
2007-10-11 12:51:06 -07:00
H. Peter Anvin
6867acc18e Use the compiler-provided booleans if available, otherwise emulate
Both C and C++ have "bool", "true" and "false" in lower case; C
requires <stdbool.h> for this, in C++ it is an inherent type built
into the compiler.  Use those instead of the old macros; emulate with
a simple typedef enum if unavailable.
2007-10-10 14:58:45 -07:00
H. Peter Anvin
8f303505ea Use autoconf to request feature macros 2007-10-03 17:40:12 -07:00
H. Peter Anvin
fe501957c0 Portability fixes
Concentrate compiler dependencies to compiler.h; make sure compiler.h
is included first in every .c file (since some prototypes may depend
on the presence of feature request macros.)

Actually use the conditional inclusion of various functions (totally
broken in previous releases.)
2007-10-02 21:53:51 -07:00
H. Peter Anvin
304b605563 Add substitutes for snprintf() and vsnprintf()
To deal with fools^Wpeople trying to keep really old systems alive,
create a proper framework for substitution functions, and make it
possible to deal with the lack of snprintf/vsnprintf in particular.
2007-09-28 10:50:20 -07:00
H. Peter Anvin
b8af9aa522 Cleaner way to handle MSVC's _snprintf() underscore damage
Some versions of MSVC have snprintf() and vsnprintf() only with a
leading underscore.  Handle that a bit more cleanly.
2007-09-17 13:53:14 -07:00
H. Peter Anvin
c40f89e1c2 AIf we have config.h, we should actually include it!!
Apparently configure was generating config.h, and nothing ever actually
included it.  Include it in nasm.h as well as compiler.h, and in
rdoff/rdlar.h which uses these macros.

There appears to be no use of HAVE_* macros in any file that doesn't
have nasm.h included; in fact, so far the only use has been in
rdoff/rdlar.h.
2007-04-13 20:06:41 +00:00
H. Peter Anvin
c1494ac5ab Macroize any compiler-specific code; macros defined in "compiler.h"
Move anything compiler-specific to "compiler.h".

There was an unguarded use of __attribute__(()) in outmacho.c; also
require gcc 4+ for __builtin_ctlz().  Speed up the open-coded version, too.
2007-04-13 19:58:42 +00:00