From fc22b3d6507c6745911b9dfcc68f1e665ae13dbc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 21:43:11 +0200 Subject: Adding upstream version 4.22.0. Signed-off-by: Daniel Baumann --- upstream/fedora-rawhide/man3/powerof2.3 | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 upstream/fedora-rawhide/man3/powerof2.3 (limited to 'upstream/fedora-rawhide/man3/powerof2.3') diff --git a/upstream/fedora-rawhide/man3/powerof2.3 b/upstream/fedora-rawhide/man3/powerof2.3 new file mode 100644 index 00000000..cd8965f4 --- /dev/null +++ b/upstream/fedora-rawhide/man3/powerof2.3 @@ -0,0 +1,46 @@ +.\" Copyright (C) 2022 Alejandro Colomar +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH powerof2 3 2023-10-31 "Linux man-pages 6.06" +.SH NAME +powerof2 \- test if a value is a power of 2 +.SH LIBRARY +Standard C library +.RI ( libc ) +.SH SYNOPSIS +.nf +.B #include +.P +.BI "int powerof2(" x ); +.fi +.SH DESCRIPTION +This macro returns true if +.I x +is a power of 2, +and false otherwise. +.P +.B 0 +is considered a power of 2. +This can make sense considering wrapping of unsigned integers, +and has interesting properties. +.SH RETURN VALUE +True or false, +if +.I x +is a power of 2 or not, +respectively. +.SH STANDARDS +BSD. +.SH CAVEATS +The arguments may be evaluated more than once. +.P +Because this macro is implemented using bitwise operations, +some negative values can invoke undefined behavior. +For example, +the following invokes undefined behavior: +.IR "powerof2(INT_MIN);". +Call it only with unsigned types to be safe. +.SH SEE ALSO +.BR stdc_bit_ceil (3), +.BR stdc_bit_floor (3) -- cgit v1.2.3