xref: /freebsd/sys/sys/_param.h (revision b93161a7e38d37ce560ca562b1f1c18f73551cc2)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1982, 1986, 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  * (c) UNIX System Laboratories, Inc.
7  */
8 
9 #ifndef _SYS__PARAM_H_
10 #define _SYS__PARAM_H_
11 
12 #define NBBY	8		/* number of bits in a byte */
13 #define NBPW	sizeof(int)	/* number of bytes per word (integer) */
14 
15 /*
16  * Macros for counting and rounding.
17  */
18 #define	nitems(x)	(sizeof((x)) / sizeof((x)[0]))
19 #ifndef howmany
20 #define howmany(x, y)	(((x)+((y)-1))/(y))
21 #endif
22 #define	rounddown(x, y)	(((x)/(y))*(y))
23 #define	rounddown2(x, y) __align_down(x, y) /* if y is power of two */
24 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
25 #define	roundup2(x, y)	__align_up(x, y) /* if y is powers of two */
26 #define powerof2(x)	((((x)-1)&(x))==0)
27 
28 #endif /* _SYS__PARAM_H_ */
29