bb6b2dcd |
1 | /* @(#) pf_save.h 96/12/18 1.8 */\r |
2 | #ifndef _pforth_save_h\r |
3 | #define _pforth_save_h\r |
4 | \r |
5 | /***************************************************************\r |
6 | ** Include file for PForth SaveForth\r |
7 | **\r |
8 | ** Author: Phil Burk\r |
9 | ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom\r |
10 | **\r |
11 | ** The pForth software code is dedicated to the public domain,\r |
12 | ** and any third party may reproduce, distribute and modify\r |
13 | ** the pForth software code or any derivative works thereof\r |
14 | ** without any compensation or license. The pForth software\r |
15 | ** code is provided on an "as is" basis without any warranty\r |
16 | ** of any kind, including, without limitation, the implied\r |
17 | ** warranties of merchantability and fitness for a particular\r |
18 | ** purpose and their equivalents under the laws of any jurisdiction.\r |
19 | **\r |
20 | ** 941031 rdg fix redefinition of MAKE_ID and EVENUP to be conditional\r |
21 | **\r |
22 | ***************************************************************/\r |
23 | \r |
24 | \r |
25 | typedef struct DictionaryInfoChunk\r |
26 | {\r |
1cb310e6 |
27 | /* All fields are stored in BIG ENDIAN format for consistency in data files.\r |
28 | * All fields must be the same size for easy endian conversion.\r |
29 | * All fields must be 32 bit for file compatibility with older versions.\r |
30 | */\r |
31 | int32_t sd_Version;\r |
32 | int32_t sd_RelContext; /* relative ptr to Dictionary Context */\r |
33 | int32_t sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */\r |
34 | int32_t sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */\r |
35 | int32_t sd_EntryPoint; /* relative ptr to entry point or NULL */\r |
36 | int32_t sd_UserStackSize; /* in bytes */\r |
37 | int32_t sd_ReturnStackSize; /* in bytes */\r |
38 | int32_t sd_NameSize; /* in bytes */\r |
39 | int32_t sd_CodeSize; /* in bytes */\r |
40 | int32_t sd_NumPrimitives; /* To distinguish between primitive and secondary. */\r |
41 | uint32_t sd_Flags;\r |
42 | int32_t sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */\r |
43 | int32_t sd_CellSize; /* In bytes. Must match code. */\r |
bb6b2dcd |
44 | } DictionaryInfoChunk;\r |
45 | \r |
46 | /* Bits in sd_Flags */\r |
47 | #define SD_F_BIG_ENDIAN_DIC (1<<0)\r |
48 | \r |
49 | #ifndef MAKE_ID\r |
1cb310e6 |
50 | #define MAKE_ID(a,b,c,d) ((((uint32_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d))\r |
bb6b2dcd |
51 | #endif\r |
52 | \r |
53 | #define ID_FORM MAKE_ID('F','O','R','M')\r |
54 | #define ID_P4TH MAKE_ID('P','4','T','H')\r |
55 | #define ID_P4DI MAKE_ID('P','4','D','I')\r |
56 | #define ID_P4NM MAKE_ID('P','4','N','M')\r |
57 | #define ID_P4CD MAKE_ID('P','4','C','D')\r |
58 | #define ID_BADF MAKE_ID('B','A','D','F')\r |
59 | \r |
60 | #ifndef EVENUP\r |
61 | #define EVENUP(n) ((n+1)&(~1))\r |
62 | #endif\r |
63 | \r |
64 | #ifdef __cplusplus\r |
65 | extern "C" {\r |
66 | #endif\r |
67 | \r |
1cb310e6 |
68 | cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize );\r |
bb6b2dcd |
69 | \r |
70 | /* Endian-ness tools. */\r |
bb6b2dcd |
71 | int IsHostLittleEndian( void );\r |
1cb310e6 |
72 | \r |
73 | ucell_t ReadCellBigEndian( const uint8_t *addr );\r |
74 | uint32_t Read32BigEndian( const uint8_t *addr );\r |
75 | uint16_t Read16BigEndian( const uint8_t *addr );\r |
76 | \r |
77 | ucell_t ReadCellLittleEndian( const uint8_t *addr );\r |
78 | uint32_t Read32LittleEndian( const uint8_t *addr );\r |
79 | uint16_t Read16LittleEndian( const uint8_t *addr );\r |
80 | \r |
81 | void WriteCellBigEndian( uint8_t *addr, ucell_t data );\r |
82 | void Write32BigEndian( uint8_t *addr, uint32_t data );\r |
83 | void Write16BigEndian( uint8_t *addr, uint16_t data );\r |
84 | \r |
85 | void WriteCellLittleEndian( uint8_t *addr, ucell_t data );\r |
86 | void Write32LittleEndian( uint8_t *addr, uint32_t data );\r |
87 | void Write16LittleEndian( uint8_t *addr, uint16_t data );\r |
bb6b2dcd |
88 | \r |
89 | #ifdef PF_SUPPORT_FP\r |
90 | void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data );\r |
91 | PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr );\r |
92 | void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data );\r |
93 | PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr );\r |
94 | #endif\r |
95 | \r |
96 | #ifdef __cplusplus\r |
97 | } \r |
98 | #endif\r |
99 | \r |
100 | #endif /* _pforth_save_h */\r |