Changeset 18dc93c in mainline
 Timestamp:
 20131119T08:30:03Z (11 years ago)
 Branches:
 lfn, master, serial, ticket/834toolchainupdate, topic/msimupgrade, topic/simplifydevexport
 Children:
 5f9768bb
 Parents:
 879d7745
 Location:
 uspace/lib/softint
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

uspace/lib/softint/generic/bits.c
r879d7745 r18dc93c 33 33 #include <bits.h> 34 34 35 /** Compute number of trailing 0bits in a number. */ 36 int __ctzdi2(long a) 37 { 38 unsigned int bits = 0; 39 while (((a >> bits) & 1) == 0) { 40 bits++; 41 if (bits >= sizeof(a) * 8) { 42 break; 43 } 44 } 45 46 return bits; 47 } 48 49 /** Compute number of trailing 0bits in a number. */ 50 int __ctzsi2(int a) 51 { 52 unsigned int bits = 0; 53 while (((a >> bits) & 1) == 0) { 54 bits++; 55 if (bits >= sizeof(a) * 8) { 56 break; 57 } 58 } 59 60 return bits; 61 } 62 63 /** Compute number of leading 0bits in a number. */ 64 int __clzdi2(long a) 65 { 66 int index = sizeof(a) * 8  1; 67 int bits = 0; 68 while (index >= 0) { 69 if (((a >> index) & 1) == 0) { 70 bits++; 71 } else { 72 break; 73 } 74 index; 75 } 76 77 return bits; 78 } 79 80 /** Compute index of the first 1bit in a number increased by one. 81 * 82 * If the number is zero, zero is returned. 83 */ 84 int __ffsdi2(long a) { 85 if (a == 0) { 86 return 0; 87 } 88 89 return 1 + __ctzdi2(a); 90 } 91 35 92 /** Compute number of set bits in a number. */ 36 93 int __popcountsi2(int a) 
uspace/lib/softint/include/bits.h
r879d7745 r18dc93c 36 36 #define __SOFTINT_BITS_H_ 37 37 38 extern int __ctzdi2(long); 39 extern int __ctzsi2(int); 40 extern int __clzdi2(long); 41 extern int __ffsdi2(long); 38 42 extern int __popcountsi2(int); 39 43 extern int __popcountdi2(long);
Note:
See TracChangeset
for help on using the changeset viewer.