Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
Show All 40 Lines | |||||
#endif | #endif | ||||
/* | /* | ||||
* Some macros for units conversion | * Some macros for units conversion | ||||
*/ | */ | ||||
/* | /* | ||||
* Disk blocks (sectors) and bytes. | * Disk blocks (sectors) and bytes. | ||||
*/ | */ | ||||
#ifndef dtob | |||||
#define dtob(DD) ((DD) << DEV_BSHIFT) | #define dtob(DD) ((DD) << DEV_BSHIFT) | ||||
#endif | |||||
#ifndef btod | |||||
#define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) | #define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) | ||||
#endif | |||||
#define btodt(BB) ((BB) >> DEV_BSHIFT) | #define btodt(BB) ((BB) >> DEV_BSHIFT) | ||||
#define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) | #define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) | ||||
/* common macros */ | /* common macros */ | ||||
#ifndef MIN | #ifndef MIN | ||||
#define MIN(a, b) ((a) < (b) ? (a) : (b)) | #define MIN(a, b) ((a) < (b) ? (a) : (b)) | ||||
#endif | #endif | ||||
#ifndef MAX | #ifndef MAX | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Macro for checking power of 2 address alignment. | * Macro for checking power of 2 address alignment. | ||||
*/ | */ | ||||
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) | #define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) | ||||
/* | /* | ||||
* Macros for counting and rounding. | * Macros for counting and rounding. | ||||
*/ | */ | ||||
#ifndef howmany | |||||
#define howmany(x, y) (((x)+((y)-1))/(y)) | #define howmany(x, y) (((x)+((y)-1))/(y)) | ||||
#endif | |||||
#ifndef roundup | |||||
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | ||||
#endif | |||||
/* | /* | ||||
* Macro to determine if value is a power of 2 | * Macro to determine if value is a power of 2 | ||||
*/ | */ | ||||
#define ISP2(x) (((x) & ((x) - 1)) == 0) | #define ISP2(x) (((x) & ((x) - 1)) == 0) | ||||
/* | /* | ||||
* Macros for various sorts of alignment and rounding. The "align" must | * Macros for various sorts of alignment and rounding. The "align" must | ||||
* be a power of 2. Often times it is a block, sector, or page. | * be a power of 2. Often times it is a block, sector, or page. | ||||
▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines |