summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Jacob <mjacob@FreeBSD.org>2001-07-04 05:16:56 +0000
committerMatt Jacob <mjacob@FreeBSD.org>2001-07-04 05:16:56 +0000
commitd99b6ac2d7e0fc37fc393dd33b9e4fb761cbc647 (patch)
tree257b5a0157e2802e22856227886a7c12cfcfd5c0
parent555451d3c88b343a1db87904b589f63cce751be6 (diff)
Notes
-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 7c0f1af3eafa..0a0206eff3fc 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