Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 351376
b: refs/heads/master
c: 9f2e733
h: refs/heads/master
v: v3
  • Loading branch information
YOSHIFUJI Hideaki / 吉藤英明 authored and David S. Miller committed Jan 14, 2013
1 parent e5e3d94 commit 86e335f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25d46f43a911b08c5aa8c8fd4fe7fa9b36445068
refs/heads/master: 9f2e73345ad9466618edfec35d98c074f2e0570d
29 changes: 28 additions & 1 deletion trunk/include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static inline void ipv6_addr_set_v4mapped(const __be32 addr,
* find the first different bit between two addresses
* length of address must be a multiple of 32bits
*/
static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen)
{
const __be32 *a1 = token1, *a2 = token2;
int i;
Expand Down Expand Up @@ -539,6 +539,33 @@ static inline int __ipv6_addr_diff(const void *token1, const void *token2, int a
return addrlen << 5;
}

#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
static inline int __ipv6_addr_diff64(const void *token1, const void *token2, int addrlen)
{
const __be64 *a1 = token1, *a2 = token2;
int i;

addrlen >>= 3;

for (i = 0; i < addrlen; i++) {
__be64 xb = a1[i] ^ a2[i];
if (xb)
return i * 64 + 63 - __fls(be64_to_cpu(xb));
}

return addrlen << 6;
}
#endif

static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
{
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
if (__builtin_constant_p(addrlen) && !(addrlen & 7))
return __ipv6_addr_diff64(token1, token2, addrlen);
#endif
return __ipv6_addr_diff32(token1, token2, addrlen);
}

static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2)
{
return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
Expand Down

0 comments on commit 86e335f

Please sign in to comment.