]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/powerpc/ffs.c
po: Incorporate translations (sr)
[thirdparty/glibc.git] / sysdeps / powerpc / ffs.c
CommitLineData
4cca6b86
UD
1/* Find first set bit in a word, counted from least significant end.
2 For PowerPC.
dff8da6b 3 Copyright (C) 1991-2024 Free Software Foundation, Inc.
41bdb6e2 4 This file is part of the GNU C Library.
4cca6b86
UD
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
4cca6b86
UD
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
4cca6b86 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6 17 License along with the GNU C Library; if not, see
5a82c748 18 <https://www.gnu.org/licenses/>. */
4cca6b86 19
cdb47f09 20#define ffsl __something_else
4e73e115 21#include <limits.h>
1f205a47 22#include <string.h>
4cca6b86 23
cdb47f09
UD
24#undef ffs
25
26#ifdef __GNUC__
27
4cca6b86 28int
19212f87 29__ffs (int x)
4cca6b86
UD
30{
31 int cnt;
32
33 asm ("cntlzw %0,%1" : "=r" (cnt) : "r" (x & -x));
34 return 32 - cnt;
35}
19212f87 36weak_alias (__ffs, ffs)
5bb43a43 37libc_hidden_def (__ffs)
2dd18ce2 38libc_hidden_builtin_def (ffs)
4e73e115 39#if ULONG_MAX == UINT_MAX
cdb47f09
UD
40#undef ffsl
41weak_alias (__ffs, ffsl)
4e73e115 42#endif
cdb47f09
UD
43
44#else
2826ac7e 45#include <string/ffs.c>
cdb47f09 46#endif