OSDN Git Service

Update FSF address.
[pf3gnuchains/gcc-fork.git] / gcc / config / h8300 / popcounthi2.c
1 /* The implementation of __popcounthi2.
2    Copyright (C) 2003  Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify
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
20 GCC is distributed in the hope that it will be useful,
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
26 along with GCC; see the file COPYING.  If not, write to
27 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA.  */
29
30 int __popcounthi2 (unsigned short x);
31
32 int
33 __popcounthi2 (unsigned short x)
34 {
35   int i;
36   int count = 0;
37   for (i = 0; i < 16; i++)
38     if (x & ((unsigned short) 1 << i))
39       count++;
40   return count;
41 }