Files
jsrt/lib/rt/jsrt.h
T
2026-10-24 15:58:51 +00:00

44 lines
1.6 KiB
C

// The runtime that emitted C is compiled with. See docs/model.md for the
// representation of values
//
// Each header declares its part, and if JSRT_IMPLEMENTATION is defined before
// this is included, also defines it. The emitted C is one file, which does
// that, and includes this before any other header
//
// The fns that the program can call have one of two prefixes:
// __rt_* the same on every platform: JS's operators, strings, numbers,
// the allocator and errors
// __native_* the platform's IO, which another platform's runtime replaces
//
// core.h values, the allocator, errors, and JS's operators on every
// kind of value
// str.h strings
// number.h numbers, and their conversions to and from strings
// io.h IO natives, async on io_uring (uring.h), and the host's loop
//
// The host owns the event loop. The program exports two fns, which the host
// calls, and a flavor of the runtime is the host. This one, for Linux, is the
// `main` in io.h: define JSRT_NO_HOST to bring another
//
// jsrt_start() runs the program's top level, then its microtasks
// jsrt_complete(h) op `h` is done: runs its callback, then the microtasks.
// The op's result can be read only until this returns
#pragma once
// io.h needs Linux's syscall() and mmap(), which -std=c11 hides. This must
// come before the first system header
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "core.h"
#include <stdint.h>
void jsrt_start(void);
void jsrt_complete(int32_t h);
#include "str.h"
#include "number.h"
#include "io.h"