Files
BFM-decomp/include/common.h
T
Drew T 7141e9752b feat(phase-16): S0 close + S2 foundation — m2c-compat in common.h (byte-verified)
- S0 (cookbook §15): ran m2c on real ov_SC01_077 stubs (R14). Finding: m2c
  --valid-syntax output COMPILES via m2c_macros.h (M2C_FIELD = byte-faithful cast);
  30/30 sampled targets use only byte-faithful macros. Compiling != matching: the
  residual is regalloc/schedule -> decomp-permuter is the byte-closer; struct types
  are an enhancer, not the sole gate (S3/GATE-B measures the lift). ML parked (owner).
- common.h: add s64/u64/f64 + M2C_UNK* typedefs + byte-faithful M2C_FIELD/M2C_BITWISE
  macros (non-faithful m2c macros left UNDEFINED = early 'defer' signal). Byte-neutral:
  main 143dbb89 (clean rebuild, R22), resident 8e17e02f, ov_SC01_077 d19c9580 all OK.
- CURRENT_PHASE.md: Phase 16 plan + S0-S9 gated tasks + Sun-afternoon timeline +
  known-answer oracle test method.
2026-06-18 22:32:03 -06:00

42 lines
1.7 KiB
C

/* common.h — shared prelude for every matched C translation unit under src/.
*
* Created Phase 6 (the asm->c flip): splat emits `#include "common.h"` at the top
* of each generated src/ file, but does NOT generate the header itself — it is a
* hand-maintained, COMMITTED file (unlike the gitignored include/ .inc macros).
*
* For the all-INCLUDE_ASM scaffold only `include_asm.h` is required; the fixed-width
* typedefs below are the psyq/sotn convention, here ready for the first matched C.
* Grow this (PSY-Q types, hardware-register decls, shared structs) as functions match.
*/
#ifndef COMMON_H
#define COMMON_H
#include "include_asm.h"
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef signed char s8;
typedef short s16;
typedef int s32;
typedef float f32;
/* wider scalars (Phase 16: m2c's M2C_UNK64 needs s64). Byte-neutral — no existing match uses them. */
typedef unsigned long long u64;
typedef long long s64;
typedef double f64;
/* m2c --valid-syntax compat (Phase 16, cookbook §15) — the BYTE-FAITHFUL macros only.
* M2C_FIELD(p,t,o) == *(t)((s8*)p+o): identical codegen to `p->field`, so m2c struct-heavy
* output compiles AND byte-matches without a struct definition. The NON-faithful m2c macros
* (M2C_ERROR/MULT_HI/CLZ/GTE/...) are deliberately left UNDEFINED: a draft using one fails to
* compile = an early "not m2c-matchable, defer" signal (it could never byte-match anyway). */
typedef s32 M2C_UNK;
typedef s8 M2C_UNK8;
typedef s16 M2C_UNK16;
typedef s32 M2C_UNK32;
typedef s64 M2C_UNK64;
#define M2C_FIELD(expr, type_ptr, offset) (*(type_ptr)((s8 *)(expr) + (offset)))
#define M2C_BITWISE(type, expr) ((type)(expr))
#endif /* COMMON_H */