From b3ad2602f4c6a2236081ed2d913d4e03892182a6 Mon Sep 17 00:00:00 2001 From: "phil@softsynth.com" Date: Mon, 5 Jul 2010 22:52:35 +0000 Subject: [PATCH] Add patch from Aleksej for 64 bit cells on 32 bit system. --- csrc/pf_core.c | 8 ++++---- csrc/pf_guts.h | 20 ++++++++------------ csrc/pf_inner.c | 8 ++++---- csrc/pf_save.c | 8 ++++---- csrc/pfcompil.c | 26 +++++++++++++------------- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/csrc/pf_core.c b/csrc/pf_core.c index 7abe8c1..41fa5f7 100644 --- a/csrc/pf_core.c +++ b/csrc/pf_core.c @@ -53,7 +53,7 @@ ExecToken gAcceptP_XT; /* XT of ACCEPT */ cell_t gDepthAtColon; /* Global Forth variables. */ -char *gVarContext; /* Points to last name field. */ +cell_t gVarContext; /* Points to last name field. */ cell_t gVarState; /* 1 if compiling. */ cell_t gVarBase; /* Numeric Base. */ cell_t gVarEcho; /* Echo input. */ @@ -87,7 +87,7 @@ static void pfInit( void ) gCurrentDictionary = NULL; gNumPrimitives = 0; gLocalCompiler_XT = 0; - gVarContext = NULL; /* Points to last name field. */ + gVarContext = (cell_t)NULL; /* Points to last name field. */ gVarState = 0; /* 1 if compiling. */ gVarEcho = 0; /* Echo input. */ gVarTraceLevel = 0; /* Trace Level for Inner Interpreter. */ @@ -174,7 +174,7 @@ nomem: cell_t pfExecIfDefined( const char *CString ) { int result = 0; - if( NAME_BASE != NULL) + if( NAME_BASE != (cell_t)NULL) { ExecToken XT; if( ffFindC( CString, &XT ) ) @@ -235,7 +235,7 @@ PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize ) dic->dic_HeaderBase = DIC_ALIGN(dic->dic_HeaderBaseUnaligned); pfSetMemory( dic->dic_HeaderBase, 0xA5, (ucell_t) HeaderSize); dic->dic_HeaderLimit = dic->dic_HeaderBase + HeaderSize; - dic->dic_HeaderPtr.Byte = dic->dic_HeaderBase; + dic->dic_HeaderPtr = dic->dic_HeaderBase; } else { diff --git a/csrc/pf_guts.h b/csrc/pf_guts.h index 806ff84..425f226 100644 --- a/csrc/pf_guts.h +++ b/csrc/pf_guts.h @@ -422,26 +422,22 @@ typedef struct pfDictionary_s ucell_t dic_Flags; /* Headers contain pointers to names and dictionary. */ - uint8_t *dic_HeaderBaseUnaligned; + ucell_t dic_HeaderBaseUnaligned; - uint8_t *dic_HeaderBase; - union - { - cell_t *Cell; - uint8_t *Byte; - } dic_HeaderPtr; - uint8_t *dic_HeaderLimit; + ucell_t dic_HeaderBase; + ucell_t dic_HeaderPtr; + ucell_t dic_HeaderLimit; /* Code segment contains tokenized code and data. */ - uint8_t *dic_CodeBaseUnaligned; + ucell_t dic_CodeBaseUnaligned; - uint8_t *dic_CodeBase; + ucell_t dic_CodeBase; union { cell_t *Cell; uint8_t *Byte; } dic_CodePtr; - uint8_t *dic_CodeLimit; + ucell_t dic_CodeLimit; } pfDictionary_t; /* Save state of include when nesting files. */ @@ -487,7 +483,7 @@ extern ExecToken gAcceptP_XT; /* XT of ACCEPT */ extern cell_t gDepthAtColon; /* Global variables. */ -extern char *gVarContext; /* Points to last name field. */ +extern cell_t gVarContext; /* Points to last name field. */ extern cell_t gVarState; /* 1 if compiling. */ extern cell_t gVarBase; /* Numeric Base. */ extern cell_t gVarEcho; /* Echo input from file. */ diff --git a/csrc/pf_inner.c b/csrc/pf_inner.c index 11c5dce..5472942 100644 --- a/csrc/pf_inner.c +++ b/csrc/pf_inner.c @@ -1536,7 +1536,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); #if (defined(PF_BIG_ENDIAN_DIC) || defined(PF_LITTLE_ENDIAN_DIC)) if( IN_DICS( TOS ) ) { - WRITE_CELL_DIC(TOS,M_POP); + WRITE_CELL_DIC((cell_t *)TOS,M_POP); } else { @@ -1666,7 +1666,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); case ID_VAR_ECHO: DO_VAR(gVarEcho); endcase; case ID_VAR_HEADERS_BASE: DO_VAR(gCurrentDictionary->dic_HeaderBase); endcase; case ID_VAR_HEADERS_LIMIT: DO_VAR(gCurrentDictionary->dic_HeaderLimit); endcase; - case ID_VAR_HEADERS_PTR: DO_VAR(gCurrentDictionary->dic_HeaderPtr.Cell); endcase; + case ID_VAR_HEADERS_PTR: DO_VAR(gCurrentDictionary->dic_HeaderPtr); endcase; case ID_VAR_NUM_TIB: DO_VAR(gCurrentTask->td_SourceNum); endcase; case ID_VAR_OUT: DO_VAR(gCurrentTask->td_OUT); endcase; case ID_VAR_STATE: DO_VAR(gVarState); endcase; @@ -1684,7 +1684,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); #if (defined(PF_BIG_ENDIAN_DIC) || defined(PF_LITTLE_ENDIAN_DIC)) if( IN_DICS( TOS ) ) { - TOS = (uint16_t) READ_SHORT_DIC((uint8_t *)TOS); + TOS = (uint16_t) READ_SHORT_DIC((uint16_t *)TOS); } else { @@ -1700,7 +1700,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); #if (defined(PF_BIG_ENDIAN_DIC) || defined(PF_LITTLE_ENDIAN_DIC)) if( IN_DICS( TOS ) ) { - WRITE_SHORT_DIC(TOS,M_POP); + WRITE_SHORT_DIC((uint16_t *)TOS,(uint16_t)M_POP); } else { diff --git a/csrc/pf_save.c b/csrc/pf_save.c index 6a9d195..128b474 100644 --- a/csrc/pf_save.c +++ b/csrc/pf_save.c @@ -423,7 +423,7 @@ cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, uint32_t relativeHeaderPtr; /* Development mode. */ SD.sd_RelContext = ABS_TO_NAMEREL(gVarContext); - relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr.Byte); + relativeHeaderPtr = ABS_TO_NAMEREL(gCurrentDictionary->dic_HeaderPtr); SD.sd_RelHeaderPtr = relativeHeaderPtr; /* How much real name space is there? */ @@ -645,13 +645,13 @@ DBUG(("pfLoadDictionary( %s )\n", FileName )); if( sd->sd_NameSize > 0 ) { gVarContext = (char *) NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */ - gCurrentDictionary->dic_HeaderPtr.Byte = (uint8_t *) + gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(sd->sd_RelHeaderPtr); } else { gVarContext = 0; - gCurrentDictionary->dic_HeaderPtr.Byte = NULL; + gCurrentDictionary->dic_HeaderPtr = (ucell_t)NULL; } gCurrentDictionary->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(sd->sd_RelCodePtr); gNumPrimitives = sd->sd_NumPrimitives; /* Must match compiled dictionary. */ @@ -810,7 +810,7 @@ PForthDictionary pfLoadStaticDictionary( void ) if( NAME_BASE != NULL) { /* Setup name space. */ - dic->dic_HeaderPtr.Byte = (uint8_t *) NAMEREL_TO_ABS(HEADERPTR); + dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR); gVarContext = (char *) NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */ /* Find special words in dictionary for global XTs. */ diff --git a/csrc/pfcompil.c b/csrc/pfcompil.c index 3613b33..025eebf 100644 --- a/csrc/pfcompil.c +++ b/csrc/pfcompil.c @@ -58,7 +58,7 @@ void CreateDicEntry( ExecToken XT, const ForthStringPtr FName, ucell_t Flags ) { cfNameLinks *cfnl; - cfnl = (cfNameLinks *) gCurrentDictionary->dic_HeaderPtr.Byte; + cfnl = (cfNameLinks *) gCurrentDictionary->dic_HeaderPtr; /* Set link to previous header, if any. */ if( gVarContext ) @@ -74,20 +74,20 @@ void CreateDicEntry( ExecToken XT, const ForthStringPtr FName, ucell_t Flags ) WRITE_CELL_DIC( &cfnl->cfnl_ExecToken, XT ); /* Advance Header Dictionary Pointer */ - gCurrentDictionary->dic_HeaderPtr.Byte += sizeof(cfNameLinks); + gCurrentDictionary->dic_HeaderPtr += sizeof(cfNameLinks); /* Laydown name. */ - gVarContext = (char *) gCurrentDictionary->dic_HeaderPtr.Byte; - pfCopyMemory( gCurrentDictionary->dic_HeaderPtr.Byte, FName, (*FName)+1 ); - gCurrentDictionary->dic_HeaderPtr.Byte += (*FName)+1; + gVarContext = (char *) gCurrentDictionary->dic_HeaderPtr; + pfCopyMemory( (char *)gCurrentDictionary->dic_HeaderPtr, FName, (*FName)+1 ); + gCurrentDictionary->dic_HeaderPtr += (*FName)+1; /* Set flags. */ - *gVarContext |= (char) Flags; + *(char*)gVarContext |= (char) Flags; /* Align to quad byte boundaries with zeroes. */ - while( ((ucell_t) gCurrentDictionary->dic_HeaderPtr.Byte) & UINT32_MASK ) + while( gCurrentDictionary->dic_HeaderPtr & UINT32_MASK ) { - *gCurrentDictionary->dic_HeaderPtr.Byte++ = 0; + *(char*)(gCurrentDictionary->dic_HeaderPtr++) = 0; } } @@ -528,16 +528,16 @@ DBUG(("ffFindC: %s\n", WordName )); static cell_t ffCheckDicRoom( void ) { cell_t RoomLeft; - RoomLeft = gCurrentDictionary->dic_HeaderLimit - - gCurrentDictionary->dic_HeaderPtr.Byte; + RoomLeft = (char *)gCurrentDictionary->dic_HeaderLimit - + (char *)gCurrentDictionary->dic_HeaderPtr; if( RoomLeft < DIC_SAFETY_MARGIN ) { pfReportError("ffCheckDicRoom", PF_ERR_HEADER_ROOM); return PF_ERR_HEADER_ROOM; } - RoomLeft = gCurrentDictionary->dic_CodeLimit - - gCurrentDictionary->dic_CodePtr.Byte; + RoomLeft = (char *)gCurrentDictionary->dic_CodeLimit - + (char *)gCurrentDictionary->dic_CodePtr.Byte; if( RoomLeft < DIC_SAFETY_MARGIN ) { pfReportError("ffCheckDicRoom", PF_ERR_CODE_ROOM); @@ -662,7 +662,7 @@ void ffDefer( void ) /* Unsmudge the word to make it visible. */ void ffUnSmudge( void ) { - *gVarContext &= ~FLAG_SMUDGE; + *(char*)gVarContext &= ~FLAG_SMUDGE; } /* Implement ; */ -- 2.20.1