From: Alan Cox Date: Sat, 21 Feb 2015 00:31:09 +0000 (+0000) Subject: kernel: Add a definition for BLKOFF(x) which does the right casting X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5540395e689b44ba2284a42e43d57f2a218a5260;p=FUZIX.git kernel: Add a definition for BLKOFF(x) which does the right casting This avoids promotion to long and ugly code coming out of the Z80 compiler in particular (and excessive code on 6502). --- diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index a87240a1..055665bd 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -93,6 +93,9 @@ typedef uint16_t blkno_t; /* Can have 65536 512-byte blocks in filesystem */ #define BLKSHIFT 9 #define BLKMASK 511 +/* Help the 8bit compilers out by preventing any 32bit promotions */ +#define BLKOFF(x) (((uint16_t)(x)) & BLKMASK) + /* we need a busier-than-busy state for superblocks, so that if those blocks * are read by userspace through bread() they are not subsequently freed by * bfree() until the filesystem is unmounted */