]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man3/roundup.3
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man3 / roundup.3
CommitLineData
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
7roundup \- round up in steps
8.SH LIBRARY
9Standard 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
18This macro rounds
19.I x
20to the nearest multiple of
21.I step
22that is not less than
23.IR x .
c6d039a3 24.P
87a31c30
AC
25It is typically used for
26rounding up a pointer to align it or
27increasing a buffer to be allocated.
c6d039a3 28.P
87a31c30
AC
29This API is not designed to be generic,
30and doesn't work in some cases
31that are not important for the typical use cases described above.
32See CAVEATS.
33.SH RETURN VALUE
34This macro returns the rounded value.
35.SH STANDARDS
4131356c 36None.
87a31c30
AC
37.SH CAVEATS
38The arguments may be evaluated more than once.
c6d039a3 39.P
87a31c30
AC
40.I x
41should be nonnegative,
42and
43.I step
44should be positive.
c6d039a3 45.P
87a31c30
AC
46If
47.I x + step
48would overflow or wrap around,
49the 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)