cosmopolitan/tool/plinko/lib/gc.h
Justine Tunney fa20edc44d
Reduce header complexity
- Remove most __ASSEMBLER__ __LINKER__ ifdefs
- Rename libc/intrin/bits.h to libc/serialize.h
- Block pthread cancelation in fchmodat() polyfill
- Remove `clang-format off` statements in third_party
2023-11-28 14:39:42 -08:00

32 lines
720 B
C

#ifndef COSMOPOLITAN_TOOL_PLINKO_LIB_GC_H_
#define COSMOPOLITAN_TOOL_PLINKO_LIB_GC_H_
#include "tool/plinko/lib/types.h"
COSMOPOLITAN_C_START_
struct Gc {
int A, B, C;
unsigned n;
unsigned noop;
unsigned *P;
dword M[];
};
int MarkSweep(int, int);
struct Gc *NewGc(int);
int Census(struct Gc *);
void Sweep(struct Gc *);
void Marker(const dword[], int, int);
int Relocater(const dword[], const unsigned[], int, int);
forceinline int Relocate(const struct Gc *G, int x) {
if (x >= G->C) return x;
return Relocater(G->M, G->P, G->A, x);
}
forceinline void Mark(struct Gc *G, int x) {
if (x >= G->A) return;
Marker(G->M, G->A, x);
}
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_TOOL_PLINKO_LIB_GC_H_ */