]>
Commit | Line | Data |
---|---|---|
87a31c30 AC |
1 | .\" Copyright (C) 2023 Alejandro Colomar <alx@kernel.org> |
2 | .\" | |
3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft | |
4 | .\" | |
5 | .TH roundup 3 (date) "Linux man-pages (unreleased)" | |
6 | .SH NAME | |
7 | roundup \- round up in steps | |
8 | .SH LIBRARY | |
9 | Standard C library | |
10 | .RI ( libc ) | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .B #include <sys/param.h> | |
c6d039a3 | 14 | .P |
87a31c30 AC |
15 | .BI roundup( x ", " step ); |
16 | .fi | |
17 | .SH DESCRIPTION | |
18 | This macro rounds | |
19 | .I x | |
20 | to the nearest multiple of | |
21 | .I step | |
22 | that is not less than | |
23 | .IR x . | |
c6d039a3 | 24 | .P |
87a31c30 AC |
25 | It is typically used for |
26 | rounding up a pointer to align it or | |
27 | increasing a buffer to be allocated. | |
c6d039a3 | 28 | .P |
87a31c30 AC |
29 | This API is not designed to be generic, |
30 | and doesn't work in some cases | |
31 | that are not important for the typical use cases described above. | |
32 | See CAVEATS. | |
33 | .SH RETURN VALUE | |
34 | This macro returns the rounded value. | |
35 | .SH STANDARDS | |
4131356c | 36 | None. |
87a31c30 AC |
37 | .SH CAVEATS |
38 | The arguments may be evaluated more than once. | |
c6d039a3 | 39 | .P |
87a31c30 AC |
40 | .I x |
41 | should be nonnegative, | |
42 | and | |
43 | .I step | |
44 | should be positive. | |
c6d039a3 | 45 | .P |
87a31c30 AC |
46 | If |
47 | .I x + step | |
48 | would overflow or wrap around, | |
49 | the behavior is undefined. | |
50 | .SH SEE ALSO | |
51 | .BR ceil (3), | |
52 | .BR floor (3), | |
53 | .BR lrint (3), | |
54 | .BR rint (3), | |
55 | .BR lround (3), | |
56 | .BR round (3) |