From 5540395e689b44ba2284a42e43d57f2a218a5260 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 21 Feb 2015 00:31:09 +0000 Subject: [PATCH] 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). --- Kernel/include/kernel.h | 3 +++ 1 file changed, 3 insertions(+) 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 */ -- 2.34.1