summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2001-07-04 05:16:56 +0000
committermjacob <mjacob@FreeBSD.org>2001-07-04 05:16:56 +0000
commitd506b2b2f1707872a011c76f0e6b0786f8c1c3be (patch)
tree257b5a0157e2802e22856227886a7c12cfcfd5c0
parentfcd999f3208dbbbd35a679be613f90244a28dbba (diff)
downloadFreeBSD-src-d506b2b2f1707872a011c76f0e6b0786f8c1c3be.zip
FreeBSD-src-d506b2b2f1707872a011c76f0e6b0786f8c1c3be.tar.gz
Follow Bruce's suggestions. They're probably wrong, but better than before.
-rw-r--r--sys/alpha/include/param.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/alpha/include/param.h b/sys/alpha/include/param.h
index 7c0f1af..0a0206e 100644
--- a/sys/alpha/include/param.h
+++ b/sys/alpha/include/param.h
@@ -157,9 +157,16 @@
#define ctob(x) ((x) << PAGE_SHIFT)
#define btoc(x) (((x) + PAGE_MASK) >> PAGE_SHIFT)
-/* bytes to disk blocks */
-#define btodb(x) ((x) >> DEV_BSHIFT)
-#define dbtob(x) ((x) << DEV_BSHIFT)
+/*
+ * btodb() is messy and perhaps slow because `bytes' may be an off_t. We
+ * want to shift an unsigned type to avoid sign extension and we don't
+ * want to widen `bytes' unnecessarily. Assume that the result fits in
+ * a daddr_t.
+ */
+#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
+ (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)
+#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
+ ((off_t)(db) << DEV_BSHIFT)
/*
* Mach derived conversion macros
OpenPOWER on IntegriCloud