Browse Source

Shorten definition of oper_has_neighboring bang, cleanup base macros

master
cancel 6 years ago
parent
commit
c577a4a25f
  1. 18
      base.h
  2. 23
      sim.c

18
base.h

@ -11,32 +11,26 @@
#if defined(__GNUC__) || defined(__clang__)
#define ORCA_FORCE_INLINE __attribute__((always_inline)) inline
#define ORCA_FORCE_STATIC_INLINE __attribute__((always_inline)) static inline
#define ORCA_FORCE_NO_INLINE __attribute__((noinline))
#elif defined(_MSC_VER)
#define ORCA_FORCE_INLINE __forceinline
#define ORCA_FORCE_STATIC_INLINE __forceinline static
#define ORCA_FORCE_NO_INLINE __declspec(noinline)
#else
#define ORCA_FORCE_INLINE inline
#define ORCA_FORCE_STATIC_INLINE inline static
#endif
#if defined(__GNUC__) || defined(__clang__)
#define ORCA_FORCE_NO_INLINE __attribute__((noinline))
#elif defined(_MSC_VER)
#define ORCA_FORCE_NO_INLINE __declspec(noinline)
#else
#define ORCA_FORCE_NO_INLINE
#endif
#if defined(__GNUC__) || defined(__clang__)
#define ORCA_ASSUME_ALIGNED(_ptr, _alignment) \
__builtin_assume_aligned(_ptr, _alignment)
#else
#define ORCA_ASSUME_ALIGNED(_ptr, _alignment) (_ptr)
#endif
#if defined(__GNUC__) || defined(__clang__)
#define ORCA_PURE __attribute__((pure))
#define ORCA_LIKELY(_x) __builtin_expect(_x, 1)
#else
#define ORCA_ASSUME_ALIGNED(_ptr, _alignment) (_ptr)
#define ORCA_PURE
#define ORCA_LIKELY(_x) (_x)
#endif

23
sim.c

@ -70,18 +70,21 @@ static Glyph glyphs_mod(Glyph a, Glyph b) {
return indexed_glyphs[ib == 0 ? 0 : (ia % ib)];
}
// todo check if these inlines are actually being inlinded -- might be bad,
// should probably mark them not inlined
static bool oper_has_neighboring_bang(Gbuffer gbuf, Usz h, Usz w, Usz y,
Usz x) {
return gbuffer_peek_relative(gbuf, h, w, y, x, 0, 1) == '*' ||
gbuffer_peek_relative(gbuf, h, w, y, x, 0, -1) == '*' ||
gbuffer_peek_relative(gbuf, h, w, y, x, 1, 0) == '*' ||
gbuffer_peek_relative(gbuf, h, w, y, x, -1, 0) == '*';
ORCA_PURE static bool oper_has_neighboring_bang(Glyph const* gbuf, Usz h, Usz w,
Usz y, Usz x) {
Glyph const* gp = gbuf + w * y + x;
if (x < w && gp[1] == '*')
return true;
if (x > 0 && gp[-1] == '*')
return true;
if (y < h && gp[w] == '*')
return true;
if (y > 0 && gp[-w] == '*')
return true;
return false;
}
static ORCA_FORCE_NO_INLINE void
ORCA_FORCE_NO_INLINE static void
oper_move_relative_or_explode(Gbuffer gbuf, Mbuffer mbuf, Usz height, Usz width,
Glyph moved, Usz y, Usz x, Isz delta_y,
Isz delta_x) {

Loading…
Cancel
Save