relicense to 0BSD
[pforth] / csrc / pf_save.h
index 3bf8c2f..098cd8e 100644 (file)
-/* @(#) pf_save.h 96/12/18 1.8 */\r
-#ifndef _pforth_save_h\r
-#define _pforth_save_h\r
-\r
-/***************************************************************\r
-** Include file for PForth SaveForth\r
-**\r
-** Author: Phil Burk\r
-** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom\r
-**\r
-** The pForth software code is dedicated to the public domain,\r
-** and any third party may reproduce, distribute and modify\r
-** the pForth software code or any derivative works thereof\r
-** without any compensation or license.  The pForth software\r
-** code is provided on an "as is" basis without any warranty\r
-** of any kind, including, without limitation, the implied\r
-** warranties of merchantability and fitness for a particular\r
-** purpose and their equivalents under the laws of any jurisdiction.\r
-**\r
-**     941031  rdg             fix redefinition of MAKE_ID and EVENUP to be conditional\r
-**\r
-***************************************************************/\r
-\r
-\r
-typedef struct DictionaryInfoChunk\r
-{\r
-/* All fields are stored in BIG ENDIAN format for consistency in data files.\r
- * All fields must be the same size for easy endian conversion.\r
- * All fields must be 32 bit for file compatibility with older versions.\r
- */\r
-       int32_t  sd_Version;\r
-       int32_t  sd_RelContext;      /* relative ptr to Dictionary Context */\r
-       int32_t  sd_RelHeaderPtr;    /* relative ptr to Dictionary Header Ptr */\r
-       int32_t  sd_RelCodePtr;      /* relative ptr to Dictionary Header Ptr */\r
-       int32_t  sd_EntryPoint;  /* relative ptr to entry point or NULL */\r
-       int32_t  sd_UserStackSize;   /* in bytes */\r
-       int32_t  sd_ReturnStackSize; /* in bytes */\r
-       int32_t  sd_NameSize;        /* in bytes */\r
-       int32_t  sd_CodeSize;        /* in bytes */\r
-       int32_t  sd_NumPrimitives;   /* To distinguish between primitive and secondary. */\r
-       uint32_t sd_Flags;\r
-       int32_t  sd_FloatSize;       /* In bytes. Must match code. 0 means no floats. */\r
-       int32_t  sd_CellSize;        /* In bytes. Must match code. */\r
-} DictionaryInfoChunk;\r
-\r
-/* Bits in sd_Flags */\r
-#define SD_F_BIG_ENDIAN_DIC    (1<<0)\r
-\r
-#ifndef MAKE_ID\r
-#define MAKE_ID(a,b,c,d) ((((uint32_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d))\r
-#endif\r
-\r
-#define ID_FORM MAKE_ID('F','O','R','M')\r
-#define ID_P4TH MAKE_ID('P','4','T','H')\r
-#define ID_P4DI MAKE_ID('P','4','D','I')\r
-#define ID_P4NM MAKE_ID('P','4','N','M')\r
-#define ID_P4CD MAKE_ID('P','4','C','D')\r
-#define ID_BADF MAKE_ID('B','A','D','F')\r
-\r
-#ifndef EVENUP\r
-#define EVENUP(n) ((n+1)&(~1))\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize );\r
-\r
-/* Endian-ness tools. */\r
-int    IsHostLittleEndian( void );\r
-       \r
-ucell_t ReadCellBigEndian( const uint8_t *addr );\r
-uint32_t Read32BigEndian( const uint8_t *addr );\r
-uint16_t Read16BigEndian( const uint8_t *addr );\r
-       \r
-ucell_t ReadCellLittleEndian( const uint8_t *addr );\r
-uint32_t Read32LittleEndian( const uint8_t *addr );\r
-uint16_t Read16LittleEndian( const uint8_t *addr );\r
-       \r
-void WriteCellBigEndian( uint8_t *addr, ucell_t data );\r
-void Write32BigEndian( uint8_t *addr, uint32_t data );\r
-void Write16BigEndian( uint8_t *addr, uint16_t data );\r
-       \r
-void WriteCellLittleEndian( uint8_t *addr, ucell_t data );\r
-void Write32LittleEndian( uint8_t *addr, uint32_t data );\r
-void Write16LittleEndian( uint8_t *addr, uint16_t data );\r
-\r
-#ifdef PF_SUPPORT_FP\r
-void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data );\r
-PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr );\r
-void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data );\r
-PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr );\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-}   \r
-#endif\r
-\r
-#endif /* _pforth_save_h */\r
+/* @(#) pf_save.h 96/12/18 1.8 */
+#ifndef _pforth_save_h
+#define _pforth_save_h
+
+/***************************************************************
+** Include file for PForth SaveForth
+**
+** Author: Phil Burk
+** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
+**
+** Permission to use, copy, modify, and/or distribute this
+** software for any purpose with or without fee is hereby granted.
+**
+** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+**
+**  941031  rdg     fix redefinition of MAKE_ID and EVENUP to be conditional
+**
+***************************************************************/
+
+
+typedef struct DictionaryInfoChunk
+{
+/* 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_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d))
+#endif
+
+#define ID_FORM MAKE_ID('F','O','R','M')
+#define ID_P4TH MAKE_ID('P','4','T','H')
+#define ID_P4DI MAKE_ID('P','4','D','I')
+#define ID_P4NM MAKE_ID('P','4','N','M')
+#define ID_P4CD MAKE_ID('P','4','C','D')
+#define ID_BADF MAKE_ID('B','A','D','F')
+
+#ifndef EVENUP
+#define EVENUP(n) ((n+1)&(~1))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize );
+
+/* Endian-ness tools. */
+int    IsHostLittleEndian( void );
+
+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 );
+PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr );
+void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data );
+PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _pforth_save_h */