One commit, because the parts below only build together. Allocator: an interval needed at the current instruction is never evicted, and the allocated-program verifier checks that every operand sits where the allocation says. AArch64 encoder: compiler_aarch64.zi encodes allocated machine IR with the shared ARM byte helpers, maps the function-address relocation, sign-extends signed 8- and 16-bit loads and rejects what it cannot encode with a named diagnostic. It has no AOT ELF writer yet. Native default with checked pointers and no fallback: on linux-x86_64, `ziran run app.zx`, `zi2zx run`, the embedding API's Auto and the Kryon players run a bundle's verified program as native code in W^X memory. Stray and freed pointers, double free, bounds and read-only stores trap. A native gap is a named preflight error, nothing falls back to the engine, and `--backend engine` picks it explicitly. zx2native uses the same preflight. Native code exchanges module state for hot reload, checks the stack, zeroes fresh locals, spends fuel at the engine's checkpoints and returns records, arrays and strings from host calls. `zi2zx --debug` source origins name lines in native traps and `zx2native --emit map`. The host value API drops its VM prefix (HostValue, HOST_*). A call with a record result loads the hidden result address into rax only after its stack arguments are stored, and an indirect target stays in r10: rax could hold a stack argument (Kryon's text-field clip guard arrived as an address) or the target (indirect calls returning records crashed). Self-hosting ports: compiler_backend_process, compiler_backend_cache, compiler_native_names and compiler_runtime_emit replace the zir_c_build, zir_c_cache and zir_c_process C, with checked bootstrap C and Makefile rules. zir_c.toolchain again reports "compiling OUT failed:" with the head of the compiler output and a truncation marker. The parallel scheduler no longer stalls on a held compiler after reaping a finished job, and poll or read errors now fail the build. A fresh BUILD_DIR (Kryon's runtime build) builds: generated files have pattern rules, objects wait for the headers they include, and engine flags are per object instead of leaking into zi2c. Legacy removals F1-F10 and N1-N4: the duplicate LirX64 encoder and its spec test, zir_c_*, zir_runtime and zir_native, nine zero-reference spec tests, vec_capacity, the zx_metadata and native_cache_names benchmarks, build-android-host.sh and two shell wrappers are deleted; zx2native is machine-only; `zi2zx` rejects `--opt` on ZX input; the bootstrap is regenerated. ASSEMBLY docs, the legacy-removal plan, the milestones and the remaining-work plan record the current position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
88 lines
2.2 KiB
C
88 lines
2.2 KiB
C
/* Generated by zi2c from file_linux.zi. */
|
|
#ifndef ZIRAN_FILE_LINUX_H
|
|
#define ZIRAN_FILE_LINUX_H
|
|
|
|
#include <stdbool.h>
|
|
#include "zir_string_types.h"
|
|
#include "zir_slice.h"
|
|
#include "c_string.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#ifdef ZIRAN_FILE_LINUX_H_PRIVATE
|
|
typedef struct DirectoryMetadata DirectoryMetadata;
|
|
#endif
|
|
typedef struct FileHandle FileHandle;
|
|
typedef struct DirectoryCursor DirectoryCursor;
|
|
typedef uint8_t DirectoryKind;
|
|
typedef struct DirectoryEntry DirectoryEntry;
|
|
#ifdef ZIRAN_FILE_LINUX_H_PRIVATE
|
|
|
|
struct DirectoryMetadata {
|
|
uint64_t inode;
|
|
int64_t offset;
|
|
uint16_t record_length;
|
|
uint8_t kind;
|
|
uint8_t name[256];
|
|
};
|
|
#endif
|
|
|
|
struct FileHandle {
|
|
int32_t fd;
|
|
bool valid;
|
|
};
|
|
|
|
struct DirectoryCursor {
|
|
void* storage;
|
|
bool valid;
|
|
bool failed;
|
|
};
|
|
|
|
enum {
|
|
DirectoryKind_Unknown = 0,
|
|
DirectoryKind_Directory = 4,
|
|
DirectoryKind_Regular = 8,
|
|
DirectoryKind_Link = 10,
|
|
DirectoryKind_Other = 255,
|
|
};
|
|
|
|
struct DirectoryEntry {
|
|
uint8_t name[256];
|
|
int32_t name_count;
|
|
bool valid;
|
|
DirectoryKind kind;
|
|
};
|
|
FileHandle OpenRead(String path);
|
|
FileHandle OpenUpdate(String path);
|
|
FileHandle OpenWrite(String path);
|
|
FileHandle OpenReplace(String path);
|
|
FileHandle OpenNew(String path);
|
|
FileHandle OpenExclusivePrivate(String path);
|
|
bool RemoveFile(String path);
|
|
bool PathIsLink(String path);
|
|
bool PathExists(String path);
|
|
bool file_linux_DirectoryExists(String path);
|
|
bool RenamePath(String source, String destination);
|
|
bool RenameNoReplace(String source, String destination);
|
|
bool LinkFile(String source, String destination);
|
|
bool CreateDirectory(String path);
|
|
bool CreatePrivateDirectory(String path);
|
|
int64_t FileSize(FileHandle file);
|
|
int64_t ReadAt(FileHandle file, Slice output, int64_t offset);
|
|
int64_t WriteAt(FileHandle file, Slice input, int64_t offset);
|
|
int64_t WriteTextAt(FileHandle file, String input, int64_t offset);
|
|
bool CloseFile(FileHandle file);
|
|
bool SyncFile(FileHandle file);
|
|
int64_t Read(FileHandle file, Slice output);
|
|
int64_t Write(FileHandle file, Slice input);
|
|
DirectoryCursor OpenDirectory(String path);
|
|
DirectoryEntry NextDirectoryEntry(DirectoryCursor* cursor);
|
|
bool CloseDirectory(DirectoryCursor* cursor);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_FILE_LINUX_H */
|