X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/dfd1608a672a1d476a91af174e02946071b8a1a0..5d01b1b9514a258c5a3c201e944f676cb2c467f0:/ghash.h diff --git a/ghash.h b/ghash.h index d3a039b..d20aff4 100644 --- a/ghash.h +++ b/ghash.h @@ -7,7 +7,7 @@ * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -61,9 +61,9 @@ typedef struct ghash_ops { #define GH_DESTROY(h) (h)->ops->destroy((h)) #define GH_COPY(h) (h)->ops->copy((h)) -#define GH_HASHU_(h, n, w) do { \ - unsigned long n_ = (n); octet b_[SZ_##w]; \ - STORE##w(b_, n_); GH_HASH((h), b_, SZ_##w); \ +#define GH_HASHU_(h, n, W) do { \ + TY_U##W n_ = (n); octet b_[SZ_##W]; \ + STORE##W(b_, n_); GH_HASH((h), b_, SZ_##W); \ } while (0) #define GH_HASHU8(h, n) GH_HASHU_((h), (n), 8) #define GH_HASHU16(h, n) GH_HASHU_((h), (n), 16) @@ -75,10 +75,15 @@ typedef struct ghash_ops { #define GH_HASHU32(h, n) GH_HASHU_((h), (n), 32) #define GH_HASHU32_B(h, n) GH_HASHU_((h), (n), 32_B) #define GH_HASHU32_L(h, n) GH_HASHU_((h), (n), 32_L) +#ifdef HAVE_UINT64 +# define GH_HASHU64(h, n) GH_HASHU_((h), (n), 64) +# define GH_HASHU64_B(h, n) GH_HASHU_((h), (n), 64_B) +# define GH_HASHU64_L(h, n) GH_HASHU_((h), (n), 64_L) +#endif -#define GH_HASHBUF_(h, p, sz, w) do { \ - size_t sz_ = (sz); assert(sz_ <= MASK##w); \ - GH_HASHU_(h, sz_, w); GH_HASH(h, (p), sz_); \ +#define GH_HASHBUF_(h, p, sz, W) do { \ + size_t sz_ = (sz); assert(sz_ <= MASK##W); \ + GH_HASHU_(h, sz_, W); GH_HASH(h, (p), sz_); \ } while (0) #define GH_HASHBUF8(h, p, sz) GH_HASHBUF_((h), (p), (sz), 8) #define GH_HASHBUF16(h, p, sz) GH_HASHBUF_((h), (p), (sz), 16) @@ -90,9 +95,14 @@ typedef struct ghash_ops { #define GH_HASHBUF32(h, p, sz) GH_HASHBUF_((h), (p), (sz), 32) #define GH_HASHBUF32_L(h, p, sz) GH_HASHBUF_((h), (p), (sz), 32_L) #define GH_HASHBUF32_B(h, p, sz) GH_HASHBUF_((h), (p), (sz), 32_B) +#ifdef HAVE_UINT64 +# define GH_HASHBUF64(h, p, sz) GH_HASHBUF_((h), (p), (sz), 64) +# define GH_HASHBUF64_L(h, p, sz) GH_HASHBUF_((h), (p), (sz), 64_L) +# define GH_HASHBUF64_B(h, p, sz) GH_HASHBUF_((h), (p), (sz), 64_B) +#endif -#define GH_HASHSTR_(h, p, w) do { \ - const char *p_ = (p); GH_HASHBUF_((h), p_, strlen(p_), w); \ +#define GH_HASHSTR_(h, p, W) do { \ + const char *p_ = (p); GH_HASHBUF_((h), p_, strlen(p_), W); \ } while (0) #define GH_HASHSTR8(h, p) GH_HASHSTR_((h), (p), 8) #define GH_HASHSTR16(h, p) GH_HASHSTR_((h), (p), 16) @@ -104,6 +114,11 @@ typedef struct ghash_ops { #define GH_HASHSTR32(h, p) GH_HASHSTR_((h), (p), 32) #define GH_HASHSTR32_L(h, p) GH_HASHSTR_((h), (p), 32_L) #define GH_HASHSTR32_B(h, p) GH_HASHSTR_((h), (p), 32_B) +#ifdef HAVE_UINT64 +# define GH_HASHSTR64(h, p) GH_HASHSTR_((h), (p), 64) +# define GH_HASHSTR64_L(h, p) GH_HASHSTR_((h), (p), 64_L) +# define GH_HASHSTR64_B(h, p) GH_HASHSTR_((h), (p), 64_B) +#endif #define GH_HASHSTRZ(h, p) do { \ const char *p_ = (p); GH_HASH((h), p_, strlen(p_) + 1); \