--- deliantra/Deliantra-Client/Client.xs 2018/11/18 15:24:24 1.330 +++ deliantra/Deliantra-Client/Client.xs 2018/11/19 00:10:34 1.331 @@ -78,14 +78,7 @@ # include #endif -#if __GNUC__ >= 4 -# define expect(expr,value) __builtin_expect ((expr),(value)) -#else -# define expect(expr,value) (expr) -#endif - -#define expect_false(expr) expect ((expr) != 0, 0) -#define expect_true(expr) expect ((expr) != 0, 1) +#include "ecb.h" #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ @@ -113,7 +106,7 @@ STRLEN len = SvLEN (sv); STRLEN want = SvCUR (sv) + need; - if (expect_false (len < want)) + if (ecb_expect_false (len < want)) { do len *= 2; @@ -258,6 +251,8 @@ *h = rect.height; } +///////////////////////////////////////////////////////////////////////////// + typedef uint16_t tileid; typedef uint16_t faceid; @@ -304,7 +299,8 @@ { T *p; - Newxz (p, sze + inc, T); + Newx (p, inc + sze, T); + Zero (p, inc, T); Move (ptr, p + inc, sze, T); Safefree (ptr); @@ -534,17 +530,6 @@ return n + 1; } -static unsigned int -popcount (unsigned int n) -{ - n -= (n >> 1) & 0x55555555U; - n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); - n = ((n >> 4) + n) & 0x0f0f0f0fU; - n *= 0x01010101U; - - return n >> 24; -} - /* SDL should provide this, really. */ #define SDLK_MODIFIER_MIN 300 #define SDLK_MODIFIER_MAX 314 @@ -884,6 +869,10 @@ IV minpot (UV n) IV popcount (UV n) + CODE: + RETVAL = ecb_popcount32 (n); + OUTPUT: + RETVAL NV distance (NV dx, NV dy) CODE: @@ -2308,7 +2297,7 @@ px = (x + 1) * Th - tex.w; py = (y + 1) * Tw - tex.h; - if (expect_false (cell->player == player) && expect_false (z == 2)) + if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2)) { pl_x = px; pl_y = py; @@ -2361,7 +2350,7 @@ } } - if (expect_false (z == 2) && expect_false (cell->flags)) + if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags)) { // overlays such as the speech bubble, probably more to come if (cell->flags & 1) @@ -2490,7 +2479,7 @@ int px = x * Tw; int py = y * Th; - if (expect_false (cell->player == player)) + if (ecb_expect_false (cell->player == player)) { px += sdx; py += sdy;