Native companion headers
The installed atom_native.h API supports generated code, publishing and source loaders. Match generated C to the runtime's ATOM_NATIVE_ABI (7 in this source snapshot). AtomNativeEntry is int (*)(AtomNativeFrame *). Generated entries exchange VM execution state using the frame protocol. Use atom.h for normal embedding and the following APIs when integrating generated native programs.
| Signature | Behavior |
|---|---|
int atom_native_step(AtomNativeFrame *frame, unsigned pc) |
Runs a VM step from generated code. |
int atom_native_call(AtomNativeFrame *frame, unsigned pc) |
Executes a bytecode call at the given native frame position. |
int atom_native_tick(AtomNativeFrame *frame, unsigned pc) |
Accounts for a native instruction and checks execution limits/interrupts. |
int atom_native_pc(AtomNativeFrame *frame) |
Reads the saved bytecode instruction index. |
AtomValue *atom_native_registers(AtomNativeFrame *frame) |
Borrows the frame's value registers. |
const AtomValue *atom_native_constants(AtomNativeFrame *frame) |
Borrows the compiled constant array. |
int atom_native_record_pair(AtomNativeFrame *frame, unsigned receiver, unsigned fields) |
Checks/caches the packed-field locations used by generated paired field access. |
int atom_native_account(AtomNativeFrame *frame, unsigned pc, bool poll) |
Inline helper that calls tick when accounting or polling is required. |
AtomStatus atom_run_native(AtomVM *vm, const AtomProgram *program, unsigned abi, size_t count, const AtomNativeEntry *functions, AtomValue *out) |
Runs with a matching ABI and table of generated entries. |
bool atom_set_native_modules(AtomVM *vm, unsigned abi, const AtomNativeModule *modules, size_t count) |
Supplies a matching packaged native module table. Descriptor data must remain live while used by the VM. |
int atom_windows_main(int (*entry)(int, char **)) |
Windows helper to call a CLI entry with UTF-8 arguments. |
bool atom_file_read(const char *path, char **data, size_t *length) |
Reads a file into a malloc-owned buffer. Caller frees it. |
char *atom_file_canonical(const char *path) |
Resolves an existing path to a malloc-owned canonical string. Returns NULL on failure. |
bool atom_file_module_load(void *context, const char *importer, const char *name, AtomSource *source) |
Default relative/absolute source loader, with matching release callback. |
void atom_file_module_release(void *context, const AtomSource *source) |
Frees source bytes and canonical filename allocated by a file loader. |
bool atom_path_module_load(void *context, const char *importer, const char *name, AtomSource *source) |
File loader with search directories supplied as AtomModulePaths. |
bool atom_visit_file_imports(const AtomProgram *program, AtomImportVisitor visitor, void *context) |
Visits compiled file import declarations with importer and path. False indicates failure or a visitor stop. |
bool atom_package_open(AtomPackage *package, const void *data, size_t size) |
Parses a package into borrowed spans. Keep its backing data alive. |
void atom_package_config(AtomPackage *package, AtomConfig *config) |
Installs package-backed module/resource loaders. Keep the package and its bytes live for execution. |
AtomStatus atom_native_register_module(AtomVM *vm, const char *name, AtomNativeModuleInit initialize, unsigned permission) |
Registers a compiled standard module through its initializer if the configuration requests and permits it. Permission constants cover resources, files, network and FFI. |
AtomStatus atom_emit_packaged_c(const AtomProgram *program, const AtomNativePackage *package, AtomWrite write, void *context) |
Emits native C with package data, modules and optional module pruning. |
AtomStatus atom_emit_c(const AtomProgram *program, AtomWrite write, void *context) |
Emits native C for the program without a supplied package. |
bool atom_add_i64(int64_t a, int64_t b, int64_t *result), atom_sub_i64, atom_mul_i64, atom_mod_i64 with the same parameter types |
Inline checked native integer arithmetic. False signals overflow on add/subtract/multiply or zero divisor on modulo. Minimum i64 modulo -1 is zero. |
atom_native_iter.h provides bool atom_iter_fast(const AtomNativeIterator *) to test fast-path applicability, AtomValue atom_iter_key(uint64_t) to represent a sequence index as signed or unsigned, and bool atom_iter_advance(AtomNativeIterator *, AtomValue *key, AtomValue *value) to advance a valid fast range or f64 iterator. These are generated-code helpers. Initialize and use ordinary Atom iteration in script code.