Imported Upstream version 21
[debian/pforth] / csrc / pf_save.h
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, Devid Rosenboom
10 **
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.
19 **
20 **      941031  rdg             fix redefinition of MAKE_ID and EVENUP to be conditional
21 **
22 ***************************************************************/
23
24
25 typedef struct DictionaryInfoChunk
26 {\r
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. */
29         int32  sd_Version;
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
39         uint32 sd_Flags;\r
40         int32  sd_FloatSize;       /* In bytes. Must match code. 0 means no floats. */\r
41         uint32 sd_Reserved;
42 } DictionaryInfoChunk;
43 \r
44 /* Bits in sd_Flags */\r
45 #define SD_F_BIG_ENDIAN_DIC    (1<<0)\r
46
47 #ifndef MAKE_ID
48 #define MAKE_ID(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|d)
49 #endif
50
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')
57
58 #ifndef EVENUP
59 #define EVENUP(n) ((n+1)&(~1))
60 #endif
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 int32 ffSaveForth( const char *FileName, ExecToken EntryPoint, int32 NameSize, int32 CodeSize );
67 cfDictionary *pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr );\r
68 \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
78 \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
84 #endif\r
85
86 #ifdef __cplusplus
87 }   
88 #endif
89
90 #endif /* _pforth_save_h */