Changeset 2923c7b in mainline


Ignore:
Timestamp:
2013-10-16T16:21:44Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f3287e5
Parents:
12d6c98
Message:

Actually implement popcountsi2()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/bitops.c

    r12d6c98 r2923c7b  
    3333#include <bitops.h>
    3434
    35 extern int __popcountsi2(int a)
     35int __popcountsi2(int a)
    3636{
    37         return __builtin_popcount(a);
     37        int bits = 0;
     38        for (unsigned int i = 0; i < sizeof(a) * 8; i++)         {
     39                if (((a >> i) & 1) != 0) {
     40                        bits++;
     41                }
     42        }
     43        return bits;                                                                   
    3844}
    3945
Note: See TracChangeset for help on using the changeset viewer.