mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
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.)
This commit is contained in:
parent
4a8daf0607
commit
fe501957c0
@ -82,6 +82,8 @@
|
||||
* used for conditional jump over longer jump
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
18
compiler.h
18
compiler.h
@ -13,15 +13,25 @@
|
||||
*
|
||||
* Compiler-specific macros for NASM. Feel free to add support for
|
||||
* other compilers in here.
|
||||
*
|
||||
* This header file should be included before any other header.
|
||||
*/
|
||||
|
||||
#ifndef COMPILER_H
|
||||
#define COMPILER_H 1
|
||||
#ifndef NASM_COMPILER_H
|
||||
#define NASM_COMPILER_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
/* Request as many features as we can */
|
||||
#define _GNU_SOURCE
|
||||
#define _ISO99_SOURCE
|
||||
#define _POSIX_SOURCE
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#define _XOPEN_SOURCE 600
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define HAVE_GNUC_4
|
||||
@ -38,9 +48,9 @@
|
||||
#endif
|
||||
|
||||
/* Some versions of MSVC have these only with underscores in front */
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
# ifdef HAVE__SNPRINTF
|
||||
@ -58,4 +68,4 @@ int vsnprintf(char *, size_t, const char *, va_list);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* COMPILER_H */
|
||||
#endif /* NASM_COMPILER_H */
|
||||
|
@ -82,6 +82,9 @@ fi
|
||||
dnl Check for <inttypes.h> or add a substitute version
|
||||
AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
|
||||
|
||||
dnl The standard header for str*casecmp is <strings.h>
|
||||
AC_CHECK_HEADERS(strings.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
@ -107,6 +110,10 @@ if $missing; then
|
||||
XOBJS="$XOBJS lib/snprintf.o"
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(strcasecmp stricmp)
|
||||
AC_CHECK_FUNCS(strncasecmp strnicmp)
|
||||
AC_CHECK_FUNCS(strsep)
|
||||
|
||||
AC_CHECK_FUNCS(getuid)
|
||||
AC_CHECK_FUNCS(getgid)
|
||||
|
||||
|
2
disasm.c
2
disasm.c
@ -8,6 +8,8 @@
|
||||
* initial version 27/iii/95 by Simon Tatham
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
2
eval.c
2
eval.c
@ -8,6 +8,8 @@
|
||||
* initial version 27/iii/95 by Simon Tatham
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
2
float.c
2
float.c
@ -8,6 +8,8 @@
|
||||
* initial version 13/ix/96 by Simon Tatham
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -4,6 +4,8 @@
|
||||
* Efficient dictionary hash table class.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include "nasm.h"
|
||||
|
2
labels.c
2
labels.c
@ -6,6 +6,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -4,6 +4,8 @@
|
||||
* Implement snprintf() in terms of vsnprintf()
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -5,6 +5,8 @@
|
||||
* that don't have them...
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -8,6 +8,8 @@
|
||||
* initial version 2/vii/97 by Simon Tatham
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
@ -19,7 +19,7 @@ undef $tasm_count;
|
||||
open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
|
||||
|
||||
print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
|
||||
" - don't edit it */\n\n#include <stddef.h>\n\nstatic const char *stdmac[] = {\n";
|
||||
" - don't edit it */\n\n#include \"compiler.h\"\n\nstatic const char *stdmac[] = {\n";
|
||||
|
||||
foreach $fname ( @ARGV ) {
|
||||
open(INPUT,$fname) or die "unable to open $fname\n";
|
||||
|
2
nasm.c
2
nasm.c
@ -6,6 +6,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
3
nasm.h
3
nasm.h
@ -11,10 +11,11 @@
|
||||
#ifndef NASM_NASM_H
|
||||
#define NASM_NASM_H
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "version.h" /* generated NASM version macros */
|
||||
#include "compiler.h"
|
||||
#include "nasmlib.h"
|
||||
#include "insnsi.h" /* For enum opcode */
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -144,7 +146,7 @@ char *nasm_strndup(char *s, size_t len)
|
||||
return p;
|
||||
}
|
||||
|
||||
#if !defined(stricmp) && !defined(strcasecmp)
|
||||
#ifndef nasm_stricmp
|
||||
int nasm_stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 && tolower(*s1) == tolower(*s2))
|
||||
@ -158,7 +160,7 @@ int nasm_stricmp(const char *s1, const char *s2)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(strnicmp) && !defined(strncasecmp)
|
||||
#ifndef nasm_strnicmp
|
||||
int nasm_strnicmp(const char *s1, const char *s2, int n)
|
||||
{
|
||||
while (n > 0 && *s1 && tolower(*s1) == tolower(*s2))
|
||||
@ -172,7 +174,7 @@ int nasm_strnicmp(const char *s1, const char *s2, int n)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(strsep)
|
||||
#ifndef nasm_strsep
|
||||
char *nasm_strsep(char **stringp, const char *delim)
|
||||
{
|
||||
char *s = *stringp;
|
||||
|
25
nasmlib.h
25
nasmlib.h
@ -9,9 +9,14 @@
|
||||
#ifndef NASM_NASMLIB_H
|
||||
#define NASM_NASMLIB_H
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "compiler.h"
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this is defined, the wrappers around malloc et al will
|
||||
@ -98,27 +103,23 @@ char *nasm_strndup_log(char *, int, char *, size_t);
|
||||
* ANSI doesn't guarantee the presence of `stricmp' or
|
||||
* `strcasecmp'.
|
||||
*/
|
||||
#if defined(stricmp) || defined(strcasecmp)
|
||||
#if defined(stricmp)
|
||||
#define nasm_stricmp stricmp
|
||||
#else
|
||||
#if defined(HAVE_STRCASECMP)
|
||||
#define nasm_stricmp strcasecmp
|
||||
#endif
|
||||
#elif defined(HAVE_STRICMP)
|
||||
#define nasm_stricmp stricmp
|
||||
#else
|
||||
int nasm_stricmp(const char *, const char *);
|
||||
#endif
|
||||
|
||||
#if defined(strnicmp) || defined(strncasecmp)
|
||||
#if defined(strnicmp)
|
||||
#define nasm_strnicmp strnicmp
|
||||
#else
|
||||
#if defined(HAVE_STRNCASECMP)
|
||||
#define nasm_strnicmp strncasecmp
|
||||
#endif
|
||||
#elif defined(HAVE_STRNICMP)
|
||||
#define nasm_strnicmp strnicmp
|
||||
#else
|
||||
int nasm_strnicmp(const char *, const char *, int);
|
||||
#endif
|
||||
|
||||
#if defined(strsep)
|
||||
#if defined(HAVE_STRSEP)
|
||||
#define nasm_strsep strsep
|
||||
#else
|
||||
char *nasm_strsep(char **stringp, const char *delim);
|
||||
|
@ -6,6 +6,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -9,6 +9,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -44,6 +44,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -36,6 +36,8 @@
|
||||
*
|
||||
* David Lindauer, LADsoft
|
||||
*/
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -10,6 +10,8 @@
|
||||
/* Most of this file is, like Mach-O itself, based on a.out. For more
|
||||
* guidelines see outaout.c. */
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -7,6 +7,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -12,6 +12,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -9,6 +9,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
2
parser.c
2
parser.c
@ -8,6 +8,8 @@
|
||||
* initial version 27/iii/95 by Simon Tatham
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
1
pptok.pl
1
pptok.pl
@ -138,6 +138,7 @@ if ($what eq 'c') {
|
||||
|
||||
die if ($n & ($n-1));
|
||||
|
||||
print OUT "#include \"compiler.h\"\n";
|
||||
print OUT "#include <inttypes.h>\n";
|
||||
print OUT "#include <ctype.h>\n";
|
||||
print OUT "#include \"nasmlib.h\"\n";
|
||||
|
@ -34,6 +34,8 @@
|
||||
* detoken is used to convert the line back to text
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -4,8 +4,9 @@
|
||||
* This file is public domain.
|
||||
*/
|
||||
|
||||
#include "collectn.h"
|
||||
#include "compiler.h"
|
||||
#include <stdlib.h>
|
||||
#include "collectn.h"
|
||||
|
||||
void collection_init(Collection * c)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
const uint32_t consttab[] = {
|
||||
|
@ -24,6 +24,8 @@
|
||||
* under DOS. '#define STINGY_MEMORY' may help a little.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* rdf2bin.c - convert an RDOFF object file to flat binary
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -4,6 +4,8 @@
|
||||
* Note that this program only writes 16-bit HEX.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* rdfdump.c - dump RDOFF file header.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -23,6 +23,8 @@
|
||||
* content size, followed by data.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -17,6 +17,8 @@
|
||||
* - support for segment relocations (hard to do in ANSI C)
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -3,6 +3,8 @@
|
||||
* Copyright (c) 2002 RET & COM Research.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* rdlib.c - routines for manipulating RDOFF libraries (.rdl)
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -15,6 +15,8 @@
|
||||
* make it portable.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -12,6 +12,8 @@
|
||||
files. You can use these files in your own program to load RDOFF objects
|
||||
and execute the code in them in a similar way to what is shown here. */
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "segtab.h"
|
||||
|
@ -7,6 +7,9 @@
|
||||
* redistributable under the licence given in the file "Licence"
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
5
regs.pl
5
regs.pl
@ -78,7 +78,7 @@ close(REGS);
|
||||
|
||||
if ( $fmt eq 'h' ) {
|
||||
# Output regs.h
|
||||
print "/* automatically generated from $file - do not edit */\n";
|
||||
print "/* automatically generated from $file - do not edit */\n\n";
|
||||
$expr_regs = 1;
|
||||
printf "#define EXPR_REG_START %d\n", $expr_regs;
|
||||
print "enum reg_enum {\n";
|
||||
@ -101,7 +101,8 @@ if ( $fmt eq 'h' ) {
|
||||
print "\n";
|
||||
} elsif ( $fmt eq 'c' ) {
|
||||
# Output regs.c
|
||||
print "/* automatically generated from $file - do not edit */\n";
|
||||
print "/* automatically generated from $file - do not edit */\n\n";
|
||||
print "#include \"compiler.h\"\n\n";
|
||||
print "static const char * const reg_names[] = "; $ch = '{';
|
||||
# This one has no dummy entry for 0
|
||||
foreach $reg ( sort(keys(%regs)) ) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
2
sync.c
2
sync.c
@ -6,6 +6,8 @@
|
||||
* distributed in the NASM archive.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
@ -168,6 +168,7 @@ if ($output eq 'h') {
|
||||
print " */\n";
|
||||
print "\n";
|
||||
|
||||
print "#include \"compiler.h\"\n";
|
||||
print "#include <string.h>\n";
|
||||
print "#include \"nasm.h\"\n";
|
||||
print "#include \"hashtbl.h\"\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user