X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..bd6d65e32b835551677456bf286d09ced6859882:/symm/ghash-def.h diff --git a/symm/ghash-def.h b/symm/ghash-def.h index 2ede96f3..6aef1175 100644 --- a/symm/ghash-def.h +++ b/symm/ghash-def.h @@ -58,57 +58,58 @@ * Use: Defines the generic hash instance. */ -#define GHASH_DEF(PRE, pre) \ +#define GHASH_DEF(PRE, pre) GHASH_DEFX(PRE, pre, #pre) +#define GHASH_DEFX(PRE, pre, name) \ \ -static const ghash_ops gops; \ +static const ghash_ops gops_##pre; \ \ -typedef struct gctx { \ +typedef struct gctx_##pre { \ ghash h; \ pre##_ctx c; \ octet buf[PRE##_HASHSZ]; \ -} gctx; \ +} gctx_##pre; \ \ -static ghash *ghinit(void) \ +static ghash *ghinit_##pre(void) \ { \ - gctx *g = S_CREATE(gctx); \ - g->h.ops = &gops; \ + gctx_##pre *g = S_CREATE(gctx_##pre); \ + g->h.ops = &gops_##pre; \ pre##_init(&g->c); \ return (&g->h); \ } \ \ -static void ghhash(ghash *h, const void *p, size_t sz) \ +static void ghhash_##pre(ghash *h, const void *p, size_t sz) \ { \ - gctx *g = (gctx *)h; \ + gctx_##pre *g = (gctx_##pre *)h; \ pre##_hash(&g->c, p, sz); \ } \ \ -static octet *ghdone(ghash *h, void *buf) \ +static octet *ghdone_##pre(ghash *h, void *buf) \ { \ - gctx *g = (gctx *)h; \ + gctx_##pre *g = (gctx_##pre *)h; \ if (!buf) \ buf = g->buf; \ pre##_done(&g->c, buf); \ return (buf); \ } \ \ -static void ghdestroy(ghash *h) \ +static void ghdestroy_##pre(ghash *h) \ { \ - gctx *g = (gctx *)h; \ + gctx_##pre *g = (gctx_##pre *)h; \ BURN(*g); \ S_DESTROY(g); \ } \ \ -static ghash *ghcopy(ghash *h) \ +static ghash *ghcopy_##pre(ghash *h) \ { \ - gctx *g = (gctx *)h; \ - gctx *gg = S_CREATE(gctx); \ - memcpy(gg, g, sizeof(gctx)); \ + gctx_##pre *g = (gctx_##pre *)h; \ + gctx_##pre *gg = S_CREATE(gctx_##pre); \ + memcpy(gg, g, sizeof(gctx_##pre)); \ return (&gg->h); \ } \ \ -static const ghash_ops gops = \ - { &pre, ghhash, ghdone, ghdestroy, ghcopy }; \ -const gchash pre = { #pre, PRE##_HASHSZ, ghinit, PRE##_BUFSZ }; +static const ghash_ops gops_##pre = \ + { &pre, ghhash_##pre, ghdone_##pre, ghdestroy_##pre, ghcopy_##pre }; \ +const gchash pre = { name, PRE##_HASHSZ, ghinit_##pre, PRE##_BUFSZ }; /*----- That's all, folks -------------------------------------------------*/