avmpack.h

Include dependency graph for avmpack.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "7" [label="stdbool.h" tooltip="stdbool.h"]
    "4" [label="atom.h" tooltip="atom.h"]
    "10" [label="assert.h" tooltip="assert.h"]
    "18" [label="synclist.h" tooltip="synclist.h"]
    "3" [label="stdint.h" tooltip="stdint.h"]
    "5" [label="stdlib.h" tooltip="stdlib.h"]
    "15" [label="utils.h" tooltip="utils.h"]
    "6" [label="atom_table.h" tooltip="atom_table.h"]
    "9" [label="term_typedef.h" tooltip="term_typedef.h"]
    "16" [label="stddef.h" tooltip="stddef.h"]
    "11" [label="limits.h" tooltip="limits.h"]
    "23" [label="refc_binary.h" tooltip="refc_binary.h"]
    "21" [label="string.h" tooltip="string.h"]
    "14" [label="mailbox.h" tooltip="mailbox.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" fillcolor="#BFBFBF"]
    "20" [label="term.h" tooltip="term.h"]
    "8" [label="erl_nif.h" tooltip="erl_nif.h"]
    "24" [label="resources.h" tooltip="resources.h"]
    "17" [label="smp.h" tooltip="smp.h"]
    "2" [label="globalcontext.h" tooltip="globalcontext.h"]
    "22" [label="memory.h" tooltip="memory.h"]
    "19" [label="stdio.h" tooltip="stdio.h"]
    "25" [label="timer_list.h" tooltip="timer_list.h"]
    "13" [label="list.h" tooltip="list.h"]
    "12" [label="inttypes.h" tooltip="inttypes.h"]
    "4" -> "3" [dir=forward tooltip="include"]
    "4" -> "5" [dir=forward tooltip="include"]
    "18" -> "13" [dir=forward tooltip="include"]
    "18" -> "19" [dir=forward tooltip="include"]
    "18" -> "17" [dir=forward tooltip="include"]
    "15" -> "16" [dir=forward tooltip="include"]
    "6" -> "7" [dir=forward tooltip="include"]
    "6" -> "4" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "9" -> "11" [dir=forward tooltip="include"]
    "9" -> "12" [dir=forward tooltip="include"]
    "9" -> "3" [dir=forward tooltip="include"]
    "23" -> "7" [dir=forward tooltip="include"]
    "23" -> "5" [dir=forward tooltip="include"]
    "23" -> "13" [dir=forward tooltip="include"]
    "23" -> "24" [dir=forward tooltip="include"]
    "14" -> "7" [dir=forward tooltip="include"]
    "14" -> "13" [dir=forward tooltip="include"]
    "14" -> "9" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "13" [dir=forward tooltip="include"]
    "1" -> "7" [dir=forward tooltip="include"]
    "1" -> "16" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "20" -> "7" [dir=forward tooltip="include"]
    "20" -> "3" [dir=forward tooltip="include"]
    "20" -> "19" [dir=forward tooltip="include"]
    "20" -> "5" [dir=forward tooltip="include"]
    "20" -> "21" [dir=forward tooltip="include"]
    "20" -> "22" [dir=forward tooltip="include"]
    "20" -> "23" [dir=forward tooltip="include"]
    "20" -> "15" [dir=forward tooltip="include"]
    "20" -> "9" [dir=forward tooltip="include"]
    "8" -> "9" [dir=forward tooltip="include"]
    "24" -> "5" [dir=forward tooltip="include"]
    "24" -> "8" [dir=forward tooltip="include"]
    "24" -> "13" [dir=forward tooltip="include"]
    "24" -> "22" [dir=forward tooltip="include"]
    "17" -> "7" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "4" [dir=forward tooltip="include"]
    "2" -> "6" [dir=forward tooltip="include"]
    "2" -> "8" [dir=forward tooltip="include"]
    "2" -> "13" [dir=forward tooltip="include"]
    "2" -> "14" [dir=forward tooltip="include"]
    "2" -> "17" [dir=forward tooltip="include"]
    "2" -> "18" [dir=forward tooltip="include"]
    "2" -> "20" [dir=forward tooltip="include"]
    "2" -> "25" [dir=forward tooltip="include"]
    "22" -> "8" [dir=forward tooltip="include"]
    "22" -> "9" [dir=forward tooltip="include"]
    "22" -> "15" [dir=forward tooltip="include"]
    "22" -> "3" [dir=forward tooltip="include"]
    "22" -> "5" [dir=forward tooltip="include"]
    "25" -> "7" [dir=forward tooltip="include"]
    "25" -> "3" [dir=forward tooltip="include"]
    "25" -> "13" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include avmpack.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" fillcolor="#BFBFBF"]
    "4" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c"]
    "3" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "3" [dir=back tooltip="include"]
    "1" -> "4" [dir=back tooltip="include"]
}

AVM Pack file format parsing function.

Defines

END_OF_FILE 0
BEAM_START_FLAG 1
BEAM_CODE_FLAG 2

Typedefs

