1 /* @(#) pf_save.h 96/12/18 1.8 */
5 /***************************************************************
6 ** Include file for PForth SaveForth
9 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
11 ** The pForth software code is dedicated to the public domain,
12 ** and any third party may reproduce, distribute and modify
13 ** the pForth software code or any derivative works thereof
14 ** without any compensation or license. The pForth software
15 ** code is provided on an "as is" basis without any warranty
16 ** of any kind, including, without limitation, the implied
17 ** warranties of merchantability and fitness for a particular
18 ** purpose and their equivalents under the laws of any jurisdiction.
20 ** 941031 rdg fix redefinition of MAKE_ID and EVENUP to be conditional
22 ***************************************************************/
25 typedef struct DictionaryInfoChunk
27 /* All fields are stored in BIG ENDIAN format for consistency in data files. */
\r
28 /* All fileds must be the same size as int32 for easy endian conversion. */
30 int32 sd_RelContext; /* relative ptr to Dictionary Context */
31 int32 sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */
32 int32 sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */
33 ExecToken sd_EntryPoint; /* relative ptr to entry point or NULL */
34 int32 sd_UserStackSize; /* in bytes */
35 int32 sd_ReturnStackSize; /* in bytes */
36 int32 sd_NameSize; /* in bytes */
37 int32 sd_CodeSize; /* in bytes */
38 int32 sd_NumPrimitives; /* To distinguish between primitive and secondary. */
\r
40 int32 sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */
\r
42 } DictionaryInfoChunk;
44 /* Bits in sd_Flags */
\r
45 #define SD_F_BIG_ENDIAN_DIC (1<<0)
\r
48 #define MAKE_ID(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|d)
51 #define ID_FORM MAKE_ID('F','O','R','M')
52 #define ID_P4TH MAKE_ID('P','4','T','H')
53 #define ID_P4DI MAKE_ID('P','4','D','I')
54 #define ID_P4NM MAKE_ID('P','4','N','M')
55 #define ID_P4CD MAKE_ID('P','4','C','D')
56 #define ID_BADF MAKE_ID('B','A','D','F')
59 #define EVENUP(n) ((n+1)&(~1))
66 int32 ffSaveForth( const char *FileName, ExecToken EntryPoint, int32 NameSize, int32 CodeSize );
67 cfDictionary *pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr );
\r
69 /* Endian-ness tools. */
\r
70 uint32 ReadLongBigEndian( const uint32 *addr );
\r
71 uint16 ReadShortBigEndian( const uint16 *addr );
\r
72 uint32 ReadLongLittleEndian( const uint32 *addr );
\r
73 uint16 ReadShortLittleEndian( const uint16 *addr );
\r
74 void WriteLongBigEndian( uint32 *addr, uint32 data );
\r
75 void WriteShortBigEndian( uint16 *addr, uint16 data );
\r
76 void WriteLongLittleEndian( uint32 *addr, uint32 data );
\r
77 void WriteShortLittleEndian( uint16 *addr, uint16 data );
\r
79 #ifdef PF_SUPPORT_FP
\r
80 void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data );
\r
81 PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr );
\r
82 void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data );
\r
83 PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr );
\r
90 #endif /* _pforth_save_h */