From 9eae2b485a53deec4bd83c7d4e1a53ec0d8097d1 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 4 Mar 2012 20:14:18 +0000 Subject: [PATCH] ATTRIBUTE((pure)) for Ptile2tile(), add a forgotten comment. git-svn-id: https://svn.eduke32.com/eduke32@2412 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 2 +- polymer/eduke32/build/include/compat.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 8cc08eff3..ffcc3e2e0 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -799,7 +799,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]); int32_t hicclearsubst(int32_t picnum, int32_t palnum); -int32_t Ptile2tile(int32_t tile, int32_t pallet); +int32_t Ptile2tile(int32_t tile, int32_t pallet) ATTRIBUTE((pure)); int32_t md_loadmodel(const char *fn); int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags); // int32_t md_tilehasmodel(int32_t tilenume, int32_t pal); diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 82f974e15..32751a8d4 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -395,7 +395,7 @@ static inline __attribute__((warn_unused_result)) int clamp(int in, int min, int static inline int clamp(int in, int min, int max) #endif { - return in <= min ? min : in >= max ? max : in; + return in <= min ? min : (in >= max ? max : in); } #define BMAX_PATH 256 @@ -504,6 +504,10 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff # define Bstrlen strlen # define Bstrchr strchr # define Bstrrchr strrchr +// XXX: different across 32- and 64-bit archs (e.g. +// parsing the decimal representation of 0xffffffff, +// 4294967295 -- long is signed, so strtol would +// return LONG_MAX (== 0x7fffffff on 32-bit archs)) # define Batoi(str) ((int32_t)strtol(str, NULL, 10)) # define Batol(str) (strtol(str, NULL, 10)) # define Bstrtol strtol