Skip to content

Commit b8cc8b4

Browse files
JoeMattclaude
andcommitted
fix(blitter): portable always-inline (MSVC has no GCC attribute)
MSVC x86 / x64 compilation checks failed on PR #129 because `__attribute__((always_inline))` is GCC/Clang-specific. Wrap it in a BLITTER_ALWAYS_INLINE macro that maps to: GCC / Clang: inline __attribute__((always_inline)) MSVC: __forceinline (replaces inline) Other: inline (best-effort) The macro spells the inline keyword itself so call sites are just `static BLITTER_ALWAYS_INLINE void foo(...)` -- no extra INLINE qualifier (MSVC's __forceinline conflicts with another inline keyword, which is why the original `static INLINE __attribute__(...)` form would have failed there even if MSVC understood the attribute). Verified: clang still inlines (AvP accurate ~196 FPS, same as the attribute-only form); test suite passes; libretro buildbot's MSVC target should now build clean. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent 25278cb commit b8cc8b4

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/tom/blitter.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@
3434
#define USE_ORIGINAL_BLITTER
3535
#define USE_MIDSUMMER_BLITTER_MKII
3636

37+
/* Portable always-inline. Spelled to include the inline keyword
38+
* itself (MSVC's __forceinline IS the inline keyword for that
39+
* compiler), so call sites use `static BLITTER_ALWAYS_INLINE void
40+
* foo(...)` without an extra INLINE/inline. Used to force inlining
41+
* of the blitter helpers (ADD16SAT, ADDARRAY, COMP_CTRL, DATA) so
42+
* the compiler can specialise them per call site. */
43+
#if defined(_MSC_VER)
44+
# define BLITTER_ALWAYS_INLINE __forceinline
45+
#elif defined(__GNUC__) || defined(__clang__)
46+
# define BLITTER_ALWAYS_INLINE inline __attribute__((always_inline))
47+
#else
48+
# define BLITTER_ALWAYS_INLINE inline
49+
#endif
50+
3751
// Local global variables
3852

3953
// Blitter register RAM (most of it is hidden from the user)
@@ -993,7 +1007,7 @@ void ADDRADD(int16_t *addq_x, int16_t *addq_y, bool a1fracldi,
9931007
* call sites in BlitterMidsummer2 (compile-time daddasel/daddbsel/
9941008
* daddmode -> dead switch arms eliminated) and the call inside DATA
9951009
* (where the args are loop-invariant for the duration of a blit). */
996-
static INLINE __attribute__((always_inline))
1010+
static BLITTER_ALWAYS_INLINE
9971011
void ADD16SAT(uint16_t *r, uint8_t *co, uint16_t a, uint16_t b,
9981012
uint8_t cin, bool sat, bool eightbit, bool hicinh)
9991013
{
@@ -1031,7 +1045,7 @@ void ADD16SAT(uint16_t *r, uint8_t *co, uint16_t a, uint16_t b,
10311045
*r |= (hisaturate ? (ctop ? 0xFF00 : 0x0000) : q & 0xFF00);
10321046
}
10331047

1034-
static INLINE __attribute__((always_inline))
1048+
static BLITTER_ALWAYS_INLINE
10351049
void ADDARRAY(uint16_t *addq, uint8_t daddasel, uint8_t daddbsel,
10361050
uint8_t daddmode, uint64_t dstd, uint32_t iinc,
10371051
uint8_t initcin[], uint64_t initinc, uint16_t initpix,
@@ -1119,7 +1133,7 @@ void ADDARRAY(uint16_t *addq, uint8_t daddasel, uint8_t daddbsel,
11191133
ADD16SAT(&addq[3], &co[3], adda[3], addb[3], cin[3], sat, eightbit, hicinh);
11201134
}
11211135

1122-
static INLINE __attribute__((always_inline))
1136+
static BLITTER_ALWAYS_INLINE
11231137
void COMP_CTRL(uint8_t *dbinh, bool *nowrite,
11241138
bool bcompen, bool big_pix, bool bkgwren, uint8_t dcomp, bool dcompen, uint8_t icount,
11251139
uint8_t pixsize, bool phrase_mode, uint8_t srcd, uint8_t zcomp)
@@ -1326,7 +1340,7 @@ Dbinh[7] := NAN2 (dbinh\[7], di7t[2], phrase_mode);*/
13261340
*dbinh = ~*dbinh;
13271341
}
13281342

1329-
static INLINE __attribute__((always_inline))
1343+
static BLITTER_ALWAYS_INLINE
13301344
void DATA(uint64_t *wdata, uint8_t *dcomp, uint8_t *zcomp, bool *nowrite,
13311345
bool big_pix, bool cmpdst, uint8_t daddasel, uint8_t daddbsel, uint8_t daddmode, bool daddq_sel, uint8_t data_sel,
13321346
uint8_t dbinh, uint8_t dend, uint8_t dstart, uint64_t dstd, uint32_t iinc, uint8_t lfu_func, uint64_t *patd, bool patdadd,

0 commit comments

Comments
 (0)