diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-09-17 13:53:14 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-09-17 13:53:14 -0700 |
commit | b8af9aa522935e7c261e8b4464dd2f4d0c972a14 (patch) | |
tree | f37823084167eef2f01238e658e6d4be05fdadc0 | |
parent | 2ced2ec3709d8cbcbb80d51f23092af260258cd1 (diff) | |
download | nasm-b8af9aa522935e7c261e8b4464dd2f4d0c972a14.tar.gz nasm-b8af9aa522935e7c261e8b4464dd2f4d0c972a14.tar.bz2 nasm-b8af9aa522935e7c261e8b4464dd2f4d0c972a14.zip |
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.
-rw-r--r-- | Makefile.in | 111 | ||||
-rw-r--r-- | Mkfiles/msvc.mak | 116 | ||||
-rw-r--r-- | compiler.h | 10 | ||||
-rw-r--r-- | configure.in | 26 | ||||
-rw-r--r-- | nasm.h | 6 | ||||
-rw-r--r-- | nasmlib.h | 1 |
6 files changed, 140 insertions, 130 deletions
diff --git a/Makefile.in b/Makefile.in index 6b1dd7e..ffc99a8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -207,67 +207,72 @@ alldeps: perlreq # @object-ending: ".$(O)" # @path-separator: "/" #-- Everything below is generated by mkdep.pl - do not edit --# -assemble.$(O): assemble.c preproc.h insns.h pptok.h regs.h regflags.c \ - config.h version.h nasmlib.h nasm.h regvals.c insnsi.h assemble.h +assemble.$(O): assemble.c preproc.h insns.h compiler.h pptok.h regs.h \ + regflags.c config.h version.h nasmlib.h nasm.h regvals.c insnsi.h \ + assemble.h crc64.$(O): crc64.c -disasm.$(O): disasm.c insns.h sync.h regdis.c regs.h config.h regs.c \ - version.h nasm.h insnsn.c names.c insnsi.h disasm.h -eval.$(O): eval.c labels.h eval.h regs.h config.h version.h nasmlib.h nasm.h \ +disasm.$(O): disasm.c insns.h sync.h compiler.h regdis.c regs.h config.h \ + regs.c version.h nasm.h insnsn.c names.c insnsi.h disasm.h +eval.$(O): eval.c labels.h eval.h compiler.h regs.h config.h version.h \ + nasmlib.h nasm.h insnsi.h +float.$(O): float.c compiler.h regs.h config.h version.h nasm.h insnsi.h +hashtbl.$(O): hashtbl.c compiler.h regs.h config.h version.h nasmlib.h \ + hashtbl.h nasm.h insnsi.h +insnsa.$(O): insnsa.c insns.h compiler.h regs.h config.h version.h nasm.h \ insnsi.h -float.$(O): float.c regs.h config.h version.h nasm.h insnsi.h -hashtbl.$(O): hashtbl.c regs.h config.h version.h nasmlib.h hashtbl.h nasm.h \ +insnsd.$(O): insnsd.c insns.h compiler.h regs.h config.h version.h nasm.h \ insnsi.h -insnsa.$(O): insnsa.c insns.h regs.h config.h version.h nasm.h insnsi.h -insnsd.$(O): insnsd.c insns.h regs.h config.h version.h nasm.h insnsi.h insnsn.$(O): insnsn.c -labels.$(O): labels.c regs.h config.h version.h hashtbl.h nasmlib.h nasm.h \ - insnsi.h -listing.$(O): listing.c regs.h config.h version.h nasmlib.h nasm.h insnsi.h \ - listing.h +labels.$(O): labels.c compiler.h regs.h config.h version.h hashtbl.h \ + nasmlib.h nasm.h insnsi.h +listing.$(O): listing.c compiler.h regs.h config.h version.h nasmlib.h \ + nasm.h insnsi.h listing.h macros.$(O): macros.c names.$(O): names.c regs.c insnsn.c -nasm.$(O): nasm.c labels.h preproc.h insns.h parser.h eval.h pptok.h regs.h \ - outform.h config.h version.h nasmlib.h nasm.h stdscan.h assemble.h insnsi.h \ - listing.h -nasmlib.$(O): nasmlib.c insns.h regs.h config.h version.h nasmlib.h nasm.h \ - insnsi.h -ndisasm.$(O): ndisasm.c insns.h sync.h regs.h config.h version.h nasmlib.h \ - nasm.h insnsi.h disasm.h -outform.$(O): outform.c regs.h config.h outform.h version.h nasm.h insnsi.h -output/outaout.$(O): output/outaout.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outas86.$(O): output/outas86.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outbin.$(O): output/outbin.c labels.h eval.h regs.h outform.h \ - config.h version.h nasmlib.h nasm.h stdscan.h insnsi.h -output/outcoff.$(O): output/outcoff.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outdbg.$(O): output/outdbg.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outelf32.$(O): output/outelf32.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outelf64.$(O): output/outelf64.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outieee.$(O): output/outieee.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outmacho.$(O): output/outmacho.c compiler.h regs.h outform.h config.h \ - version.h nasmlib.h nasm.h insnsi.h -output/outobj.$(O): output/outobj.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outrdf.$(O): output/outrdf.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outrdf2.$(O): output/outrdf2.c rdoff/rdoff.h regs.h outform.h \ - config.h version.h nasmlib.h nasm.h insnsi.h -parser.$(O): parser.c insns.h parser.h float.h regs.h regflags.c config.h \ - version.h nasmlib.h nasm.h stdscan.h insnsi.h -pptok.$(O): pptok.c preproc.h pptok.h nasmlib.h -preproc.$(O): preproc.c preproc.h macros.c pptok.h regs.h config.h version.h \ - hashtbl.h nasmlib.h nasm.h insnsi.h +nasm.$(O): nasm.c preproc.h insns.h eval.h config.h nasmlib.h nasm.h \ + stdscan.h assemble.h insnsi.h labels.h parser.h compiler.h regs.h pptok.h \ + outform.h version.h listing.h +nasmlib.$(O): nasmlib.c insns.h config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h version.h +ndisasm.$(O): ndisasm.c insns.h config.h nasmlib.h nasm.h insnsi.h disasm.h \ + sync.h compiler.h regs.h version.h +outform.$(O): outform.c config.h nasm.h insnsi.h compiler.h regs.h outform.h \ + version.h +output/outaout.$(O): output/outaout.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outas86.$(O): output/outas86.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outbin.$(O): output/outbin.c eval.h config.h nasmlib.h nasm.h \ + stdscan.h insnsi.h labels.h compiler.h regs.h outform.h version.h +output/outcoff.$(O): output/outcoff.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outdbg.$(O): output/outdbg.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outelf32.$(O): output/outelf32.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outelf64.$(O): output/outelf64.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outieee.$(O): output/outieee.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outmacho.$(O): output/outmacho.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outobj.$(O): output/outobj.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outrdf.$(O): output/outrdf.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outrdf2.$(O): output/outrdf2.c config.h nasmlib.h nasm.h insnsi.h \ + rdoff/rdoff.h compiler.h regs.h outform.h version.h +parser.$(O): parser.c insns.h regflags.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h parser.h float.h compiler.h regs.h version.h +pptok.$(O): pptok.c preproc.h config.h nasmlib.h compiler.h pptok.h +preproc.$(O): preproc.c preproc.h config.h hashtbl.h nasmlib.h nasm.h \ + insnsi.h macros.c compiler.h pptok.h regs.h version.h regdis.$(O): regdis.c regflags.$(O): regflags.c regs.$(O): regs.c regvals.$(O): regvals.c -stdscan.$(O): stdscan.c insns.h regs.h config.h version.h nasmlib.h nasm.h \ - stdscan.h insnsi.h +stdscan.$(O): stdscan.c insns.h config.h nasmlib.h nasm.h stdscan.h insnsi.h \ + compiler.h regs.h version.h sync.$(O): sync.c sync.h -tokhash.$(O): tokhash.c insns.h regs.h config.h version.h nasm.h insnsi.h +tokhash.$(O): tokhash.c insns.h config.h nasm.h insnsi.h compiler.h regs.h \ + version.h diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 66fe7f2..3f3ff3a 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -15,7 +15,7 @@ mandir = $(prefix)/man CC = cl CFLAGS = /O2 /Ox /Oy /W2 BUILD_CFLAGS = $(CFLAGS) /I$(srcdir)/inttypes -INTERNAL_CFLAGS = /I$(srcdir) /I. /Dsnprintf=sprintf_s +INTERNAL_CFLAGS = /I$(srcdir) /I. /DHAVE__SNPRINTF /DHAVE__VSNPRINTF ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS) LDFLAGS = LIBS = @@ -165,67 +165,71 @@ everything: all doc rdf # @object-ending: ".$(O)" # @path-separator: "/" #-- Everything below is generated by mkdep.pl - do not edit --# -assemble.$(O): assemble.c preproc.h insns.h pptok.h regs.h regflags.c \ - config.h version.h nasmlib.h nasm.h regvals.c insnsi.h assemble.h +assemble.$(O): assemble.c preproc.h insns.h regflags.c config.h nasmlib.h \ + nasm.h assemble.h insnsi.h compiler.h pptok.h regs.h version.h regvals.c crc64.$(O): crc64.c -disasm.$(O): disasm.c insns.h sync.h regdis.c regs.h config.h regs.c \ - version.h nasm.h insnsn.c names.c insnsi.h disasm.h -eval.$(O): eval.c labels.h eval.h regs.h config.h version.h nasmlib.h nasm.h \ - insnsi.h -float.$(O): float.c regs.h config.h version.h nasm.h insnsi.h -hashtbl.$(O): hashtbl.c regs.h config.h version.h nasmlib.h hashtbl.h nasm.h \ - insnsi.h -insnsa.$(O): insnsa.c insns.h regs.h config.h version.h nasm.h insnsi.h -insnsd.$(O): insnsd.c insns.h regs.h config.h version.h nasm.h insnsi.h +disasm.$(O): disasm.c insns.h regdis.c config.h regs.c nasm.h names.c \ + insnsi.h disasm.h sync.h compiler.h regs.h version.h insnsn.c +eval.$(O): eval.c eval.h config.h nasmlib.h nasm.h insnsi.h labels.h \ + compiler.h regs.h version.h +float.$(O): float.c config.h nasm.h insnsi.h compiler.h regs.h version.h +hashtbl.$(O): hashtbl.c config.h nasmlib.h hashtbl.h nasm.h insnsi.h \ + compiler.h regs.h version.h +insnsa.$(O): insnsa.c insns.h config.h nasm.h insnsi.h compiler.h regs.h \ + version.h +insnsd.$(O): insnsd.c insns.h config.h nasm.h insnsi.h compiler.h regs.h \ + version.h insnsn.$(O): insnsn.c -labels.$(O): labels.c regs.h config.h version.h hashtbl.h nasmlib.h nasm.h \ - insnsi.h -listing.$(O): listing.c regs.h config.h version.h nasmlib.h nasm.h insnsi.h \ - listing.h +labels.$(O): labels.c config.h hashtbl.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h version.h +listing.$(O): listing.c config.h nasmlib.h nasm.h insnsi.h compiler.h regs.h \ + version.h listing.h macros.$(O): macros.c names.$(O): names.c regs.c insnsn.c -nasm.$(O): nasm.c labels.h preproc.h insns.h parser.h eval.h pptok.h regs.h \ - outform.h config.h version.h nasmlib.h nasm.h stdscan.h assemble.h insnsi.h \ - listing.h -nasmlib.$(O): nasmlib.c insns.h regs.h config.h version.h nasmlib.h nasm.h \ - insnsi.h -ndisasm.$(O): ndisasm.c insns.h sync.h regs.h config.h version.h nasmlib.h \ - nasm.h insnsi.h disasm.h -outform.$(O): outform.c regs.h config.h outform.h version.h nasm.h insnsi.h -output/outaout.$(O): output/outaout.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outas86.$(O): output/outas86.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outbin.$(O): output/outbin.c labels.h eval.h regs.h outform.h \ - config.h version.h nasmlib.h nasm.h stdscan.h insnsi.h -output/outcoff.$(O): output/outcoff.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outdbg.$(O): output/outdbg.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outelf32.$(O): output/outelf32.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outelf64.$(O): output/outelf64.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outieee.$(O): output/outieee.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outmacho.$(O): output/outmacho.c compiler.h regs.h outform.h config.h \ - version.h nasmlib.h nasm.h insnsi.h -output/outobj.$(O): output/outobj.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h stdscan.h insnsi.h -output/outrdf.$(O): output/outrdf.c regs.h outform.h config.h version.h \ - nasmlib.h nasm.h insnsi.h -output/outrdf2.$(O): output/outrdf2.c rdoff/rdoff.h regs.h outform.h \ - config.h version.h nasmlib.h nasm.h insnsi.h -parser.$(O): parser.c insns.h parser.h float.h regs.h regflags.c config.h \ - version.h nasmlib.h nasm.h stdscan.h insnsi.h -pptok.$(O): pptok.c preproc.h pptok.h nasmlib.h -preproc.$(O): preproc.c preproc.h macros.c pptok.h regs.h config.h version.h \ - hashtbl.h nasmlib.h nasm.h insnsi.h +nasm.$(O): nasm.c preproc.h insns.h eval.h config.h nasmlib.h nasm.h \ + stdscan.h assemble.h insnsi.h labels.h parser.h compiler.h pptok.h regs.h \ + outform.h version.h listing.h +nasmlib.$(O): nasmlib.c insns.h config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h version.h +ndisasm.$(O): ndisasm.c insns.h config.h nasmlib.h nasm.h insnsi.h disasm.h \ + sync.h compiler.h regs.h version.h +outform.$(O): outform.c config.h nasm.h insnsi.h compiler.h regs.h outform.h \ + version.h +output/outaout.$(O): output/outaout.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outas86.$(O): output/outas86.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outbin.$(O): output/outbin.c eval.h config.h nasmlib.h nasm.h \ + stdscan.h insnsi.h labels.h compiler.h regs.h outform.h version.h +output/outcoff.$(O): output/outcoff.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outdbg.$(O): output/outdbg.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outelf32.$(O): output/outelf32.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outelf64.$(O): output/outelf64.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outieee.$(O): output/outieee.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outmacho.$(O): output/outmacho.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outobj.$(O): output/outobj.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h compiler.h regs.h outform.h version.h +output/outrdf.$(O): output/outrdf.c config.h nasmlib.h nasm.h insnsi.h \ + compiler.h regs.h outform.h version.h +output/outrdf2.$(O): output/outrdf2.c config.h nasmlib.h nasm.h insnsi.h \ + rdoff/rdoff.h compiler.h regs.h outform.h version.h +parser.$(O): parser.c insns.h regflags.c config.h nasmlib.h nasm.h stdscan.h \ + insnsi.h parser.h float.h compiler.h regs.h version.h +pptok.$(O): pptok.c preproc.h config.h nasmlib.h compiler.h pptok.h +preproc.$(O): preproc.c preproc.h config.h hashtbl.h nasmlib.h nasm.h \ + insnsi.h macros.c compiler.h pptok.h regs.h version.h regdis.$(O): regdis.c regflags.$(O): regflags.c regs.$(O): regs.c regvals.$(O): regvals.c -stdscan.$(O): stdscan.c insns.h regs.h config.h version.h nasmlib.h nasm.h \ - stdscan.h insnsi.h +stdscan.$(O): stdscan.c insns.h config.h nasmlib.h nasm.h stdscan.h insnsi.h \ + compiler.h regs.h version.h sync.$(O): sync.c sync.h -tokhash.$(O): tokhash.c insns.h regs.h config.h version.h nasm.h insnsi.h +tokhash.$(O): tokhash.c insns.h config.h nasm.h insnsi.h compiler.h regs.h \ + version.h @@ -37,4 +37,14 @@ # define _unused #endif +/* Some versions of MSVC have these only with underscores in front */ + +#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF) +# define snprintf _snprintf +#endif + +#if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF) +# define vsnprintf _vsnprintf +#endif + #endif /* COMPILER_H */ diff --git a/configure.in b/configure.in index b45d754..a52b620 100644 --- a/configure.in +++ b/configure.in @@ -87,28 +87,22 @@ AC_C_CONST AC_TYPE_SIZE_T dnl Checks for library functions. -AC_FUNC_VPRINTF -if test $ac_cv_func_vprintf = no; then - AC_MSG_ERROR([NASM requires ANSI C (specifically, "vprintf" and friends)]) -fi -AC_CHECK_FUNCS(strcspn) -if test $ac_cv_func_strcspn = no; then - AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]) -fi +AC_CHECK_FUNCS(strcspn, , + AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")])) -AC_CHECK_FUNCS(strspn) -if test $ac_cv_func_strspn = no; then - AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]) -fi +AC_CHECK_FUNCS(strspn, , + AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")])) -AC_CHECK_FUNCS(snprintf) -if test $ac_cv_func_snprintf = no; then +missing=true +AC_CHECK_FUNCS([snprintf _snprintf], missing=false) +if $missing; then AC_MSG_ERROR([NASM requires ISO C99 (specifically, "snprintf")]) fi -AC_CHECK_FUNCS(vsnprintf) -if test $ac_cv_func_snprintf = no; then +missing=true +AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false) +if $missing; then AC_MSG_ERROR([NASM requires ISO C99 (specifically, "vsnprintf")]) fi @@ -14,11 +14,7 @@ #include <stdio.h> #include <inttypes.h> #include "version.h" /* generated NASM version macros */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - +#include "compiler.h" #include "insnsi.h" /* For enum opcode */ #ifndef NULL @@ -11,6 +11,7 @@ #include <inttypes.h> #include <stdio.h> +#include "compiler.h" /* * If this is defined, the wrappers around malloc et al will |