typedef void *(*avmpack_fold_fun)(void *accum, const void *section_ptr, uint32_t section_size, const void *beam_ptr, uint32_t flags, const char *section_name)

callback function for AVMPack section fold.

Instances of this function are supplied to the avmpack_fold function, in order to provide a callback mechanism for folding over the contents of the AVM binary.

Param accum:

The accumulator supplied by the application.

Param section_ptr:

a pointer to the start of the AVM section (including the module header).

Param section_size:

the size of the entire section (including the module header).

Param beam_ptr:

the start of the beam module portion of the section. This pointers starts immediately after the (aligned) header.

Param flags:

the section flags, as defined in the module header.

Param section_name:

the section name, as defined in the module header.

Return:

an accumulator, which will be supplied to the next call to this function, and eventually returned from the avmpack_fold function.

Functions

static inline void avmpack_data_init(struct AVMPackData *avm_pack_data, const struct AVMPackInfo *info)
static inline void avmpack_data_destroy(struct AVMPackData *avm_pack_data, GlobalContext *global)
int avmpack_find_section_by_flag(const void *avmpack_binary, uint32_t flags_mask, const void **ptr, uint32_t *size, const char **name)

Finds an AVM Pack section that has certain flags set.

Finds an AVM Pack section that has certain flags set and returns a pointer to it, its size and its name.

Parameters:
  • avmpack_binary – a pointer to valid AVM Pack file data.

  • flags_mask – that will be matched against file sections.

  • ptr – will point to the found file section.

  • size – will be set to the file section size that has been found, if the section has not been found it will not be updated.

  • name – the section name, as defined in the module header.

Returns:

1 if the file section has been found, 0 otherwise.

int avmpack_find_section_by_name(const void *avmpack_binary, const char *name, const void **ptr, uint32_t *size)

Finds an AVM Pack section that has certain name.

Finds an AVM Pack section with a certain name and returns a pointer to it and its size.

Parameters:
  • avmpack_binary – a pointer to valid AVM Pack file data.

  • name – the file section name that will be searched.

  • ptr – will point to the found file section, if the section has not been found it will not be updated.

  • size – will be set to the file section size that has been found, if the section has not been found it will not be updated.

Returns:

1 if the file section has been found, 0 otherwise.

int avmpack_is_valid(const void *avmpack_binary, uint32_t size)

Returns 1 if the pointed binary is a valid AVM Pack.

Returns if the pointed binary is a valid AVM Pack binary or not.

Parameters:
  • avmpack_binary – a pointer to an AVM Pack binary.

  • size – the size of AVM Pack binary.

Returns:

1 if it is a valid AVM Pack binary, 0 otherwise.

void *avmpack_fold(void *accum, const void *avmpack_binary, avmpack_fold_fun fold_fun)

Fold over all the sections in an AVM Pack.

This function will call the callback on each section of the AVM Pack, passing in the current section of each module in the AVM binary to the supplied fold function.

Parameters:
  • accum – The accumulator supplied by the application.

  • avmpack_binary – a pointer to an AVM Pack binary.

  • fold_fun – function that will be called for each AVM section.

Variables

const struct AVMPackInfo in_memory_avm_pack_info
const struct AVMPackInfo const_avm_pack_info
struct AVMPackInfo
#include <avmpack.h>

Public Members

void (*destructor)(struct AVMPackData *obj, GlobalContext *global)
struct AVMPackData
#include <avmpack.h>

Collaboration diagram for AVMPackData:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="AVMPackData" tooltip="AVMPackData" fillcolor="#BFBFBF"]
    "3" [label="ListHead" tooltip="ListHead"]
    "2" [label="AVMPackInfo" tooltip="AVMPackInfo"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "3" [dir=forward tooltip="usage"]
    "3" -> "3" [dir=forward tooltip="usage"]
}

Public Members

const struct AVMPackInfo *obj_info
struct ListHead avmpack_head
bool in_use
int name_atom_id
const void *data
struct InMemoryAVMPack
#include <avmpack.h>

Collaboration diagram for InMemoryAVMPack:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="InMemoryAVMPack" tooltip="InMemoryAVMPack" fillcolor="#BFBFBF"]
    "2" [label="AVMPackData" tooltip="AVMPackData"]
    "4" [label="ListHead" tooltip="ListHead"]
    "3" [label="AVMPackInfo" tooltip="AVMPackInfo"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "2" -> "4" [dir=forward tooltip="usage"]
    "4" -> "4" [dir=forward tooltip="usage"]
}

Public Members

struct AVMPackData base
struct ConstAVMPack
#include <avmpack.h>

Collaboration diagram for ConstAVMPack:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="AVMPackData" tooltip="AVMPackData"]
    "4" [label="ListHead" tooltip="ListHead"]
    "3" [label="AVMPackInfo" tooltip="AVMPackInfo"]
    "1" [label="ConstAVMPack" tooltip="ConstAVMPack" fillcolor="#BFBFBF"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "2" -> "4" [dir=forward tooltip="usage"]
    "4" -> "4" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
}

Public Members

struct AVMPackData base