]>
Commit | Line | Data |
---|---|---|
5d39821d KH |
1 | /* The implementation of __ctzhi2. |
2 | Copyright (C) 2003 Free Software Foundation, Inc. | |
3 | ||
7ec022b2 | 4 | This file is part of GCC. |
5d39821d | 5 | |
7ec022b2 | 6 | GCC is free software; you can redistribute it and/or modify |
5d39821d KH |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | In addition to the permissions in the GNU General Public License, the | |
12 | Free Software Foundation gives you unlimited permission to link the | |
13 | compiled version of this file into combinations with other programs, | |
14 | and to distribute those combinations without any restriction coming | |
15 | from the use of this file. (The General Public License restrictions | |
16 | do apply in other respects; for example, they cover modification of | |
17 | the file, and distribution when not linked into a combine | |
18 | executable.) | |
19 | ||
7ec022b2 | 20 | GCC is distributed in the hope that it will be useful, |
5d39821d KH |
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | GNU General Public License for more details. | |
24 | ||
25 | You should have received a copy of the GNU General Public License | |
7ec022b2 | 26 | along with GCC; see the file COPYING. If not, write to |
5d39821d KH |
27 | the Free Software Foundation, 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. */ | |
29 | ||
30 | int | |
31 | __ctzhi2 (unsigned short x) | |
32 | { | |
33 | int i; | |
34 | for (i = 0; i < 16; i++) | |
35 | if (x & ((unsigned short) 1 << i)) | |
36 | break; | |
37 | return i; | |
38 | } |