From aed2b39c46fcdfdd017adbf9e50c254efc5dea42 Mon Sep 17 00:00:00 2001 From: jtvolpe Date: Sun, 4 Feb 2001 15:50:58 +0000 Subject: [PATCH] New Memory Allocation functions git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@575 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- as/as_z80.dsp | 6 +- as/aslink.dsp | 6 +- as/asx8051.dsp | 4 +- as/mcs51/asdata.c | 6 +- as/mcs51/asexpr.c | 6 +- as/mcs51/aslex.c | 6 +- as/mcs51/aslist.c | 6 +- as/mcs51/asmain.c | 11 +- as/mcs51/asnoice.c | 6 +- as/mcs51/asout.c | 6 +- as/mcs51/asstore.c | 6 +- as/mcs51/assubr.c | 6 +- as/mcs51/lkarea.c | 6 +- as/mcs51/lkdata.c | 6 +- as/mcs51/lkeval.c | 6 +- as/mcs51/lkhead.c | 6 +- as/mcs51/lkihx.c | 6 +- as/mcs51/lklex.c | 6 +- as/mcs51/lklibr.c | 10 +- as/mcs51/lklist.c | 6 +- as/mcs51/lkmain.c | 10 +- as/mcs51/lknoice.c | 6 +- as/mcs51/lkrloc.c | 6 +- as/mcs51/lks19.c | 6 +- as/mcs51/lkstore.c | 6 +- as/z80/alloc.h | 8 +- as/z80/asdata.c | 6 +- as/z80/asexpr.c | 6 +- as/z80/aslex.c | 6 +- as/z80/aslist.c | 1 + as/z80/asmain.c | 6 +- as/z80/asout.c | 6 +- as/z80/assubr.c | 6 +- debugger/mcs51/break.c | 2 +- debugger/mcs51/sdcdb.c | 22 ++-- debugger/mcs51/sdcdb.h | 28 ++-- debugger/mcs51/symtab.c | 14 +- device/lib/printfl.c | 280 ++++++++++++++++++++-------------------- link/z80/lklibr.c | 6 +- packihx/PackIhx.dsp | 4 +- sdcc_vc.h | 2 + src/SDCC.lex | 3 +- src/SDCC.y | 3 +- src/SDCCBBlock.c | 26 ++-- src/SDCCBBlock.h | 11 ++ src/SDCCast.c | 9 +- src/SDCCbitv.c | 9 +- src/SDCCcse.c | 3 +- src/SDCCglobl.h | 24 ++-- src/SDCCglue.c | 9 +- src/SDCChasht.c | 7 +- src/SDCCicode.c | 5 +- src/SDCCloop.c | 5 +- src/SDCCmain.c | 43 +++++- src/SDCCpeeph.c | 23 ++-- src/SDCCset.c | 12 +- src/SDCCsymt.c | 11 +- src/SDCCval.c | 7 +- src/avr/avr.dsp | 5 +- src/avr/gen.c | 7 +- src/ds390/ds390.dsp | 5 +- src/ds390/gen.c | 13 +- src/mcs51/gen.c | 13 +- src/mcs51/mcs51.dsp | 5 +- src/mcs51/ralloc.c | 9 +- src/pic/gen.c | 13 +- src/pic/glue.c | 5 +- src/pic/pic.dsp | 5 +- src/pic/ralloc.c | 4 + src/src.dsp | 15 ++- src/z80/gen.c | 23 ++-- src/z80/z80.dsp | 8 +- support/Util/NewAlloc.c | 136 +++++++++++++++++++ support/Util/SDCCerr.h | 183 ++++++++++++++++++++++++++ support/Util/newalloc.h | 75 +++++++++++ support/Util/sdccerr.c | 222 +++++++++++++++++++++++++++++++ support/cpp/config.h | 3 +- support/cpp/cppalloc.c | 78 +++++------ support/cpp/cppexp.c | 18 +-- support/cpp/cpphash.c | 11 +- support/cpp/cpplib.c | 113 ++++++++-------- support/cpp/cpplib.h | 30 +++++ support/cpp/sdcpp.dsp | 17 ++- 83 files changed, 1266 insertions(+), 524 deletions(-) create mode 100644 support/Util/NewAlloc.c create mode 100644 support/Util/SDCCerr.h create mode 100644 support/Util/newalloc.h create mode 100644 support/Util/sdccerr.c diff --git a/as/as_z80.dsp b/as/as_z80.dsp index 147e7a60..71f3cc4f 100644 --- a/as/as_z80.dsp +++ b/as/as_z80.dsp @@ -42,8 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /YX /J /FD /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -67,8 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /J /FD /GZ /c -# SUBTRACT CPP /WX /Fr +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/as/aslink.dsp b/as/aslink.dsp index 8d63976f..a9e52e8b 100644 --- a/as/aslink.dsp +++ b/as/aslink.dsp @@ -42,8 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /J /FD /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -68,8 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/as/asx8051.dsp b/as/asx8051.dsp index 881d4096..44096f69 100644 --- a/as/asx8051.dsp +++ b/as/asx8051.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /J /FD /c +# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/as/mcs51/asdata.c b/as/mcs51/asdata.c index e49a257b..51f1c37b 100644 --- a/as/mcs51/asdata.c +++ b/as/mcs51/asdata.c @@ -17,9 +17,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /*)Module asdata.c diff --git a/as/mcs51/asexpr.c b/as/mcs51/asexpr.c index c648026e..5d34b045 100644 --- a/as/mcs51/asexpr.c +++ b/as/mcs51/asexpr.c @@ -12,9 +12,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /*)Module asexpr.c diff --git a/as/mcs51/aslex.c b/as/mcs51/aslex.c index a0af00c6..fcf39100 100644 --- a/as/mcs51/aslex.c +++ b/as/mcs51/aslex.c @@ -15,9 +15,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /*)Module aslex.c diff --git a/as/mcs51/aslist.c b/as/mcs51/aslist.c index 6a6cf7c9..c8518278 100644 --- a/as/mcs51/aslist.c +++ b/as/mcs51/aslist.c @@ -15,9 +15,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include #include "asm.h" diff --git a/as/mcs51/asmain.c b/as/mcs51/asmain.c index 9dfe59bc..a2f11db6 100644 --- a/as/mcs51/asmain.c +++ b/as/mcs51/asmain.c @@ -14,10 +14,13 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#include -#endif + +//#if defined(_MSC_VER) +//#include +//#else // _MSC_VER +//#include +//#endif // _MSC_VER + #include "asm.h" extern VOID machine(struct mne *); diff --git a/as/mcs51/asnoice.c b/as/mcs51/asnoice.c index 4611587c..b8de1bb3 100644 --- a/as/mcs51/asnoice.c +++ b/as/mcs51/asnoice.c @@ -9,9 +9,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /* Return basic file name without path or extension */ diff --git a/as/mcs51/asout.c b/as/mcs51/asout.c index c21b4ac2..54d4bb31 100644 --- a/as/mcs51/asout.c +++ b/as/mcs51/asout.c @@ -16,9 +16,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/as/mcs51/asstore.c b/as/mcs51/asstore.c index 4e394730..8170ff3d 100644 --- a/as/mcs51/asstore.c +++ b/as/mcs51/asstore.c @@ -3,9 +3,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /* diff --git a/as/mcs51/assubr.c b/as/mcs51/assubr.c index 786712e9..8cabf28e 100644 --- a/as/mcs51/assubr.c +++ b/as/mcs51/assubr.c @@ -12,9 +12,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" /*)Module assubr.c diff --git a/as/mcs51/lkarea.c b/as/mcs51/lkarea.c index baaa6ac3..29fa00b6 100644 --- a/as/mcs51/lkarea.c +++ b/as/mcs51/lkarea.c @@ -15,9 +15,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lkarea.c diff --git a/as/mcs51/lkdata.c b/as/mcs51/lkdata.c index ecd9cd3e..607b946d 100644 --- a/as/mcs51/lkdata.c +++ b/as/mcs51/lkdata.c @@ -16,9 +16,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lkdata.c diff --git a/as/mcs51/lkeval.c b/as/mcs51/lkeval.c index 4834139e..0a980df3 100644 --- a/as/mcs51/lkeval.c +++ b/as/mcs51/lkeval.c @@ -11,9 +11,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lkeval.c diff --git a/as/mcs51/lkhead.c b/as/mcs51/lkhead.c index fa3105ef..898d7fe8 100644 --- a/as/mcs51/lkhead.c +++ b/as/mcs51/lkhead.c @@ -11,9 +11,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*Module lkhead.c diff --git a/as/mcs51/lkihx.c b/as/mcs51/lkihx.c index 7fb4f8ff..2e52d94b 100644 --- a/as/mcs51/lkihx.c +++ b/as/mcs51/lkihx.c @@ -11,9 +11,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lkihx.c diff --git a/as/mcs51/lklex.c b/as/mcs51/lklex.c index 5e894e15..d80b9ae4 100644 --- a/as/mcs51/lklex.c +++ b/as/mcs51/lklex.c @@ -11,9 +11,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lklex.c diff --git a/as/mcs51/lklibr.c b/as/mcs51/lklibr.c index 000843ee..84032719 100644 --- a/as/mcs51/lklibr.c +++ b/as/mcs51/lklibr.c @@ -17,11 +17,11 @@ #include #include -#if defined(_MSC_VER) -#include -#else -#include -#endif +//#if defined(_MSC_VER) +//#include +//#else +//#include +//#endif #include "aslink.h" /*)Module lklibr.c diff --git a/as/mcs51/lklist.c b/as/mcs51/lklist.c index 3842b1d9..11d7adc3 100644 --- a/as/mcs51/lklist.c +++ b/as/mcs51/lklist.c @@ -17,9 +17,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include #include "aslink.h" diff --git a/as/mcs51/lkmain.c b/as/mcs51/lkmain.c index 22fcac0b..8abd00f4 100644 --- a/as/mcs51/lkmain.c +++ b/as/mcs51/lkmain.c @@ -16,11 +16,11 @@ #include #include -#if defined(_MSC_VER) -#include -#else -#include -#endif +//#if defined(_MSC_VER) +//#include +//#else +//#include +//#endif #include "aslink.h" /* yuck - but including unistd.h causes problems on Cygwin by redefining diff --git a/as/mcs51/lknoice.c b/as/mcs51/lknoice.c index dab3b078..dd4c86f3 100644 --- a/as/mcs51/lknoice.c +++ b/as/mcs51/lknoice.c @@ -11,9 +11,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" static void DefineGlobal( char *name, Addr_T value, int page ); diff --git a/as/mcs51/lkrloc.c b/as/mcs51/lkrloc.c index 863de315..f6ac50bf 100644 --- a/as/mcs51/lkrloc.c +++ b/as/mcs51/lkrloc.c @@ -16,9 +16,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lkrloc.c diff --git a/as/mcs51/lks19.c b/as/mcs51/lks19.c index a730df5d..b222415d 100644 --- a/as/mcs51/lks19.c +++ b/as/mcs51/lks19.c @@ -11,9 +11,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /*)Module lks19.c diff --git a/as/mcs51/lkstore.c b/as/mcs51/lkstore.c index 73c21d01..5eb8d68f 100644 --- a/as/mcs51/lkstore.c +++ b/as/mcs51/lkstore.c @@ -9,9 +9,9 @@ #include #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "aslink.h" /* diff --git a/as/z80/alloc.h b/as/z80/alloc.h index 417d3704..f4ee1b95 100644 --- a/as/z80/alloc.h +++ b/as/z80/alloc.h @@ -2,9 +2,9 @@ /* DECUS C */ #ifndef SDK -extern char *alloc(); -extern char *malloc(); -extern char *calloc(); -extern char *realloc(); +//extern char *alloc(); +//extern char *malloc(); +//extern char *calloc(); +//extern char *realloc(); #endif diff --git a/as/z80/asdata.c b/as/z80/asdata.c index 82060ae9..4af2fdcc 100644 --- a/as/z80/asdata.c +++ b/as/z80/asdata.c @@ -13,9 +13,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/as/z80/asexpr.c b/as/z80/asexpr.c index d65ae50e..2e2a123e 100644 --- a/as/z80/asexpr.c +++ b/as/z80/asexpr.c @@ -13,9 +13,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/as/z80/aslex.c b/as/z80/aslex.c index 4f764dd6..2713ff8d 100644 --- a/as/z80/aslex.c +++ b/as/z80/aslex.c @@ -17,9 +17,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/as/z80/aslist.c b/as/z80/aslist.c index d65660fe..2c006cb3 100644 --- a/as/z80/aslist.c +++ b/as/z80/aslist.c @@ -17,6 +17,7 @@ #include #include +//#include "newalloc.h" #if defined(_MSC_VER) #include #else diff --git a/as/z80/asmain.c b/as/z80/asmain.c index 0da2d11a..5f6d6a1c 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -17,9 +17,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #ifdef SDK #include diff --git a/as/z80/asout.c b/as/z80/asout.c index 5e4c57fe..51b6bb9a 100644 --- a/as/z80/asout.c +++ b/as/z80/asout.c @@ -13,9 +13,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/as/z80/assubr.c b/as/z80/assubr.c index 29c37416..2150cb45 100644 --- a/as/z80/assubr.c +++ b/as/z80/assubr.c @@ -17,9 +17,9 @@ #include #include -#if !defined(_MSC_VER) -#include -#endif +//#if !defined(_MSC_VER) +//#include +//#endif #include "asm.h" diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c index 3ba14a65..61286f54 100644 --- a/debugger/mcs51/break.c +++ b/debugger/mcs51/break.c @@ -42,7 +42,7 @@ int setBreakPoint (unsigned addr, char addrType, char bpType, char simbuf[50]; /* allocate & init a new bp */ - ALLOC(bp,sizeof(breakp)); + Safe_calloc(bp,sizeof(breakp)); bp->addr = addr; bp->addrType = addrType; bp->bpType = bpType; diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c index ef85f5bb..3cb36cc8 100644 --- a/debugger/mcs51/sdcdb.c +++ b/debugger/mcs51/sdcdb.c @@ -153,7 +153,7 @@ struct cmdtab char *gc_strdup(const char *s) { char *ret; - ALLOC_ATOMIC(ret, strlen(s)+1); + Safe_calloc(ret, strlen(s)+1); strcpy(ret, s); return ret; } @@ -168,7 +168,7 @@ char *alloccpy ( char *s, int size) if (!size) return NULL; - ALLOC(d,size+1); + Safe_calloc(d,size+1); memcpy(d,s,size); d[size] = '\0'; @@ -183,7 +183,7 @@ void **resize (void **array, int newSize) void **vptr; if (array) - vptr = realloc(array,newSize*(sizeof(void **))); + vptr = Safe_realloc(array,newSize*(sizeof(void **))); else vptr = calloc(1, sizeof(void **)); @@ -209,7 +209,7 @@ static int readCdb (FILE *file) if (!(bp = fgets(buffer,sizeof(buffer),file))) return 0; - ALLOC(currl,sizeof(cdbrecs)); + Safe_calloc(currl,sizeof(cdbrecs)); recsRoot = currl ; while (1) { @@ -237,7 +237,7 @@ static int readCdb (FILE *file) } bp += 2; - ALLOC(currl->line,strlen(bp)); + Safe_calloc(currl->line,strlen(bp)); strncpy(currl->line,bp,strlen(bp)-1); currl->line[strlen(bp)-1] = '\0'; } @@ -248,7 +248,7 @@ static int readCdb (FILE *file) if (feof(file)) break; - ALLOC(currl->next,sizeof(cdbrecs)); + Safe_calloc(currl->next,sizeof(cdbrecs)); currl = currl->next; } @@ -351,7 +351,7 @@ srcLine **loadFile (char *name, int *nlines) slines = (srcLine **)resize((void **)slines,*nlines); - ALLOC(slines[(*nlines)-1],sizeof(srcLine)); + Safe_calloc(slines[(*nlines)-1],sizeof(srcLine)); slines[(*nlines)-1]->src = alloccpy(bp,strlen(bp)); } @@ -464,7 +464,7 @@ static void functionPoints () if (func->exitline < j) func->exitline = j; - ALLOC(ep,sizeof(exePoint)); + Safe_calloc(ep,sizeof(exePoint)); ep->addr = mod->cLines[j]->addr ; ep->line = j; ep->block= mod->cLines[j]->block; @@ -487,7 +487,7 @@ static void functionPoints () func->aexitline = j; /* add it to the execution point */ - ALLOC(ep,sizeof(exePoint)); + Safe_calloc(ep,sizeof(exePoint)); ep->addr = mod->asmLines[j]->addr ; ep->line = j; addSet(&func->afpoints,ep); @@ -559,7 +559,7 @@ int cmdFile (char *s,context *cctxt) } /* allocate for context */ - ALLOC(currCtxt ,sizeof(context)); + Safe_calloc(currCtxt ,sizeof(context)); /* readin the debug information */ if (!readCdb (cdbFile)) { @@ -718,7 +718,7 @@ static void parseCmdLine (int argc, char **argv) if (!ssdirl) ssdirl = &argv[i][12]; else { - char *p = malloc(strlen(ssdirl)+strlen(&argv[i][12])+2); + char *p = Safe_malloc(strlen(ssdirl)+strlen(&argv[i][12])+2); strcat(strcat(strcpy(p,&argv[i][12]),":"),ssdirl); ssdirl = p; } diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h index c3bc3c20..02f8be0b 100644 --- a/debugger/mcs51/sdcdb.h +++ b/debugger/mcs51/sdcdb.h @@ -48,20 +48,20 @@ typedef short bool; #define min(a,b) (a < b ? a : b) #endif -#ifndef ALLOC -#define ALLOC(x,sz) if (!(x = calloc(1, sz))) \ - { \ - fprintf(stderr,"sdcdb: out of memory\n"); \ - exit (1); \ - } -#endif -#ifndef ALLOC_ATOMIC -#define ALLOC_ATOMIC(x,sz) if (!(x = calloc(1, sz))) \ - { \ - fprintf(stderr,"sdcdb: out of memory\n"); \ - exit (1); \ - } -#endif +//#ifndef ALLOC +//#define ALLOC(x,sz) if (!(x = calloc(1, sz))) \ +// { \ +// fprintf(stderr,"sdcdb: out of memory\n"); \ +// exit (1); \ +// } +//#endif +//#ifndef ALLOC_ATOMIC +//#define ALLOC_ATOMIC(x,sz) if (!(x = calloc(1, sz))) \ +// { \ +// fprintf(stderr,"sdcdb: out of memory\n"); \ +// exit (1); \ +// } +//#endif /* generalpurpose stack related macros */ #define STACK_DCL(stack,type,size) \ typedef type t_##stack ; \ diff --git a/debugger/mcs51/symtab.c b/debugger/mcs51/symtab.c index 3ea0e8fd..c79906c2 100644 --- a/debugger/mcs51/symtab.c +++ b/debugger/mcs51/symtab.c @@ -90,7 +90,7 @@ void parseFunc (char *line) function *func ; char *rs; int i; - ALLOC(func,sizeof(function)); + Safe_calloc(func,sizeof(function)); func->sym = parseSymbol(line,&rs); func->sym->isfunc = 1; func->modName = currModName ; @@ -119,7 +119,7 @@ static char *parseTypeInfo (symbol *sym, char *s) s = ++bp; while (*s != ')') { /* till we reach the end */ link *type; - ALLOC(type,sizeof(link)); + Safe_calloc(type,sizeof(link)); if (*s == ',') s++; /* is a declarator */ @@ -240,7 +240,7 @@ symbol *parseSymbol (char *s, char **rs) symbol *nsym ; char *bp = s; - ALLOC(nsym,sizeof(symbol)); + Safe_calloc(nsym,sizeof(symbol)); /* copy over the mangled name */ while (*bp != '(') bp++; @@ -335,7 +335,7 @@ module *parseModule (char *s, bool createName ) module *nmod ; char buffer[512]; - ALLOC(nmod,sizeof(module)); + Safe_calloc(nmod,sizeof(module)); addSet (&modules,nmod); @@ -346,11 +346,11 @@ module *parseModule (char *s, bool createName ) if (createName) { sprintf(buffer,"%s.c",s); - ALLOC(nmod->c_name,strlen(buffer)+1); + Safe_calloc(nmod->c_name,strlen(buffer)+1); strcpy(nmod->c_name,buffer); sprintf(buffer,"%s.asm",s); - ALLOC(nmod->asm_name,strlen(buffer)+1); + Safe_calloc(nmod->asm_name,strlen(buffer)+1); strcpy(nmod->asm_name,buffer); } @@ -432,7 +432,7 @@ structdef *structWithName (char *s) return structs[i]; } - ALLOC(nsdef,sizeof(structdef)); + Safe_calloc(nsdef,sizeof(structdef)); nsdef->tag = alloccpy(s,strlen(s)); nsdef->sname = currModName ; diff --git a/device/lib/printfl.c b/device/lib/printfl.c index 7cf18ea0..6fe4e342 100644 --- a/device/lib/printfl.c +++ b/device/lib/printfl.c @@ -1,37 +1,37 @@ /*----------------------------------------------------------------- - printfl.c - source file for reduced version of printf - + printfl.c - source file for reduced version of printf + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! + what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ /* following formats are supported :- format output type argument-type %d decimal int - %ld decimal long + %ld decimal long %hd decimal short/char %x hexadecimal int - %lx hexadecimal long + %lx hexadecimal long %hx hexadecimal short/char %o octal int - %lo octal long + %lo octal long %ho octal short/char %c character char/short %s character _generic pointer @@ -52,163 +52,163 @@ static data long val; static void pvalhex( long val) { - volatile char sp = SP; - unsigned long lval = val; + volatile char sp = SP; + unsigned long lval = val; - if (!long_flag) - lval &= 0x0000ffff; + if (!long_flag) + lval &= 0x0000ffff; if (short_flag) - lval &= 0x000000ff; + lval &= 0x000000ff; - while (lval) { - ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f]; - _asm push _ch _endasm; - lval /= 16; - } + while (lval) { + ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f]; + _asm push _ch _endasm; + lval /= 16; + } - while (sp != SP) { - _asm pop _ch _endasm; - putchar(ch); + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); } - + } -static void pvaloct(long val) +static void pvaloct(long val) { - char sp ; - unsigned long lval; - sp = SP; - if (val < 0) { - lval = -val; - sign = 1; - } else { - lval = val; - sign = 0; - } - - if (!long_flag) - lval &= 0x0000ffff; + char sp ; + unsigned long lval; + sp = SP; + if (val < 0) { + lval = -val; + sign = 1; + } else { + lval = val; + sign = 0; + } + + if (!long_flag) + lval &= 0x0000ffff; if (short_flag) - lval &= 0x000000ff; + lval &= 0x000000ff; while (lval) { - ch = (lval % 8) + '0'; - _asm push _ch _endasm; + ch = (lval % 8) + '0'; + _asm push _ch _endasm; lval = lval / 8; - } - - if (sign) { - ch = '-'; - _asm push _ch _endasm; - } - - - while (sp != SP) { - _asm pop _ch _endasm; - putchar(ch); + } + + if (sign) { + ch = '-'; + _asm push _ch _endasm; + } + + + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); } } -static void pvaldec(long val ) +static void pvaldec(long val ) { - char sp ; - unsigned long lval; - sp = SP; - if (val < 0) { - lval = -val; - sign = 1; - } else { - lval = val; - sign = 0; - } - + char sp ; + unsigned long lval; + sp = SP; + if (val < 0) { + lval = -val; + sign = 1; + } else { + lval = val; + sign = 0; + } + while (lval) { - ch = (lval % 10) + '0'; - _asm push _ch _endasm; + ch = (lval % 10) + '0'; + _asm push _ch _endasm; lval = lval / 10; - } - - if (sign) { - ch = '-'; - _asm push _ch _endasm; - } - - - while (sp != SP) { - _asm pop _ch _endasm; - putchar(ch); + } + + if (sign) { + ch = '-'; + _asm push _ch _endasm; + } + + + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); } } void printf_small (char * fmt, ... ) reentrant { va_list ap ; - + va_start(ap,fmt); - + for (; *fmt ; fmt++ ) { - if (*fmt == '%') { - long_flag = string_flag = short_flag = 0; - fmt++ ; - switch (*fmt) { - case 'l': - long_flag = 1; - fmt++; - break; - case 'h': - short_flag = 1; - fmt++; - } - - switch (*fmt) { - case 's': - string_flag = 1; - break; - case 'd': - radix = 10; - break; - case 'x': - radix = 16; - break; - case 'c': - radix = 0; - break; - case 'o': - radix = 8; - break; - } - - if (string_flag) { - str = va_arg(ap,char _generic *); - while (*str) putchar(*str++); - continue ; - } - - if (long_flag) - val = va_arg(ap,long); - else - if (short_flag) - val = va_arg(ap,short); - else - val = va_arg(ap,int); - + if (*fmt == '%') { + long_flag = string_flag = short_flag = 0; + fmt++ ; + switch (*fmt) { + case 'l': + long_flag = 1; + fmt++; + break; + case 'h': + short_flag = 1; + fmt++; + } + + switch (*fmt) { + case 's': + string_flag = 1; + break; + case 'd': + radix = 10; + break; + case 'x': + radix = 16; + break; + case 'c': + radix = 0; + break; + case 'o': + radix = 8; + break; + } + + if (string_flag) { + str = va_arg(ap,char _generic *); + while (*str) putchar(*str++); + continue ; + } + + if (long_flag) + val = va_arg(ap,long); + else + if (short_flag) + val = va_arg(ap,short); + else + val = va_arg(ap,int); + switch (radix) { - case 10: - pvaldec(val) ; - break; - case 16: - pvalhex (val); - break; - case 0: - putchar((char)val); - break; - case 8: - pvaloct(val) ; - break; - } - - } else - putchar(*fmt); - } + case 10: + pvaldec(val) ; + break; + case 16: + pvalhex (val); + break; + case 0: + putchar((char)val); + break; + case 8: + pvaloct(val) ; + break; + } + + } else + putchar(*fmt); + } } diff --git a/link/z80/lklibr.c b/link/z80/lklibr.c index e5999621..4e730bef 100644 --- a/link/z80/lklibr.c +++ b/link/z80/lklibr.c @@ -480,7 +480,7 @@ int buildlibraryindex() relfil[NINPUT+1] = '\0'; relfil[strlen(relfil) - 1] = '\0'; if (path != NULL) { - str = (char *)malloc(strlen(path)+strlen(relfil)+6); + str = (char *)Safe_malloc(strlen(path)+strlen(relfil)+6); strcpy(str,path); #ifdef OTHERSYSTEM #ifdef SDK @@ -498,7 +498,7 @@ int buildlibraryindex() } #endif } else { - str = (char *)malloc(strlen(relfil) + 5); + str = (char *)Safe_malloc(strlen(relfil) + 5); } #ifdef SDK #ifdef UNIX @@ -523,7 +523,7 @@ int buildlibraryindex() /*3*/ if ((fp = fopen(str, "r")) != NULL) { /* Opened OK - create a new libraryfile object for it */ - This->next = (pmlibraryfile)malloc( sizeof( mlibraryfile )); + This->next = (pmlibraryfile)Safe_malloc( sizeof( mlibraryfile )); if (This->next == NULL) { printf("panic: cant allocate memory.\n"); exit(-1); diff --git a/packihx/PackIhx.dsp b/packihx/PackIhx.dsp index cf6cc71f..fbf47893 100644 --- a/packihx/PackIhx.dsp +++ b/packihx/PackIhx.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /J /FD /c +# ADD CPP /nologo /G3 /Zp1 /W3 /WX /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/sdcc_vc.h b/sdcc_vc.h index 0677a76e..ca2e5156 100644 --- a/sdcc_vc.h +++ b/sdcc_vc.h @@ -32,6 +32,8 @@ #undef OPT_DISABLE_GBZ80 #undef OPT_DISABLE_MCS51 #undef OPT_DISABLE_AVR +#define OPT_DISABLE_I186 1 +#define OPT_DISABLE_TLCS900H 1 #endif diff --git a/src/SDCC.lex b/src/SDCC.lex index edd42cf0..a668b0ae 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -34,6 +34,7 @@ IS (u|U|l|L)* #include #include #include "common.h" +#include "newalloc.h" char *stringLiteral(); char *currFname; @@ -262,7 +263,7 @@ int checkCurrFile ( char *s) /* mark the end of the filename */ while (*s != '"') s++; *s = '\0'; - ALLOC(currFname,strlen(sb)+1); + currFname = Safe_calloc(strlen(sb)+1); strcpy(currFname,sb); yylineno = lNum - 2; } diff --git a/src/SDCC.y b/src/SDCC.y index 8dd9d97b..02fce6ea 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -32,6 +32,7 @@ #include "SDCCmem.h" #include "SDCCast.h" #include "port.h" +#include "newalloc.h" extern int yyerror (char *); extern FILE *yyin; @@ -1113,7 +1114,7 @@ statement | jump_statement | INLINEASM ';' { ast *ex = newNode(INLINEASM,NULL,NULL); - ALLOC(ex->values.inlineasm,strlen($1)); + ex->values.inlineasm = Safe_calloc(strlen($1)); strcpy(ex->values.inlineasm,$1); $$ = ex; } diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c index 5d975e5f..2059b3d7 100644 --- a/src/SDCCBBlock.c +++ b/src/SDCCBBlock.c @@ -24,6 +24,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" int eBBNum = 0; set *graphEdges = NULL ; /* list of edges in this flow graph */ @@ -46,7 +47,7 @@ eBBlock *neweBBlock () { eBBlock *ebb; - ALLOC(ebb,sizeof(eBBlock)); + ebb = Safe_calloc(sizeof(eBBlock)); return ebb ; } @@ -57,7 +58,7 @@ edge *newEdge (eBBlock *from, eBBlock *to) { edge *ep ; - ALLOC(ep,sizeof(edge)); + ep = Safe_calloc(sizeof(edge)); ep->from = from; ep->to = to; @@ -385,7 +386,8 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count) *count = 0 ; /* allocate for the first entry */ - ALLOC(ebbs,sizeof(eBBlock **)); + + ebbs = Safe_calloc(sizeof(eBBlock **)); while (loop) { @@ -400,12 +402,10 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count) /* put it in the array */ ebbs[(*count)++] = ebb ; - /* allocate for the next one. Remember to clear the new */ - /* pointer at the end, that was created by realloc. */ - if (!(ebbs = realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) { - werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); - exit (1); - } + /* allocate for the next one. Remember to clear the new */ + /* pointer at the end, that was created by realloc. */ + + ebbs = Safe_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)) ; ebbs[*count] = 0; @@ -444,11 +444,11 @@ eBBlock **iCodeBreakDown (iCode *ic, int *count) } (*count)++ ; + /* if we have stopped at the block , allocate for an extra one */ - if (!(ebbs = realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) { - werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); - exit (1); - } + + ebbs = Safe_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)) ; + ebbs[*count] = 0; /* then move the block down one count */ diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index b12a5e39..f4bf9a65 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -91,4 +91,15 @@ iCode *iCodeFromeBBlock ( eBBlock **,int); int otherPathsPresent (eBBlock **,eBBlock *); void replaceLabel(eBBlock *,symbol *,symbol *); void dumpEbbsToFileExt (char *,eBBlock **,int); + +#if defined(_MSC_VER) + +/*-----------------------------------------------------------------*/ +/* dumpLiveRanges - dump liverange information into a file */ +/*-----------------------------------------------------------------*/ + +void dumpLiveRanges (char *ext,hTab *liveRanges) ; + +#endif // _MSC_VER + #endif diff --git a/src/SDCCast.c b/src/SDCCast.c index ff75fff7..04be1921 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -23,6 +23,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" int currLineno = 0; set *astList = NULL ; @@ -71,7 +72,7 @@ ast *newAst (int type, void *op ) ast *ex ; static int oldLineno = 0 ; - ALLOC(ex,sizeof(ast)); + Safe_calloc(ex,sizeof(ast)); ex->type = type ; ex->lineno = (noLineno ? oldLineno : yylineno); @@ -104,7 +105,7 @@ static ast* newAst_(unsigned type) ast *ex ; static int oldLineno = 0 ; - ALLOC(ex,sizeof(ast)); + ex = Safe_calloc(sizeof(ast)); ex->type = type ; ex->lineno = (noLineno ? oldLineno : yylineno); @@ -206,7 +207,7 @@ void copyAstValues (ast *dest,ast *src) break ; case INLINEASM: - ALLOC(dest->values.inlineasm,strlen(src->values.inlineasm)); + dest->values.inlineasm = Safe_calloc(strlen(src->values.inlineasm)); strcpy(dest->values.inlineasm,src->values.inlineasm); case FOR: @@ -230,7 +231,7 @@ ast *copyAst (ast *src) if (!src) return NULL ; - ALLOC(dest,sizeof(ast)); + dest = Safe_calloc(sizeof(ast)); dest->type = src->type ; dest->lineno = src->lineno ; diff --git a/src/SDCCbitv.c b/src/SDCCbitv.c index fe8e1b60..c5ec50da 100644 --- a/src/SDCCbitv.c +++ b/src/SDCCbitv.c @@ -24,6 +24,8 @@ #include "common.h" +#include "newalloc.h" + int bitVectDefault = 1024; /* genernal note about a bitvectors: @@ -38,11 +40,11 @@ bitVect *newBitVect (int size) bitVect *bvp; int byteSize ; - ALLOC(bvp,sizeof (bitVect)); + bvp = Safe_calloc(sizeof (bitVect)); bvp->size = size; bvp->bSize = byteSize = ( size / 8) + 1 ; - ALLOC(bvp->vect,byteSize); + bvp->vect = Safe_calloc(byteSize); return bvp; } @@ -63,9 +65,10 @@ bitVect *bitVectResize (bitVect *bvp, int size) return bvp; } + bvp->vect = Clear_realloc(bvp->vect, bvp -> bSize, bSize); bvp->size = size; bvp->bSize= bSize; - bvp->vect = realloc(bvp->vect, bSize); + return bvp; } diff --git a/src/SDCCcse.c b/src/SDCCcse.c index ba572b6a..f3ebccab 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -23,6 +23,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" /*-----------------------------------------------------------------*/ /* newCseDef - new cseDef */ @@ -32,7 +33,7 @@ cseDef *newCseDef (operand *sym, iCode *ic) cseDef *cdp ; assert (sym); - ALLOC(cdp,sizeof(cseDef)); + cdp = Safe_calloc(sizeof(cseDef)); cdp->sym = sym; cdp->diCode = ic; diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index f7877795..0b78524f 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -88,18 +88,18 @@ typedef int bool; type *type##FreeStack [size] ; \ int type##StackPtr = 0 ; -#define ALLOC(x,sz) if (!(x = calloc(1, sz))) \ - { \ - werror(E_OUT_OF_MEM,__FILE__,(long) sz);\ - exit (1); \ - } - - -#define ALLOCTYPE(type,size) if (!(type##Pool = calloc(1, size*sizeof(type))))\ - { \ - werror(E_OUT_OF_MEM,__FILE__,(long) size); \ - exit (1); \ - } +//#define ALLOC(x,sz) if (!(x = calloc(1, sz))) \ +// { \ +// werror(E_OUT_OF_MEM,__FILE__,(long) sz);\ +// exit (1); \ +// } + + +//#define ALLOCTYPE(type,size) if (!(type##Pool = calloc(1, size*sizeof(type))))\ +// { \ +// werror(E_OUT_OF_MEM,__FILE__,(long) size); \ +// exit (1); \ +// } #define PUSH(x,y) x##FreeStack[x##StackPtr++] = y #define PEEK(x) x##FreeStack[x##StackPtr-1] diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 3cd5c434..901d2911 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -25,6 +25,7 @@ #include "common.h" #include "asm.h" #include +#include "newalloc.h" #if !defined(__BORLANDC__) && !defined(_MSC_VER) #if 0 /* This should no longer be necessary. */ @@ -121,7 +122,7 @@ char *aopLiteralLong(value *val, int offset, int size) /* Hmm. Too big for now. */ assert(0); } - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } @@ -135,7 +136,7 @@ char *aopLiteralLong(value *val, int offset, int size) #else tsprintf(buffer, "!immedbyte", fl.c[offset]); #endif - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } @@ -1350,6 +1351,7 @@ void glue () */ FILE *tempfile(void) { +#if !defined(_MSC_VER) const char *tmpdir = NULL; if (getenv("TMP")) tmpdir = getenv("TMP"); @@ -1369,13 +1371,14 @@ FILE *tempfile(void) } return NULL; } +#endif return tmpfile(); } char *gc_strdup(const char *s) { char *ret; - ALLOC(ret, strlen(s)+1); + ret = Safe_calloc(strlen(s)+1); strcpy(ret, s); return ret; } diff --git a/src/SDCChasht.c b/src/SDCChasht.c index 97033265..22b453ce 100644 --- a/src/SDCChasht.c +++ b/src/SDCChasht.c @@ -28,6 +28,7 @@ #include #include "SDCCglobl.h" #include "SDCChasht.h" +#include "newalloc.h" #define DEFAULT_HTAB_SIZE 128 @@ -38,7 +39,7 @@ static hashtItem *_newHashtItem (int key, void *pkey, void *item) { hashtItem *htip; - ALLOC(htip,sizeof(hashtItem)); + htip = Safe_calloc(sizeof(hashtItem)); htip->key = key ; htip->pkey = pkey; @@ -54,7 +55,7 @@ hTab *newHashTable (int size) { hTab *htab; - ALLOC(htab,sizeof(hTab)); + htab = Safe_calloc(sizeof(hTab)); if (!(htab->table = calloc((size +1), sizeof(hashtItem *)))) { fprintf(stderr,"out of virtual memory %s %d\n", @@ -76,7 +77,7 @@ void hTabAddItemLong(hTab **htab, int key, void *pkey, void *item) if (key > (*htab)->size ) { int i; - (*htab)->table = realloc ((*htab)->table, + (*htab)->table = Safe_realloc ((*htab)->table, (key*2 + 2)*sizeof(hashtItem *)); for ( i = (*htab)->size +1; i <= (key*2 + 1); i++ ) (*htab)->table[i] = NULL ; diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 9d82ef56..19c833be 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -23,6 +23,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" /*-----------------------------------------------------------------*/ /* global variables */ @@ -412,7 +413,7 @@ operand *newOperand () { operand *op ; - ALLOC(op,sizeof(operand)); + op = Safe_calloc(sizeof(operand)); op->key = 0 ; return op; @@ -425,7 +426,7 @@ iCode *newiCode (int op, operand *left, operand *right) { iCode *ic ; - ALLOC(ic,sizeof(iCode)); + ic = Safe_calloc(sizeof(iCode)); ic->lineno = lineno ; ic->filename= filename ; diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 4cf349c4..64d3d502 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -24,6 +24,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" DEFSETFUNC(isDefAlive); @@ -37,7 +38,7 @@ induction *newInduction (operand *sym, unsigned int op, { induction *ip; - ALLOC(ip,sizeof(induction)); + ip = Safe_calloc(sizeof(induction)); ip->sym = sym; ip->asym= asym; @@ -55,7 +56,7 @@ region *newRegion () { region *lp ; - ALLOC(lp,sizeof(region)); + lp = Safe_calloc(sizeof(region)); return lp; } diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 4a4c7a6b..2d44d466 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -26,6 +26,7 @@ #include "common.h" #include +#include "newalloc.h" #if NATIVE_WIN32 #include @@ -71,6 +72,14 @@ int nrelFiles = 0; bool verboseExec = FALSE; char *preOutName; +// In MSC VC6 default search path for exe's to path for this + +#if defined(_MSC_VER) + +char DefaultExePath[_MAX_PATH] ; + +#endif + /* Far functions, far data */ #define OPTION_LARGE_MODEL "-model-large" /* Far functions, near data */ @@ -474,7 +483,7 @@ static void processFile (char *s) /* get rid of the "." */ strtok(buffer,"."); - ALLOC(srcFileName,strlen(buffer)+1); + srcFileName = Safe_calloc(strlen(buffer)+1); strcpy(srcFileName,buffer); /* get rid of any path information @@ -487,7 +496,7 @@ static void processFile (char *s) *(fext-1) != '/' && *(fext-1) != ':') fext--; - ALLOC(moduleName,strlen(fext)+1); + moduleName = Safe_calloc(strlen(fext)+1); strcpy(moduleName,fext); return ; @@ -1138,7 +1147,7 @@ int parseCmdLine ( int argc, char **argv ) #if defined(_MSC_VER) -char *try_dir[]= {NULL}; // TODO : Fill in some default search list +char *try_dir[]= {DefaultExePath, NULL}; // TODO : Fill in some default search list #else @@ -1198,14 +1207,16 @@ int my_system (const char *cmd) } return e; } + #else + int my_system (const char *cmd, char **cmd_argv) { char *dir, *got= NULL; int i= 0; while (!got && try_dir[i]) { - dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10); + dir= (char*)Safe_malloc(strlen(try_dir[i])+strlen(cmd)+10); strcpy(dir, try_dir[i]); strcat(dir, "/"); strcat(dir, cmd); @@ -1548,6 +1559,28 @@ int main ( int argc, char **argv , char **envp) if (port->init) port->init(); +#if defined(_MSC_VER) + + { + int i ; + + // Create a default exe search path from the path to the sdcc command + + strcpy(DefaultExePath,argv[0]) ; + + for(i = strlen(DefaultExePath) ; i > 0 ; i--) + if (DefaultExePath[i] == '\\') + { + DefaultExePath[i] = '\0' ; + break ; + } + + if (i == 0) + DefaultExePath[0] = '\0' ; + } + +#endif + setDefaultOptions(); parseCmdLine(argc,argv); @@ -1630,4 +1663,4 @@ int main ( int argc, char **argv , char **envp) return 0; -} + } diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index 90762177..51c65eb2 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -25,6 +25,7 @@ #include "common.h" #include "SDCCpeeph.h" +#include "newalloc.h" peepRule *rootRules = NULL; peepRule *currRule = NULL; @@ -270,13 +271,13 @@ peepRule *newPeepRule (lineNode *match , { peepRule *pr ; - ALLOC(pr,sizeof(peepRule)); + pr= Safe_calloc(sizeof(peepRule)); pr->match = match; pr->replace= replace; pr->restart = restart; if (cond && *cond) { - ALLOC(pr->cond,strlen(cond)+1); + pr->cond = Safe_calloc(strlen(cond)+1); strcpy(pr->cond,cond); } else pr->cond = NULL ; @@ -299,8 +300,8 @@ lineNode *newLineNode (char *line) { lineNode *pl; - ALLOC(pl,sizeof(lineNode)); - ALLOC(pl->line,strlen(line)+1); + pl = Safe_calloc(sizeof(lineNode)); + pl->line = Safe_calloc(strlen(line)+1); strcpy(pl->line,line); return pl; } @@ -506,7 +507,7 @@ static void bindVar (int key, char **s, hTab **vtab) *s = vvx ; *vv = '\0'; /* got value */ - ALLOC(vvx,strlen(vval)+1); + vvx = Safe_calloc(strlen(vval)+1); strcpy(vvx,vval); hTabAddItem(vtab,key,vvx); @@ -786,9 +787,7 @@ static void buildLabelRefCountHash(lineNode *head) { labelHashEntry *entry; - ALLOC(entry, sizeof(labelHashEntry)); - - assert(entry != NULL); + entry = Safe_calloc(sizeof(labelHashEntry)); memcpy(entry->name, label, labelLen); entry->name[labelLen] = 0; @@ -911,10 +910,10 @@ static char *readFileIntoBuffer (char *fname) lb[nch] = '\0'; /* copy it into allocated buffer */ if (rs) { - rs = realloc(rs,strlen(rs)+strlen(lb)+1); + rs = Safe_realloc(rs,strlen(rs)+strlen(lb)+1); strcat(rs,lb); } else { - ALLOC(rs,strlen(lb)+1); + rs = Safe_calloc(strlen(lb)+1); strcpy(rs,lb); } nch = 0 ; @@ -926,10 +925,10 @@ static char *readFileIntoBuffer (char *fname) lb[nch] = '\0'; /* copy it into allocated buffer */ if (rs) { - rs = realloc(rs,strlen(rs)+strlen(lb)+1); + rs = Safe_realloc(rs,strlen(rs)+strlen(lb)+1); strcat(rs,lb); } else { - ALLOC(rs,strlen(lb)+1); + rs = Safe_calloc(strlen(lb)+1); strcpy(rs,lb); } } diff --git a/src/SDCCset.c b/src/SDCCset.c index f1f039d0..25fbf0c2 100644 --- a/src/SDCCset.c +++ b/src/SDCCset.c @@ -23,7 +23,7 @@ -------------------------------------------------------------------------*/ #include -#include +#include "newalloc.h" #include #include "SDCCset.h" @@ -34,11 +34,11 @@ set *newSet () { set *lp ; - lp = calloc(1, sizeof(set)); - if (lp == 0) { - fprintf(stderr, "out of virtual memory: %s\n", __FILE__); - exit(1); - } + lp = Safe_calloc(sizeof(set)); +// if (lp == 0) { +// fprintf(stderr, "out of virtual memory: %s\n", __FILE__); +// exit(1); +// } lp->item = lp->curr= lp->next = NULL; return lp; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 8ff43f18..294cb8e5 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -22,6 +22,7 @@ -------------------------------------------------------------------------*/ #include "common.h" +#include "newalloc.h" bucket *SymbolTab [256] ; /* the symbol table */ bucket *StructTab [256] ; /* the structure table */ @@ -48,7 +49,7 @@ bucket *newBucket () { bucket *bp ; - ALLOC(bp,sizeof(bucket)); + bp = Safe_calloc(sizeof(bucket)); return bp ; } @@ -80,7 +81,7 @@ void addSym ( bucket **stab , /* the symbols are always added at the head of the list */ i = hashKey(sname) ; /* get a free entry */ - ALLOC(bp,sizeof(bucket)); + bp = Safe_calloc(sizeof(bucket)); bp->sym = sym ; /* update the symbol pointer */ bp->level = level; /* update the nest level */ @@ -221,7 +222,7 @@ symbol *newSymbol (char *name, int scope ) { symbol *sym ; - ALLOC(sym,sizeof(symbol)); + sym = Safe_calloc(sizeof(symbol)); strcpy(sym->name,name); /* copy the name */ sym->level = scope ; /* set the level */ @@ -237,7 +238,7 @@ sym_link *newLink () { sym_link *p ; - ALLOC(p,sizeof(sym_link)); + p = Safe_calloc(sizeof(sym_link)); return p; } @@ -249,7 +250,7 @@ structdef *newStruct ( char *tag ) { structdef *s; - ALLOC(s,sizeof(structdef)); + s = Safe_calloc(sizeof(structdef)); strcpy(s->tag,tag) ; /* copy the tag */ return s ; diff --git a/src/SDCCval.c b/src/SDCCval.c index 644054df..83885665 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -27,6 +27,7 @@ #include #include #include +#include "newalloc.h" int cNestLevel ; @@ -37,7 +38,7 @@ value *newValue () { value *val ; - ALLOC(val,sizeof(value)); + val = Safe_calloc(sizeof(value)); return val ; } @@ -50,7 +51,7 @@ initList *newiList ( int type, void *ilist) initList *nilist; - ALLOC(nilist,sizeof(initList)); + nilist = Safe_calloc(sizeof(initList)); nilist->type = type ; nilist->lineno = yylineno ; @@ -402,7 +403,7 @@ value *strVal ( char *s ) SPEC_NOUN(val->etype) = V_CHAR ; SPEC_SCLS(val->etype) = S_LITERAL; - ALLOC(SPEC_CVAL(val->etype).v_char,strlen(s)+1); + SPEC_CVAL(val->etype).v_char = Safe_calloc(strlen(s)+1); copyStr (SPEC_CVAL(val->etype).v_char,s); return val; } diff --git a/src/avr/avr.dsp b/src/avr/avr.dsp index d47e808f..ccda6ac8 100644 --- a/src/avr/avr.dsp +++ b/src/avr/avr.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c # SUBTRACT CPP /WX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,8 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/src/avr/gen.c b/src/avr/gen.c index 40fdc977..1a8ffb63 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -29,6 +29,7 @@ #include #include #include "SDCCglobl.h" +#include "newalloc.h" #ifdef HAVE_SYS_ISA_DEFS_H #include @@ -234,7 +235,7 @@ static asmop *newAsmop (short type) { asmop *aop; - ALLOC(aop,sizeof(asmop)); + aop = Safe_calloc(sizeof(asmop)); aop->type = type; return aop; } @@ -322,7 +323,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result) /* special case for a function */ if (IS_FUNC(sym->type)) { sym->aop = aop = newAsmop(AOP_IMMD); - ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1); strcpy(aop->aopu.aop_immd,sym->rname); aop->size = FPTRSIZE; return aop; @@ -372,7 +373,7 @@ static asmop *aopForRemat (symbol *sym) else strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname); - ALLOC(aop->aopu.aop_immd,strlen(buffer)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1); strcpy(aop->aopu.aop_immd,buffer); return aop; } diff --git a/src/ds390/ds390.dsp b/src/ds390/ds390.dsp index caff518c..8ac20eb6 100644 --- a/src/ds390/ds390.dsp +++ b/src/ds390/ds390.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /Fp"Release/ds390.pch" /YX /J /FD /Zm500 /c +# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /Fp"Release/ds390.pch" /YX /FD /Zm500 /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,8 +64,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/src/ds390/gen.c b/src/ds390/gen.c index f202e191..9ff7e114 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -37,6 +37,7 @@ #include "ralloc.h" #include "gen.h" #include "SDCCglobl.h" +#include "newalloc.h" #ifdef HAVE_SYS_ISA_DEFS_H #include @@ -254,7 +255,7 @@ static asmop *newAsmop (short type) { asmop *aop; - ALLOC(aop,sizeof(asmop)); + aop = Safe_calloc(sizeof(asmop)); aop->type = type; return aop; } @@ -479,7 +480,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool useDP2) /* special case for a function */ if (IS_FUNC(sym->type)) { sym->aop = aop = newAsmop(AOP_IMMD); - ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1); strcpy(aop->aopu.aop_immd,sym->rname); aop->size = FPTRSIZE; return aop; @@ -537,7 +538,7 @@ static asmop *aopForRemat (symbol *sym) else strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname); - ALLOC(aop->aopu.aop_immd,strlen(buffer)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1); strcpy(aop->aopu.aop_immd,buffer); return aop; } @@ -908,7 +909,7 @@ static char *aopGet (asmop *aop, return (dname ? "acc" : "a"); } sprintf(s,"@%s",aop->aopu.aop_ptr->name); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -974,7 +975,7 @@ static char *aopGet (asmop *aop, else sprintf(s,"#%s", aop->aopu.aop_immd); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -985,7 +986,7 @@ static char *aopGet (asmop *aop, offset); else sprintf(s,"%s",aop->aopu.aop_dir); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index fe68ff17..22f17582 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -33,6 +33,7 @@ #include #include #include "SDCCglobl.h" +#include "newalloc.h" #ifdef HAVE_SYS_ISA_DEFS_H #include @@ -229,7 +230,7 @@ static asmop *newAsmop (short type) { asmop *aop; - ALLOC(aop,sizeof(asmop)); + aop = Safe_calloc(sizeof(asmop)); aop->type = type; return aop; } @@ -353,7 +354,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result) /* special case for a function */ if (IS_FUNC(sym->type)) { sym->aop = aop = newAsmop(AOP_IMMD); - ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1); strcpy(aop->aopu.aop_immd,sym->rname); aop->size = FPTRSIZE; return aop; @@ -400,7 +401,7 @@ static asmop *aopForRemat (symbol *sym) else strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname); - ALLOC(aop->aopu.aop_immd,strlen(buffer)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1); strcpy(aop->aopu.aop_immd,buffer); return aop; } @@ -747,7 +748,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) return (dname ? "acc" : "a"); } sprintf(s,"@%s",aop->aopu.aop_ptr->name); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -797,7 +798,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) else sprintf(s,"#%s", aop->aopu.aop_immd); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -808,7 +809,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) offset); else sprintf(s,"%s",aop->aopu.aop_dir); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; diff --git a/src/mcs51/mcs51.dsp b/src/mcs51/mcs51.dsp index 05659098..0f5899b4 100644 --- a/src/mcs51/mcs51.dsp +++ b/src/mcs51/mcs51.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c # SUBTRACT CPP /WX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,8 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 58ae61cc..f9976eeb 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -129,7 +129,14 @@ regs *mcs51_regWithIdx (int idx) /*-----------------------------------------------------------------*/ static void freeReg (regs *reg) { - reg->isFree = 1; + if (!reg) + { + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "freeReg - Freeing NULL register"); + exit(1); + } + + reg->isFree = 1; } diff --git a/src/pic/gen.c b/src/pic/gen.c index d9757f2c..28acf401 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -34,6 +34,7 @@ #include #include #include "SDCCglobl.h" +#include "newalloc.h" #if defined(_MSC_VER) #define __FUNCTION__ __FILE__ @@ -309,7 +310,7 @@ static asmop *newAsmop (short type) { asmop *aop; - ALLOC(aop,sizeof(asmop)); + aop = Safe_calloc(sizeof(asmop)); aop->type = type; return aop; } @@ -439,7 +440,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result) /* special case for a function */ if (IS_FUNC(sym->type)) { sym->aop = aop = newAsmop(AOP_IMMD); - ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1); strcpy(aop->aopu.aop_immd,sym->rname); aop->size = FPTRSIZE; return aop; @@ -489,7 +490,7 @@ static asmop *aopForRemat (symbol *sym) strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname); //DEBUGemitcode(";","%s",buffer); - ALLOC(aop->aopu.aop_immd,strlen(buffer)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1); strcpy(aop->aopu.aop_immd,buffer); return aop; } @@ -848,7 +849,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) return (dname ? "acc" : "a"); } sprintf(s,"@%s",aop->aopu.aop_ptr->name); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -899,7 +900,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) else sprintf(s,"%s", aop->aopu.aop_immd); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -910,7 +911,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) offset); else sprintf(s,"%s",aop->aopu.aop_dir); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; diff --git a/src/pic/glue.c b/src/pic/glue.c index 4613e1e0..e34d8081 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -25,6 +25,7 @@ #include "../common.h" #include #include "ralloc.h" +#include "newalloc.h" extern symbol *interrupts[256]; void printIval (symbol *, sym_link *, initList *, FILE *); @@ -88,7 +89,7 @@ char *pic14aopLiteral (value *val, int offset) v >>= (offset * 8); sprintf(buffer,"0x%02x",((char) v) & 0xff); - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } @@ -99,7 +100,7 @@ char *pic14aopLiteral (value *val, int offset) #else sprintf(buffer,"0x%02x",fl.c[offset]); #endif - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } diff --git a/src/pic/pic.dsp b/src/pic/pic.dsp index 08f7d7f9..80bf2d34 100644 --- a/src/pic/pic.dsp +++ b/src/pic/pic.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c # SUBTRACT CPP /WX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,8 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /Zm500 /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 81900514..cb918766 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -28,6 +28,10 @@ #include "ralloc.h" #include "gen.h" +#if defined(_MSC_VER) +#define __FUNCTION__ __FILE__ +#endif + /*-----------------------------------------------------------------*/ /* At this point we start getting processor specific although */ /* some routines are non-processor specific & can be reused when */ diff --git a/src/src.dsp b/src/src.dsp index 372580ee..513451c4 100644 --- a/src/src.dsp +++ b/src/src.dsp @@ -68,8 +68,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c -# SUBTRACT CPP /WX /YX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "..\support\util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -95,6 +94,10 @@ SOURCE=.\asm.c # End Source File # Begin Source File +SOURCE=..\support\Util\NewAlloc.c +# End Source File +# Begin Source File + SOURCE=.\SDCC.lex !IF "$(CFG)" == "src - Win32 Release" @@ -175,7 +178,7 @@ SOURCE=.\SDCCdflow.c # End Source File # Begin Source File -SOURCE=.\SDCCerr.c +SOURCE=..\support\Util\sdccerr.c # End Source File # Begin Source File @@ -247,11 +250,15 @@ SOURCE=.\sdccy.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\support\Util\newalloc.h +# End Source File +# Begin Source File + SOURCE=..\sdcc_vc.h # End Source File # Begin Source File -SOURCE=.\SDCCalloc.h +SOURCE=.\SDCCBBlock.h # End Source File # Begin Source File diff --git a/src/z80/gen.c b/src/z80/gen.c index 1d95fc8a..7a2984eb 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -59,6 +59,7 @@ #include "SDCCpeeph.h" #include "gen.h" #include "SDCCglue.h" +#include "newalloc.h" /* this is the down and dirty file with all kinds of kludgy & hacky stuff. This is what it is all about CODE GENERATION for a specific MCU. @@ -334,7 +335,7 @@ static asmop *newAsmop (short type) { asmop *aop; - ALLOC(aop,sizeof(asmop)); + aop = Safe_calloc(sizeof(asmop)); aop->type = type; return aop; } @@ -369,7 +370,7 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a) /* special case for a function */ if (IS_FUNC(sym->type)) { sym->aop = aop = newAsmop(AOP_IMMD); - ALLOC(aop->aopu.aop_immd,strlen(sym->rname)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(sym->rname)+1); strcpy(aop->aopu.aop_immd,sym->rname); aop->size = 2; return aop; @@ -429,7 +430,7 @@ static asmop *aopForRemat (symbol *sym) break; } - ALLOC(aop->aopu.aop_immd,strlen(buffer)+1); + aop->aopu.aop_immd = Safe_calloc(strlen(buffer)+1); strcpy(aop->aopu.aop_immd,buffer); return aop; } @@ -716,7 +717,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash) tsprintf(s, "!hashedstr + %d", aop->aopu.aop_immd, offset); else tsprintf(s, "%s + %d", aop->aopu.aop_immd, offset); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; case AOP_LIT: { @@ -733,7 +734,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash) tsprintf(buffer, "!immedword", v); else tsprintf(buffer, "!constword", v); - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } else { @@ -744,7 +745,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash) tsprintf(buffer, "!immedword", f.w[offset/2]); else tsprintf(buffer, "!constword", f.w[offset/2]); - ALLOC(rs,strlen(buffer)+1); + rs = Safe_calloc(strlen(buffer)+1); return strcpy (rs,buffer); } } @@ -994,7 +995,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16) default: wassert(0); } - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -1002,7 +1003,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16) wassert(IS_GB); emitcode("ld", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset); sprintf(s, "a"); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -1010,7 +1011,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16) wassert(IS_GB); emitcode("ldh", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset); sprintf(s, "a"); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -1027,7 +1028,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16) wassert(IS_Z80); setupPair(PAIR_IY, aop, offset); tsprintf(s,"!*iyx", offset); - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; @@ -1041,7 +1042,7 @@ static char *aopGet(asmop *aop, int offset, bool bit16) offset += _G.stack.param_offset; tsprintf(s,"!*ixx ; x", aop->aopu.aop_stk+offset); } - ALLOC(rs,strlen(s)+1); + rs = Safe_calloc(strlen(s)+1); strcpy(rs,s); return rs; diff --git a/src/z80/z80.dsp b/src/z80/z80.dsp index 2288d0ac..6980f7e6 100644 --- a/src/z80/z80.dsp +++ b/src/z80/z80.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /J /FD /Zm500 /c +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /Zm500 /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,7 +64,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I ".." /I "." /I "..\.." /I "..\..\support\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /J /FD /GZ /Zm500 /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -98,7 +98,7 @@ SOURCE=".\peeph-z80.def" !IF "$(CFG)" == "z80 - Win32 Release" # Begin Custom Build -InputPath=.\peeph-z80.def +InputPath=".\peeph-z80.def" "peeph-z80.rul" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo on @@ -109,7 +109,7 @@ InputPath=.\peeph-z80.def !ELSEIF "$(CFG)" == "z80 - Win32 Debug" # Begin Custom Build -InputPath=.\peeph-z80.def +InputPath=".\peeph-z80.def" "peeph-z80.rul peeph.rul peeph-gbz80.rul" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo on diff --git a/support/Util/NewAlloc.c b/support/Util/NewAlloc.c new file mode 100644 index 00000000..920286eb --- /dev/null +++ b/support/Util/NewAlloc.c @@ -0,0 +1,136 @@ +/* +=============================================================================== +NEWALLOC - SDCC Memory allocation functions + +These functions are wrappers for the standard malloc, realloc and free +functions. + + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +=============================================================================== +*/ + +//#include "SDCCerr.h" + +#include +#include +#include +#include + +#include "newalloc.h" +/* +------------------------------------------------------------------------------- +Clear_realloc - Reallocate a memory block and clear any memory added with +out of memory error detection + +------------------------------------------------------------------------------- +*/ + +void *Clear_realloc(void *OldPtr,size_t OldSize,size_t NewSize) + +{ +void *NewPtr ; + +NewPtr = realloc(OldPtr,NewSize) ; + +if (!NewPtr) + { + printf("ERROR - No more memory\n") ; +// werror(E_OUT_OF_MEM,__FILE__,NewSize); + exit (1); + } + +if (NewPtr) + if (NewSize > OldSize) + memset((char *) NewPtr + OldSize,0x00,NewSize - OldSize) ; + +return NewPtr ; +} +/* +------------------------------------------------------------------------------- +Safe_realloc - Reallocate a memory block with out of memory error detection + +------------------------------------------------------------------------------- +*/ + +void *Safe_realloc(void *OldPtr,size_t NewSize) + +{ +void *NewPtr ; + +NewPtr = realloc(OldPtr,NewSize) ; + +if (!NewPtr) + { + printf("ERROR - No more memory\n") ; +// werror(E_OUT_OF_MEM,__FILE__,NewSize); + exit (1); + } + +return NewPtr ; +} +/* +------------------------------------------------------------------------------- +Safe_calloc - Allocate a block of memory from the application heap, clearing +all data to zero and checking for out of memory errors. + +------------------------------------------------------------------------------- +*/ + +void *Safe_calloc(size_t Size) + +{ +void *NewPtr ; + +NewPtr = calloc(Size,1) ; + +if (!NewPtr) + { + printf("ERROR - No more memory\n") ; +// werror(E_OUT_OF_MEM,__FILE__,Size); + exit (1); + } + +return NewPtr ; +} +/* +------------------------------------------------------------------------------- +Safe_malloc - Allocate a block of memory from the application heap +and checking for out of memory errors. + +------------------------------------------------------------------------------- +*/ + +void *Safe_malloc(size_t Size) + +{ +void *NewPtr ; + +NewPtr = malloc(Size) ; + +if (!NewPtr) + { + printf("ERROR - No more memory\n") ; +// werror(E_OUT_OF_MEM,__FILE__,Size); + exit (1); + } + +return NewPtr ; +} diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h new file mode 100644 index 00000000..bc18d4cd --- /dev/null +++ b/support/Util/SDCCerr.h @@ -0,0 +1,183 @@ +/* +=============================================================================== +SDCCERR - SDCC Standard error handler + + +=============================================================================== +*/ + +#if !defined(__SDCCERR_H) + +#define __SDCCERR_H + +#include +#include + +/* ERROR MEssage Definition */ + +#define E_DUPLICATE 0 /* Duplicate variable */ +#define E_SYNTAX_ERROR 1 /* Syntax Error */ +#define E_CONST_EXPECTED 2 /* constant expected */ +#define E_OUT_OF_MEM 3 /* malloc failed */ +#define E_FILE_OPEN_ERR 4 /* File open failed */ +#define E_INVALID_OCLASS 5 /* output class invalid */ +#define E_CANNOT_ALLOC 6 /* cannot allocate space*/ +#define E_OLD_STYLE 7 /* old style C ! allowed*/ +#define E_STACK_OUT 8 /* v r out of stack */ +#define E_INTERNAL_ERROR 9 /* unable to alloc tvar */ +#define E_LVALUE_REQUIRED 10 /* lvalue required */ +#define E_TMPFILE_FAILED 11 /* tmpfile creation failed */ +#define E_FUNCTION_EXPECTED 12 /* function expected */ +#define E_USING_ERROR 13 /* using in error */ +#define E_SFR_INIT 14 /* init error for sbit */ +#define E_INIT_IGNORED 15 /* initialiser ignored */ +#define E_AUTO_ASSUMED 16 /* sclass auto assumed */ +#define E_AUTO_ABSA 17 /* abs addr for auto var*/ +#define E_INIT_WRONG 18 /* initializer type != */ +#define E_FUNC_REDEF 19 /* func name redefined */ +#define E_ID_UNDEF 20 /* identifer undefined */ +#define W_STACK_OVERFLOW 21 /* stack overflow */ +#define E_NEED_ARRAY_PTR 22 /* array or pointer reqd*/ +#define E_IDX_NOT_INT 23 /* index not an integer */ +#define E_ARRAY_BOUND 24 /* array limit exceeded */ +#define E_STRUCT_UNION 25 /* struct,union expected*/ +#define E_NOT_MEMBER 26 /* !struct/union member */ +#define E_PTR_REQD 27 /* pointer required */ +#define E_UNARY_OP 28 /* unary operator bad op*/ +#define E_CONV_ERR 29 /* conversion error */ +#define E_INT_REQD 30 /* bit field must be int*/ +#define E_BITFLD_SIZE 31 /* bit field size > 16 */ +#define E_TRUNCATION 32 /* high order trucation */ +#define E_CODE_WRITE 33 /* trying 2 write to code */ +#define E_LVALUE_CONST 34 /* lvalue is a const */ +#define E_ILLEGAL_ADDR 35 /* address of bit */ +#define E_CAST_ILLEGAL 36 /* cast illegal */ +#define E_MULT_INTEGRAL 37 /* mult opernd must b integral */ +#define E_ARG_ERROR 38 /* argument count error*/ +#define E_ARG_COUNT 39 /* func expecting more */ +#define E_FUNC_EXPECTED 40 /* func name expected */ +#define E_PLUS_INVALID 41 /* plus invalid */ +#define E_PTR_PLUS_PTR 42 /* pointer + pointer */ +#define E_SHIFT_OP_INVALID 43 /* shft op op invalid */ +#define E_COMPARE_OP 44 /* compare operand */ +#define E_BITWISE_OP 45 /* bit op invalid op */ +#define E_ANDOR_OP 46 /* && || op invalid */ +#define E_TYPE_MISMATCH 47 /* type mismatch */ +#define E_AGGR_ASSIGN 48 /* aggr assign */ +#define E_ARRAY_DIRECT 49 /* array indexing in */ +#define E_BIT_ARRAY 50 /* bit array not allowed */ +#define E_DUPLICATE_TYPEDEF 51 /* typedef name duplicate */ +#define E_ARG_TYPE 52 /* arg type mismatch */ +#define E_RET_VALUE 53 /* return value mismatch */ +#define E_FUNC_AGGR 54 /* function returing aggr */ +#define E_FUNC_DEF 55 /* ANSI Style def neede */ +#define E_DUPLICATE_LABEL 56 /* duplicate label name */ +#define E_LABEL_UNDEF 57 /* undefined label used */ +#define E_FUNC_VOID 58 /* void func ret value */ +#define E_VOID_FUNC 59 /* func must return value */ +#define E_RETURN_MISMATCH 60 /* return value mismatch */ +#define E_CASE_CONTEXT 61 /* case stmnt without switch */ +#define E_CASE_CONSTANT 62 /* case expression ! const*/ +#define E_BREAK_CONTEXT 63 /* break statement invalid*/ +#define E_SWITCH_AGGR 64 /* non integral for switch*/ +#define E_FUNC_BODY 65 /* func has body already */ +#define E_UNKNOWN_SIZE 66 /* variable has unknown size */ +#define E_AUTO_AGGR_INIT 67 /* auto aggregates no init */ +#define E_INIT_COUNT 68 /* too many initializers */ +#define E_INIT_STRUCT 69 /* struct init wrong */ +#define E_INIT_NON_ADDR 70 /* non address xpr for init */ +#define E_INT_DEFINED 71 /* interrupt already over */ +#define E_INT_ARGS 72 /* interrupt rtn cannot have args */ +#define E_INCLUDE_MISSING 73 /* compiler include missing */ +#define E_NO_MAIN 74 /* main function undefined */ +#define E_EXTERN_INIT 75 /* extern variable initialised */ +#define E_PRE_PROC_FAILED 76 /* preprocessor failed */ +#define E_DUP_FAILED 77 /* file DUP failed */ +#define E_INCOMPAT_CAST 78 /* incompatible pointer casting */ +#define E_LOOP_ELIMINATE 79 /* loop eliminated */ +#define W_NO_SIDE_EFFECTS 80 /* expression has no side effects */ +#define E_CONST_TOO_LARGE 81 /* constant out of range */ +#define W_BAD_COMPARE 82 /* bad comparison */ +#define E_TERMINATING 83 /* compiler terminating */ +#define W_LOCAL_NOINIT 84 /* local reference before assignment */ +#define W_NO_REFERENCE 85 /* no reference to local variable */ +#define E_OP_UNKNOWN_SIZE 86 /* unknown size for operand */ +#define W_LONG_UNSUPPORTED 87 /* 'long' not supported yet */ +#define W_LITERAL_GENERIC 88 /* literal being cast to generic pointer */ +#define E_SFR_ADDR_RANGE 89 /* sfr address out of range */ +#define E_BITVAR_STORAGE 90 /* storage given for 'bit' variable */ +#define W_EXTERN_MISMATCH 91 /* extern declaration mismatches */ +#define E_NONRENT_ARGS 92 /* fptr non reentrant has args */ +#define W_DOUBLE_UNSUPPORTED 93 /* 'double' not supported yet */ +#define W_IF_NEVER_TRUE 94 /* if always false */ +#define W_FUNC_NO_RETURN 95 /* no return statement found */ +#define W_PRE_PROC_WARNING 96 /* preprocessor generated warning */ +#define W_STRUCT_AS_ARG 97 /* structure passed as argument */ +#define E_PREV_DEF_CONFLICT 98 /* previous definition conflicts with current */ +#define E_CODE_NO_INIT 99 /* vars in code space must have initializer */ +#define E_OPS_INTEGRAL 100 /* operans must be integral for certian assignments */ +#define E_TOO_MANY_PARMS 101 /* too many parameters */ +#define E_TO_FEW_PARMS 102 /* to few parameters */ +#define E_FUNC_NO_CODE 103 /* fatalError */ +#define E_TYPE_MISMATCH_PARM 104 /* type mismatch for parameter */ +#define E_INVALID_FLOAT_CONST 105 /* invalid floating point literal string */ +#define E_INVALID_OP 106 /* invalid operand for some operation */ +#define E_SWITCH_NON_INTEGER 107 /* switch value not integer */ +#define E_CASE_NON_INTEGER 108 /* case value not integer */ +#define E_FUNC_TOO_LARGE 109 /* function too large */ +#define W_CONTROL_FLOW 110 /* control flow changed due to optimization */ +#define W_PTR_TYPE_INVALID 111 /* invalid type specifier for pointer */ +#define W_IMPLICIT_FUNC 112 /* function declared implicitly */ +#define E_CONTINUE 113 /* more than one line */ +#define W_TOOMANY_SPILS 114 /* too many spils occured */ +#define W_UNKNOWN_PRAGMA 115 /* #pragma directive unsupported */ +#define W_SHIFT_CHANGED 116 /* shift changed to zero */ +#define W_UNKNOWN_OPTION 117 /* don't know the option */ +#define W_UNSUPP_OPTION 118 /* processor reset has been redifned */ +#define W_UNKNOWN_FEXT 119 /* unknown file extension */ +#define W_TOO_MANY_SRC 120 /* can only compile one .c file at a time */ +#define I_CYCLOMATIC 121 /* information message */ +#define E_DIVIDE_BY_ZERO 122 /* / 0 */ +#define E_FUNC_BIT 123 /* function cannot return bit */ +#define E_CAST_ZERO 124 /* casting to from size zero */ +#define W_CONST_RANGE 125 /* constant too large */ +#define W_CODE_UNREACH 126 /* unreachable code */ +#define W_NONPTR2_GENPTR 127 /* non pointer cast to generic pointer */ +#define W_POSSBUG 128 /* possible code generation error */ +#define W_PTR_ASSIGN 129 /* incampatible pointer assignment */ +#define W_UNKNOWN_MODEL 130 /* Unknown memory model */ +#define E_UNKNOWN_TARGET 131 /* target not defined */ +#define W_INDIR_BANKED 132 /* Indirect call to a banked fun */ +#define W_UNSUPPORTED_MODEL 133 /* Unsupported model, ignored */ +#define W_BANKED_WITH_NONBANKED 134 /* banked and nonbanked attributes mixed */ +#define W_BANKED_WITH_STATIC 135 /* banked and static mixed */ +#define W_INT_TO_GEN_PTR_CAST 136 /* Converting integer type to generic pointer. */ + +/* +------------------------------------------------------------------------------- +SetErrorOut - Set the error output file + +------------------------------------------------------------------------------- +*/ + +FILE * SetErrorOut(FILE *NewErrorOut) ; + +/* +------------------------------------------------------------------------------- +vwerror - Output a standard eror message with variable number of arguements + +------------------------------------------------------------------------------- +*/ + +void vwerror (int errNum, va_list marker) ; + +/* +------------------------------------------------------------------------------- +werror - Output a standard eror message with variable number of arguements + +------------------------------------------------------------------------------- +*/ + +void werror (int errNum, ... ) ; + +#endif diff --git a/support/Util/newalloc.h b/support/Util/newalloc.h new file mode 100644 index 00000000..e27957fa --- /dev/null +++ b/support/Util/newalloc.h @@ -0,0 +1,75 @@ +/* +=============================================================================== +NEWALLOC - SDCC Memory allocation functions + +These functions are wrappers for the standard malloc, realloc and free +functions. + + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +=============================================================================== +*/ + +#if !defined(_NewAlloc_H) + +#define _NewAlloc_H + +#include + +/* +------------------------------------------------------------------------------- +Clear_realloc - Reallocate a memory block and clear any memory added with +out of memory error detection + +------------------------------------------------------------------------------- +*/ + +void *Clear_realloc(void *OldPtr,size_t OldSize,size_t NewSize) ; + +/* +------------------------------------------------------------------------------- +Safe_realloc - Reallocate a memory block with out of memory error detection + +------------------------------------------------------------------------------- +*/ + +void *Safe_realloc(void *OldPtr,size_t NewSize) ; + +/* +------------------------------------------------------------------------------- +Safe_calloc - Allocate a block of memory from the application heap, clearing +all data to zero and checking for out or memory errors. + +------------------------------------------------------------------------------- +*/ + +void *Safe_calloc(size_t Size) ; + +/* +------------------------------------------------------------------------------- +Safe_malloc - Allocate a block of memory from the application heap +and checking for out or memory errors. + +------------------------------------------------------------------------------- +*/ + +void *Safe_malloc(size_t Size) ; + +#endif diff --git a/support/Util/sdccerr.c b/support/Util/sdccerr.c new file mode 100644 index 00000000..4507bb61 --- /dev/null +++ b/support/Util/sdccerr.c @@ -0,0 +1,222 @@ +/* +=============================================================================== +ERROR - Standard error handler + + +=============================================================================== +*/ + +#include + +#include "sdccerr.h" + +#define USE_STDOUT_FOR_ERRORS 0 + +#if USE_STDOUT_FOR_ERRORS + +static FILE *ErrorOut = stdout ; + +#else + +static FILE *ErrorOut = stderr ; + +#endif + +#define ERROR 0 +#define WARNING 1 + +extern char *filename ; +extern int lineno ; +extern int fatalError ; + +struct { + int errType ; + char *errText ; +} ErrTab [] = +{ +{ ERROR ,"error *** Duplicate symbol '%s', symbol IGNORED\n" }, +{ ERROR ,"error *** Syntax Error Declaration ingonerd\n" }, +{ ERROR ,"error *** Constant Expected Found Variable\n" }, +{ ERROR ,"error *** 'malloc' failed file '%s' for size %ld\n" }, +{ ERROR ,"error *** 'fopen' failed on file '%s'\n" }, +{ ERROR ,"error *** Internal Error Oclass invalid '%s'\n" }, +{ ERROR ,"error *** Cannot allocate variable '%s'.\n" }, +{ ERROR ,"error *** Old style C declaration. IGNORED '%s'\n" }, +{ ERROR ,"error *** Out of stack Space. '%s' not allocted\n" }, +{ ERROR ,"error *** FATAL Compiler Internal Error in file '%s' line number '%d' : %s \nContact Author with source code\n" }, +{ ERROR ,"error *** 'lvalue' required for '%s' operation .\n" }, +{ ERROR ,"error *** Creation of temp file failed\n" }, +{ ERROR ,"error *** Function expected here '%s'\n" }, +{ ERROR ,"error *** 'using', 'interrupt' or 'reentrant' must follow a function definiton .'%s'\n"}, +{ ERROR ,"error *** Absolute address & initial value both cannot be specified for\n a 'sfr','sbit' storage class, initial value ignored '%s'\n" }, +{ WARNING,"warning *** Variable in the storage class cannot be initialized.'%s'\n"}, +{ WARNING,"warning *** storage class not allowed for automatic variable '%s' in reentrant function\n" }, +{ ERROR ,"error *** absolute address not allowed for automatic var '%s' in reentrant function \n" }, +{ WARNING,"warning *** Initializer different levels of indirections\n" }, +{ ERROR ,"error *** Function name '%s' redefined \n" }, +{ ERROR ,"error *** Undefined identifier '%s'\n" }, +{ WARNING,"warning *** stack exceeds 256 bytes for function '%s'\n"}, +{ ERROR ,"error *** Array or pointer required for '%s' operation \n" }, +{ ERROR ,"error *** Array index not an integer\n" }, +{ ERROR ,"error *** Array bound Exceeded, assuming zero\n" }, +{ ERROR ,"error *** Structure/Union expected left of '.%s'\n" }, +{ ERROR ,"error *** '%s' not a structure/union member\n" }, +{ ERROR ,"error *** Pointer required\n" }, +{ ERROR ,"error *** 'unary %c': illegal operand\n" }, +{ ERROR ,"error *** convertion error: integral promotion failed\n" }, +{ ERROR ,"error *** type must be INT for bit field definition\n" }, +{ ERROR ,"error *** bit field size greater than 16 . assuming 16\n" }, +{ WARNING,"warning *** high order truncation might occur\n" }, +{ ERROR ,"error *** Attempt to assign value to a constant variable %s\n" }, +{ ERROR ,"error *** Lvalue specifies constant object\n" }, +{ ERROR ,"error *** '&' illegal operand , %s\n" }, +{ ERROR ,"error *** illegal cast (cast cannot be aggregate)\n" }, +{ ERROR ,"error *** '*' bad operand\n" }, +{ ERROR ,"error *** Argument count error, argument ignored\n" }, +{ ERROR ,"error *** Function was expecting more arguments\n" }, +{ ERROR ,"error *** Function name expected '%s'.ANSI style declaration REQUIRED\n"}, +{ ERROR ,"error *** invalid operand '%s'\n" }, +{ ERROR ,"error *** pointer + pointer invalid\n" }, +{ ERROR ,"error *** invalid operand for shift operator\n" }, +{ ERROR ,"error *** compare operand cannot be struct/union\n" }, +{ ERROR ,"error *** operand invalid for bitwise operation\n" }, +{ ERROR ,"error *** Invalid operand for '&&' or '||'\n" }, +{ WARNING,"warning *** indirections to different types %s %s \n" }, +{ ERROR ,"error *** cannot assign values to aggregates\n" }, +{ ERROR ,"error *** bit Arrays can be accessed by literal index only\n" }, +{ ERROR ,"error *** Array or Pointer to bit|sbit|sfr not allowed.'%s'\n" }, +{ ERROR ,"error *** typedef/enum '%s' duplicate.Previous definiton Ignored\n" }, +{ ERROR ,"error *** Actual Argument type different from declaration %d\n" }, +{ ERROR ,"error *** Function return value mismatch\n" }, +{ ERROR ,"error *** Function cannot return aggregate. Func body ignored\n" }, +{ ERROR ,"error *** ANSI Style declaration needed\n" }, +{ ERROR ,"error *** Label name redefined '%s'\n" }, +{ ERROR ,"error *** Label undefined '%s'\n" }, +{ ERROR ,"error *** void function returning value\n" }, +{ ERROR ,"error *** function '%s' must return value\n" }, +{ WARNING,"warning *** function return value mismatch\n" }, +{ ERROR ,"error *** 'case/default' found without 'switch'.statement ignored\n" }, +{ ERROR ,"error *** 'case' expression not constant. statement ignored\n" }, +{ ERROR ,"error *** 'break/continue' statement out of context\n" }, +{ ERROR ,"error *** nonintegral used in switch expression\n" }, +{ ERROR ,"error *** function '%s' already has body\n" }, +{ ERROR ,"error *** attempt to allocate variable of unknown size '%s'\n" }, +{ ERROR ,"error *** aggregate 'auto' variable '%s' cannot be initialized\n" }, +{ ERROR ,"error *** too many initializers\n" }, +{ ERROR ,"error *** struct/union/array '%s' :initialization needs curly braces\n"}, +{ ERROR ,"error *** non-address initialization expression\n" }, +{ ERROR ,"error *** interrupt no '%d' already has a service routine '%s'\n" }, +{ ERROR ,"error *** interrupt routine cannot have arguments, arguments ingored\n"}, +{ ERROR ,"error *** critical compiler #include file missing. \n" }, +{ ERROR ,"error *** function 'main' undefined\n" }, +{ ERROR ,"error *** 'extern' variable '%s' cannot be initialised \n" }, +{ ERROR ,"error *** Pre-Processor %s\n" }, +{ ERROR ,"error *** _dup call failed\n" }, +{ WARNING,"warning *** pointer being cast to incompatible type \n" }, +{ WARNING,"warning *** 'while' loop with 'zero' constant.loop eliminated\n" }, +{ WARNING,"warning *** %s expression has NO side effects.expr eliminated\n" }, +{ WARNING,"warning *** constant value '%s', out of range.\n" }, +{ WARNING,"warning *** comparison will either, ALWAYs succeed or ALWAYs fail\n" }, +{ ERROR ,"error *** Compiler Terminating , contact author with source\n" }, +{ WARNING,"warning *** 'auto' variable '%s' may be used before initialization at %s(%d)\n" }, +{ WARNING,"warning *** in function %s unreferenced %s : '%s'\n" }, +{ ERROR ,"error *** unknown size for operand\n" }, +{ WARNING,"warning *** '%s' 'long' not supported , declared as 'int' .\n" }, +{ WARNING,"warning *** LITERAL value being cast to '_generic' pointer\n" }, +{ ERROR ,"error *** %s '%s' address out of range\n" }, +{ ERROR ,"error *** storage class CANNOT be specified for bit variable '%s'\n" }, +{ WARNING,"warning *** extern definition for '%s' mismatches with declaration.\n" }, +{ WARNING,"warning *** Functions called via pointers must be 'reentrant' to take arguments\n" }, +{ WARNING,"warning *** type 'double' not supported assuming 'float'\n" }, +{ WARNING,"warning *** if-statement condition always false.if-statement not generated\n"}, +{ WARNING,"warning *** no 'return' statement found for function '%s'\n" }, +{ WARNING,"warning *** Pre-Processor %s\n" }, +{ WARNING,"warning *** structure '%s' passed as function argument changed to pointer\n"}, +{ ERROR ,"error *** conflict with previous definition of '%s' for attribute '%s'\n" }, +{ ERROR ,"error *** variable '%s' declared in code space must have initialiser\n" }, +{ ERROR ,"error *** operands not integral for assignment operation\n" }, +{ ERROR ,"error *** too many parameters \n" }, +{ ERROR ,"error *** to few parameters\n" }, +{ ERROR ,"error *** code not generated for '%s' due to previous errors\n"}, +{ WARNING,"warning *** type mismatch for parameter number %d\n"}, +{ ERROR ,"error *** invalid float constant '%s'\n"}, +{ ERROR ,"error *** invalid operand for '%s' operation\n"}, +{ ERROR ,"error *** switch value not an integer\n"}, +{ ERROR ,"error *** case label not an integer\n"}, +{ WARNING,"warning *** function '%s' too large for global optimization\n"}, +{ WARNING,"warning *** conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG\n"}, +{ WARNING,"warning *** invalid type specifier for pointer type specifier ignored\n"}, +{ WARNING,"warning *** function '%s' implicit declaration\n"}, +{ WARNING,"warning *** %s"}, +{ WARNING,"info *** %s extended by %d bytes for compiler temp(s) :in function '%s': %s \n"}, +{ WARNING,"warning *** unknown or unsupported #pragma directive '%s'\n"}, +{ WARNING,"warning *** %s shifting more than size of object changed to zero\n"}, +{ WARNING,"warning *** unknown compiler option '%s' ignored\n"}, +{ WARNING,"warning *** option '%s' no longer supported '%s' \n"}, +{ WARNING,"warning *** don't know what to do with file '%s'. file extension unsupported\n"}, +{ WARNING,"warning *** cannot compile more than one source file . file '%s' ignored\n"}, +{ WARNING,"info *** function '%s', # edges %d , # nodes %d , cyclomatic complexity %d\n"}, +{ ERROR ,"error *** dividing by ZERO\n"}, +{ ERROR ,"error *** function cannot return 'bit'\n"}, +{ ERROR ,"error *** casting from to type 'void' is illegal\n"}, +{ WARNING,"warning *** constant is out of range %s\n" }, +{ WARNING,"warning *** unreachable code %s(%d)\n"}, +{ WARNING,"warning *** non-pointer type cast to _generic pointer\n"}, +{ WARNING,"warning *** possible code generation error at line %d,\n send source to sandeep.dutta@usa.net\n"}, +{ WARNING,"warning *** pointer types incompatible \n" }, +{ WARNING,"warning *** unknown memory model at %s : %d\n" }, +{ ERROR ,"error *** cannot generate code for target '%s'\n"}, +{ WARNING,"warning *** Indirect call to a banked function not implemented.\n"}, +{ WARNING,"warning *** Model '%s' not supported for %s, ignored.\n"}, +{ WARNING,"warning *** Both banked and nonbanked attributes used. nonbanked wins.\n"}, +{ WARNING,"warning *** Both banked and static used. static wins.\n"}, +{ WARNING,"warning *** converting integer type to generic pointer: assuming XDATA\n"} +}; +/* +------------------------------------------------------------------------------- +SetErrorOut - Set the error output file + +------------------------------------------------------------------------------- +*/ + +FILE *SetErrorOut(FILE *NewErrorOut) + +{ +ErrorOut = NewErrorOut ; + +return NewErrorOut ; +} +/* +------------------------------------------------------------------------------- +vwerror - Output a standard eror message with variable number of arguements + +------------------------------------------------------------------------------- +*/ + +void vwerror (int errNum, va_list marker) + +{ +if ( ErrTab[errNum].errType == ERROR ) + fatalError++ ; + +if ( filename && lineno ) + fprintf(ErrorOut, "%s(%d):",filename,lineno); + +vfprintf(ErrorOut, ErrTab[errNum].errText,marker); +} +/* +------------------------------------------------------------------------------- +werror - Output a standard eror message with variable number of arguements + +------------------------------------------------------------------------------- +*/ + +void werror (int errNum, ... ) + +{ +va_list marker; +va_start(marker,errNum); +vwerror(errNum, marker); +va_end( marker ); +} + diff --git a/support/cpp/config.h b/support/cpp/config.h index 47df72ee..fefe22e7 100644 --- a/support/cpp/config.h +++ b/support/cpp/config.h @@ -3,6 +3,7 @@ #include #include "i386/i386.h" #include "i386/xm-i386.h" +#define alloca Safe_calloc #define bcopy(s, d, n) memcpy(d, s, n) #define bcmp memcmp #define bzero(p, l) memset(p, 0, l) @@ -15,7 +16,7 @@ #include "i386/xm-linux.h" #ifndef __BORLANDC__ -#define alloca malloc +#define alloca Safe_calloc #else #include #include diff --git a/support/cpp/cppalloc.c b/support/cpp/cppalloc.c index 4af9bd94..23cd61f5 100644 --- a/support/cpp/cppalloc.c +++ b/support/cpp/cppalloc.c @@ -22,42 +22,42 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ -#include "config.h" -#ifdef HAVE_MALLOC_H -#include -#endif - -static void -memory_full () -{ - perror ("Memory exhausted."); -} - -char *xmalloc ( unsigned size) -{ - register char *ptr = (char *) malloc (size); - if (ptr != 0) return (ptr); - memory_full (); - /*NOTREACHED*/ - return 0; -} - -char *xrealloc ( - char *old, - unsigned size ) -{ - register char *ptr = (char *) realloc (old, size); - if (ptr == 0) - memory_full (); - return ptr; -} - -char *xcalloc ( - unsigned number, unsigned size) -{ - register unsigned total = number * size; - register char *ptr = (char *) calloc (number, size); - if (ptr == 0) - memory_full (); - return ptr; -} +// #include "config.h" +// #ifdef HAVE_MALLOC_H +// #include +// #endif +// +// static void +// memory_full () +// { +// perror ("Memory exhausted."); +//} +// +// char *xmalloc ( unsigned size) +// { +// register char *ptr = (char *) malloc (size); +// if (ptr != 0) return (ptr); +// memory_full (); + /*NOTREACHED*/ +// return 0; +// } +// +// char *xrealloc ( +// char *old, +// unsigned size ) +// { +// register char *ptr = (char *) realloc (old, size); +// if (ptr == 0) +// memory_full (); +// return ptr; +// } +// +// char *xcalloc ( +// unsigned number, unsigned size) +// { +// register unsigned total = number * size; +// register char *ptr = (char *) calloc (number, size); +// if (ptr == 0) +// memory_full (); +// return ptr; +// } diff --git a/support/cpp/cppexp.c b/support/cpp/cppexp.c index 54fb434b..9dc3b874 100644 --- a/support/cpp/cppexp.c +++ b/support/cpp/cppexp.c @@ -24,15 +24,17 @@ Written by Per Bothner 1994. */ /* Parse a C expression from text in a string */ -#if defined(_MSC_VER) -#include -#endif +//#if defined(_MSC_VER) +//#include +//#endif #include "config.h" #include "cpplib.h" -extern char *xmalloc PARAMS ((unsigned)); -extern char *xrealloc PARAMS ((char *, unsigned)); +#include "newalloc.h" + +//extern char *xmalloc PARAMS ((unsigned)); +//extern char *xrealloc PARAMS ((char *, unsigned)); #ifdef MULTIBYTE_CHARS #include @@ -68,7 +70,7 @@ struct arglist { #define NULL_PTR ((GENERIC_PTR)0) #endif -extern char *xmalloc (); +//extern char *xmalloc (); #ifndef CHAR_TYPE_SIZE #define CHAR_TYPE_SIZE BITS_PER_UNIT @@ -979,10 +981,10 @@ cpp_parse_expr ( int old_size = (char*)limit - (char*)stack; int new_size = 2 * old_size; if (stack != init_stack) - new_stack = (struct operation*) xrealloc (stack, new_size); + new_stack = (struct operation*) Safe_realloc (stack, new_size); else { - new_stack = (struct operation*) xmalloc (new_size); + new_stack = (struct operation*) Safe_malloc (new_size); bcopy ((char *) stack, (char *) new_stack, old_size); } stack = new_stack; diff --git a/support/cpp/cpphash.c b/support/cpp/cpphash.c index e9645aa6..d9a3dca1 100644 --- a/support/cpp/cpphash.c +++ b/support/cpp/cpphash.c @@ -24,7 +24,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cpplib.h" #include "cpphash.h" -extern char *xmalloc PARAMS ((unsigned)); +//extern char *xmalloc PARAMS ((unsigned)); + +#include "newalloc.h" + +#if defined(_MSC_VER) +#include +#include +#endif /* Define a generic NULL if one hasn't already been defined. */ @@ -177,7 +184,7 @@ install ( hash = hashf (name, len, HASHSIZE); i = sizeof (HASHNODE) + len + 1; - hp = (HASHNODE *) xmalloc (i); + hp = (HASHNODE *) Safe_malloc (i); bucket = hash; hp->bucket_hdr = &hashtab[bucket]; hp->next = hashtab[bucket]; diff --git a/support/cpp/cpplib.c b/support/cpp/cpplib.c index c395b834..4efe80df 100644 --- a/support/cpp/cpplib.c +++ b/support/cpp/cpplib.c @@ -48,7 +48,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. for the sake of machines with limited C compilers. */ #ifndef EMACS #include "config.h" -#include +#include "newalloc.h" #include #endif /* not EMACS */ #define GCC_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" @@ -272,7 +272,7 @@ struct cpp_pending { /* Forward declarations. */ -extern char *xmalloc (); +//extern char *Safe_malloc (); static void add_import (); static void append_include_chain (); @@ -313,8 +313,8 @@ static int safe_read (); static void push_macro_expansion PARAMS ((cpp_reader *, U_CHAR*, int, HASHNODE*)); static struct cpp_pending *nreverse_pending PARAMS ((struct cpp_pending*)); -extern char *xrealloc (); -extern char *xcalloc (); +//extern char *xrealloc (); +//extern char *xcalloc (); static char *savestring (); static void conditional_skip (); @@ -558,8 +558,7 @@ cpp_grow_buffer ( { long old_written = CPP_WRITTEN (pfile); pfile->token_buffer_size = n + 2 * pfile->token_buffer_size; - pfile->token_buffer = (U_CHAR*) - xrealloc(pfile->token_buffer, pfile->token_buffer_size); + pfile->token_buffer = (U_CHAR*) Safe_realloc(pfile->token_buffer, pfile->token_buffer_size); CPP_SET_WRITTEN (pfile, old_written); } @@ -733,7 +732,7 @@ deps_output ( if (pfile->deps_size + size + 8 > pfile->deps_allocated_size) { pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2; - pfile->deps_buffer = (char *) xrealloc (pfile->deps_buffer, + pfile->deps_buffer = (char *) Safe_realloc(pfile->deps_buffer, pfile->deps_allocated_size); } if (spacer == ' ' && pfile->deps_column > 0) @@ -768,18 +767,18 @@ path_include ( while (*q != 0 && *q != PATH_SEPARATOR) q++; if (p == q) { /* An empty name in the path stands for the current directory. */ - name = (char *) xmalloc (2); + name = (char *) Safe_malloc (2); name[0] = '.'; name[1] = 0; } else { /* Otherwise use the directory that is named. */ - name = (char *) xmalloc (q - p + 1); + name = (char *) Safe_malloc (q - p + 1); bcopy (p, name, q - p); name[q - p] = 0; } dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = 0; @@ -1287,7 +1286,7 @@ collect_expansion ( while (p < limit) if (*p++ == '@') maxsize++; - defn = (DEFINITION *) xcalloc (1, maxsize); + defn = (DEFINITION *) Safe_calloc(maxsize); defn->nargs = nargs; exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION); @@ -1450,7 +1449,7 @@ collect_expansion ( break; /* make a pat node for this arg and append it to the end of the pat list */ - tpat = (struct reflist *) xmalloc (sizeof (struct reflist)); + tpat = (struct reflist *) Safe_malloc (sizeof (struct reflist)); tpat->next = NULL; tpat->raw_before = concat == id_beg; tpat->raw_after = 0; @@ -1513,7 +1512,7 @@ collect_expansion ( #if 0 /* This isn't worth the time it takes. */ /* give back excess storage */ - defn->expansion = (U_CHAR *) xrealloc (defn->expansion, defn->length + 1); + defn->expansion = (U_CHAR *) Safe_realloc(defn->expansion, defn->length + 1); #endif return defn; @@ -1647,7 +1646,7 @@ create_definition ( /* Now set defn->args.argnames to the result of concatenating the argument names in reverse order with comma-space between them. */ - defn->args.argnames = (U_CHAR *) xmalloc (arglengths + 1); + defn->args.argnames = (U_CHAR *) Safe_malloc (arglengths + 1); { struct arglist *temp; int i = 0; @@ -1929,7 +1928,7 @@ cpp_push_buffer ( bzero ((char *) buf, sizeof (cpp_buffer)); CPP_BUFFER (pfile) = buf; #else - register cpp_buffer *buf = (cpp_buffer*) xmalloc (sizeof(cpp_buffer)); + register cpp_buffer *buf = (cpp_buffer*) Safe_malloc (sizeof(cpp_buffer)); bzero ((char *) buf, sizeof (cpp_buffer)); CPP_PREV_BUFFER (buf) = CPP_BUFFER (pfile); CPP_BUFFER (pfile) = buf; @@ -2924,7 +2923,7 @@ macroexpand ( args[ap->argno].use_count++; } - xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); + xbuf = (U_CHAR *) Safe_malloc (xbuf_len + 1); /* Generate in XBUF the complete expansion with arguments substituted in. @@ -3327,7 +3326,7 @@ do_include ( /* Allocate this permanently, because it gets stored in the definitions of macros. */ - fname = (char *) xmalloc (pfile->max_include_len + flen + 4); + fname = (char *) Safe_malloc (pfile->max_include_len + flen + 4); /* + 2 above for slash and terminating null. */ /* + 2 added for '.h' on VMS (to support '#include filename') */ @@ -3479,7 +3478,7 @@ do_include ( /* This is the first time for this file. */ /* Add it to list of files included. */ - ptr = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + ptr = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list)); ptr->control_macro = 0; ptr->c_system_include_path = 0; ptr->next = pfile->all_include_files; @@ -3639,7 +3638,7 @@ assertion_install ( register U_CHAR *p, *q; i = sizeof (ASSERTION_HASHNODE) + len + 1; - hp = (ASSERTION_HASHNODE *) xmalloc (i); + hp = (ASSERTION_HASHNODE *) Safe_malloc (i); bucket = hash; hp->bucket_hdr = &pfile->assertion_hashtab[bucket]; hp->next = pfile->assertion_hashtab[bucket]; @@ -3867,7 +3866,7 @@ do_line ( } if (hp == 0) { /* Didn't find it; cons up a new one. */ - hp = (HASHNODE *) xcalloc (1, sizeof (HASHNODE) + fname_length + 1); + hp = (HASHNODE *) Safe_calloc(sizeof (HASHNODE) + fname_length + 1); hp->next = *hash_bucket; *hash_bucket = hp; @@ -3947,7 +3946,7 @@ do_error ( U_CHAR *buf,U_CHAR *limit) { int length = limit - buf; - U_CHAR *copy = (U_CHAR *) xmalloc (length + 1); + U_CHAR *copy = (U_CHAR *) Safe_malloc (length + 1); bcopy (buf, copy, length); copy[length] = 0; SKIP_WHITE_SPACE (copy); @@ -3968,7 +3967,7 @@ do_warning ( U_CHAR *buf,U_CHAR *limit) { int length = limit - buf; - U_CHAR *copy = (U_CHAR *) xmalloc (length + 1); + U_CHAR *copy = (U_CHAR *) Safe_malloc (length + 1); bcopy (buf, copy, length); copy[length] = 0; SKIP_WHITE_SPACE (copy); @@ -3995,7 +3994,7 @@ do_once ( } - new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + new = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list)); new->next = pfile->dont_repeat_files; pfile->dont_repeat_files = new; new->fname = savestring (ip->fname); @@ -4250,7 +4249,7 @@ do_xifdef ( skip = (hp == NULL) ^ (keyword->type == T_IFNDEF); if (start_of_file && !skip) { - control_macro = (U_CHAR *) xmalloc (ident_length + 1); + control_macro = (U_CHAR *) Safe_malloc (ident_length + 1); bcopy (ident, control_macro, ident_length + 1); } } @@ -4302,7 +4301,7 @@ conditional_skip ( { IF_STACK_FRAME *temp; - temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); + temp = (IF_STACK_FRAME *) Safe_calloc(sizeof (IF_STACK_FRAME)); temp->fname = CPP_BUFFER (pfile)->nominal_fname; #if 0 temp->lineno = CPP_BUFFER (pfile)->lineno; @@ -4397,7 +4396,7 @@ skip_if_group ( case T_IFDEF: case T_IFNDEF: temp - = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); + = (IF_STACK_FRAME *) Safe_calloc(sizeof (IF_STACK_FRAME)); temp->next = pfile->if_stack; pfile->if_stack = temp; #if 0 @@ -5195,7 +5194,7 @@ cpp_get_token ( CPP_SET_WRITTEN (pfile, before_name_written); special_symbol (hp, pfile); xbuf_len = CPP_WRITTEN (pfile) - before_name_written; - xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); + xbuf = (U_CHAR *) Safe_malloc (xbuf_len + 1); CPP_SET_WRITTEN (pfile, before_name_written); bcopy (CPP_PWRITTEN (pfile), xbuf, xbuf_len + 1); push_macro_expansion (pfile, xbuf, xbuf_len, hp); @@ -5390,8 +5389,8 @@ add_import ( hashval = import_hash (fname); fstat (fd, &sb); - i = (struct import_file *)xmalloc (sizeof (struct import_file)); - i->name = (char *)xmalloc (strlen (fname)+1); + i = (struct import_file *)Safe_malloc (sizeof (struct import_file)); + i->name = (char *)Safe_malloc (strlen (fname)+1); strcpy (i->name, fname); bcopy ((char *) &sb.st_ino, (char *) &i->inode, sizeof (sb.st_ino)); i->dev = sb.st_dev; @@ -5428,7 +5427,7 @@ read_filename_string ( int len; len = 20; - set = alloc = xmalloc (len + 1); + set = alloc = Safe_malloc (len + 1); if (! is_space[ch]) { *set++ = ch; @@ -5437,7 +5436,7 @@ read_filename_string ( if (set - alloc == len) { len *= 2; - alloc = xrealloc (alloc, len + 1); + alloc = Safe_realloc(alloc, len + 1); set = alloc + len / 2; } *set++ = ch; @@ -5473,7 +5472,7 @@ read_name_map ( return map_list_ptr->map_list_map; map_list_ptr = ((struct file_name_map_list *) - xmalloc (sizeof (struct file_name_map_list))); + Safe_malloc (sizeof (struct file_name_map_list))); map_list_ptr->map_list_name = savestring (dirname); map_list_ptr->map_list_map = NULL; @@ -5503,7 +5502,7 @@ read_name_map ( to = read_filename_string (ch, f); ptr = ((struct file_name_map *) - xmalloc (sizeof (struct file_name_map))); + Safe_malloc (sizeof (struct file_name_map))); ptr->map_from = from; /* Make the real filename absolute. */ @@ -5511,7 +5510,7 @@ read_name_map ( ptr->map_to = to; else { - ptr->map_to = xmalloc (dirlen + strlen (to) + 2); + ptr->map_to = Safe_malloc (dirlen + strlen (to) + 2); strcpy (ptr->map_to, dirname); ptr->map_to[dirlen] = '/'; strcpy (ptr->map_to + dirlen + 1, to); @@ -5654,7 +5653,7 @@ finclude ( fp->cleanup = file_cleanup; if (S_ISREG (st_mode)) { - fp->buf = (U_CHAR *) xmalloc (st_size + 2); + fp->buf = (U_CHAR *) Safe_malloc (st_size + 2); fp->alimit = fp->buf + st_size + 2; fp->cur = fp->buf; @@ -5676,7 +5675,7 @@ finclude ( int bsize = 2000; st_size = 0; - fp->buf = (U_CHAR *) xmalloc (bsize + 2); + fp->buf = (U_CHAR *) Safe_malloc (bsize + 2); for (;;) { i = safe_read (f, fp->buf + st_size, bsize - st_size); @@ -5686,7 +5685,7 @@ finclude ( if (st_size != bsize) break; /* End of file */ bsize *= 2; - fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2); + fp->buf = (U_CHAR *) Safe_realloc(fp->buf, bsize + 2); } fp->cur = fp->buf; length = st_size; @@ -5912,7 +5911,7 @@ push_parse_file ( if (*startp == PATH_SEPARATOR) num_dirs++; include_defaults - = (struct default_include *) xmalloc ((num_dirs + = (struct default_include *) Safe_malloc ((num_dirs * sizeof (struct default_include)) + sizeof (include_defaults_array)); startp = endp = epath; @@ -5970,9 +5969,9 @@ push_parse_file ( if (!strncmp (p->fname, default_prefix, default_len)) { /* Yes; change prefix and add to search list. */ struct file_name_list *new - = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list)); int this_len = strlen (specd_prefix) + strlen (p->fname) - default_len; - char *str = (char *) xmalloc (this_len + 1); + char *str = (char *) Safe_malloc (this_len + 1); strcpy (str, specd_prefix); strcat (str, p->fname + default_len); new->fname = str; @@ -5991,7 +5990,7 @@ push_parse_file ( if (!p->cplusplus || (opts->cplusplus && !opts->no_standard_cplusplus_includes)) { struct file_name_list *new - = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + = (struct file_name_list *) Safe_malloc (sizeof (struct file_name_list)); new->control_macro = 0; new->c_system_include_path = !p->cxx_aware; new->fname = p->fname; @@ -6084,7 +6083,7 @@ push_parse_file ( if (*s != 0) { opts->deps_target = s + 1; - output_file = (char *) xmalloc (s - spec + 1); + output_file = (char *) Safe_malloc (s - spec + 1); bcopy (spec, output_file, s - spec); output_file[s - spec] = 0; } @@ -6103,7 +6102,7 @@ push_parse_file ( if (opts->print_deps) { pfile->deps_allocated_size = 200; - pfile->deps_buffer = (char *) xmalloc (pfile->deps_allocated_size); + pfile->deps_buffer = (char *) Safe_malloc (pfile->deps_allocated_size); pfile->deps_buffer[0] = 0; pfile->deps_size = 0; pfile->deps_column = 0; @@ -6244,7 +6243,7 @@ init_parse_file ( pfile->get_token = cpp_get_token; pfile->token_buffer_size = 200; - pfile->token_buffer = (U_CHAR*)xmalloc (pfile->token_buffer_size); + pfile->token_buffer = (U_CHAR*)Safe_malloc (pfile->token_buffer_size); CPP_SET_WRITTEN (pfile, 0); pfile->system_include_depth = 0; @@ -6278,7 +6277,7 @@ push_pending ( char *arg) { struct cpp_pending *pend - = (struct cpp_pending*)xmalloc (sizeof (struct cpp_pending)); + = (struct cpp_pending*)Safe_malloc (sizeof (struct cpp_pending)); pend->cmd = cmd; pend->arg = arg; pend->next = CPP_OPTIONS (pfile)->pending; @@ -6333,11 +6332,11 @@ cpp_handle_options ( fatal ("Filename missing after `-isystem' option"); dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; dirtmp->control_macro = 0; dirtmp->c_system_include_path = 1; - dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + 1); + dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1]) + 1); strcpy (dirtmp->fname, argv[++i]); dirtmp->got_name_map = 0; @@ -6363,14 +6362,14 @@ cpp_handle_options ( } dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = 0; if (i + 1 == argc) fatal ("Directory name missing after `-iwithprefix' option"); - dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1]) + strlen (prefix) + 1); strcpy (dirtmp->fname, prefix); strcat (dirtmp->fname, argv[++i]); @@ -6398,14 +6397,14 @@ cpp_handle_options ( } dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = 0; if (i + 1 == argc) fatal ("Directory name missing after `-iwithprefixbefore' option"); - dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + dirtmp->fname = (char *) Safe_malloc (strlen (argv[i+1]) + strlen (prefix) + 1); strcpy (dirtmp->fname, prefix); strcat (dirtmp->fname, argv[++i]); @@ -6418,7 +6417,7 @@ cpp_handle_options ( struct file_name_list *dirtmp; dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = 0; @@ -6701,7 +6700,7 @@ cpp_handle_options ( } else { dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); + Safe_malloc (sizeof (struct file_name_list)); dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = 0; @@ -6903,7 +6902,7 @@ do_assert ( U_CHAR *symname = pfile->token_buffer + symstart; int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE); struct tokenlist_list *value - = (struct tokenlist_list *) xmalloc (sizeof (struct tokenlist_list)); + = (struct tokenlist_list *) Safe_malloc (sizeof (struct tokenlist_list)); hp = assertion_lookup (pfile, symname, sym_length, hashcode); if (hp == NULL) { @@ -7154,7 +7153,7 @@ read_token_list ( length = CPP_WRITTEN (pfile) - name_written; temp = (struct arglist *) - xmalloc (sizeof (struct arglist) + length + 1); + Safe_malloc (sizeof (struct arglist) + length + 1); temp->name = (U_CHAR *) (temp + 1); bcopy ((char *) (pfile->token_buffer + name_written), (char *) temp->name, length); @@ -7242,7 +7241,7 @@ savestring ( char *input) { unsigned size = strlen (input); - char *output = xmalloc (size + 1); + char *output = Safe_malloc (size + 1); strcpy (output, input); return output; } @@ -7538,7 +7537,7 @@ cpp_error_from_errno ( if (ip != NULL) cpp_file_line_for_message (pfile, ip->nominal_fname, ip->lineno, -1); - cpp_message (pfile, 1, "%s: %s", name, my_strerror (errno)); + cpp_message (pfile, 1, "%s: %s", name, my_strerror (errno),NULL); } void diff --git a/support/cpp/cpplib.h b/support/cpp/cpplib.h index 321e157a..7787f7d8 100644 --- a/support/cpp/cpplib.h +++ b/support/cpp/cpplib.h @@ -646,6 +646,36 @@ extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *)); extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*, int, int)); +/* Define the MS VC6 stuff - Some of these should also be defined for +the other hosts but they are here until declared safe for all */ + +#if defined(_MSC_VER) + +void init_parse_file (cpp_reader *pfile) ; + +void init_parse_options (struct cpp_options *opts) ; + +int push_parse_file (cpp_reader *pfile,char *fname) ; + +void cpp_finish (cpp_reader *pfile) ; + +void cpp_hash_cleanup (cpp_reader *pfile) ; + +void cpp_file_line_for_message (cpp_reader *pfile,char *filename ,int line, int column) ; + +void cpp_print_containing_files (cpp_reader *pfile) ; + +void cpp_message (cpp_reader *pfile,int is_error,char *msg,char *arg1, char *arg2, char *arg3) ; + +void skip_rest_of_line (cpp_reader *pfile) ; + +/* Parse an identifier starting with C. */ + +int parse_name (cpp_reader *pfile, int c) ; + +#endif + + #ifdef __cplusplus } #endif diff --git a/support/cpp/sdcpp.dsp b/support/cpp/sdcpp.dsp index 3cfc66eb..1cb01880 100644 --- a/support/cpp/sdcpp.dsp +++ b/support/cpp/sdcpp.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /J /FD /c +# ADD CPP /nologo /G3 /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c # SUBTRACT CPP /WX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -68,16 +68,15 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G3 /Zp1 /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /J /FD /GZ /c -# SUBTRACT CPP /WX +# ADD CPP /nologo /G3 /Zp8 /ML /W3 /Gm /GX /ZI /Od /I "..\util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"./" /J /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo -# ADD BSC32 /nologo +# ADD BSC32 /nologo /o".\sdcpp.bsc" LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /out:"..\..\bin\sdcpp.exe" /pdbtype:sept +# ADD LINK32 /nologo /version:2.2 /subsystem:console /debug /machine:I386 /out:"..\..\bin\sdcpp.exe" /pdbtype:sept # SUBTRACT LINK32 /incremental:no !ENDIF @@ -113,6 +112,10 @@ SOURCE=cpplib.c SOURCE=cppmain.c # End Source File +# Begin Source File + +SOURCE=..\Util\NewAlloc.c +# End Source File # End Group # Begin Group "Header Files" @@ -131,6 +134,10 @@ SOURCE=.\cpplib.h # End Source File # Begin Source File +SOURCE=..\Util\newalloc.h +# End Source File +# Begin Source File + SOURCE=.\tm.h # End Source File # End Group -- 2.47.2