kernel: Add a definition for BLKOFF(x) which does the right casting
authorAlan Cox <alan@linux.intel.com>
Sat, 21 Feb 2015 00:31:09 +0000 (00:31 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 21 Feb 2015 00:31:09 +0000 (00:31 +0000)
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

index a87240a..055665b 100644 (file)
@@ -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 */