From: Phil Burk Date: Thu, 3 May 2018 03:40:21 +0000 (-0700) Subject: Merge pull request #50 from linuxuser27/win64_warnings X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/commitdiff_plain/ee8dc9e9e0f59b8e38dec3732caefe9f3af2b431?hp=d71efe1792a1414a5b102ae8e69f3913c70aa8b0 Merge pull request #50 from linuxuser27/win64_warnings Windows and 64-bit --- diff --git a/build/win32/vs2017/pforth.sln b/build/win32/vs2017/pforth.sln index 3e19d6a..b35fd9c 100644 --- a/build/win32/vs2017/pforth.sln +++ b/build/win32/vs2017/pforth.sln @@ -8,13 +8,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Debug|Win32.ActiveCfg = Debug|Win32 {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Debug|Win32.Build.0 = Debug|Win32 + {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Debug|x64.ActiveCfg = Debug|x64 + {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Debug|x64.Build.0 = Debug|x64 {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Release|Win32.ActiveCfg = Release|Win32 {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Release|Win32.Build.0 = Release|Win32 + {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Release|x64.ActiveCfg = Release|x64 + {58B76DB8-1985-4B8A-8E71-C012D8F0C518}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/win32/vs2017/pforth_main.vcxproj b/build/win32/vs2017/pforth_main.vcxproj index ca50ca4..0b6ab8b 100644 --- a/build/win32/vs2017/pforth_main.vcxproj +++ b/build/win32/vs2017/pforth_main.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {58B76DB8-1985-4B8A-8E71-C012D8F0C518} @@ -23,20 +31,37 @@ NotSet true + + Application + v141 + NotSet + true + Application v141 Unicode + + Application + v141 + Unicode + + + + + + + <_ProjectFileVersion>15.0.27130.2010 @@ -46,11 +71,17 @@ $(Configuration)\ true + + true + $(SolutionDir)..\..\..\fth\ $(Configuration)\ false + + false + Disabled @@ -68,6 +99,22 @@ MachineX86 + + + Disabled + WIN32;_DEBUG;_CONSOLE;PF_SUPPORT_FP;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + true + Console + + WIN32;NDEBUG;_CONSOLE;PF_SUPPORT_FP;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) @@ -84,6 +131,22 @@ MachineX86 + + + WIN32;NDEBUG;_CONSOLE;PF_SUPPORT_FP;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + true + Console + true + true + + diff --git a/csrc/pf_core.c b/csrc/pf_core.c index 1736aa9..a6d7c26 100644 --- a/csrc/pf_core.c +++ b/csrc/pf_core.c @@ -170,9 +170,9 @@ nomem: ** Dictionary Management ***************************************************************/ -cell_t pfExecIfDefined( const char *CString ) +ThrowCode pfExecIfDefined( const char *CString ) { - int result = 0; + ThrowCode result = 0; if( NAME_BASE != (cell_t)NULL) { ExecToken XT; @@ -427,11 +427,11 @@ void pfMessage( const char *CString ) /************************************************************************** ** Main entry point for pForth. */ -cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit ) +ThrowCode pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit ) { pfTaskData_t *cftd; pfDictionary_t *dic = NULL; - cell_t Result = 0; + ThrowCode Result = 0; ExecToken EntryPoint = 0; #ifdef PF_USER_INIT diff --git a/csrc/pf_guts.h b/csrc/pf_guts.h index 5aa4a70..a55d857 100644 --- a/csrc/pf_guts.h +++ b/csrc/pf_guts.h @@ -462,7 +462,7 @@ typedef struct IncludeFrame extern "C" { #endif -int pfCatch( ExecToken XT ); +ThrowCode pfCatch( ExecToken XT ); #ifdef __cplusplus } diff --git a/csrc/pf_inner.c b/csrc/pf_inner.c index dffadf0..57559bd 100644 --- a/csrc/pf_inner.c +++ b/csrc/pf_inner.c @@ -197,8 +197,8 @@ static void TraceNames( ExecToken Token, cell_t Level ) static uint64_t UdToUint64( ucell_t Lo, ucell_t Hi ) { return (( 2 * sizeof(ucell_t) == sizeof(uint64_t) ) - ? (((uint64_t)Lo) | (((uint64_t)Hi) >> (sizeof(ucell_t) * 8))) - : Lo ); + ? (((uint64_t)Lo) | (((uint64_t)Hi) >> (sizeof(ucell_t) * 8))) + : Lo); } /* Return TRUE if the unsigned double cell integer LO/HI is not greater @@ -207,15 +207,15 @@ static uint64_t UdToUint64( ucell_t Lo, ucell_t Hi ) static int UdIsUint64( ucell_t Lo, ucell_t Hi ) { return (( 2 * sizeof(ucell_t) == sizeof(uint64_t) ) - ? TRUE - : Hi == 0 ); + ? TRUE + : Hi == 0); } -static const char *pfSelectFileModeCreate( int fam ); -static const char *pfSelectFileModeOpen( int fam ); +static const char *pfSelectFileModeCreate(cell_t fam ); +static const char *pfSelectFileModeOpen(cell_t fam ); /**************************************************************/ -static const char *pfSelectFileModeCreate( int fam ) +static const char *pfSelectFileModeCreate( cell_t fam ) { const char *famText = NULL; switch( fam ) @@ -240,7 +240,7 @@ static const char *pfSelectFileModeCreate( int fam ) } /**************************************************************/ -static const char *pfSelectFileModeOpen( int fam ) +static const char *pfSelectFileModeOpen( cell_t fam ) { const char *famText = NULL; switch( fam ) @@ -269,7 +269,7 @@ static const char *pfSelectFileModeOpen( int fam ) } /**************************************************************/ -int pfCatch( ExecToken XT ) +ThrowCode pfCatch( ExecToken XT ) { register cell_t TopOfStack; /* Cache for faster execution. */ register cell_t *DataStackPtr; @@ -1089,7 +1089,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); TOS = -3; /* TODO err num? */ break; } - offset = offsetLow; + offset = (file_offset_t)offsetLow; TOS = sdSeekFile( FileID, offset, PF_SEEK_SET ); } endcase; diff --git a/csrc/pf_main.c b/csrc/pf_main.c index 5783f0f..1c7ef96 100644 --- a/csrc/pf_main.c +++ b/csrc/pf_main.c @@ -67,7 +67,7 @@ int main( int argc, char **argv ) char IfInit = FALSE; char *s; cell_t i; - int Result; + ThrowCode Result; /* For Metroworks on Mac */ #ifdef __MWERKS__ @@ -140,7 +140,7 @@ int main( int argc, char **argv ) Result = pfDoForth( DicName, SourceName, IfInit); on_error: - return Result; + return (int)Result; } #endif /* PF_EMBEDDED */ diff --git a/csrc/pf_save.c b/csrc/pf_save.c index 03f4ce8..f72981e 100644 --- a/csrc/pf_save.c +++ b/csrc/pf_save.c @@ -315,7 +315,7 @@ cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, /***************************************************************/ static int Write32ToFile( FileStream *fid, uint32_t Val ) { - int numw; + cell_t numw; uint8_t pad[4]; Write32BigEndian(pad,Val); @@ -332,8 +332,10 @@ static cell_t WriteChunkToFile( FileStream *fid, cell_t ID, char *Data, int32_t EvenNumW = EVENUP(NumBytes); - if( Write32ToFile( fid, ID ) < 0 ) goto error; - if( Write32ToFile( fid, EvenNumW ) < 0 ) goto error; + assert(ID <= UINT32_MAX); + if( Write32ToFile( fid, (uint32_t)ID ) < 0 ) goto error; + assert(EvenNumW <= UINT32_MAX); + if( Write32ToFile( fid, (uint32_t)EvenNumW ) < 0 ) goto error; numw = sdWriteFile( Data, 1, EvenNumW, fid ); if( numw != EvenNumW ) goto error; @@ -515,7 +517,7 @@ error: /***************************************************************/ static int32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr ) { - int32_t numr; + cell_t numr; uint8_t pad[4]; numr = sdReadFile( pad, 1, sizeof(pad), fid ); if( numr != sizeof(pad) ) return -1; @@ -533,7 +535,7 @@ PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPt uint32_t ChunkSize; uint32_t FormSize; uint32_t BytesLeft; - uint32_t numr; + cell_t numr; int isDicBigEndian; DBUG(("pfLoadDictionary( %s )\n", FileName )); @@ -726,7 +728,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName )); /* Find special words in dictionary for global XTs. */ if( (Result = FindSpecialXTs()) < 0 ) { - pfReportError("pfLoadDictionary: FindSpecialXTs", Result); + pfReportError("pfLoadDictionary: FindSpecialXTs", (Err)Result); goto error; } } diff --git a/csrc/pf_text.c b/csrc/pf_text.c index e48e457..03430a7 100644 --- a/csrc/pf_text.c +++ b/csrc/pf_text.c @@ -222,7 +222,7 @@ DBUGX(("ffCompareText: return 0x%x\n", Result )); ** Compare two strings, case sensitive. ** Return zero if they match, -1 if s1s2; */ -cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 ) +cell_t ffCompare( const char *s1, cell_t len1, const char *s2, cell_t len2 ) { cell_t i, result, n, diff; diff --git a/csrc/pf_text.h b/csrc/pf_text.h index 05431d7..fd71371 100644 --- a/csrc/pf_text.h +++ b/csrc/pf_text.h @@ -54,7 +54,7 @@ void pfReportThrow( ThrowCode code ); char *ForthStringToC( char *dst, const char *FString, cell_t dstSize ); char *CStringToForth( char *dst, const char *CString, cell_t dstSize ); -cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 ); +cell_t ffCompare( const char *s1, cell_t len1, const char *s2, cell_t len2 ); cell_t ffCompareText( const char *s1, const char *s2, cell_t len ); cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len ); diff --git a/csrc/pfcompil.c b/csrc/pfcompil.c index b618c9f..937e39e 100644 --- a/csrc/pfcompil.c +++ b/csrc/pfcompil.c @@ -981,7 +981,7 @@ ThrowCode ffIncludeFile( FileStream *InputFile ) ***************************************************************/ Err ffPushInputStream( FileStream *InputFile ) { - cell_t Result = 0; + Err Result = 0; IncludeFrame *inf; /* Push current input state onto special include stack. */ diff --git a/csrc/pfinnrfp.h b/csrc/pfinnrfp.h index ec476f7..23b379b 100644 --- a/csrc/pfinnrfp.h +++ b/csrc/pfinnrfp.h @@ -23,7 +23,7 @@ #ifdef PF_SUPPORT_FP -#define FP_DHI1 (((PF_FLOAT)(1L<<(sizeof(cell_t)*8-2)))*4.0) +#define FP_DHI1 (((PF_FLOAT)((cell_t)1<<(sizeof(cell_t)*8-2)))*4.0) case ID_FP_D_TO_F: /* ( dlo dhi -- ) ( F: -- r ) */ PUSH_FP_TOS; diff --git a/csrc/pforth.h b/csrc/pforth.h index cd74336..96eb93f 100644 --- a/csrc/pforth.h +++ b/csrc/pforth.h @@ -39,7 +39,7 @@ extern "C" { #endif /* Main entry point to pForth. */ -cell_t pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit ); +ThrowCode pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit ); /* Turn off messages. */ void pfSetQuiet( cell_t IfQuiet ); @@ -78,7 +78,7 @@ void pfDeleteDictionary( PForthDictionary dict ); ThrowCode pfQuit( void ); /* Execute a single execution token in the current task and return 0 or an error code. */ -int pfCatch( ExecToken XT ); +ThrowCode pfCatch( ExecToken XT ); /* Include the given pForth source code file. */ ThrowCode pfIncludeFile( const char *FileName );