mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-22 15:07:43 +08:00
6864c08b94
- For prevent confuse about what BSD license variant we used, 2- or 3-clause license, we change the license to FreeBSD license to make it unambiguously refers to the 2-clause license.
33 lines
771 B
C
33 lines
771 B
C
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
|
|
|
This copyrighted material is made available to anyone wishing to use,
|
|
modify, copy, or redistribute it subject to the terms and conditions
|
|
of the FreeBSD License. This program is distributed in the hope that
|
|
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
|
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. A copy of this license is available at
|
|
http://www.opensource.org/licenses.
|
|
*/
|
|
#include <strings.h>
|
|
|
|
int
|
|
ffs (int word)
|
|
{
|
|
#if __riscv_xlen == 32
|
|
return (__builtin_ffs (word));
|
|
#else
|
|
int i;
|
|
|
|
if (!word)
|
|
return 0;
|
|
|
|
i = 0;
|
|
for (;;)
|
|
{
|
|
if (((1 << i++) & word) != 0)
|
|
return i;
|
|
}
|
|
return 0;
|
|
#endif
|
|
}
|