From a65d1093f225f763a152e29a1b60dbb62f3ae58c Mon Sep 17 00:00:00 2001 From: cancel Date: Sat, 1 Dec 2018 14:21:27 +0900 Subject: [PATCH] Cleanup, fix accidental bitwise or --- base.h | 2 ++ sim.c | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/base.h b/base.h index 007d1b3..2a862b1 100644 --- a/base.h +++ b/base.h @@ -29,10 +29,12 @@ __builtin_assume_aligned(_ptr, _alignment) #define ORCA_PURE __attribute__((pure)) #define ORCA_LIKELY(_x) __builtin_expect(_x, 1) +#define ORCA_UNLIKELY(_x) __builtin_expect(_x, 0) #else #define ORCA_ASSUME_ALIGNED(_ptr, _alignment) (_ptr) #define ORCA_PURE #define ORCA_LIKELY(_x) (_x) +#define ORCA_UNLIKELY(_x) (_x) #endif #define ORCA_Y_MAX UINT16_MAX diff --git a/sim.c b/sim.c index 993c9b5..fbe3d46 100644 --- a/sim.c +++ b/sim.c @@ -16,10 +16,10 @@ enum { Glyphs_array_num = sizeof indexed_glyphs }; // capitalized glyphs as well. The index of the lower-cased glyph is returned // if the glyph is capitalized. #if 0 -static inline Glyph glyph_lowered(Glyph c) { +inline static Glyph glyph_lowered(Glyph c) { return (c >= 'A' && c <= 'Z') ? (char)(c - ('a' - 'A')) : c; } -static ORCA_FORCE_NO_INLINE Usz index_of__reference(Glyph c) { +static Usz index_of(Glyph c) { Glyph c0 = glyph_lowered(c); if (c0 == '.') return 0; @@ -29,8 +29,7 @@ static ORCA_FORCE_NO_INLINE Usz index_of__reference(Glyph c) { } return 0; } -#endif - +#else static Usz index_of(Glyph c) { if (c == '.') return 0; @@ -52,6 +51,7 @@ static Usz index_of(Glyph c) { } return 0; } +#endif static inline Glyph glyph_of(Usz index) { assert(index < Glyphs_array_num); @@ -117,18 +117,16 @@ typedef struct { } Oper_bank_read_params; // static may cause warning if programmer doesn't use bank storage -void ORCA_FORCE_NO_INLINE oper_bank_store(Oper_bank_write_params* bank_params, - Usz width, Usz y, Usz x, - I32* restrict vals, Usz num_vals) { +static void oper_bank_store(Oper_bank_write_params* bank_params, Usz width, + Usz y, Usz x, I32* restrict vals, Usz num_vals) { assert(num_vals > 0); Usz index = y * width + x; assert(index < ORCA_BANK_INDEX_MAX); bank_params->size = bank_append(bank_params->bank, bank_params->size, index, vals, num_vals); } -Usz ORCA_FORCE_NO_INLINE oper_bank_load(Oper_bank_read_params* bank_params, - Usz width, Usz y, Usz x, - I32* restrict out_vals, Usz out_count) { +static Usz oper_bank_load(Oper_bank_read_params* bank_params, Usz width, Usz y, + Usz x, I32* restrict out_vals, Usz out_count) { Usz index = y * width + x; assert(index < ORCA_BANK_INDEX_MAX); return bank_read(bank_params->bank->data, bank_params->size, @@ -245,7 +243,7 @@ Usz usz_clamp(Usz val, Usz min, Usz max) { #define REALIZE_DUAL \ bool const Dual_is_active = \ - Dual_is_uppercase | \ + Dual_is_uppercase || \ oper_has_neighboring_bang(gbuffer, height, width, y, x); #define PSEUDO_DUAL bool const Dual_is_active = true