1/* 2 Title: polyexports.h 3 4 Copyright (c) 2006, 2011, 2015, 2019 David C.J. Matthews 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License version 2.1 as published by the Free Software Foundation. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18*/ 19 20/* 21This header contains the structures used in saved state created by "export". 22*/ 23 24#ifndef _STANDALONE_H 25#define _STANDALONE_H 1 26 27// Get time_t 28#ifdef HAVE_TIME_H 29#include <time.h> 30#endif 31 32// Get uintptr_t 33#if HAVE_STDINT_H 34# include <stdint.h> 35#endif 36 37#if HAVE_INTTYPES_H 38# ifndef __STDC_FORMAT_MACROS 39# define __STDC_FORMAT_MACROS 40# endif 41# include <inttypes.h> 42#endif 43 44#ifdef HAVE_STDDEF_H 45# include <stddef.h> 46#endif 47 48#if defined(HAVE_WINDOWS_H) 49# include <windows.h> 50#endif 51 52// There are several entries 53typedef struct _memTableEntry { 54 void *mtCurrentAddr; // The address of the area of memory 55 void *mtOriginalAddr; // The original address, for saved states and 32-in-64. 56 uintptr_t mtLength; // The length in bytes of the area 57 unsigned mtFlags; // Flags describing the area. 58 unsigned mtIndex; // An index to identify permanent spaces. 59} memoryTableEntry; 60 61#define MTF_WRITEABLE 0x00000001 // The area is writeable by ML code 62#define MTF_EXECUTABLE 0x00000002 // The area contains executable code 63#define MTF_NO_OVERWRITE 0x00000004 // With MTF_WRITEABLE: Don't load over the top 64#define MTF_BYTES 0x00000008 // Contains only byte data and no addresses 65 66typedef struct _exportDescription { 67 unsigned structLength; // The length of this structure 68 unsigned memTableSize; // The size of each entry in the memory table 69 unsigned memTableEntries; // The number of entries in the memory table 70 memoryTableEntry *memTable; // Pointer to the memory table. 71 void *rootFunction; // Points to the start-up function 72 time_t timeStamp; // Creation time stamp 73 unsigned architecture; // Machine architecture 74 unsigned rtsVersion; // Run-time system version 75 void *originalBaseAddr; // Original base address (32-in-64 only) 76} exportDescription; 77 78extern exportDescription poly_exports; 79 80#ifdef __cplusplus 81extern "C" { 82#endif 83 84#if (defined(_WIN32)) 85#include <windows.h> 86 87# ifdef LIBPOLYML_BUILD 88# ifdef DLL_EXPORT 89# define POLYLIB_API __declspec (dllexport) 90# endif 91# elif defined _MSC_VER 92 // Visual C - POLYLIB_EXPORTS is defined in the library project settings 93# ifdef POLYLIB_EXPORTS 94# define POLYLIB_API __declspec (dllexport) 95# else 96# define POLYLIB_API __declspec (dllimport) 97# endif 98# elif defined DLL_EXPORT 99# define POLYLIB_API __declspec (dllimport) 100# else 101# define POLYLIB_API 102# endif 103 104extern POLYLIB_API int PolyWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 105 LPSTR lpCmdLine, int nCmdShow, exportDescription *exports); 106#else 107int polymain(int argc, char *argv[], exportDescription *exports); 108#endif 109 110#ifdef __cplusplus 111}; 112#endif 113 114#endif 115