Files
kdm-re/include/gk/types.h
T
ulw-execute 9f96ef8ffc feat(arch): portable-core seam + gk::fp dual-fidelity + i386-gated ABI + seam-symbol check
Introduce the core/platform/host header seam under include/gk/ (portable value
types in core/, Kinect/PE mirror layouts in platform/, the camera-elevation
service interface in host/); the existing include/gk/structs/* paths become
compatibility forwards so no definition is duplicated. Add include/gk/fp.h with
gk::fp::round32 (binary32 rounding barrier) and gk::fp::ExtendedAcc (long double
faithful / double portable), and a GK_FIDELITY=faithful|portable CMake knob
paired with -mfpmath; faithful stays the drop-in differential target. i386-gate
GK_CDECL/STDCALL/THISCALL so non-i386 GNU builds get empty macros (native
-Werror). Migrate the three proven slice functions onto the seam without
behaviour change: box_distance expresses FP through gk/fp.h while keeping the
volatile spill the differential pins; the bodies stay in src/game/*.cpp where
prove_t11.py compiles and greps them. Add tools/seam_symbol_check.py (G5) and
re/game/seam_symbols.json asserting each flagged seam RVA ships as a
non-inlined, addressable symbol.

Verified: prove_t11.py exit 0 / ALL DIFFERENTIALS PASS (faithful, exact-FP from
df1620e); native GK_FIDELITY=portable validity compile under -Werror; macro
cross-check; G5 tool reports all three seam symbols addressable.
2026-11-29 00:54:30 -05:00

57 lines
2.5 KiB
C++

#pragma once
// gamekdm reconstructed-source types: fixed-width integer includes and
// MSVC-matching calling-convention / layout macros. The original gamekdm.dll
// was built with MSVC (cl.exe) for 32-bit Windows (__cdecl default, but many
// internal entry points/vtables use __stdcall or __thiscall); GCC/MinGW is
// ABI-compatible with these calling conventions on i686, so the macros below
// just name the convention explicitly at each declaration site so a reader
// (and a future llvm-mingw/clang-cl cross-check) can see which ABI a given
// function uses without guessing.
#include <cstdint>
#include <cstddef>
#if defined(__GNUC__) && defined(__i386__)
# define GK_CDECL __attribute__((cdecl))
# define GK_STDCALL __attribute__((stdcall))
# define GK_THISCALL __attribute__((thiscall))
#elif defined(__GNUC__)
# define GK_CDECL
# define GK_STDCALL
# define GK_THISCALL
#elif defined(_MSC_VER)
# define GK_CDECL __cdecl
# define GK_STDCALL __stdcall
# define GK_THISCALL __thiscall
#else
# error "gk/types.h: unsupported compiler for calling-convention macros"
#endif
// MSVC-matching struct packing guidance:
//
// The original binary was compiled by MSVC with its default struct packing
// (natural alignment, i.e. #pragma pack(8) equivalent on x86 unless the
// source explicitly set a tighter pack). Any reconstructed struct in
// include/gk/structs/ that must match the original's binary layout (parsed
// from the binary via static/dynamic analysis in later tasks) MUST either:
// 1. rely on natural alignment matching MSVC's default (true for most
// int/float/pointer-only structs on x86), or
// 2. bracket itself with an explicit pack pragma reproducing MSVC's pack
// state at that point in the original translation unit, e.g.:
//
// #pragma pack(push, 1)
// struct SomePackedThing { /* ... */ };
// #pragma pack(pop)
//
// GCC/MinGW both honor `#pragma pack` identically to MSVC. Use the pack
// macros below at each struct that needs it, and comment the source of the
// packing evidence (e.g. "offsets confirmed via Ghidra struct editor on
// orig/gamekdm.dll"). See docs/conventions.md ("Struct packing").
//
// GK_PRAGMA(x) stringizes x and emits it as a _Pragma.
// GK_PACK_PUSH(n) emits `#pragma pack(push, n)` to match MSVC's pack state.
// GK_PACK_POP emits `#pragma pack(pop)` to restore it.
#define GK_PRAGMA(x) _Pragma(#x)
#define GK_PACK_PUSH(n) GK_PRAGMA(pack(push, n))
#define GK_PACK_POP GK_PRAGMA(pack(pop))