source: trunk/Softwares/MiBench/src/c/bitcount-bitcnt_2.c @ 128

Last change on this file since 128 was 117, checked in by rosiere, 15 years ago

1) Platforms : add new organization for test
2) Load_Store_Unit : add array to count nb_check in store_queue
3) Issue_queue and Core_Glue : rewrite the issue network
4) Special_Register_Unit : add reset value to register CID
5) Softwares : add multicontext test
6) Softwares : add SPECINT
7) Softwares : add MiBench?
7) Read_queue : inhib access for r0
8) Change Core_Glue (network) - dont yet support priority and load balancing scheme

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 841 bytes
Line 
1/* +++Date last modified: 05-Jul-1997 */
2
3/*
4**  Bit counter by Ratko Tomic
5*/
6
7#include "bitcount-bitops.h"
8
9int CDECL bitcount(long i)
10{
11      i = ((i & 0xAAAAAAAAL) >>  1) + (i & 0x55555555L);
12      i = ((i & 0xCCCCCCCCL) >>  2) + (i & 0x33333333L);
13      i = ((i & 0xF0F0F0F0L) >>  4) + (i & 0x0F0F0F0FL);
14      i = ((i & 0xFF00FF00L) >>  8) + (i & 0x00FF00FFL);
15      i = ((i & 0xFFFF0000L) >> 16) + (i & 0x0000FFFFL);
16      return (int)i;
17}
18
19#ifdef TEST
20
21#include <stdlib.h>
22#include "snip_str.h"               /* For plural_text() macro    */
23
24main(int argc, char *argv[])
25{
26      long n;
27
28      while(--argc)
29      {
30            int i;
31
32            n = atol(*++argv);
33            i = bitcount(n);
34            printf("%ld contains %d bit%s set\n",
35                  n, i, plural_text(i));
36      }
37      return 0;
38}
39
40#endif /* TEST */
Note: See TracBrowser for help on using the repository browser.