X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/blobdiff_plain/970d32b553a44051cedd2caf34267b7b1cdbab78..1cb310e62eaf4422ee298d9d87c35f9dd6b4c71c:/csrc/pf_save.h diff --git a/csrc/pf_save.h b/csrc/pf_save.h index f4d1e7a..3bf8c2f 100644 --- a/csrc/pf_save.h +++ b/csrc/pf_save.h @@ -24,28 +24,30 @@ typedef struct DictionaryInfoChunk { -/* All fields are stored in BIG ENDIAN format for consistency in data files. */ -/* All fileds must be the same size as int32 for easy endian conversion. */ - int32 sd_Version; - int32 sd_RelContext; /* relative ptr to Dictionary Context */ - int32 sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */ - int32 sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */ - ExecToken sd_EntryPoint; /* relative ptr to entry point or NULL */ - int32 sd_UserStackSize; /* in bytes */ - int32 sd_ReturnStackSize; /* in bytes */ - int32 sd_NameSize; /* in bytes */ - int32 sd_CodeSize; /* in bytes */ - int32 sd_NumPrimitives; /* To distinguish between primitive and secondary. */ - uint32 sd_Flags; - int32 sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */ - uint32 sd_Reserved; +/* All fields are stored in BIG ENDIAN format for consistency in data files. + * All fields must be the same size for easy endian conversion. + * All fields must be 32 bit for file compatibility with older versions. + */ + int32_t sd_Version; + int32_t sd_RelContext; /* relative ptr to Dictionary Context */ + int32_t sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */ + int32_t sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */ + int32_t sd_EntryPoint; /* relative ptr to entry point or NULL */ + int32_t sd_UserStackSize; /* in bytes */ + int32_t sd_ReturnStackSize; /* in bytes */ + int32_t sd_NameSize; /* in bytes */ + int32_t sd_CodeSize; /* in bytes */ + int32_t sd_NumPrimitives; /* To distinguish between primitive and secondary. */ + uint32_t sd_Flags; + int32_t sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */ + int32_t sd_CellSize; /* In bytes. Must match code. */ } DictionaryInfoChunk; /* Bits in sd_Flags */ #define SD_F_BIG_ENDIAN_DIC (1<<0) #ifndef MAKE_ID -#define MAKE_ID(a,b,c,d) ((((uint32)a)<<24)|(((uint32)b)<<16)|(((uint32)c)<<8)|((uint32)d)) +#define MAKE_ID(a,b,c,d) ((((uint32_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d)) #endif #define ID_FORM MAKE_ID('F','O','R','M') @@ -63,19 +65,26 @@ typedef struct DictionaryInfoChunk extern "C" { #endif -int32 ffSaveForth( const char *FileName, ExecToken EntryPoint, int32 NameSize, int32 CodeSize ); +cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize ); /* Endian-ness tools. */ - int IsHostLittleEndian( void ); -uint32 ReadLongBigEndian( const uint32 *addr ); -uint16 ReadShortBigEndian( const uint16 *addr ); -uint32 ReadLongLittleEndian( const uint32 *addr ); -uint16 ReadShortLittleEndian( const uint16 *addr ); -void WriteLongBigEndian( uint32 *addr, uint32 data ); -void WriteShortBigEndian( uint16 *addr, uint16 data ); -void WriteLongLittleEndian( uint32 *addr, uint32 data ); -void WriteShortLittleEndian( uint16 *addr, uint16 data ); + +ucell_t ReadCellBigEndian( const uint8_t *addr ); +uint32_t Read32BigEndian( const uint8_t *addr ); +uint16_t Read16BigEndian( const uint8_t *addr ); + +ucell_t ReadCellLittleEndian( const uint8_t *addr ); +uint32_t Read32LittleEndian( const uint8_t *addr ); +uint16_t Read16LittleEndian( const uint8_t *addr ); + +void WriteCellBigEndian( uint8_t *addr, ucell_t data ); +void Write32BigEndian( uint8_t *addr, uint32_t data ); +void Write16BigEndian( uint8_t *addr, uint16_t data ); + +void WriteCellLittleEndian( uint8_t *addr, ucell_t data ); +void Write32LittleEndian( uint8_t *addr, uint32_t data ); +void Write16LittleEndian( uint8_t *addr, uint16_t data ); #ifdef PF_SUPPORT_FP void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data );