old-SuperVM/libvm/exp.h

53 lines
1.5 KiB
C
Raw Permalink Normal View History

2016-06-29 10:32:55 +00:00
#pragma once
2016-06-29 16:03:31 +00:00
#if defined(_MSC_VER)
#define EXP_PACKED_STRUCT
2016-06-29 10:32:55 +00:00
#else
2016-06-29 16:03:31 +00:00
#define EXP_PACKED_STRUCT __attribute__ ((packed))
2016-06-29 10:32:55 +00:00
#endif
#include <stdint.h>
static const uint32_t EXP_MAGIC = 0x00505845; // 'E' 'X' 'P' '\0'
struct expfile
{
uint32_t magicNumber; // MUST BE EXP_MAGIC
uint16_t majorVersion; // 1
uint16_t minorVersion; // 0
uint32_t numMeta; // Number of metadata entries
uint32_t numSections; // Number of sections
uint32_t posMeta; // File pointer of first metadata entry
uint32_t posSections; // File pointer of first section definition;
2016-06-29 16:03:31 +00:00
} EXP_PACKED_STRUCT;
2016-06-29 10:32:55 +00:00
struct expsection
{
uint32_t type; // Type of the section: 0 = code, 1 = data
2016-06-29 12:04:13 +00:00
uint32_t base; // Base address of the section in memory.
2016-06-29 10:32:55 +00:00
uint32_t start; // File pointer to the begin of the section
uint32_t length; // Length of the section in bytes
char name[64]; // Name of the section, null terminated c-string
2016-06-29 16:03:31 +00:00
} EXP_PACKED_STRUCT;
2016-06-29 10:32:55 +00:00
struct expstring
{
uint32_t start; // File pointer to the start of the string
uint32_t length; // Length of the string in bytes.
2016-06-29 16:03:31 +00:00
} EXP_PACKED_STRUCT;
2016-06-29 10:32:55 +00:00
struct expmeta
{
uint32_t type; // Type of the metadata: 0 = uint32_t, 1 = int32_t, 2 = ExpString
char key[32]; // Name of the metadata, null terminated c-string
union {
uint32_t u; // uint32_t
int32_t i; // int32_t
struct expstring s; // ExpString
} value; // Value of the metadata
2016-06-29 16:03:31 +00:00
} EXP_PACKED_STRUCT;
2016-06-29 10:32:55 +00:00
typedef struct expfile expfile_t;
typedef struct expsection expsection_t;
typedef struct expstring expstring_t;
typedef struct expmeta expmeta_t;