Browse Source

Add ORCA_OK_IF_UNUSED, remove force inline on mark.h fns

master
cancel 7 years ago
parent
commit
b7c4dac86b
  1. 2
      base.h
  2. 53
      mark.h

2
base.h

@ -41,11 +41,13 @@
#define ORCA_PURE __attribute__((pure)) #define ORCA_PURE __attribute__((pure))
#define ORCA_LIKELY(_x) __builtin_expect(_x, 1) #define ORCA_LIKELY(_x) __builtin_expect(_x, 1)
#define ORCA_UNLIKELY(_x) __builtin_expect(_x, 0) #define ORCA_UNLIKELY(_x) __builtin_expect(_x, 0)
#define ORCA_OK_IF_UNUSED __attribute__((unused))
#else #else
#define ORCA_ASSUME_ALIGNED(_ptr, _alignment) (_ptr) #define ORCA_ASSUME_ALIGNED(_ptr, _alignment) (_ptr)
#define ORCA_PURE #define ORCA_PURE
#define ORCA_LIKELY(_x) (_x) #define ORCA_LIKELY(_x) (_x)
#define ORCA_UNLIKELY(_x) (_x) #define ORCA_UNLIKELY(_x) (_x)
#define ORCA_OK_IF_UNUSED
#endif #endif
// array count, safer on gcc/clang // array count, safer on gcc/clang

53
mark.h

@ -23,21 +23,21 @@ void markmap_reusable_deinit(Markmap_reusable* map);
void mbuffer_clear(Mbuffer map, Usz height, Usz width); void mbuffer_clear(Mbuffer map, Usz height, Usz width);
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height, static Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
Usz map_width, Usz y, Usz x, Isz offs_y, Usz map_width, Usz y, Usz x, Isz offs_y,
Isz offs_x); Isz offs_x);
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width, static void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width,
Usz y, Usz x, Isz offs_y, Isz offs_x, Usz y, Usz x, Isz offs_y, Isz offs_x,
Mark_flags flags); Mark_flags flags);
// Inline implementation // Inline implementation
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height, static Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
Usz map_width, Usz y, Usz x, Isz offs_y, Usz map_width, Usz y, Usz x, Isz offs_y,
Isz offs_x) { Isz offs_x) {
Isz y0 = (Isz)y + offs_y; Isz y0 = (Isz)y + offs_y;
Isz x0 = (Isz)x + offs_x; Isz x0 = (Isz)x + offs_x;
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0)
@ -45,10 +45,10 @@ Mark_flags mbuffer_peek_relative(Mbuffer map, Usz map_height,
return map[(Usz)y0 * map_width + (Usz)x0]; return map[(Usz)y0 * map_width + (Usz)x0];
} }
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width, static void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width,
Usz y, Usz x, Isz offs_y, Isz offs_x, Usz y, Usz x, Isz offs_y, Isz offs_x,
Mark_flags flags) { Mark_flags flags) {
Isz y0 = (Isz)y + offs_y; Isz y0 = (Isz)y + offs_y;
Isz x0 = (Isz)x + offs_x; Isz x0 = (Isz)x + offs_x;
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0)
@ -56,10 +56,11 @@ void mbuffer_poke_relative(Mbuffer map, Usz map_height, Usz map_width,
map[(Usz)y0 * map_width + (Usz)x0] = (U8)flags; map[(Usz)y0 * map_width + (Usz)x0] = (U8)flags;
} }
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height, static void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
Usz map_width, Usz y, Usz x, Isz offs_y, Usz map_width, Usz y, Usz x,
Isz offs_x, Mark_flags flags) { Isz offs_y, Isz offs_x,
Mark_flags flags) {
Isz y0 = (Isz)y + offs_y; Isz y0 = (Isz)y + offs_y;
Isz x0 = (Isz)x + offs_x; Isz x0 = (Isz)x + offs_x;
if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0) if (y0 >= (Isz)map_height || x0 >= (Isz)map_width || y0 < 0 || x0 < 0)
@ -67,16 +68,16 @@ void mbuffer_poke_relative_flags_or(Mbuffer map, Usz map_height,
map[(Usz)y0 * map_width + (Usz)x0] |= (U8)flags; map[(Usz)y0 * map_width + (Usz)x0] |= (U8)flags;
} }
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
void mbuffer_poke_flags_or(Mbuffer map, Usz map_height, Usz map_width, static void mbuffer_poke_flags_or(Mbuffer map, Usz map_height, Usz map_width,
Usz y, Usz x, Mark_flags flags) { Usz y, Usz x, Mark_flags flags) {
(void)map_height; (void)map_height;
map[y * map_width + x] |= (U8)flags; map[y * map_width + x] |= (U8)flags;
} }
ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width, static Mark_flags mbuffer_peek(Mbuffer map, Usz map_height, Usz map_width,
Usz y, Usz x) { Usz y, Usz x) {
(void)map_height; (void)map_height;
return map[y * map_width + x]; return map[y * map_width + x];
} }

Loading…
Cancel
Save