wdvi

network DVI viewer
Log | Files | Refs

commit d5ae6c5ff3a6e2bc5319001e1058de310e5a5887
parent 2e988f0bdcabc7fd993b185ffbe3e819ae1f353b
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu, 26 Aug 2021 03:35:45 +0000

Pick a definition of BMUNITS and BMBYTES

unsigned int seems reasonable for BMUNITS (bitmap units) but BMBYTES
cannot be calculated at compile time but is needed to define the size of
related types. Use concrete values for both of them.

Add static_assert() such that BMUNIT and BMBYTES are required to be
synchronized.

Diffstat:
Mxdvi.h | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xdvi.h b/xdvi.h @@ -38,6 +38,7 @@ NOTE: #include "config.h" +#include <assert.h> #include <stddef.h> #include <stdlib.h> @@ -150,8 +151,10 @@ typedef Boolean wide_bool; #define spell_conv0(n, f) ((long) (n * f)) #define spell_conv(n) spell_conv0(n, dimconv) -#define BMUNIT unsigned BMTYPE +#define BMUNIT unsigned int +#define BMBYTES 4 /* sizeof(BMUNIT) */ #define BMBITS (8 * BMBYTES) +static_assert(sizeof(BMUNIT) == BMBYTES, "BMUNIT does not match BMBYTES"); #define ADD(a, b) ((BMUNIT *) (((char *) a) + b)) #define SUB(a, b) ((BMUNIT *) (((char *) a) - b))