Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / machine / riscv / ffs.c
blob2f2176e68b234501ea5fd1c84848ba13a048248e
1 /* Copyright (c) 2017 SiFive Inc. All rights reserved.
3 This copyrighted material is made available to anyone wishing to use,
4 modify, copy, or redistribute it subject to the terms and conditions
5 of the FreeBSD License. This program is distributed in the hope that
6 it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7 including the implied warranties of MERCHANTABILITY or FITNESS FOR
8 A PARTICULAR PURPOSE. A copy of this license is available at
9 http://www.opensource.org/licenses.
11 #include <strings.h>
13 int
14 ffs (int word)
16 #if __riscv_xlen == 32
17 return (__builtin_ffs (word));
18 #else
19 int i;
21 if (!word)
22 return 0;
24 i = 0;
25 for (;;)
27 if (((1 << i++) & word) != 0)
28 return i;
30 return 0;
31 #endif