README: Update links
[man-pages.git] / man3 / roundup.3
blob376591a11b29a4df68d022a320eb91df66bf9d0a
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>
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 .
25 It is typically used for
26 rounding up a pointer to align it or
27 increasing a buffer to be allocated.
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
36 None.
37 .SH CAVEATS
38 The arguments may be evaluated more than once.
40 .I x
41 should be nonnegative,
42 and
43 .I step
44 should be positive.
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)