Update.
[glibc.git] / sysdeps / i960 / ffs.c
blobdc09ba90e829cee68f72785fa039a1480a7278a5
1 /* ffs -- find first set bit in a word, counted from least significant end.
2 For i960 Core architecture
3 This file is part of the GNU C Library.
4 Copyright (C) 1994, 1997 Free Software Foundation, Inc.
5 Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
6 On-Line Applications Research Corporation.
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with the GNU C Library; see the file COPYING.LIB. If not,
20 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #include <string.h>
25 #undef ffs
27 #if defined (__GNUC__) && defined (__i960__)
29 int
30 __ffs (x)
31 int x;
33 int cnt;
35 asm ("scanbit %1,%0" : "=d" (cnt) : "rm" (x & -x));
37 return cnt;
39 weak_alias (__ffs, ffs)
41 #else
43 #include <sysdeps/generic/ffs.c>
45 #endif