LockCloseOnExec was 131072 and LockNoFollow 262144, which on Linux are O_NOFOLLOW and O_NOATIME, so the build lock got no-follow only by accident on x86 and not at all on ARM, where 131072 is O_LARGEFILE. LockNoFollow is now O_NOFOLLOW per platform: 256 on macOS, 32768 on ARM64 and ARMv7 Linux and Android, 131072 elsewhere. The build lock is opened without close-on-exec, as inherited_by_compilers, so compilers a killed builder leaves behind keep the output directory locked, which native_build_parallel_cases checks; macOS no longer differs there. The object store's sweep lock opens with each platform's own O_RDWR|O_CREAT|O_CLOEXEC.
650 lines
27 KiB
C
650 lines
27 KiB
C
/* Generated by zi2c from compiler_backend_cache.zi. */
|
|
#ifndef ZIRAN_COMPILER_BACKEND_CACHE_H
|
|
#define ZIRAN_COMPILER_BACKEND_CACHE_H
|
|
|
|
#include <stdbool.h>
|
|
#include "zir_string.h"
|
|
#include "zir_slice.h"
|
|
#ifndef ZIRAN_TYPE_FORWARD_Digest
|
|
#define ZIRAN_TYPE_FORWARD_Digest
|
|
typedef struct Digest Digest;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_9f828aa1372cb21a
|
|
#define ZIRAN_CONCRETE_FORWARD___type_9f828aa1372cb21a
|
|
typedef struct __type_9f828aa1372cb21a __type_9f828aa1372cb21a;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_Fingerprint
|
|
#define ZIRAN_TYPE_FORWARD_Fingerprint
|
|
typedef struct Fingerprint Fingerprint;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_c555612ad40905fa
|
|
#define ZIRAN_CONCRETE_FORWARD___type_c555612ad40905fa
|
|
typedef struct __type_c555612ad40905fa __type_c555612ad40905fa;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_03c9bb6e22816916
|
|
#define ZIRAN_CONCRETE_FORWARD___type_03c9bb6e22816916
|
|
typedef struct __type_03c9bb6e22816916 __type_03c9bb6e22816916;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_PathIndex
|
|
#define ZIRAN_TYPE_FORWARD_PathIndex
|
|
typedef struct PathIndex PathIndex;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_BuildCache
|
|
#define ZIRAN_TYPE_FORWARD_BuildCache
|
|
typedef struct BuildCache BuildCache;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_StoreItem
|
|
#define ZIRAN_TYPE_FORWARD_StoreItem
|
|
typedef struct StoreItem StoreItem;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ClockValue
|
|
#define ZIRAN_TYPE_FORWARD_ClockValue
|
|
typedef struct ClockValue ClockValue;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_HashState
|
|
#define ZIRAN_TYPE_FORWARD_HashState
|
|
typedef struct HashState HashState;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ByteView
|
|
#define ZIRAN_TYPE_FORWARD_ByteView
|
|
typedef struct ByteView ByteView;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_View
|
|
#define ZIRAN_TYPE_FORWARD_View
|
|
typedef struct View View;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_Results__bool__bool
|
|
#define ZIRAN_TYPE_FORWARD_Results__bool__bool
|
|
typedef struct Results__bool__bool Results__bool__bool;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_131eebaaeb761e42
|
|
#define ZIRAN_CONCRETE_FORWARD___type_131eebaaeb761e42
|
|
typedef struct __type_131eebaaeb761e42 __type_131eebaaeb761e42;
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_b92b5008b0f9f374
|
|
#define ZIRAN_CONCRETE_FORWARD___type_b92b5008b0f9f374
|
|
typedef struct __type_b92b5008b0f9f374 __type_b92b5008b0f9f374;
|
|
#endif
|
|
#include "file.h"
|
|
#include "vec.h"
|
|
#include "file_tree_linux.h"
|
|
#include "environment.h"
|
|
#include "text_tools.h"
|
|
#include "sort.h"
|
|
#include "process_run_linux.h"
|
|
#include "c_string.h"
|
|
#include "compiler_foreign.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#define ItemMaximum 16384
|
|
#define ProbeMaximum 65536
|
|
#define PathMaximum 4096
|
|
#define CacheMagic "Ziran C cache 1\n"
|
|
#define IdentitySeed "Ziran native object cache 5"
|
|
#define StoreMagic "Ziran object store 1\n"
|
|
#define StoreSuffix ".zo"
|
|
#define StoreDefaultBytes 2147483648
|
|
#define StoreEntryMaximum 268435456
|
|
#define StoreSweepSeconds 300
|
|
#define StoreLockFlags 524354
|
|
#define StoreStaleSeconds 3600
|
|
#define OutputToken "\001output\001"
|
|
|
|
struct Digest {
|
|
uint8_t bytes[32];
|
|
};
|
|
#ifndef ZIRAN_CONCRETE___type_9f828aa1372cb21a
|
|
#define ZIRAN_CONCRETE___type_9f828aa1372cb21a
|
|
|
|
struct __type_9f828aa1372cb21a {
|
|
String* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
|
|
struct Fingerprint {
|
|
String path;
|
|
String parent;
|
|
Digest digest;
|
|
PathInfo info;
|
|
bool unsafe;
|
|
__type_9f828aa1372cb21a probes;
|
|
bool directory;
|
|
bool recent;
|
|
};
|
|
#ifndef ZIRAN_CONCRETE___type_c555612ad40905fa
|
|
#define ZIRAN_CONCRETE___type_c555612ad40905fa
|
|
|
|
struct __type_c555612ad40905fa {
|
|
Fingerprint* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE___type_03c9bb6e22816916
|
|
#define ZIRAN_CONCRETE___type_03c9bb6e22816916
|
|
|
|
struct __type_03c9bb6e22816916 {
|
|
int64_t* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
|
|
struct PathIndex {
|
|
__type_03c9bb6e22816916 slots;
|
|
int64_t count;
|
|
};
|
|
|
|
struct BuildCache {
|
|
Digest identity;
|
|
__type_9f828aa1372cb21a roots;
|
|
String output;
|
|
String executable;
|
|
int64_t started_seconds;
|
|
int64_t started_nanoseconds;
|
|
__type_c555612ad40905fa files;
|
|
__type_c555612ad40905fa candidates;
|
|
PathIndex file_index;
|
|
PathIndex candidate_index;
|
|
bool piped;
|
|
Digest shared;
|
|
String alias;
|
|
bool portable;
|
|
String store;
|
|
int64_t budget;
|
|
String problem;
|
|
bool published;
|
|
};
|
|
|
|
struct StoreItem {
|
|
String name;
|
|
int64_t size;
|
|
int64_t used;
|
|
};
|
|
|
|
struct ClockValue {
|
|
ptrdiff_t seconds;
|
|
ptrdiff_t nanoseconds;
|
|
};
|
|
|
|
struct HashState {
|
|
uint8_t bytes[128];
|
|
};
|
|
|
|
struct ByteView {
|
|
uint8_t* data;
|
|
int64_t count;
|
|
};
|
|
|
|
struct View {
|
|
uint8_t* data;
|
|
size_t count;
|
|
};
|
|
|
|
struct Results__bool__bool {
|
|
bool value_0;
|
|
bool value_1;
|
|
};
|
|
#ifndef ZIRAN_CONCRETE___type_131eebaaeb761e42
|
|
#define ZIRAN_CONCRETE___type_131eebaaeb761e42
|
|
|
|
struct __type_131eebaaeb761e42 {
|
|
uint8_t* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
#ifndef ZIRAN_CONCRETE___type_b92b5008b0f9f374
|
|
#define ZIRAN_CONCRETE___type_b92b5008b0f9f374
|
|
|
|
struct __type_b92b5008b0f9f374 {
|
|
StoreItem* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
extern __type_9f828aa1372cb21a ProfileNames;
|
|
#ifdef __APPLE__
|
|
int32_t zir_foreign_compiler_backend_cache__ClockRaw(int32_t clock, ClockValue* value) __asm__("_clock_gettime");
|
|
#else
|
|
int32_t zir_foreign_compiler_backend_cache__ClockRaw(int32_t clock, ClockValue* value) __asm__("clock_gettime");
|
|
#endif
|
|
#ifdef __APPLE__
|
|
void zir_foreign_compiler_backend_cache__ShaBegin(void* hash) __asm__("_Sha256Begin");
|
|
#else
|
|
void zir_foreign_compiler_backend_cache__ShaBegin(void* hash) __asm__("Sha256Begin");
|
|
#endif
|
|
#ifdef __APPLE__
|
|
void zir_foreign_compiler_backend_cache__ShaEnd(void* hash, uint8_t* output) __asm__("_Sha256End");
|
|
#else
|
|
void zir_foreign_compiler_backend_cache__ShaEnd(void* hash, uint8_t* output) __asm__("Sha256End");
|
|
#endif
|
|
#ifdef __APPLE__
|
|
int32_t zir_foreign_compiler_backend_cache__LockRaw(int32_t descriptor, int32_t operation) __asm__("_flock");
|
|
#else
|
|
int32_t zir_foreign_compiler_backend_cache__LockRaw(int32_t descriptor, int32_t operation) __asm__("flock");
|
|
#endif
|
|
#ifdef __APPLE__
|
|
int32_t zir_foreign_compiler_backend_cache__CloseRaw(int32_t descriptor) __asm__("_close");
|
|
#else
|
|
int32_t zir_foreign_compiler_backend_cache__CloseRaw(int32_t descriptor) __asm__("close");
|
|
#endif
|
|
HashState compiler_backend_cache_HashNew(void);
|
|
void compiler_backend_cache_HashBytes(HashState* hash, String value);
|
|
void compiler_backend_cache_HashInteger(HashState* hash, uint64_t value);
|
|
void compiler_backend_cache_HashText(HashState* hash, String value);
|
|
void compiler_backend_cache_HashFinish(HashState* hash, Digest* output);
|
|
void compiler_backend_cache_ProfileCount(String name);
|
|
uint8_t* compiler_backend_cache_ProfileName(String name);
|
|
Slice compiler_backend_cache_BytesFromPointer(uint8_t* data, uint64_t count);
|
|
String compiler_backend_cache_Owned(String value);
|
|
void compiler_backend_cache_Release(String value);
|
|
bool compiler_backend_cache_SameText(String left, String right);
|
|
bool compiler_backend_cache_HasPrefix(String value, String prefix);
|
|
bool compiler_backend_cache_HasSuffix(String value, String suffix);
|
|
bool compiler_backend_cache_Contains(String value, String piece);
|
|
String compiler_backend_cache_TextName(String value);
|
|
String compiler_backend_cache_JoinTemporary(String left, String right);
|
|
String compiler_backend_cache_JoinPath(String left, String right);
|
|
bool compiler_backend_cache_AppendOwned(__type_9f828aa1372cb21a* values, String value);
|
|
void compiler_backend_cache_ClearNames(__type_9f828aa1372cb21a* values);
|
|
String compiler_backend_cache_Executable(String command);
|
|
bool compiler_backend_cache_Runnable(String path);
|
|
String compiler_backend_cache_Resolved(String path);
|
|
bool compiler_backend_cache_NativeImage(String path);
|
|
bool compiler_backend_cache_PairedArgument(String value);
|
|
bool compiler_backend_cache_RequestedPipe(Slice arguments);
|
|
bool compiler_backend_cache_UnsupportedEffects(void);
|
|
bool compiler_backend_cache_SupportedArguments(Slice arguments);
|
|
bool compiler_backend_cache_SupportedOption(String value);
|
|
int64_t compiler_backend_cache_FileFind(BuildCache* cache, String path, bool directory);
|
|
uint64_t compiler_backend_cache_PathHash(String path);
|
|
int64_t compiler_backend_cache_IndexFind(PathIndex* index, __type_c555612ad40905fa* items, String path);
|
|
void compiler_backend_cache_IndexPlace(PathIndex* index, __type_c555612ad40905fa* items, int64_t item);
|
|
bool compiler_backend_cache_IndexAdd(PathIndex* index, __type_c555612ad40905fa* items, int64_t item);
|
|
int64_t compiler_backend_cache_FileAdd(BuildCache* cache, String path, bool directory);
|
|
int64_t compiler_backend_cache_ProbeLiteral(String text, int64_t start, String* name);
|
|
int64_t compiler_backend_cache_Minimum(int64_t left, int64_t right);
|
|
Results__bool__bool compiler_backend_cache_TextHazards(String text);
|
|
bool compiler_backend_cache_ProbeNames(String text, __type_9f828aa1372cb21a* names);
|
|
int64_t compiler_backend_cache_FileDigest(BuildCache* cache, String path);
|
|
bool compiler_backend_cache_OlderThanBuild(BuildCache* cache, PathInfo info, bool changed);
|
|
int64_t compiler_backend_cache_SpellingDigest(BuildCache* cache, String spelling, String root);
|
|
bool compiler_backend_cache_EnvironmentEntries(Slice bytes, __type_9f828aa1372cb21a* entries);
|
|
bool compiler_backend_cache_CompilerEnvironment(String entry);
|
|
bool compiler_backend_cache_HashEnvironment(HashState* hash, HashState* shared);
|
|
__type_131eebaaeb761e42 compiler_backend_cache_Probe(Slice arguments, bool piped);
|
|
bool compiler_backend_cache_HashProbeOutput(HashState* hash, String text);
|
|
bool compiler_backend_cache_JoinProbeVersions(__type_9f828aa1372cb21a* lines);
|
|
BuildCache* compiler_backend_cache_Open(Slice arguments, String output, String executable);
|
|
void compiler_backend_cache_HashPair(BuildCache* cache, HashState* hash, HashState* shared, String value);
|
|
bool compiler_backend_cache_DebugArguments(Slice arguments);
|
|
bool compiler_backend_cache_PathOption(String value);
|
|
bool compiler_backend_cache_RelativeArguments(Slice arguments);
|
|
int64_t compiler_backend_cache_OutputLength(BuildCache* cache, String value, int64_t at);
|
|
int64_t compiler_backend_cache_NextCandidate(String value, String candidate, int64_t from, int64_t known);
|
|
String compiler_backend_cache_Normalized(BuildCache* cache, String value);
|
|
String compiler_backend_cache_Denormalized(BuildCache* cache, String value);
|
|
void compiler_backend_cache_HashSnapshot(HashState* hash, PathInfo info);
|
|
String compiler_backend_cache_ToolFromLine(String line);
|
|
bool compiler_backend_cache_ParseProbe(BuildCache* cache, HashState* hash, HashState* shared, String text, bool piped);
|
|
String compiler_backend_cache_OutputRelative(BuildCache* cache, String path);
|
|
bool compiler_backend_cache_SpellingKey(BuildCache* cache, HashState* hash, String written, __type_9f828aa1372cb21a* parents, bool* recordable);
|
|
bool compiler_backend_cache_LookupDigest(BuildCache* cache, __type_9f828aa1372cb21a* dependencies, Digest* output, bool recording);
|
|
bool compiler_backend_cache_ReadDependencies(String object, __type_9f828aa1372cb21a* dependencies);
|
|
bool compiler_backend_cache_ReadInteger(Slice bytes, int64_t* offset, uint32_t* output);
|
|
bool compiler_backend_cache_ReadDigest(Slice bytes, int64_t* offset, Digest* output);
|
|
bool compiler_backend_cache_SameDigest(Digest left, Digest right);
|
|
bool compiler_backend_cache_Piped(BuildCache* cache);
|
|
bool compiler_backend_cache_Hit(BuildCache* cache, String object);
|
|
bool compiler_backend_cache_AppendBytes(__type_131eebaaeb761e42* output, Slice bytes);
|
|
bool compiler_backend_cache_AppendText(__type_131eebaaeb761e42* output, String value);
|
|
bool compiler_backend_cache_AppendDigest(__type_131eebaaeb761e42* output, Digest value);
|
|
bool compiler_backend_cache_AppendCount(__type_131eebaaeb761e42* output, uint32_t value);
|
|
bool compiler_backend_cache_AppendNumber(__type_131eebaaeb761e42* output, int64_t value);
|
|
void compiler_backend_cache_Record(BuildCache* cache, String object, String source);
|
|
bool compiler_backend_cache_WriteInputs(BuildCache* cache, String object, __type_9f828aa1372cb21a* dependencies, Digest lookup, Digest compiled);
|
|
bool compiler_backend_cache_PlaceFile(String near, String marker, String final, Slice bytes);
|
|
String compiler_backend_cache_TemporaryPath(String near, String marker, int64_t attempt);
|
|
bool compiler_backend_cache_ReadWhole(String path, __type_131eebaaeb761e42* bytes, int64_t maximum);
|
|
void compiler_backend_cache_StoreOpen(BuildCache* cache);
|
|
String compiler_backend_cache_Problem(BuildCache* cache);
|
|
String compiler_backend_cache_StorePath(BuildCache* cache, String source, Digest digest);
|
|
bool compiler_backend_cache_Fetch(BuildCache* cache, String object, String source);
|
|
void compiler_backend_cache_Publish(BuildCache* cache, String object, String source, __type_9f828aa1372cb21a* dependencies, Digest lookup, Digest compiled);
|
|
void compiler_backend_cache_StoreTouch(String path);
|
|
void compiler_backend_cache_StoreSweep(BuildCache* cache);
|
|
void compiler_backend_cache_ReleaseFingerprints(__type_c555612ad40905fa* values);
|
|
void compiler_backend_cache_Close(BuildCache* cache);
|
|
|
|
/* Small procedures other modules inline; compiler_backend_cache.c defines them. */
|
|
#if !defined(__cplusplus) && !defined(ZIRAN_COMPILER_BACKEND_CACHE_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
|
|
#include "zir_vec.h"
|
|
#include <stdbool.h>
|
|
#include "zir_string.h"
|
|
#ifndef ZIRAN_HELPER_ZiShl32
|
|
#define ZIRAN_HELPER_ZiShl32
|
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPTIMIZE__)
|
|
#define ZiShl32(a, s, w) __extension__ ({ uint32_t __zi_a = (a); uint64_t __zi_s = (s); if(__zi_s >= (uint64_t)(w)) abort(); (uint32_t)(__zi_a << __zi_s); })
|
|
#else
|
|
static inline uint32_t ZiShl32(uint32_t a, uint64_t s, int w) {
|
|
if(s >= (uint64_t)w) abort();
|
|
return (uint32_t)(a << s);
|
|
}
|
|
#endif
|
|
#endif
|
|
static inline void compiler_backend_cache_HashText_ziran_inline(HashState* hash, String value);
|
|
#define compiler_backend_cache_HashText(...) compiler_backend_cache_HashText_ziran_inline(__VA_ARGS__)
|
|
static inline Slice compiler_backend_cache_BytesFromPointer_ziran_inline(uint8_t* data, uint64_t count);
|
|
#define compiler_backend_cache_BytesFromPointer(...) compiler_backend_cache_BytesFromPointer_ziran_inline(__VA_ARGS__)
|
|
static inline String compiler_backend_cache_Owned_ziran_inline(String value);
|
|
#define compiler_backend_cache_Owned(...) compiler_backend_cache_Owned_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_SameText_ziran_inline(String left, String right);
|
|
#define compiler_backend_cache_SameText(...) compiler_backend_cache_SameText_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_HasPrefix_ziran_inline(String value, String prefix);
|
|
#define compiler_backend_cache_HasPrefix(...) compiler_backend_cache_HasPrefix_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_HasSuffix_ziran_inline(String value, String suffix);
|
|
#define compiler_backend_cache_HasSuffix(...) compiler_backend_cache_HasSuffix_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_Contains_ziran_inline(String value, String piece);
|
|
#define compiler_backend_cache_Contains(...) compiler_backend_cache_Contains_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_Runnable_ziran_inline(String path);
|
|
#define compiler_backend_cache_Runnable(...) compiler_backend_cache_Runnable_ziran_inline(__VA_ARGS__)
|
|
static inline int64_t compiler_backend_cache_FileFind_ziran_inline(BuildCache* cache, String path, bool directory);
|
|
#define compiler_backend_cache_FileFind(...) compiler_backend_cache_FileFind_ziran_inline(__VA_ARGS__)
|
|
static inline uint64_t compiler_backend_cache_PathHash_ziran_inline(String path);
|
|
#define compiler_backend_cache_PathHash(...) compiler_backend_cache_PathHash_ziran_inline(__VA_ARGS__)
|
|
static inline int64_t compiler_backend_cache_IndexFind_ziran_inline(PathIndex* index, __type_c555612ad40905fa* items, String path);
|
|
#define compiler_backend_cache_IndexFind(...) compiler_backend_cache_IndexFind_ziran_inline(__VA_ARGS__)
|
|
static inline void compiler_backend_cache_IndexPlace_ziran_inline(PathIndex* index, __type_c555612ad40905fa* items, int64_t item);
|
|
#define compiler_backend_cache_IndexPlace(...) compiler_backend_cache_IndexPlace_ziran_inline(__VA_ARGS__)
|
|
static inline int64_t compiler_backend_cache_Minimum_ziran_inline(int64_t left, int64_t right);
|
|
#define compiler_backend_cache_Minimum(...) compiler_backend_cache_Minimum_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_OlderThanBuild_ziran_inline(BuildCache* cache, PathInfo info, bool changed);
|
|
#define compiler_backend_cache_OlderThanBuild(...) compiler_backend_cache_OlderThanBuild_ziran_inline(__VA_ARGS__)
|
|
static inline void compiler_backend_cache_HashPair_ziran_inline(BuildCache* cache, HashState* hash, HashState* shared, String value);
|
|
#define compiler_backend_cache_HashPair(...) compiler_backend_cache_HashPair_ziran_inline(__VA_ARGS__)
|
|
static inline int64_t compiler_backend_cache_NextCandidate_ziran_inline(String value, String candidate, int64_t from, int64_t known);
|
|
#define compiler_backend_cache_NextCandidate(...) compiler_backend_cache_NextCandidate_ziran_inline(__VA_ARGS__)
|
|
static inline void compiler_backend_cache_HashSnapshot_ziran_inline(HashState* hash, PathInfo info);
|
|
#define compiler_backend_cache_HashSnapshot(...) compiler_backend_cache_HashSnapshot_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_ReadInteger_ziran_inline(Slice bytes, int64_t* offset, uint32_t* output);
|
|
#define compiler_backend_cache_ReadInteger(...) compiler_backend_cache_ReadInteger_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_ReadDigest_ziran_inline(Slice bytes, int64_t* offset, Digest* output);
|
|
#define compiler_backend_cache_ReadDigest(...) compiler_backend_cache_ReadDigest_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_SameDigest_ziran_inline(Digest left, Digest right);
|
|
#define compiler_backend_cache_SameDigest(...) compiler_backend_cache_SameDigest_ziran_inline(__VA_ARGS__)
|
|
static inline bool compiler_backend_cache_Piped_ziran_inline(BuildCache* cache);
|
|
#define compiler_backend_cache_Piped(...) compiler_backend_cache_Piped_ziran_inline(__VA_ARGS__)
|
|
|
|
static inline void
|
|
compiler_backend_cache_HashText_ziran_inline(HashState* hash, String value)
|
|
{
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)((int64_t)(value).length));
|
|
compiler_backend_cache_HashBytes(hash, value);
|
|
}
|
|
|
|
static inline Slice
|
|
compiler_backend_cache_BytesFromPointer_ziran_inline(uint8_t* data, uint64_t count)
|
|
{
|
|
Slice result = {0};
|
|
if (data == ((void *)0)) {
|
|
return result;
|
|
}
|
|
ByteView* descriptor = (ByteView*)(&(result));
|
|
uint8_t** value_0 = &(descriptor->data);
|
|
(*value_0) = data;
|
|
int64_t* value_1 = &(descriptor->count);
|
|
(*value_1) = (int64_t)(count);
|
|
return result;
|
|
}
|
|
|
|
static inline String
|
|
compiler_backend_cache_Owned_ziran_inline(String value)
|
|
{
|
|
return vec_TextDetach(vec_TextCopy(value));
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_SameText_ziran_inline(String left, String right)
|
|
{
|
|
return StringEqual(left, right);
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_HasPrefix_ziran_inline(String value, String prefix)
|
|
{
|
|
return text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_HasSuffix_ziran_inline(String value, String suffix)
|
|
{
|
|
return text_tools_TextHasSuffix(value, suffix);
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_Contains_ziran_inline(String value, String piece)
|
|
{
|
|
return text_tools_TextContains(value, piece);
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_Runnable_ziran_inline(String path)
|
|
{
|
|
PathInfo info = file_tree_linux_PathStatus(path, true);
|
|
return ((PathKind)(info.kind)) == ((PathKind)(1)) && ((int32_t)((uint32_t)(info.mode) & 73u)) != 0;
|
|
}
|
|
|
|
static inline int64_t
|
|
compiler_backend_cache_FileFind_ziran_inline(BuildCache* cache, String path, bool directory)
|
|
{
|
|
if (directory) {
|
|
return compiler_backend_cache_IndexFind(&(cache->candidate_index), &(cache->candidates), path);
|
|
}
|
|
return compiler_backend_cache_IndexFind(&(cache->file_index), &(cache->files), path);
|
|
}
|
|
|
|
static inline uint64_t
|
|
compiler_backend_cache_PathHash_ziran_inline(String path)
|
|
{
|
|
uint64_t hash = 14695981039346656037ULL;
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(path).length; it_index++) {
|
|
uint8_t byte = (uint8_t)path.data[it_index];
|
|
hash = (uint64_t)(((uint64_t)hash ^ (uint64_t)(byte)) * UINT64_C(1099511628211));
|
|
}
|
|
return hash;
|
|
}
|
|
|
|
static inline int64_t
|
|
compiler_backend_cache_IndexFind_ziran_inline(PathIndex* index, __type_c555612ad40905fa* items, String path)
|
|
{
|
|
int64_t value_0 = index->slots.count;
|
|
if (value_0 == 0LL) {
|
|
return -1LL;
|
|
}
|
|
int64_t mask = (int64_t)((uint64_t)(index->slots.count) - UINT64_C(1));
|
|
uint64_t value_1 = (uint64_t)((uint64_t)(compiler_backend_cache_PathHash(path)) & (uint64_t)(mask));
|
|
int64_t slot = (int64_t)(value_1);
|
|
while (true) {
|
|
int64_t value_2 = (index->slots).data[slot];
|
|
if (!(value_2 != 0LL)) { break; }
|
|
int64_t item = (int64_t)((uint64_t)((index->slots).data[slot]) - UINT64_C(1));
|
|
if (StringEqual(((*(items)).data[item]).path, path)) {
|
|
return item;
|
|
}
|
|
slot = (int64_t)(((uint64_t)slot + UINT64_C(1)) & (uint64_t)mask);
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
static inline void
|
|
compiler_backend_cache_IndexPlace_ziran_inline(PathIndex* index, __type_c555612ad40905fa* items, int64_t item)
|
|
{
|
|
int64_t mask = (int64_t)((uint64_t)(index->slots.count) - UINT64_C(1));
|
|
uint64_t value_0 = (uint64_t)((uint64_t)(compiler_backend_cache_PathHash(((*(items)).data[item]).path)) & (uint64_t)(mask));
|
|
int64_t slot = (int64_t)(value_0);
|
|
while (true) {
|
|
int64_t value_1 = (index->slots).data[slot];
|
|
if (!(value_1 != 0LL)) { break; }
|
|
slot = (int64_t)(((uint64_t)slot + UINT64_C(1)) & (uint64_t)mask);
|
|
}
|
|
int64_t* value_2 = &(ZIRAN_VEC_INDEX((index->slots).data, (index->slots).count, slot));
|
|
(*value_2) = (int64_t)((uint64_t)item + UINT64_C(1));
|
|
int64_t* value_3 = &(index->count);
|
|
(*value_3) = (int64_t)((uint64_t)((*value_3)) + UINT64_C(1));
|
|
}
|
|
|
|
static inline int64_t
|
|
compiler_backend_cache_Minimum_ziran_inline(int64_t left, int64_t right)
|
|
{
|
|
int64_t value_0 = 0;
|
|
if (left < right) {
|
|
value_0 = left;
|
|
} else {
|
|
value_0 = right;
|
|
}
|
|
return value_0;
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_OlderThanBuild_ziran_inline(BuildCache* cache, PathInfo info, bool changed)
|
|
{
|
|
int64_t value_0 = 0;
|
|
if (changed) {
|
|
value_0 = info.changed;
|
|
} else {
|
|
value_0 = info.modified;
|
|
}
|
|
int64_t seconds = value_0;
|
|
uint32_t value_1 = 0;
|
|
if (changed) {
|
|
value_1 = info.changed_nanoseconds;
|
|
} else {
|
|
value_1 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_1;
|
|
int64_t value_2 = cache->started_seconds;
|
|
if (seconds != value_2) {
|
|
int64_t value_3 = cache->started_seconds;
|
|
return seconds < value_3;
|
|
}
|
|
int64_t value_4 = (int64_t)(nanoseconds);
|
|
int64_t value_5 = cache->started_nanoseconds;
|
|
return value_4 < value_5;
|
|
}
|
|
|
|
static inline void
|
|
compiler_backend_cache_HashPair_ziran_inline(BuildCache* cache, HashState* hash, HashState* shared, String value)
|
|
{
|
|
HashState* value_0 = hash;
|
|
String value_1 = value;
|
|
{
|
|
HashState* value_3 = value_0;
|
|
String value_4 = value_1;
|
|
compiler_backend_cache_HashInteger(value_3, (uint64_t)((int64_t)(value_4).length));
|
|
compiler_backend_cache_HashBytes(value_3, value_4);
|
|
}
|
|
String portable = compiler_backend_cache_Normalized(cache, value);
|
|
{
|
|
HashState* value_6 = shared;
|
|
String value_7 = portable;
|
|
compiler_backend_cache_HashInteger(value_6, (uint64_t)((int64_t)(value_7).length));
|
|
compiler_backend_cache_HashBytes(value_6, value_7);
|
|
}
|
|
compiler_backend_cache_Release(portable);
|
|
}
|
|
|
|
static inline int64_t
|
|
compiler_backend_cache_NextCandidate_ziran_inline(String value, String candidate, int64_t from, int64_t known)
|
|
{
|
|
if ((int64_t)(candidate).length == 0LL || known == -1LL || known >= from) {
|
|
int64_t value_0 = 0;
|
|
if ((int64_t)(candidate).length == 0LL) {
|
|
value_0 = -1LL;
|
|
} else {
|
|
value_0 = known;
|
|
}
|
|
return value_0;
|
|
}
|
|
return text_tools_TextFind(value, candidate, from);
|
|
}
|
|
|
|
static inline void
|
|
compiler_backend_cache_HashSnapshot_ziran_inline(HashState* hash, PathInfo info)
|
|
{
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_major));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_minor));
|
|
compiler_backend_cache_HashInteger(hash, info.inode);
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.mode));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.size));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified_nanoseconds));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed_nanoseconds));
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_ReadInteger_ziran_inline(Slice bytes, int64_t* offset, uint32_t* output)
|
|
{
|
|
int64_t value_0 = (int64_t)((uint64_t)(*(offset)) + UINT64_C(4));
|
|
int64_t value_1 = (int64_t)(bytes).length;
|
|
if (value_0 > value_1) {
|
|
return false;
|
|
}
|
|
uint32_t value = 0;
|
|
for (int64_t index = 0LL; index <= 3LL; index++) {
|
|
uint32_t value_2 = ZiShl32((uint32_t)(((uint8_t *)(bytes).data)[((int64_t)((uint64_t)(*(offset)) + (uint64_t)index))]), (uint64_t)((uint32_t)(((int64_t)(UINT64_C(8) * (uint64_t)index)))), 32);
|
|
value = (uint32_t)((uint32_t)value | (uint32_t)value_2);
|
|
}
|
|
int64_t* value_3 = &((*(offset)));
|
|
(*value_3) = (int64_t)((uint64_t)((*value_3)) + UINT64_C(4));
|
|
uint32_t* value_4 = &((*(output)));
|
|
(*value_4) = value;
|
|
return true;
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_ReadDigest_ziran_inline(Slice bytes, int64_t* offset, Digest* output)
|
|
{
|
|
int64_t value_0 = (int64_t)((uint64_t)(*(offset)) + UINT64_C(32));
|
|
int64_t value_1 = (int64_t)(bytes).length;
|
|
if (value_0 > value_1) {
|
|
return false;
|
|
}
|
|
for (int64_t index = 0LL; index <= 31LL; index++) {
|
|
uint8_t* value_2 = &(output->bytes[index]);
|
|
(*value_2) = ((uint8_t *)(bytes).data)[((int64_t)((uint64_t)(*(offset)) + (uint64_t)index))];
|
|
}
|
|
int64_t* value_3 = &((*(offset)));
|
|
(*value_3) = (int64_t)((uint64_t)((*value_3)) + UINT64_C(32));
|
|
return true;
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_SameDigest_ziran_inline(Digest left, Digest right)
|
|
{
|
|
for (int64_t index = 0LL; index <= 31LL; index++) {
|
|
if ((left.bytes)[index] != (right.bytes)[index]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static inline bool
|
|
compiler_backend_cache_Piped_ziran_inline(BuildCache* cache)
|
|
{
|
|
return cache != ((void *)0) && cache->piped;
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_COMPILER_BACKEND_CACHE_H */
|