[haiku-commits] r40362 - haiku/trunk/src/kits/network/libnetapi

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 5 Feb 2011 17:15:58 +0100 (CET)

Author: kallisti5
Date: 2011-02-05 17:15:58 +0100 (Sat, 05 Feb 2011)
New Revision: 40362
Changeset: http://dev.haiku-os.org/changeset/40362

Modified:
   haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp
Log:
cleanup of some bad language and style within bitfield counting optimization as 
per axel; made addr_bitcount static

Modified: haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp
===================================================================
--- haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp   2011-02-05 
11:34:44 UTC (rev 40361)
+++ haiku/trunk/src/kits/network/libnetapi/NetworkAddress.cpp   2011-02-05 
16:15:58 UTC (rev 40362)
@@ -21,14 +21,15 @@
  * Benefits include faster execution time as the builtin
  * uses a bitcounting cpu instruction if it exists
  */
-#if __GNUC__ >= 4
-#      define BitCount(buffer) __builtin_popcount(buffer)
+#if __GNUC__ > 3
+#      define addr_bitcount(bitfield) __builtin_popcount(bitfield)
 #else
-ssize_t BitCount(uint32 buf)
+static ssize_t
+addr_bitcount(uint32 bitfield)
 {
        ssize_t result = 0;
        for (uint8 i = 32; i > 0; i--) {
-               if ((buf & (1 << (i - 1))) == 0)
+               if ((bitfield & (1 << (i - 1))) == 0)
                        break;
                result++;
        }
@@ -784,14 +785,14 @@
                        sockaddr_in& mask = (sockaddr_in&)fAddress;
 
                        uint32 hostMask = ntohl(mask.sin_addr.s_addr);
-                       return BitCount(hostMask);
+                       return addr_bitcount(hostMask);
                }
 
                case AF_INET6:
                {
                        sockaddr_in6& mask = (sockaddr_in6&)fAddress;
 
-                       // TODO : see if we can use the optimized BitCount for 
this
+                       // TODO : see if we can use the optimized addr_bitcount 
for this
                        ssize_t result = 0;
                        for (uint8 i = 0; i < sizeof(in6_addr); i++) {
                                for (uint8 j = 0; j < 8; j++) {


Other related posts:

  • » [haiku-commits] r40362 - haiku/trunk/src/kits/network/libnetapi - kallisti5