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]>
215 lines
7.2 KiB
C
215 lines
7.2 KiB
C
/* Generated by zi2c from file_tree_linux.zi. */
|
|
#ifndef ZIRAN_FILE_TREE_LINUX_H
|
|
#define ZIRAN_FILE_TREE_LINUX_H
|
|
|
|
#include <stdbool.h>
|
|
#include "zir_string_types.h"
|
|
#include "zir_slice.h"
|
|
#include "c_string.h"
|
|
#include "byte_text_linux.h"
|
|
#include "sort.h"
|
|
#include "file_linux.h"
|
|
#include "vec.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
#define CURRENT_DIRECTORY -100
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
#define NO_FOLLOW 256
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
#define BASIC_STATS 2047
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
#define EXISTS 17
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
#define zir_d_01152c6c26cea146 4
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
typedef struct StatxRecord StatxRecord;
|
|
#endif
|
|
typedef uint8_t PathKind;
|
|
typedef struct PathInfo PathInfo;
|
|
typedef struct PathQueryResult PathQueryResult;
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_838711075b90279a
|
|
#define ZIRAN_CONCRETE_FORWARD___type_838711075b90279a
|
|
typedef struct __type_838711075b90279a __type_838711075b90279a;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_c53c2d7c4913dc02
|
|
#define ZIRAN_CONCRETE_FORWARD___type_c53c2d7c4913dc02
|
|
typedef struct __type_c53c2d7c4913dc02 __type_c53c2d7c4913dc02;
|
|
#endif
|
|
#ifdef ZIRAN_FILE_TREE_LINUX_H_PRIVATE
|
|
|
|
struct StatxRecord {
|
|
uint64_t words[32];
|
|
};
|
|
#endif
|
|
|
|
enum {
|
|
PathKind_Missing = 0,
|
|
PathKind_File = 1,
|
|
PathKind_Directory = 2,
|
|
PathKind_Link = 3,
|
|
PathKind_Other = 4,
|
|
};
|
|
|
|
struct PathInfo {
|
|
PathKind kind;
|
|
uint32_t owner_uid;
|
|
int32_t mode;
|
|
int64_t size;
|
|
int64_t modified;
|
|
uint32_t modified_nanoseconds;
|
|
uint32_t metadata_mask;
|
|
bool identity_valid;
|
|
uint64_t inode;
|
|
int64_t changed;
|
|
uint32_t changed_nanoseconds;
|
|
uint32_t device_major;
|
|
uint32_t device_minor;
|
|
};
|
|
|
|
struct PathQueryResult {
|
|
PathInfo info;
|
|
bool valid;
|
|
bool missing;
|
|
int32_t error;
|
|
};
|
|
#ifndef ZIRAN_CONCRETE___type_838711075b90279a
|
|
#define ZIRAN_CONCRETE___type_838711075b90279a
|
|
|
|
struct __type_838711075b90279a {
|
|
uint8_t* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE___type_c53c2d7c4913dc02
|
|
#define ZIRAN_CONCRETE___type_c53c2d7c4913dc02
|
|
|
|
struct __type_c53c2d7c4913dc02 {
|
|
String* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
PathQueryResult file_tree_linux_PathQuery(String path, bool follow_links);
|
|
PathInfo file_tree_linux_PathStatus(String path, bool follow_links);
|
|
PathInfo file_tree_linux_FileSnapshot(String path);
|
|
bool file_tree_linux_SameFileSnapshot(PathInfo left, PathInfo right);
|
|
bool file_tree_linux_IsFile(String path);
|
|
bool file_tree_linux_IsDirectory(String path);
|
|
bool file_tree_linux_SetPathMode(String path, int32_t mode);
|
|
Text file_tree_linux_JoinPath(String directory, String name);
|
|
String file_tree_linux_PathName(String path);
|
|
String file_tree_linux_PathParent(String path);
|
|
String file_tree_linux_PathSuffix(String path);
|
|
String file_tree_linux_PathStem(String path);
|
|
Text file_tree_linux_ResolvePath(String path);
|
|
Text file_tree_linux_CreateTemporaryDirectory(String parent, String prefix);
|
|
Text file_tree_linux_WorkingDirectory(void);
|
|
bool file_tree_linux_CreateDirectories(String path, int32_t mode);
|
|
void file_tree_linux_FreeDirectoryNames(__type_c53c2d7c4913dc02* names);
|
|
bool file_tree_linux_ListDirectory(String path, __type_c53c2d7c4913dc02* names);
|
|
bool file_tree_linux_RemoveTree(String path);
|
|
bool file_tree_linux_CopyFile(String source, String target);
|
|
bool file_tree_linux_CopyTree(String source, String target);
|
|
bool file_tree_linux_CopySymbolicLink(String source, String target);
|
|
bool file_tree_linux_CopyFileNew(String source, String target);
|
|
bool file_tree_linux_CopyTreeNew(String source, String target);
|
|
bool file_tree_linux_ReplaceFile(String path, String text);
|
|
int32_t file_tree_linux_LockPath(String path, bool exclusive, bool wait);
|
|
void file_tree_linux_UnlockPath(int32_t fd);
|
|
bool file_tree_linux_MatchName(String name, String pattern);
|
|
|
|
/* Small procedures other modules inline; file_tree_linux.c defines them. */
|
|
#if !defined(__cplusplus) && !defined(ZIRAN_FILE_TREE_LINUX_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
|
|
#include "zir_vec.h"
|
|
#include <stdbool.h>
|
|
#include "zir_string_types.h"
|
|
static inline PathInfo file_tree_linux_PathStatus_ziran_inline(String path, bool follow_links);
|
|
#define file_tree_linux_PathStatus(...) file_tree_linux_PathStatus_ziran_inline(__VA_ARGS__)
|
|
static inline PathInfo file_tree_linux_FileSnapshot_ziran_inline(String path);
|
|
#define file_tree_linux_FileSnapshot(...) file_tree_linux_FileSnapshot_ziran_inline(__VA_ARGS__)
|
|
static inline bool file_tree_linux_SameFileSnapshot_ziran_inline(PathInfo left, PathInfo right);
|
|
#define file_tree_linux_SameFileSnapshot(...) file_tree_linux_SameFileSnapshot_ziran_inline(__VA_ARGS__)
|
|
static inline bool file_tree_linux_IsFile_ziran_inline(String path);
|
|
#define file_tree_linux_IsFile(...) file_tree_linux_IsFile_ziran_inline(__VA_ARGS__)
|
|
static inline bool file_tree_linux_IsDirectory_ziran_inline(String path);
|
|
#define file_tree_linux_IsDirectory(...) file_tree_linux_IsDirectory_ziran_inline(__VA_ARGS__)
|
|
|
|
static inline PathInfo
|
|
file_tree_linux_PathStatus_ziran_inline(String path, bool follow_links)
|
|
{
|
|
PathQueryResult value_0 = file_tree_linux_PathQuery(path, follow_links);
|
|
return value_0.info;
|
|
}
|
|
|
|
static inline PathInfo
|
|
file_tree_linux_FileSnapshot_ziran_inline(String path)
|
|
{
|
|
String value_0 = path;
|
|
PathInfo value_1 = {0};
|
|
{
|
|
String path = value_0;
|
|
bool follow_links = false;
|
|
PathQueryResult value_3 = file_tree_linux_PathQuery(path, follow_links);
|
|
value_1 = value_3.info;
|
|
}
|
|
PathInfo result = value_1;
|
|
if (((PathKind)(result.kind)) != PathKind_File) {
|
|
bool* value_4 = &(result.identity_valid);
|
|
(*value_4) = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static inline bool
|
|
file_tree_linux_SameFileSnapshot_ziran_inline(PathInfo left, PathInfo right)
|
|
{
|
|
bool value_0 = left.identity_valid && right.identity_valid && ((PathKind)(left.kind)) == PathKind_File && ((PathKind)(right.kind)) == PathKind_File;
|
|
bool value_1 = value_0 && left.device_major == right.device_major && left.device_minor == right.device_minor && left.inode == right.inode;
|
|
bool value_2 = value_1 && left.size == right.size && left.modified == right.modified && left.modified_nanoseconds == right.modified_nanoseconds;
|
|
return value_2 && left.changed == right.changed && left.changed_nanoseconds == right.changed_nanoseconds;
|
|
}
|
|
|
|
static inline bool
|
|
file_tree_linux_IsFile_ziran_inline(String path)
|
|
{
|
|
String value_0 = path;
|
|
PathInfo value_1 = {0};
|
|
{
|
|
String path = value_0;
|
|
bool follow_links = true;
|
|
PathQueryResult value_3 = file_tree_linux_PathQuery(path, follow_links);
|
|
value_1 = value_3.info;
|
|
}
|
|
return ((PathKind)(value_1.kind)) == PathKind_File;
|
|
}
|
|
|
|
static inline bool
|
|
file_tree_linux_IsDirectory_ziran_inline(String path)
|
|
{
|
|
String value_0 = path;
|
|
PathInfo value_1 = {0};
|
|
{
|
|
String path = value_0;
|
|
bool follow_links = true;
|
|
PathQueryResult value_3 = file_tree_linux_PathQuery(path, follow_links);
|
|
value_1 = value_3.info;
|
|
}
|
|
return ((PathKind)(value_1.kind)) == PathKind_Directory;
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_FILE_TREE_LINUX_H */
|