First version of #25 implementation, providing memory_get_usage/memory_get_peak_usage/memory_limit
This commit is contained in:
@@ -86,7 +86,10 @@ typedef struct ph7_context ph7_context;
|
||||
typedef struct ph7_value ph7_value;
|
||||
typedef struct ph7_vfs ph7_vfs;
|
||||
typedef struct ph7_vm ph7_vm;
|
||||
typedef struct ph7_heap ph7_heap;
|
||||
typedef struct ph7 ph7;
|
||||
|
||||
typedef struct SyMemBackend SyMemBackend;
|
||||
/*
|
||||
* ------------------------------
|
||||
* Compile time directives
|
||||
@@ -246,9 +249,9 @@ struct Sytm {
|
||||
|
||||
/* Dynamic memory allocation methods. */
|
||||
struct SyMemMethods {
|
||||
void *(*xAlloc)(unsigned int); /* [Required:] Allocate a memory chunk */
|
||||
void *(*xRealloc)(void *, unsigned int); /* [Required:] Re-allocate a memory chunk */
|
||||
void (*xFree)(void *); /* [Required:] Release a memory chunk */
|
||||
void *(*xAlloc)(unsigned int, SyMemBackend *); /* [Required:] Allocate a memory chunk */
|
||||
void *(*xRealloc)(void *, unsigned int, SyMemBackend *); /* [Required:] Re-allocate a memory chunk */
|
||||
void (*xFree)(void *, SyMemBackend *); /* [Required:] Release a memory chunk */
|
||||
unsigned int (*xChunkSize)(void *); /* [Optional:] Return chunk size */
|
||||
int (*xInit)(void *); /* [Optional:] Initialization callback */
|
||||
void (*xRelease)(void *); /* [Optional:] Release callback */
|
||||
@@ -351,6 +354,7 @@ typedef sxi64 ph7_int64;
|
||||
#define PH7_CONFIG_ERR_OUTPUT 1 /* TWO ARGUMENTS: int (*xConsumer)(const void *pOut,unsigned int nLen,void *pUserData),void *pUserData */
|
||||
#define PH7_CONFIG_ERR_ABORT 2 /* RESERVED FOR FUTURE USE */
|
||||
#define PH7_CONFIG_ERR_LOG 3 /* TWO ARGUMENTS: const char **pzBuf,int *pLen */
|
||||
#define PH7_CONFIG_MEM_LIMIT 4 /* ONE ARGUMENT: char *iMaxLimit */
|
||||
/*
|
||||
* Virtual Machine Configuration Commands.
|
||||
*
|
||||
@@ -580,6 +584,13 @@ struct ph7_io_stream {
|
||||
int (*xSync)(void *); /* Flush open stream data */
|
||||
int (*xStat)(void *, ph7_value *, ph7_value *); /* Stat an open stream handle */
|
||||
};
|
||||
|
||||
struct ph7_heap {
|
||||
ph7_vm *pVm; /* Reference to active VM */
|
||||
sxu64 nBytes; /* Actually allocated */
|
||||
sxu64 iPeak; /* As its peak */
|
||||
sxu64 iMax; /* Max allowed */
|
||||
};
|
||||
/*
|
||||
* C-API-REF: Please refer to the official documentation for interfaces
|
||||
* purpose and expected parameters.
|
||||
|
Reference in New Issue
Block a user