diff options
| author | claudio <> | 2025-10-24 11:30:06 +0000 |
|---|---|---|
| committer | claudio <> | 2025-10-24 11:30:06 +0000 |
| commit | 8cbd4e746f40c750809e34d04c0298e0a5ff6f42 (patch) | |
| tree | de417cfcebbdd39fd868b5b5a0569e386e25b92f /src/lib/libc/string/ffs.3 | |
| parent | 2e803cbe8e599c0ae52e9dda44c3d22e3dec105d (diff) | |
| download | openbsd-8cbd4e746f40c750809e34d04c0298e0a5ff6f42.tar.gz openbsd-8cbd4e746f40c750809e34d04c0298e0a5ff6f42.tar.bz2 openbsd-8cbd4e746f40c750809e34d04c0298e0a5ff6f42.zip | |
Implement ffsl() and ffsll() using the compiler builtin __builtin_ctzl
now that all archs use at least gcc4.
ffsl() and ffsll() are now part of POSIX.
OK deraadt@, input from miod@ and jsg@
Diffstat (limited to 'src/lib/libc/string/ffs.3')
| -rw-r--r-- | src/lib/libc/string/ffs.3 | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3 index e78ab99e8f..630db1c584 100644 --- a/src/lib/libc/string/ffs.3 +++ b/src/lib/libc/string/ffs.3 | |||
| @@ -27,22 +27,31 @@ | |||
| 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. |
| 29 | .\" | 29 | .\" |
| 30 | .\" $OpenBSD: ffs.3,v 1.11 2019/08/30 18:35:03 deraadt Exp $ | 30 | .\" $OpenBSD: ffs.3,v 1.12 2025/10/24 11:30:06 claudio Exp $ |
| 31 | .\" | 31 | .\" |
| 32 | .Dd $Mdocdate: August 30 2019 $ | 32 | .Dd $Mdocdate: October 24 2025 $ |
| 33 | .Dt FFS 3 | 33 | .Dt FFS 3 |
| 34 | .Os | 34 | .Os |
| 35 | .Sh NAME | 35 | .Sh NAME |
| 36 | .Nm ffs | 36 | .Nm ffs , |
| 37 | .Nm ffsl , | ||
| 38 | .Nm ffsll | ||
| 37 | .Nd find first bit set in a bit string | 39 | .Nd find first bit set in a bit string |
| 38 | .Sh SYNOPSIS | 40 | .Sh SYNOPSIS |
| 39 | .In strings.h | 41 | .In strings.h |
| 40 | .Ft int | 42 | .Ft int |
| 41 | .Fn ffs "int value" | 43 | .Fn ffs "int value" |
| 44 | .Ft int | ||
| 45 | .Fn ffsl "long value" | ||
| 46 | .Ft int | ||
| 47 | .Fn ffsll "long long value" | ||
| 42 | .Sh DESCRIPTION | 48 | .Sh DESCRIPTION |
| 43 | The | 49 | The |
| 44 | .Fn ffs | 50 | .Fn ffs , |
| 45 | function finds the first bit set in | 51 | .Fn ffsl |
| 52 | and | ||
| 53 | .Fn ffsll | ||
| 54 | functions find the first bit set in | ||
| 46 | .Fa value | 55 | .Fa value |
| 47 | and returns the index of that bit. | 56 | and returns the index of that bit. |
| 48 | Bits are numbered starting from 1, starting at the rightmost bit. | 57 | Bits are numbered starting from 1, starting at the rightmost bit. |
| @@ -54,8 +63,20 @@ The | |||
| 54 | .Fn ffs | 63 | .Fn ffs |
| 55 | function conforms to | 64 | function conforms to |
| 56 | .St -p1003.1-2008 . | 65 | .St -p1003.1-2008 . |
| 66 | The | ||
| 67 | .Fn ffsl | ||
| 68 | and | ||
| 69 | .Fn ffsll | ||
| 70 | functions conform to | ||
| 71 | .St -p1003.1-2024 . | ||
| 57 | .Sh HISTORY | 72 | .Sh HISTORY |
| 58 | The | 73 | The |
| 59 | .Fn ffs | 74 | .Fn ffs |
| 60 | function first appeared in | 75 | function first appeared in |
| 61 | .Bx 4.2 . | 76 | .Bx 4.2 . |
| 77 | The | ||
| 78 | .Fn ffsl | ||
| 79 | and | ||
| 80 | .Fn ffsll | ||
| 81 | functions first appeared in | ||
| 82 | .Ox 7.9 . | ||
