Commit | Line | Data |
---|---|---|
8e9db35f PB |
1 | /* @(#) pf_save.h 96/12/18 1.8 */ |
2 | #ifndef _pforth_save_h | |
3 | #define _pforth_save_h | |
4 | ||
5 | /*************************************************************** | |
6 | ** Include file for PForth SaveForth | |
7 | ** | |
8 | ** Author: Phil Burk | |
9 | ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom | |
10 | ** | |
1f99f95d S |
11 | ** Permission to use, copy, modify, and/or distribute this |
12 | ** software for any purpose with or without fee is hereby granted. | |
13 | ** | |
14 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL | |
15 | ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED | |
16 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL | |
17 | ** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR | |
18 | ** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING | |
19 | ** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF | |
20 | ** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
21 | ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
8e9db35f PB |
22 | ** |
23 | ** 941031 rdg fix redefinition of MAKE_ID and EVENUP to be conditional | |
24 | ** | |
25 | ***************************************************************/ | |
26 | ||
27 | ||
28 | typedef struct DictionaryInfoChunk | |
29 | { | |
30 | /* All fields are stored in BIG ENDIAN format for consistency in data files. | |
31 | * All fields must be the same size for easy endian conversion. | |
32 | * All fields must be 32 bit for file compatibility with older versions. | |
33 | */ | |
34 | int32_t sd_Version; | |
35 | int32_t sd_RelContext; /* relative ptr to Dictionary Context */ | |
36 | int32_t sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */ | |
37 | int32_t sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */ | |
38 | int32_t sd_EntryPoint; /* relative ptr to entry point or NULL */ | |
39 | int32_t sd_UserStackSize; /* in bytes */ | |
40 | int32_t sd_ReturnStackSize; /* in bytes */ | |
41 | int32_t sd_NameSize; /* in bytes */ | |
42 | int32_t sd_CodeSize; /* in bytes */ | |
43 | int32_t sd_NumPrimitives; /* To distinguish between primitive and secondary. */ | |
44 | uint32_t sd_Flags; | |
45 | int32_t sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */ | |
46 | int32_t sd_CellSize; /* In bytes. Must match code. */ | |
47 | } DictionaryInfoChunk; | |
48 | ||
49 | /* Bits in sd_Flags */ | |
50 | #define SD_F_BIG_ENDIAN_DIC (1<<0) | |
51 | ||
52 | #ifndef MAKE_ID | |
53 | #define MAKE_ID(a,b,c,d) ((((uint32_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d)) | |
54 | #endif | |
55 | ||
56 | #define ID_FORM MAKE_ID('F','O','R','M') | |
57 | #define ID_P4TH MAKE_ID('P','4','T','H') | |
58 | #define ID_P4DI MAKE_ID('P','4','D','I') | |
59 | #define ID_P4NM MAKE_ID('P','4','N','M') | |
60 | #define ID_P4CD MAKE_ID('P','4','C','D') | |
61 | #define ID_BADF MAKE_ID('B','A','D','F') | |
62 | ||
63 | #ifndef EVENUP | |
64 | #define EVENUP(n) ((n+1)&(~1)) | |
65 | #endif | |
66 | ||
67 | #ifdef __cplusplus | |
68 | extern "C" { | |
69 | #endif | |
70 | ||
71 | cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize ); | |
72 | ||
73 | /* Endian-ness tools. */ | |
74 | int IsHostLittleEndian( void ); | |
75 | ||
76 | ucell_t ReadCellBigEndian( const uint8_t *addr ); | |
77 | uint32_t Read32BigEndian( const uint8_t *addr ); | |
78 | uint16_t Read16BigEndian( const uint8_t *addr ); | |
79 | ||
80 | ucell_t ReadCellLittleEndian( const uint8_t *addr ); | |
81 | uint32_t Read32LittleEndian( const uint8_t *addr ); | |
82 | uint16_t Read16LittleEndian( const uint8_t *addr ); | |
83 | ||
84 | void WriteCellBigEndian( uint8_t *addr, ucell_t data ); | |
85 | void Write32BigEndian( uint8_t *addr, uint32_t data ); | |
86 | void Write16BigEndian( uint8_t *addr, uint16_t data ); | |
87 | ||
88 | void WriteCellLittleEndian( uint8_t *addr, ucell_t data ); | |
89 | void Write32LittleEndian( uint8_t *addr, uint32_t data ); | |
90 | void Write16LittleEndian( uint8_t *addr, uint16_t data ); | |
91 | ||
92 | #ifdef PF_SUPPORT_FP | |
93 | void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data ); | |
94 | PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr ); | |
95 | void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data ); | |
96 | PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr ); | |
97 | #endif | |
98 | ||
99 | #ifdef __cplusplus | |
100 | } | |
101 | #endif | |
102 | ||
103 | #endif /* _pforth_save_h */ |