* config.dsp: added dependency on .version and configure_vc.awk
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 6 Dec 2005 15:12:16 +0000 (15:12 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 6 Dec 2005 15:12:16 +0000 (15:12 +0000)
* device/include/setjmp.h: updated for --stack-auto and --xstack
* device/include/mcs51/at89c51snd1c.h: corrected line endings
* device/include/mcs51/XC866.h: added, thanks Llewellyn van Zyl
* device/lib/_setjmp.c: updated for --stack-auto and --xstack
* device/lib/libsdcc.lib: added _setjmp
* src/SDCCast.c (createIvalCharPtr): fixed warnings,
  (decorateType): fixed bug 1372851,
  (optimizeGetHbit): fixed warning
* src/SDCCglue.c (printIvalChar, printIvalArray): adapted for flexible
  array initialisation
* support/regression/tests/bug1057979.c: added test for bug 1358192
* support/regression/tests/setjmp.c: added, test for setjmp/longjmp

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4002 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
config.dsp
device/include/mcs51/XC866.h [new file with mode: 0644]
device/include/setjmp.h
device/lib/_setjmp.c
device/lib/libsdcc.lib
src/SDCCast.c
src/SDCCglue.c
support/regression/tests/bug1057979.c
support/regression/tests/setjmp.c [new file with mode: 0644]

index 746d105bf422f23a1f9bfff0b58c023b30ff17d8..3ed0cdb37d947ac17a499fdb7335b78405c3257e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-12-06 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * config.dsp: added dependency on .version and configure_vc.awk
+       * device/include/setjmp.h: updated for --stack-auto and --xstack
+       * device/include/mcs51/at89c51snd1c.h: corrected line endings
+       * device/include/mcs51/XC866.h: added, thanks Llewellyn van Zyl
+       * device/lib/_setjmp.c: updated for --stack-auto and --xstack
+       * device/lib/libsdcc.lib: added _setjmp
+       * src/SDCCast.c (createIvalCharPtr): fixed warnings,
+         (decorateType): fixed bug 1372851,
+         (optimizeGetHbit): fixed warning
+       * src/SDCCglue.c (printIvalChar, printIvalArray): adapted for flexible
+         array initialisation
+       * support/regression/tests/bug1057979.c: added test for bug 1358192
+       * support/regression/tests/setjmp.c: added, test for setjmp/longjmp
+
 2005-12-03 Borut Razem <borut.razem AT siol.net>
 
        * support/scripts/sdcc.nsi: added /SOLID option to "SetCompressor lzma"
@@ -34,7 +50,7 @@
 
 2005-11-28 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
-       * device/include/mcs51/at89c51snd1c.h: added file submitted by 
+       * device/include/mcs51/at89c51snd1c.h: added file submitted by
          Weston T. Schmidt <schmidtw AT users.sourceforge.net>, patch #1368001
 
 2005-11-27 Borut Razem <borut.razem AT siol.net>
index acbcdd0a94fa402e74b9730f74ec991476b517ed..8aa6747459b9e894ef5ee1232db727c6be841f90 100644 (file)
@@ -65,7 +65,7 @@ SOURCE=.\sdcc_vc_in.h
 
 !IF  "$(CFG)" == "config - Win32 Release"
 
-USERDEP__SDCC_=".version"      
+USERDEP__SDCC_=".version"      "configure_vc.awk"      
 # Begin Custom Build
 InputPath=.\sdcc_vc_in.h
 
@@ -76,6 +76,7 @@ InputPath=.\sdcc_vc_in.h
 
 !ELSEIF  "$(CFG)" == "config - Win32 Debug"
 
+USERDEP__SDCC_=".version"      "configure_vc.awk"      
 # Begin Custom Build
 InputPath=.\sdcc_vc_in.h
 
diff --git a/device/include/mcs51/XC866.h b/device/include/mcs51/XC866.h
new file mode 100644 (file)
index 0000000..acd8964
--- /dev/null
@@ -0,0 +1,373 @@
+/*-------------------------------------------------------------------------
+   Register Declarations for the Infineon XC866
+
+   Copyright (C) 2005 - Llewellyn van Zyl, eduprep@myconnection.co.za
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+-------------------------------------------------------------------------*/
+
+#ifndef XC866_H
+#define XC866_H
+
+//   SFR byte definitions
+__sfr __at (0xE0) A;
+__sfr __at (0xCA) ADC_CHCTR0;
+__sfr __at (0xCB) ADC_CHCTR1;
+__sfr __at (0xCC) ADC_CHCTR2;
+__sfr __at (0xCD) ADC_CHCTR3;
+__sfr __at (0xCE) ADC_CHCTR4;
+__sfr __at (0xCF) ADC_CHCTR5;
+__sfr __at (0xD2) ADC_CHCTR6;
+__sfr __at (0xD3) ADC_CHCTR7;
+__sfr __at (0xCB) ADC_CHINCR;
+__sfr __at (0xCA) ADC_CHINFR;
+__sfr __at (0xCD) ADC_CHINPR;
+__sfr __at (0xCC) ADC_CHINSR;
+__sfr __at (0xCA) ADC_CRCR1;
+__sfr __at (0xCC) ADC_CRMR1;
+__sfr __at (0xCB) ADC_CRPR1;
+__sfr __at (0xCF) ADC_ETRCR;
+__sfr __at (0xCF) ADC_EVINCR;
+__sfr __at (0xCE) ADC_EVINFR;
+__sfr __at (0xD3) ADC_EVINPR;
+__sfr __at (0xD2) ADC_EVINSR;
+__sfr __at (0xCA) ADC_GLOBCTR;
+__sfr __at (0xCB) ADC_GLOBSTR;
+__sfr __at (0xCE) ADC_INPCR0;
+__sfr __at (0xCD) ADC_LCBR;
+__sfr __at (0xD1) ADC_PAGE;
+__sfr __at (0xCC) ADC_PRAR;
+__sfr __at (0xCF) ADC_Q0R0;
+__sfr __at (0xD2) ADC_QBUR0;
+__sfr __at (0xD2) ADC_QINR0;
+__sfr __at (0xCD) ADC_QMR0;
+__sfr __at (0xCE) ADC_QSR0;
+__sfr __at (0xCA) ADC_RCR0;
+__sfr __at (0xCB) ADC_RCR1;
+__sfr __at (0xCC) ADC_RCR2;
+__sfr __at (0xCD) ADC_RCR3;
+__sfr __at (0xCB) ADC_RESR0H;
+__sfr __at (0xCA) ADC_RESR0L;
+__sfr __at (0xCD) ADC_RESR1H;
+__sfr __at (0xCC) ADC_RESR1L;
+__sfr __at (0xCF) ADC_RESR2H;
+__sfr __at (0xCE) ADC_RESR2L;
+__sfr __at (0xD3) ADC_RESR3H;
+__sfr __at (0xD2) ADC_RESR3L;
+__sfr __at (0xCB) ADC_RESRA0H;
+__sfr __at (0xCA) ADC_RESRA0L;
+__sfr __at (0xCD) ADC_RESRA1H;
+__sfr __at (0xCC) ADC_RESRA1L;
+__sfr __at (0xCF) ADC_RESRA2H;
+__sfr __at (0xCE) ADC_RESRA2L;
+__sfr __at (0xD3) ADC_RESRA3H;
+__sfr __at (0xD2) ADC_RESRA3L;
+__sfr __at (0xCE) ADC_VFCR;
+__sfr __at (0xF0) B;
+__sfr __at (0xBD) BCON;
+__sfr __at (0xBE) BG;
+__sfr __at (0xFB) CCU6_CC60RH;
+__sfr __at (0xFA) CCU6_CC60RL;
+__sfr __at (0xFB) CCU6_CC60SRH;
+__sfr __at (0xFA) CCU6_CC60SRL;
+__sfr __at (0xFD) CCU6_CC61RH;
+__sfr __at (0xFC) CCU6_CC61RL;
+__sfr __at (0xFD) CCU6_CC61SRH;
+__sfr __at (0xFC) CCU6_CC61SRL;
+__sfr __at (0xFF) CCU6_CC62RH;
+__sfr __at (0xFE) CCU6_CC62RL;
+__sfr __at (0xFF) CCU6_CC62SRH;
+__sfr __at (0xFE) CCU6_CC62SRL;
+__sfr __at (0x9B) CCU6_CC63RH;
+__sfr __at (0x9A) CCU6_CC63RL;
+__sfr __at (0x9B) CCU6_CC63SRH;
+__sfr __at (0x9A) CCU6_CC63SRL;
+__sfr __at (0xA7) CCU6_CMPMODIFH;
+__sfr __at (0xA6) CCU6_CMPMODIFL;
+__sfr __at (0xFF) CCU6_CMPSTATH;
+__sfr __at (0xFE) CCU6_CMPSTATL;
+__sfr __at (0x9D) CCU6_IENH;
+__sfr __at (0x9C) CCU6_IENL;
+__sfr __at (0x9F) CCU6_INPH;
+__sfr __at (0x9E) CCU6_INPL;
+__sfr __at (0x9D) CCU6_ISH;
+__sfr __at (0x9C) CCU6_ISL;
+__sfr __at (0xA5) CCU6_ISRH;
+__sfr __at (0xA4) CCU6_ISRL;
+__sfr __at (0xA5) CCU6_ISSH;
+__sfr __at (0xA4) CCU6_ISSL;
+__sfr __at (0xA7) CCU6_MCMCTR;
+__sfr __at (0x9B) CCU6_MCMOUTH;
+__sfr __at (0x9A) CCU6_MCMOUTL;
+__sfr __at (0x9F) CCU6_MCMOUTSH;
+__sfr __at (0x9E) CCU6_MCMOUTSL;
+__sfr __at (0xFD) CCU6_MODCTRH;
+__sfr __at (0xFC) CCU6_MODCTRL;
+__sfr __at (0xA3) CCU6_PAGE;
+__sfr __at (0x9F) CCU6_PISEL0H;
+__sfr __at (0x9E) CCU6_PISEL0L;
+__sfr __at (0xA4) CCU6_PISEL2;
+__sfr __at (0xA6) CCU6_PSLR;
+__sfr __at (0xA5) CCU6_T12DTCH;
+__sfr __at (0xA4) CCU6_T12DTCL;
+__sfr __at (0xFB) CCU6_T12H;
+__sfr __at (0xFA) CCU6_T12L;
+__sfr __at (0x9B) CCU6_T12MSELH;
+__sfr __at (0x9A) CCU6_T12MSELL;
+__sfr __at (0x9D) CCU6_T12PRH;
+__sfr __at (0x9C) CCU6_T12PRL;
+__sfr __at (0xFD) CCU6_T13H;
+__sfr __at (0xFC) CCU6_T13L;
+__sfr __at (0x9F) CCU6_T13PRH;
+__sfr __at (0x9E) CCU6_T13PRL;
+__sfr __at (0xA7) CCU6_TCTR0H;
+__sfr __at (0xA6) CCU6_TCTR0L;
+__sfr __at (0xFB) CCU6_TCTR2H;
+__sfr __at (0xFA) CCU6_TCTR2L;
+__sfr __at (0x9D) CCU6_TCTR4H;
+__sfr __at (0x9C) CCU6_TCTR4L;
+__sfr __at (0xFF) CCU6_TRPCTRH;
+__sfr __at (0xFE) CCU6_TRPCTRL;
+__sfr __at (0xBA) CMCON;
+__sfr __at (0x83) DPH;
+__sfr __at (0x82) DPL;
+__sfr __at (0xA2) EO;
+__sfr __at (0xB7) EXICON0;
+__sfr __at (0xBA) EXICON1;
+__sfr __at (0xBD) FEAH;
+__sfr __at (0xBC) FEAL;
+__sfr __at (0xF7) HWBPDR;
+__sfr __at (0xF6) HWBPSR;
+__sfr __at (0xB3) ID;
+__sfr __at (0xA8) IEN0;
+__sfr __at (0xE8) IEN1;
+__sfr __at (0xB8) IP;
+__sfr __at (0xF8) IP1;
+__sfr __at (0xB9) IPH;
+__sfr __at (0xF9) IPH1;
+__sfr __at (0xB4) IRCON0;
+__sfr __at (0xB5) IRCON1;
+__sfr __at (0xF3) MMBPCR;
+__sfr __at (0xF1) MMCR;
+__sfr __at (0xE9) MMCR2;
+__sfr __at (0xF5) MMDR;
+__sfr __at (0xF4) MMICR;
+__sfr __at (0xF2) MMSR;
+__sfr __at (0xB3) MODPISEL;
+__sfr __at (0xBB) NMICON;
+__sfr __at (0xBC) NMISR;
+__sfr __at (0xB6) OSC_CON;
+__sfr __at (0x80) P0_ALTSEL0;
+__sfr __at (0x86) P0_ALTSEL1;
+__sfr __at (0x80) P0_DATA;
+__sfr __at (0x86) P0_DIR;
+__sfr __at (0x80) P0_OD;
+__sfr __at (0x86) P0_PUDEN;
+__sfr __at (0x80) P0_PUDSEL;
+__sfr __at (0x90) P1_ALTSEL0;
+__sfr __at (0x91) P1_ALTSEL1;
+__sfr __at (0x90) P1_DATA;
+__sfr __at (0x91) P1_DIR;
+__sfr __at (0x90) P1_OD;
+__sfr __at (0x91) P1_PUDEN;
+__sfr __at (0x90) P1_PUDSEL;
+__sfr __at (0xA0) P2_DATA;
+__sfr __at (0xA1) P2_PUDEN;
+__sfr __at (0xA0) P2_PUDSEL;
+__sfr __at (0xB0) P3_ALTSEL0;
+__sfr __at (0xB1) P3_ALTSEL1;
+__sfr __at (0xB0) P3_DATA;
+__sfr __at (0xB1) P3_DIR;
+__sfr __at (0xB0) P3_OD;
+__sfr __at (0xB1) P3_PUDEN;
+__sfr __at (0xB0) P3_PUDSEL;
+__sfr __at (0xBB) PASSWD;
+__sfr __at (0x87) PCON;
+__sfr __at (0xB7) PLL_CON;
+__sfr __at (0xB4) PMCON0;    
+__sfr __at (0xB5) PMCON1;    
+__sfr __at (0xB2) PORT_PAGE;    
+__sfr __at (0xD0) PSW;    
+__sfr __at (0x99) SBUF;    
+__sfr __at (0x98) SCON;    
+__sfr __at (0xBF) SCU_PAGE;    
+__sfr __at (0x81) SP;    
+__sfr __at (0xAF) SSC_BRH;    
+__sfr __at (0xAE) SSC_BRL;    
+__sfr __at (0xAB) SSC_CONH_O;    
+__sfr __at (0xAB) SSC_CONH_P;    
+__sfr __at (0xAA) SSC_CONL_O;    
+__sfr __at (0xAA) SSC_CONL_P;    
+__sfr __at (0xA9) SSC_PISEL;    
+__sfr __at (0xAD) SSC_RBL;    
+__sfr __at (0xAC) SSC_TBL;    
+__sfr __at (0x8F) SYSCON0;    
+__sfr __at (0xC3) T2_RC2H;    
+__sfr __at (0xC2) T2_RC2L;    
+__sfr __at (0xC0) T2_T2CON;    
+__sfr __at (0xC5) T2_T2H;
+__sfr __at (0xC4) T2_T2L;
+__sfr __at (0xC1) T2_T2MOD;
+__sfr __at (0x88) TCON;
+__sfr __at (0x8C) TH0;
+__sfr __at (0x8D) TH1;
+__sfr __at (0x8A) TL0;
+__sfr __at (0x8B) TL1;
+__sfr __at (0x89) TMOD;
+__sfr __at (0xBB) WDTCON;    // located in the mapped SFR area
+__sfr __at (0xBF) WDTH;      // located in the mapped SFR area
+__sfr __at (0xBE) WDTL;      // located in the mapped SFR area
+__sfr __at (0xBC) WDTREL;    // located in the mapped SFR area
+__sfr __at (0xBD) WDTWINB;   // located in the mapped SFR area
+
+__sfr __at (0xB3) XADDRH;    // beware this is in an sfr page!
+__sfr __at (0xB3) _XPAGE;    // this is the name SDCC expects for this sfr
+
+//   SFR bit definitions
+
+/*  P3  */
+__sbit __at (0xB0) P3_0 ;
+__sbit __at (0xB1) P3_1 ;
+__sbit __at (0xB2) P3_2 ;
+__sbit __at (0xB3) P3_3 ;
+__sbit __at (0xB4) P3_4 ;
+__sbit __at (0xB5) P3_5 ;
+__sbit __at (0xB6) P3_6 ;
+__sbit __at (0xB7) P3_7 ;
+
+
+//   IEN0
+__sbit __at (0xAF) EA;
+__sbit __at (0xAC) ES;
+__sbit __at (0xA9) ET0;
+__sbit __at (0xAB) ET1;
+__sbit __at (0xAD) ET2;
+__sbit __at (0xA8) EX0;
+__sbit __at (0xAA) EX1;
+
+//   IEN1
+__sbit __at (0xE8) EADC;
+__sbit __at (0xEC) ECCIP0;
+__sbit __at (0xED) ECCIP1;
+__sbit __at (0xEE) ECCIP2;
+__sbit __at (0xEF) ECCIP3;
+__sbit __at (0xE9) ESSC;
+__sbit __at (0xEA) EX2;
+__sbit __at (0xEB) EXM;
+
+//   IP1
+__sbit __at (0xF8) PADC;
+__sbit __at (0xFC) PCCIP0;
+__sbit __at (0xFD) PCCIP1;
+__sbit __at (0xFE) PCCIP2;
+__sbit __at (0xFF) PCCIP3;
+__sbit __at (0xF9) PSSC;
+__sbit __at (0xFA) PX2;
+__sbit __at (0xFB) PXM;
+
+//   IP
+__sbit __at (0xBC) PS;
+__sbit __at (0xB9) PT0;
+__sbit __at (0xBB) PT1;
+__sbit __at (0xBD) PT2;
+__sbit __at (0xB8) PX0;
+__sbit __at (0xBA) PX1;
+
+//   PSW
+__sbit __at (0xD6) AC;
+__sbit __at (0xD7) CY;
+__sbit __at (0xD5) F0;
+__sbit __at (0xD1) F1;
+__sbit __at (0xD2) OV;
+__sbit __at (0xD0) P;
+__sbit __at (0xD3) RS0;
+__sbit __at (0xD4) RS1;
+
+//   SCON
+__sbit __at (0x9A) RB8;
+__sbit __at (0x9C) REN;
+__sbit __at (0x98) RI;
+__sbit __at (0x9F) SM0;
+__sbit __at (0x9E) SM1;
+__sbit __at (0x9D) SM2;
+__sbit __at (0x9B) TB8;
+__sbit __at (0x99) TI;
+
+//   T2_T2CON
+__sbit __at (0xC0) CP_RL2;
+__sbit __at (0xC3) EXEN2;
+__sbit __at (0xC6) EXF2;
+__sbit __at (0xC7) TF2;
+__sbit __at (0xC2) TR2;
+
+//   TCON
+__sbit __at (0x89) IE0;
+__sbit __at (0x8B) IE1;
+__sbit __at (0x88) IT0;
+__sbit __at (0x8A) IT1;
+__sbit __at (0x8D) TF0;
+__sbit __at (0x8F) TF1;
+__sbit __at (0x8C) TR0;
+__sbit __at (0x8E) TR1;
+
+//   Definition of the PAGE SFR
+
+//   PORT_PAGE
+#define _pp0 PORT_PAGE=0 // PORT_PAGE postfix
+#define _pp1 PORT_PAGE=1 // PORT_PAGE postfix
+#define _pp2 PORT_PAGE=2 // PORT_PAGE postfix
+#define _pp3 PORT_PAGE=3 // PORT_PAGE postfix
+
+//   ADC_PAGE
+#define _ad0 ADC_PAGE=0 // ADC_PAGE postfix
+#define _ad1 ADC_PAGE=1 // ADC_PAGE postfix
+#define _ad2 ADC_PAGE=2 // ADC_PAGE postfix
+#define _ad3 ADC_PAGE=3 // ADC_PAGE postfix
+#define _ad4 ADC_PAGE=4 // ADC_PAGE postfix
+#define _ad5 ADC_PAGE=5 // ADC_PAGE postfix
+#define _ad6 ADC_PAGE=6 // ADC_PAGE postfix
+
+//   SCU_PAGE
+#define _su0 SCU_PAGE=0 // SCU_PAGE postfix
+#define _su1 SCU_PAGE=1 // SCU_PAGE postfix
+#define _su2 SCU_PAGE=2 // SCU_PAGE postfix
+
+//   CCU_PAGE
+#define _cc0 CCU_PAGE=0 // CCU_PAGE postfix
+#define _cc1 CCU_PAGE=1 // CCU_PAGE postfix
+#define _cc2 CCU_PAGE=2 // CCU_PAGE postfix
+#define _cc3 CCU_PAGE=3 // CCU_PAGE postfix
+
+//   FLASH_PAGE
+#define _fl0 FLASH_PAGE=0 // FLASH_PAGE postfix
+#define _fl1 FLASH_PAGE=1 // FLASH_PAGE postfix
+#define _fl2 FLASH_PAGE=2 // FLASH_PAGE postfix
+
+#define SST0 0x80         // Save SFR page to ST0
+#define RST0 0xC0         // Restore SFR page from ST0
+#define SST1 0x90         // Save SFR page to ST1
+#define RST1 0xD0         // Restore SFR page from ST1
+#define SST2 0xA0         // Save SFR page to ST2
+#define RST2 0xE0         // Restore SFR page from ST2
+#define SST3 0xB0         // Save SFR page to ST3
+#define RST3 0xF0         // Restore SFR page from ST3
+
+#define SFR_PAGE(pg,op) pg+op
+
+#endif
+
+
+
+
index 6742bb89788ec92708c9bed1200acfd4e00b86c3..866e694434309a538decd487dac893bbe4b219bc 100644 (file)
 #ifndef SDCC_SETJMP_H
 #define SDCC_SETJMP_H
 
-typedef unsigned char jmp_buf[3];
+#define SP_SIZE                1
 
-int setjmp (unsigned char *);
-int longjmp(unsigned char *, int);
+#ifdef SDCC_STACK_AUTO
+#define BP_SIZE                SP_SIZE
+#else
+#define BP_SIZE                0
+#endif
+
+#ifdef SDCC_USE_XSTACK
+#define SPX_SIZE       1
+#else
+#define SPX_SIZE       0
+#endif
+
+#define BPX_SIZE       SPX_SIZE
+
+#define RET_SIZE       2
+
+typedef unsigned char jmp_buf[RET_SIZE + SP_SIZE + BP_SIZE + SPX_SIZE + BPX_SIZE];
+
+int setjmp (jmp_buf);
+int longjmp(jmp_buf, int);
+
+#undef RET_SIZE
+#undef SP_SIZE
+#undef BP_SIZE
+#undef SPX_SIZE
+#undef BPX_SIZE
 
 #endif
index fb064a22bd536cc1ee74802a23dc86c7c49bb9ea..ff1274b8ef8ca3cdfba6300e31811829f87d5626 100644 (file)
@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------
-  setjmp.c - source file for ANSI routines setjmp & longjmp 
+  setjmp.c - source file for ANSI routines setjmp & longjmp
 
              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
 
    under the terms of the GNU Library General Public License as published by the
    Free Software Foundation; either version 2, or (at your option) any
    later version.
-   
+
    This library 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 Library General Public License for more details.
-   
+
    You should have received a copy of the GNU Library 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!
 -------------------------------------------------------------------------*/
 #include <8051.h>
+#include <setjmp.h>
+
+#if defined(SDCC_USE_XSTACK)
+
+static void dummy (void) _naked
+{
+       _asm
 
+;------------------------------------------------------------
+;Allocation info for local variables in function 'setjmp'
+;------------------------------------------------------------
+;buf                       Allocated to registers dptr b
+;------------------------------------------------------------
+;../../device/lib/_setjmp.c:180:int setjmp (jmp_buf buf)
+;      -----------------------------------------
+;       function setjmp
+;      -----------------------------------------
+       .globl _setjmp
+_setjmp:
+       ar2 = 0x02
+       ar3 = 0x03
+       ar4 = 0x04
+       ar5 = 0x05
+       ar6 = 0x06
+       ar7 = 0x07
+       ar0 = 0x00
+       ar1 = 0x01
+;../../device/lib/_setjmp.c:183:*buf++ = bpx;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,_bpx
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:184:*buf++ = spx;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,_spx
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:185:*buf++ = bp;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,_bp
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:186:*buf++ = SP;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,sp
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:187:*buf++ = *((unsigned char data *) SP  );
+;     genCast
+;     genPointerGet
+;     genNearPointerGet
+;     genPointerSet
+;     genGenPointerSet
+       mov     r0,sp
+       mov     a,@r0
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:188:*buf   = *((unsigned char data *)SP - 1);
+;     genCast
+;     genMinus
+;     genMinusDec
+;      peephole 177.g  optimized mov sequence
+       dec     r0
+;     genPointerGet
+;     genNearPointerGet
+       mov     a,@r0
+;     genPointerSet
+;     genGenPointerSet
+       lcall   __gptrput
+;../../device/lib/_setjmp.c:189:return 0;
+;     genRet
+       mov     dptr,#0x0000
+       ret
 
+;------------------------------------------------------------
+;Allocation info for local variables in function 'longjmp'
+;------------------------------------------------------------
+;rv                        Allocated to stack - offset -2
+;buf                       Allocated to registers dptr b
+;lsp                       Allocated to registers r5
+;------------------------------------------------------------
+;../../device/lib/_setjmp.c:192:int longjmp (jmp_buf buf, int rv)
+;      -----------------------------------------
+;       function longjmp
+;      -----------------------------------------
+       .globl _longjmp
+_longjmp:
+;     genReceive
+       mov     r0,_spx
+       dec     r0
+       movx    a,@r0
+       mov     r2,a
+       dec     r0
+       movx    a,@r0
+       mov     r3,a
+;../../device/lib/_setjmp.c:193:bpx = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       mov     _bpx,a
+       inc     dptr
+;../../device/lib/_setjmp.c:194:spx = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       mov     _spx,a
+       inc     dptr
+;../../device/lib/_setjmp.c:195:bp = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       mov     _bp,a
+       inc     dptr
+;../../device/lib/_setjmp.c:196:lsp = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       inc     dptr
+;     genAssign
+       mov     r5,a
+;../../device/lib/_setjmp.c:197:*((unsigned char data *) lsp) = *buf++;
+;     genCast
+       mov     r0,a
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       inc     dptr
+;     genPointerSet
+;     genNearPointerSet
+       mov     @r0,a
+;../../device/lib/_setjmp.c:198:*((unsigned char data *) lsp - 1) = *buf;
+;     genMinus
+;     genMinusDec
+       dec     r0
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+;     genPointerSet
+;     genNearPointerSet
+       mov     @r0,a
+;../../device/lib/_setjmp.c:199:SP = lsp;
+;     genAssign
+       mov     sp,r5
+;../../device/lib/_setjmp.c:200:return rv;
+;     genAssign
+       mov     dph,r2
+       mov     dpl,r3
+;     genRet
+       ret
 
-int longjmp (unsigned char *bp, int rv)
+       _endasm;
+}
+
+#elif defined(SDCC_STACK_AUTO)
+
+static void dummy (void) _naked
 {
-    unsigned char lsp; 
-    lsp = *(bp+2);
-    *((unsigned char data *) lsp) = *bp++;
-    *((unsigned char data *) lsp - 1) = *bp;
-    SP = lsp;
-    return rv;
+       _asm
+
+;------------------------------------------------------------
+;Allocation info for local variables in function 'setjmp'
+;------------------------------------------------------------
+;buf                       Allocated to registers dptr b
+;------------------------------------------------------------
+;../../device/lib/_setjmp.c:122:int setjmp (unsigned char *buf)
+;      -----------------------------------------
+;       function setjmp
+;      -----------------------------------------
+       .globl _setjmp
+_setjmp:
+       ar2 = 0x02
+       ar3 = 0x03
+       ar4 = 0x04
+       ar5 = 0x05
+       ar6 = 0x06
+       ar7 = 0x07
+       ar0 = 0x00
+       ar1 = 0x01
+;     genReceive
+;../../device/lib/_setjmp.c:125:*buf   = BP;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,_bp
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:126:*buf   = SP;
+;     genPointerSet
+;     genGenPointerSet
+       mov     a,sp
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:127:*buf++ = *((unsigned char data *) SP  );
+;     genCast
+       mov     r0,sp
+;     genPointerGet
+;     genNearPointerGet
+       mov     a,@r0
+;     genPointerSet
+;     genGenPointerSet
+       lcall   __gptrput
+       inc     dptr
+;../../device/lib/_setjmp.c:128:*buf++ = *((unsigned char data *)SP - 1);
+;     genCast
+;     genMinus
+;     genMinusDec
+       dec     r0
+;     genPointerGet
+;     genNearPointerGet
+       mov     a,@r0
+;     genPointerSet
+;     genGenPointerSet
+       lcall   __gptrput
+;../../device/lib/_setjmp.c:129:return 0;
+;     genRet
+       mov     dptr,#0x0000
+       ret
+
+;------------------------------------------------------------
+;Allocation info for local variables in function 'longjmp'
+;------------------------------------------------------------
+;rv                        Allocated to stack - offset -3
+;buf                       Allocated to registers dptr b
+;lsp                       Allocated to registers r5
+;------------------------------------------------------------
+;../../device/lib/_setjmp.c:28:int longjmp (jmp_buf buf, int rv)
+;      -----------------------------------------
+;       function longjmp
+;      -----------------------------------------
+       .globl _longjmp
+_longjmp:
+       ar2 = 0x02
+       ar3 = 0x03
+       ar4 = 0x04
+       ar5 = 0x05
+       ar6 = 0x06
+       ar7 = 0x07
+       ar0 = 0x00
+       ar1 = 0x01
+;     genReceive
+       mov     r0,sp
+       dec     r0
+       dec     r0
+       mov     ar2,@r0
+       dec     r0
+       mov     ar3,@r0
+;../../device/lib/_setjmp.c:30:bp = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       inc     dptr
+;     genAssign
+       mov     _bp,a
+;../../device/lib/_setjmp.c:31:lsp = *buf++;
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       inc     dptr
+;     genAssign
+       mov     r5,a
+;../../device/lib/_setjmp.c:32:*((unsigned char data *) lsp) = *buf++;
+;     genCast
+       mov     r0,a
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+       inc     dptr
+;     genPointerSet
+;     genNearPointerSet
+       mov     @r0,a
+;../../device/lib/_setjmp.c:33:*((unsigned char data *) lsp - 1) = *buf;
+;     genCast
+;     genMinus
+;     genMinusDec
+       dec     r0
+;     genPointerGet
+;     genGenPointerGet
+       lcall   __gptrget
+;     genPointerSet
+;     genNearPointerSet
+       mov     @r0,a
+;../../device/lib/_setjmp.c:34:SP = lsp;
+;     genAssign
+       mov     sp,r5
+;../../device/lib/_setjmp.c:35:return rv;
+;     genRet
+       mov     dph,r2
+       mov     dpl,r3
+       ret
+
+       _endasm;
 }
 
-int setjmp (unsigned char *bp)
-{    
+#else
+
+//extern unsigned char data bp;
+
+int setjmp (jmp_buf buf)
+{
     /* registers would have been saved on the
        stack anyway so we need to save SP
-       and the return address */     
-    *bp++ = *((unsigned char data *) SP  );   
-    *bp++ = *((unsigned char data *)SP - 1);    
-    *bp   = SP;
+       and the return address */
+//    *buf++ = bp;
+    *buf++ = SP;
+    *buf++ = *((unsigned char data *) SP  );
+    *buf   = *((unsigned char data *)SP - 1);
     return 0;
 }
+
+int longjmp (jmp_buf buf, int rv)
+{
+    unsigned char lsp;
+//    bp = *buf++;
+    lsp = *buf++;
+    *((unsigned char data *) lsp) = *buf++;
+    *((unsigned char data *) lsp - 1) = *buf;
+    SP = lsp;
+    return rv;
+}
+
+#endif
index 88bf7b03023c3b638cc4e9023872995059a67a61..89ee78caaef64828275397c047c58715d91332cf 100644 (file)
@@ -1,3 +1,4 @@
+_setjmp
 _iscntrl
 _isdigit
 _isgraph
index 2c98465f9ce11408aba62e76da3b3120b8b88eff..0a608a796a0b1c9dd89c7ca7dcce4b8e1f577cc7 100644 (file)
@@ -64,7 +64,7 @@ void PA(ast *t);
 int inInitMode = 0;
 memmap *GcurMemmap=NULL;  /* points to the memmap that's currently active */
 FILE *codeOutFile;
-int 
+int
 ptt (ast * tree)
 {
   printTypeChain (tree->ftype, stdout);
@@ -589,23 +589,23 @@ funcOfType (char *name, sym_link * type, sym_link * argType,
 symbol *
 funcOfTypeVarg (char *name, char * rtype, int nArgs , char **atypes)
 {
-  
+
     symbol *sym;
     int i ;
     /* create the symbol */
     sym = newSymbol (name, 0);
-    
+
     /* setup return value */
     sym->type = newLink (DECLARATOR);
     DCL_TYPE (sym->type) = FUNCTION;
     sym->type->next = typeFromStr(rtype);
     sym->etype = getSpec (sym->type);
-    
+
     /* if arguments required */
     if (nArgs) {
         value *args;
         args = FUNC_ARGS(sym->type) = newValue ();
-        
+
         for ( i = 0 ; i < nArgs ; i++ ) {
             args->type = typeFromStr(atypes[i]);
             args->etype = getSpec (args->type);
@@ -647,7 +647,7 @@ reverseParms (ast * ptree)
           ttree->left = ptree->left;
           ptree->left = ttree;
         }
-    
+
       /* Now reverse */
       ttree = ptree->left;
       ptree->left = ptree->right;
@@ -673,7 +673,7 @@ processParms (ast *func,
 {
   RESULT_TYPE resultType;
   sym_link *functype;
-  
+
   /* if none of them exist */
   if (!defParm && !*actParm)
     return 0;
@@ -692,7 +692,7 @@ processParms (ast *func,
     functype = func->ftype->next;
   else
     functype = func->ftype;
-    
+
   /* if the function is being called via a pointer &   */
   /* it has not been defined a reentrant then we cannot */
   /* have parameters                                   */
@@ -776,7 +776,7 @@ processParms (ast *func,
       if (IS_INTEGRAL (ftype)
           && (getSize (ftype) < (unsigned) INTSIZE))
         {
-          newType = newAst_LINK(INTTYPE);  
+          newType = newAst_LINK(INTTYPE);
         }
 
       if (IS_PTR(ftype) && !IS_GENPTR(ftype))
@@ -790,14 +790,14 @@ processParms (ast *func,
           newType = newAst_LINK (copyLinkChain (ftype));
           DCL_TYPE (newType->opval.lnk) = port->unqualified_pointer;
         }
-      
+
       if (newType)
         {
           /* cast required; change this op to a cast. */
           (*actParm)->decorated = 0;
            *actParm = newNode (CAST, newType, *actParm);
           (*actParm)->lineno = (*actParm)->right->lineno;
-          
+
           decorateType (*actParm, RESULT_TYPE_NONE);
         }
       return 0;
@@ -810,7 +810,7 @@ processParms (ast *func,
     return 0;
 
   resolveSymbols (*actParm);
-  
+
   /* the parameter type must be at least castable */
   if (compareType (defParm->type, (*actParm)->ftype) == 0)
     {
@@ -826,7 +826,7 @@ processParms (ast *func,
 
       resultType = getResultTypeFromType (defParm->etype);
       pTree = resolveSymbols (copyAst (*actParm));
-      
+
       /* now change the current one to a cast */
       (*actParm)->type = EX_OP;
       (*actParm)->opval.op = CAST;
@@ -896,7 +896,7 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist, ast *rootValue)
 
   if (iloop) {
     werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
-              W_EXCESS_INITIALIZERS, "struct", 
+              W_EXCESS_INITIALIZERS, "struct",
               sym->opval.val->sym->name);
   }
 
@@ -941,24 +941,24 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist, ast *rootValue)
       ast *aSym;
 
       aSym = decorateType (resolveSymbols(sym), RESULT_TYPE_NONE);
-      
+
       rast = newNode(ARRAYINIT, aSym, NULL);
       rast->values.constlist = literalL;
-      
+
       // Make sure size is set to length of initializer list.
       while (iloop)
       {
           size++;
           iloop = iloop->next;
       }
-      
+
       if (lcnt && size > lcnt)
       {
           // Array size was specified, and we have more initializers than needed.
           char *name=sym->opval.val->sym->name;
           int lineno=sym->opval.val->sym->lineDef;
           char *filename=sym->opval.val->sym->fileDef;
-          
+
           werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
       }
   }
@@ -967,7 +967,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist, ast *rootValue)
       for (;;)
       {
           ast *aSym;
-          
+
           aSym = newNode ('[', sym, newAst_VALUE (valueFromLit ((float) (size++))));
           aSym = decorateType (resolveSymbols (aSym), RESULT_TYPE_NONE);
           rast = createIval (aSym, type->next, iloop, rast, rootValue);
@@ -976,17 +976,17 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist, ast *rootValue)
           {
               break;
           }
-          
+
           /* no of elements given and we    */
           /* have generated for all of them */
-          if (!--lcnt) 
+          if (!--lcnt)
           {
               // is this a better way? at least it won't crash
               char *name = (IS_AST_SYM_VALUE(sym)) ? AST_SYMBOL(sym)->name : "";
               int lineno = iloop->lineno;
               char *filename = iloop->filename;
               werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
-              
+
               break;
           }
       }
@@ -1031,8 +1031,8 @@ createIvalCharPtr (ast * sym, sym_link * type, ast * iexpr, ast *rootVal)
       /* for each character generate an assignment */
       /* to the array element */
       char *s = SPEC_CVAL (iexpr->etype).v_char;
-      int i = 0;
-      int symsize = getSize (type);
+      unsigned int i = 0;
+      unsigned int symsize = getSize (type);
 
       size = getSize (iexpr->ftype);
       if (symsize && size>symsize)
@@ -1183,7 +1183,7 @@ gatherAutoInit (symbol * autoChain)
           SPEC_SCLS (sym->etype) != S_CODE)
         {
           symbol *newSym;
-          
+
           /* insert the symbol into the symbol table */
           /* with level = 0 & name = rname       */
           newSym = copySymbol (sym);
@@ -1195,7 +1195,7 @@ gatherAutoInit (symbol * autoChain)
           } else {
             if (getNelements(sym->type, sym->ival)>1) {
               werrorfl (sym->fileDef, sym->lineDef,
-                        W_EXCESS_INITIALIZERS, "scalar", 
+                        W_EXCESS_INITIALIZERS, "scalar",
                         sym->name);
             }
             work = newNode ('=', newAst_VALUE (symbolVal (newSym)),
@@ -1217,7 +1217,7 @@ gatherAutoInit (symbol * autoChain)
       if (sym->ival && SPEC_SCLS (sym->etype) != S_CODE)
         {
           initList *ilist=sym->ival;
-          
+
           while (ilist->type == INIT_DEEP) {
             ilist = ilist->init.deep;
           }
@@ -1225,19 +1225,19 @@ gatherAutoInit (symbol * autoChain)
           /* update lineno for error msg */
           lineno=sym->lineDef;
           setAstLineno (ilist->init.node, lineno);
-          
+
           if (IS_AGGREGATE (sym->type)) {
             work = initAggregates (sym, sym->ival, NULL);
           } else {
             if (getNelements(sym->type, sym->ival)>1) {
               werrorfl (sym->fileDef, sym->lineDef,
-                        W_EXCESS_INITIALIZERS, "scalar", 
+                        W_EXCESS_INITIALIZERS, "scalar",
                         sym->name);
             }
             work = newNode ('=', newAst_VALUE (symbolVal (sym)),
                             list2expr (sym->ival));
           }
-          
+
           // just to be sure
           setAstLineno (work, sym->lineDef);
 
@@ -1265,7 +1265,7 @@ void freeStringSymbol(symbol *sym) {
     }
   }
 }
-  
+
 /*-----------------------------------------------------------------*/
 /* stringToSymbol - creates a symbol from a literal string         */
 /*-----------------------------------------------------------------*/
@@ -1337,7 +1337,7 @@ processBlockVars (ast * tree, int *stack, int action)
         {
           *stack += allocVariables (tree->values.sym);
           autoInit = gatherAutoInit (tree->values.sym);
-        
+
           /* if there are auto inits then do them */
           if (autoInit)
             tree->left = newNode (NULLOP, autoInit, tree->left);
@@ -1364,7 +1364,7 @@ bool constExprTree (ast *cexpr) {
 
   cexpr = decorateType (resolveSymbols (cexpr), RESULT_TYPE_NONE);
 
-  switch (cexpr->type) 
+  switch (cexpr->type)
     {
     case EX_VALUE:
       if (IS_AST_LIT_VALUE(cexpr)) {
@@ -1379,7 +1379,7 @@ bool constExprTree (ast *cexpr) {
         // an array's address will never change
         return TRUE;
       }
-      if (IS_AST_SYM_VALUE(cexpr) && 
+      if (IS_AST_SYM_VALUE(cexpr) &&
           IN_CODESPACE(SPEC_OCLS(AST_SYMBOL(cexpr)->etype))) {
         // a symbol in code space will never change
         // This is only for the 'char *s="hallo"' case and will have to leave
@@ -1403,7 +1403,7 @@ bool constExprTree (ast *cexpr) {
         // cast ignored, maybe we should throw a warning here?
         return constExprTree(cexpr->right);
       }
-      if (cexpr->opval.op=='&') { 
+      if (cexpr->opval.op=='&') {
         return TRUE;
       }
       if (cexpr->opval.op==CALL || cexpr->opval.op==PCALL) {
@@ -1418,7 +1418,7 @@ bool constExprTree (ast *cexpr) {
     }
   return FALSE;
 }
-    
+
 /*-----------------------------------------------------------------*/
 /* constExprValue - returns the value of a constant expression     */
 /*                  or NULL if it is not a constant expression     */
@@ -1474,7 +1474,7 @@ constExprValue (ast * cexpr, int check)
 /*-----------------------------------------------------------------*/
 /* isLabelInAst - will return true if a given label is found       */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 isLabelInAst (symbol * label, ast * tree)
 {
   if (!tree || IS_AST_VALUE (tree) || IS_AST_LINK (tree))
@@ -1494,7 +1494,7 @@ isLabelInAst (symbol * label, ast * tree)
 /* isLoopCountable - return true if the loop count can be determi- */
 /* -ned at compile time .                                          */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 isLoopCountable (ast * initExpr, ast * condExpr, ast * loopExpr,
                  symbol ** sym, ast ** init, ast ** end)
 {
@@ -1607,7 +1607,7 @@ isLoopCountable (ast * initExpr, ast * condExpr, ast * loopExpr,
 /*-----------------------------------------------------------------*/
 /* astHasVolatile - returns true if ast contains any volatile      */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 astHasVolatile (ast * tree)
 {
   if (!tree)
@@ -1626,7 +1626,7 @@ astHasVolatile (ast * tree)
 /*-----------------------------------------------------------------*/
 /* astHasPointer - return true if the ast contains any ptr variable */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 astHasPointer (ast * tree)
 {
   if (!tree)
@@ -1651,7 +1651,7 @@ astHasPointer (ast * tree)
 /*-----------------------------------------------------------------*/
 /* astHasSymbol - return true if the ast has the given symbol      */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 astHasSymbol (ast * tree, symbol * sym)
 {
   if (!tree || IS_AST_LINK (tree))
@@ -1672,14 +1672,14 @@ astHasSymbol (ast * tree, symbol * sym)
 /*-----------------------------------------------------------------*/
 /* astHasDeref - return true if the ast has an indirect access     */
 /*-----------------------------------------------------------------*/
-static bool 
+static bool
 astHasDeref (ast * tree)
 {
   if (!tree || IS_AST_LINK (tree) || IS_AST_VALUE(tree))
     return FALSE;
 
   if (tree->opval.op == '*' && tree->right == NULL) return TRUE;
-  
+
   return astHasDeref (tree->left) || astHasDeref (tree->right);
 }
 
@@ -1687,7 +1687,7 @@ astHasDeref (ast * tree)
 /* isConformingBody - the loop body has to conform to a set of rules */
 /* for the loop to be considered reversible read on for rules      */
 /*-----------------------------------------------------------------*/
-bool 
+bool
 isConformingBody (ast * pbody, symbol * sym, ast * body)
 {
 
@@ -1706,7 +1706,7 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
   /* if we reach the end or a leaf then true */
   if (!pbody || IS_AST_LINK (pbody) || IS_AST_VALUE (pbody))
     return TRUE;
-  
+
   /* if anything else is "volatile" */
   if (IS_VOLATILE (TETYPE (pbody)))
     return FALSE;
@@ -1888,7 +1888,7 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
 /*----------------------------*/
     case CALL:
         /* if local & not passed as paramater then ok */
-        if (sym->level && !astHasSymbol(pbody->right,sym)) 
+        if (sym->level && !astHasSymbol(pbody->right,sym))
             return TRUE;
       return FALSE;
 
@@ -1954,7 +1954,7 @@ isLoopReversible (ast * loop, symbol ** loopCntrl,
 /*-----------------------------------------------------------------*/
 /* replLoopSym - replace the loop sym by loop sym -1               */
 /*-----------------------------------------------------------------*/
-static void 
+static void
 replLoopSym (ast * body, symbol * sym)
 {
   /* reached end */
@@ -2091,7 +2091,7 @@ getResultTypeFromType (sym_link *type)
   if (IS_BITFIELD (type))
     {
       int blen = SPEC_BLEN (type);
-      
+
       if (blen <= 1)
         return RESULT_TYPE_BIT;
       if (blen <= 8)
@@ -2114,7 +2114,7 @@ addCast (ast *tree, RESULT_TYPE resultType, bool promote)
 {
   sym_link *newLink;
   bool upCasted = FALSE;
-  
+
   switch (resultType)
     {
       case RESULT_TYPE_NONE:
@@ -2403,7 +2403,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
        in tree->left->?type. If the op is e.g. '=' we extract the type
        information from there and propagate it to the right branch. */
     resultTypeProp = getLeftResultType (tree, resultTypeProp);
-    
+
     switch (tree->opval.op)
       {
         case '?':
@@ -2411,12 +2411,12 @@ decorateType (ast * tree, RESULT_TYPE resultType)
              expansions might rely on this */
           dtr = tree->right;
           break;
-        case CALL: 
+        case CALL:
           /* decorate right side for CALL (parameter list) in processParms();
              there is resultType available */
           dtr = tree->right;
           break;
-        default:     
+        default:
           dtr = decorateType (tree->right, resultTypeProp);
           break;
       }
@@ -2474,6 +2474,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
 
       RRVAL (tree) = 1;
       COPYTYPE (TTYPE (tree), TETYPE (tree), LTYPE (tree)->next);
+      SPEC_CONST (TETYPE (tree)) |= DCL_PTR_CONST (LTYPE (tree));
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -2519,19 +2520,19 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       /* adjust the storage class */
       switch (DCL_TYPE(tree->left->ftype)) {
       case POINTER:
-        SPEC_SCLS(TETYPE(tree)) = S_DATA; 
+        SPEC_SCLS(TETYPE(tree)) = S_DATA;
         break;
       case FPOINTER:
-        SPEC_SCLS(TETYPE(tree)) = S_XDATA; 
+        SPEC_SCLS(TETYPE(tree)) = S_XDATA;
         break;
       case CPOINTER:
-        SPEC_SCLS(TETYPE(tree)) = S_CODE; 
+        SPEC_SCLS(TETYPE(tree)) = S_CODE;
         break;
       case GPOINTER:
         SPEC_SCLS (TETYPE (tree)) = 0;
         break;
       case PPOINTER:
-        SPEC_SCLS(TETYPE(tree)) = S_XSTACK; 
+        SPEC_SCLS(TETYPE(tree)) = S_XSTACK;
         break;
       case IPOINTER:
         SPEC_SCLS(TETYPE(tree)) = S_IDATA;
@@ -2546,7 +2547,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       case FUNCTION:
         break;
       }
-      
+
       /* This breaks with extern declarations, bitfields, and perhaps other */
       /* cases (gcse). Let's leave this optimization disabled for now and   */
       /* ponder if there's a safe way to do this. -- EEP                    */
@@ -2575,7 +2576,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
             SPEC_ABSA(sym->etype) = 1;
             addSym (SymbolTab, sym, sym->name, 0, 0, 0);
             allocGlobal (sym);
-            
+
             AST_VALUE (tree) = symbolVal(sym);
             TLVAL (tree) = 1;
             TRVAL (tree) = 0;
@@ -2584,7 +2585,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
             tree->right = NULL;
         }
       #endif
-      
+
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -2702,7 +2703,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
             }
 
           LRVAL (tree) = RRVAL (tree) = 1;
-          
+
           TTYPE (tree) = computeType (LTYPE (tree),
                                       RTYPE (tree),
                                       resultType,
@@ -2803,7 +2804,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
         ast *wtree = optimizeRRCRLC (tree);
         if (wtree != tree)
           return decorateType (wtree, RESULT_TYPE_NONE);
-        
+
         wtree = optimizeSWAP (tree);
         if (wtree != tree)
           return decorateType (wtree, RESULT_TYPE_NONE);
@@ -3035,16 +3036,16 @@ decorateType (ast * tree, RESULT_TYPE resultType)
               SPEC_SCLS(TETYPE(tree)) = S_DATA;
               break;
             case FPOINTER:
-              SPEC_SCLS(TETYPE(tree)) = S_XDATA; 
+              SPEC_SCLS(TETYPE(tree)) = S_XDATA;
               break;
             case CPOINTER:
-              SPEC_SCLS(TETYPE(tree)) = S_CODE; 
+              SPEC_SCLS(TETYPE(tree)) = S_CODE;
               break;
             case GPOINTER:
               SPEC_SCLS (TETYPE (tree)) = 0;
               break;
             case PPOINTER:
-              SPEC_SCLS(TETYPE(tree)) = S_XSTACK; 
+              SPEC_SCLS(TETYPE(tree)) = S_XSTACK;
               break;
             case IPOINTER:
               SPEC_SCLS(TETYPE(tree)) = S_IDATA;
@@ -3261,7 +3262,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                                                   resultType,
                                                   tree->opval.op));
         }
-        
+
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -3406,7 +3407,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                       tree->right = litParent->left;
                       litParent->left = tTree;
                       litTree->opval.op = '+';
-                      
+
                       tree->decorated = 0;
                       decorateType (tree, resultType);
                     }
@@ -3533,7 +3534,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       /* make smaller type only if it's a LEFT_OP */
       if (tree->opval.op == LEFT_OP)
         tree->left = addCast (tree->left, resultType, TRUE);
-      
+
       /* if they are both literal then */
       /* rewrite the tree */
       if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree)))
@@ -3681,7 +3682,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       if (IS_ADDRESS_OF_OP(tree->right)
           && IS_AST_SYM_VALUE (tree->right->left)
           && SPEC_ABSA (AST_SYMBOL (tree->right->left)->etype)) {
-        
+
         symbol * sym = AST_SYMBOL (tree->right->left);
         unsigned int gptype = 0;
         unsigned int addr = SPEC_ADDR (sym->etype);
@@ -3708,7 +3709,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
               }
             addr |= gptype << (8*(GPTRSIZE - 1));
           }
-        
+
         tree->type = EX_VALUE;
         tree->opval.val =
           valCastLiteral (LTYPE (tree), addr);
@@ -3927,7 +3928,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                   /* if (unsigned value) */
                   return tree->left;
                 }
-              
+
               /* (unsigned value) ? 1 : 0 */
               tree->opval.op = '?';
               tree->right = newNode (':',
@@ -4319,7 +4320,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       /*       function call        */
       /*----------------------------*/
     case CALL:
-      
+
       /* undo any explicit pointer derefernce; PCALL will handle it instead */
       if (IS_FUNC (LTYPE (tree)) && tree->left->type == EX_OP)
         {
@@ -4339,7 +4340,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       if (!tree->right ||
           !tree->right->decorated)
         {
-          sym_link *functype;      
+          sym_link *functype;
           parmNumber = 1;
 
           if (IS_FUNCPTR (LTYPE (tree)))
@@ -4352,8 +4353,8 @@ decorateType (ast * tree, RESULT_TYPE resultType)
             {
               goto errorTreeReturn;
             }
-        
-          if ((options.stackAuto || IFFUNC_ISREENT (functype)) && 
+
+          if ((options.stackAuto || IFFUNC_ISREENT (functype)) &&
              !IFFUNC_ISBUILTIN(functype))
             {
               reverseParms (tree->right);
@@ -4627,7 +4628,7 @@ createBlock (symbol * decl, ast * body)
 
   ex = newNode (BLOCK, NULL, body);
   ex->values.sym = decl;
-  
+
   ex->level++;
   ex->lineno = 0;
   return ex;
@@ -4746,7 +4747,7 @@ createCase (ast * swStat, ast * caseVal, ast * stmnt)
     }
 
   /* create the case label   */
-  SNPRINTF(caseLbl, sizeof(caseLbl), 
+  SNPRINTF(caseLbl, sizeof(caseLbl),
            "_case_%d_%d",
            swStat->values.switchVals.swNum,
            (int) floatFromVal (caseVal->opval.val));
@@ -5074,7 +5075,7 @@ optimizeGetHbit (ast * tree, RESULT_TYPE resultType)
   if (!expr && (resultType == RESULT_TYPE_BIT))
     {
       expr = tree->left;
-      if (isBitAndPow2 (tree) != getSize (TTYPE (expr)) * 8 - 1)
+      if (isBitAndPow2 (tree) != (signed)getSize (TTYPE (expr)) * 8 - 1)
         expr = NULL;
     }
   if (!expr)
@@ -5155,7 +5156,7 @@ optimizeGetByte (ast * tree, RESULT_TYPE resultType)
     }
   if (!expr || (i == 0) || (i % 8) || (i >= getSize (TTYPE (expr)) * 8))
     return tree;
-      
+
   /* make sure the port supports GETBYTE */
   if (port->hasExtBitOp
       && !port->hasExtBitOp(GETBYTE, getSize (TTYPE (expr))))
@@ -5181,7 +5182,7 @@ optimizeGetWord (ast * tree, RESULT_TYPE resultType)
       count = tree->left->right;
       if (AST_LIT_VALUE (tree->right) != 0xFFFF)
         expr = NULL;
-    }      
+    }
   if (!expr && resultType == RESULT_TYPE_INT)
     {
       /* if this is a right shift over a multiple of 8 */
@@ -5194,7 +5195,7 @@ optimizeGetWord (ast * tree, RESULT_TYPE resultType)
     }
   if (!expr || (i == 0) || (i % 8) || (i >= (getSize (TTYPE (expr))-1) * 8))
     return tree;
-      
+
   /* make sure the port supports GETWORD */
   if (port->hasExtBitOp
       && !port->hasExtBitOp(GETWORD, getSize (TTYPE (expr))))
@@ -5549,7 +5550,7 @@ noOptimize:
 /*-----------------------------------------------------------------*/
 /* addSymToBlock : adds the symbol to the first block we find      */
 /*-----------------------------------------------------------------*/
-void 
+void
 addSymToBlock (symbol * sym, ast * tree)
 {
   /* reached end of tree or a leaf */
@@ -5575,7 +5576,7 @@ addSymToBlock (symbol * sym, ast * tree)
 /*-----------------------------------------------------------------*/
 /* processRegParms - do processing for register parameters         */
 /*-----------------------------------------------------------------*/
-static void 
+static void
 processRegParms (value * args, ast * body)
 {
   while (args)
@@ -5692,7 +5693,6 @@ createFunction (symbol * name, ast * body)
 
   body = resolveSymbols (body); /* resolve the symbols */
   body = decorateType (body, RESULT_TYPE_NONE); /* propagateType & do semantic checks */
-                                        
 
   ex = newAst_VALUE (symbolVal (name)); /* create name */
   ex = newNode (FUNCTION, ex, body);
@@ -6020,11 +6020,11 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                         fprintf(outfile,")\n");
                         ast_print(tree->left,outfile,indent+2);
                         return ;
-                }                       
+                }
                 /*------------------------------------------------------------------*/
                 /*----------------------------*/
                 /*      multiplication        */
-                /*----------------------------*/                
+                /*----------------------------*/
                 fprintf(outfile,"MULT (%p) type (",tree);
                 printTypeChain(tree->ftype,outfile);
                 fprintf(outfile,")\n");
@@ -6174,7 +6174,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                 fprintf(outfile,")\n");
                 ast_print(tree->right,outfile,indent+2);
                 return ;
-                
+
         case AND_OP:
                 fprintf(outfile,"ANDAND (%p) type (",tree);
                 printTypeChain(tree->ftype,outfile);
@@ -6189,7 +6189,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                 ast_print(tree->left,outfile,indent+2);
                 ast_print(tree->right,outfile,indent+2);
                 return ;
-                
+
                 /*------------------------------------------------------------------*/
                 /*----------------------------*/
                 /*     comparison operators   */
@@ -6348,7 +6348,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                 fprintf(outfile,")\n");
                 ast_print(tree->left,outfile,indent+2);
                 ast_print(tree->right,outfile,indent+2);
-                return;     
+                return;
                 /*------------------------------------------------------------------*/
                 /*----------------------------*/
                 /*      comma operator        */
@@ -6489,12 +6489,12 @@ void PA(ast *t)
 int astErrors(ast *t)
 {
   int errors=0;
-  
+
   if (t)
     {
       if (t->isError)
         errors++;
-  
+
       if (t->type == EX_VALUE
           && t->opval.val->sym
           && t->opval.val->sym->undefined)
@@ -6503,6 +6503,6 @@ int astErrors(ast *t)
       errors += astErrors(t->left);
       errors += astErrors(t->right);
     }
-    
+
   return errors;
 }
index 78da017738a22143ee51f7268be971a887286f92..6f76b0fdc60609bd669816f91ac89f5fe5633552 100644 (file)
@@ -790,21 +790,29 @@ printIvalStruct (symbol * sym, sym_link * type,
 /* printIvalChar - generates initital value for character array    */
 /*-----------------------------------------------------------------*/
 int 
-printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s)
+printIvalChar (symbol * sym, sym_link * type, initList * ilist, FILE * oFile, char *s)
 {
   value *val;
+  unsigned int size = DCL_ELEM (type);
 
   if (!s)
     {
-
       val = list2val (ilist);
       /* if the value is a character string  */
       if (IS_ARRAY (val->type) && IS_CHAR (val->etype))
         {
-          if (!DCL_ELEM (type))
-            DCL_ELEM (type) = strlen (SPEC_CVAL (val->etype).v_char) + 1;
+          if (!size)
+            {
+              /* we have not been given a size, but now we know it */
+              size = strlen (SPEC_CVAL (val->etype).v_char) + 1;
+              /* but first check, if it's a flexible array */
+              if (sym && IS_STRUCT (sym->type))
+                sym->flexArrayLength = size;
+              else
+                DCL_ELEM (type) = size;
+            }
 
-          printChar (oFile, SPEC_CVAL (val->etype).v_char, DCL_ELEM (type));
+          printChar (oFile, SPEC_CVAL (val->etype).v_char, size);
 
           return 1;
         }
@@ -835,7 +843,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
         werrorfl (ilist->filename, ilist->lineno, E_CONST_EXPECTED);
         return;
       }
-      if (printIvalChar (type,
+      if (printIvalChar (sym, type,
                          (ilist->type == INIT_DEEP ? ilist->init.deep : ilist),
                          oFile, SPEC_CVAL (sym->etype).v_char))
         return;
@@ -864,8 +872,12 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
       }
     }
   } else {
-    // we have not been given a size, but we now know it
-    DCL_ELEM (type) = size;
+    /* we have not been given a size, but now we know it */
+    /* but first check, if it's a flexible array */
+    if (IS_STRUCT (sym->type))
+      sym->flexArrayLength = size * getSize (type->next);
+    else
+      DCL_ELEM (type) = size;
   }
 
   return;
index 2493f2773dcd17c67aa60381988459f1abb569e0..e5632cb13f46c55833d4aa8e40e37a80bc1b7921 100644 (file)
@@ -38,5 +38,12 @@ test_sprintf(void)
   sprintf( s, "%-3.3s", "ab" );
   ASSERT( 0 == strcmp( s, "ab " ) );
 
+  //and from bug 1358192
+#if defined(SDCC__ds390)
+  sprintf( s, "%f", 10.1 );
+  LOG((s));
+  ASSERT( 0 == strcmp( s, "10.100000" ) );
+#endif
+
   ASSERT( s[12]==0x12 );
 }
diff --git a/support/regression/tests/setjmp.c b/support/regression/tests/setjmp.c
new file mode 100644 (file)
index 0000000..89176f1
--- /dev/null
@@ -0,0 +1,54 @@
+/** setjmp/longjmp tests.
+*/
+#include <testfwk.h>
+#include <setjmp.h>
+
+unsigned int global_int = 0;
+unsigned int *gpInt;
+
+#if defined(SDCC_mcs51)
+#include <8052.h>
+
+void T2_isr (void) interrupt 5 //no using
+{
+  //do not clear flag TF2 so it keeps interrupting !
+  (*gpInt)++;
+}
+#endif
+
+#if defined(SDCC_mcs51) || defined(PORT_HOST)
+
+void try_fun(jmp_buf catch, int except)
+{
+  longjmp(catch, except);
+}
+
+#endif
+
+void
+testJmp(void)
+{
+#if defined(SDCC_mcs51) || defined(PORT_HOST)
+
+  jmp_buf catch;
+  int exception;
+
+#if defined(SDCC_mcs51)
+  gpInt = &global_int;
+  //enable the interrupt and set it's flag to generate some heavy stack usage
+  ET2 = 1;
+  EA = 1;
+  TF2 = 1;
+#endif
+
+  exception = setjmp(catch);
+  if (exception == 0)
+  {
+       try_fun(catch, 1);
+       //should not get here!
+       ASSERT(0);
+  }
+  ASSERT(exception == 1);
+
+#endif
+}