diff options
author | dfr <dfr@FreeBSD.org> | 2002-04-06 12:55:48 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2002-04-06 12:55:48 +0000 |
commit | 447927a106846f75d712cf401c59cd053424d605 (patch) | |
tree | 583c32705a40683d683d10eb5b66c10ee0f7860b /sys/ia64/include/param.h | |
parent | b7178f19de40ee6c36daa89de6471de97997b442 (diff) | |
download | FreeBSD-src-447927a106846f75d712cf401c59cd053424d605.zip FreeBSD-src-447927a106846f75d712cf401c59cd053424d605.tar.gz |
Merge fixes for dbtob() and btodb() from alpha/include/param.h. This stops
ffs_snapshot() from using negative numbers for byte offsets in large file
systems.
Diffstat (limited to 'sys/ia64/include/param.h')
-rw-r--r-- | sys/ia64/include/param.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/ia64/include/param.h b/sys/ia64/include/param.h index db87619..a516325 100644 --- a/sys/ia64/include/param.h +++ b/sys/ia64/include/param.h @@ -185,9 +185,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 |