[2/2] iphlpapi: Use the new version of the IP_ADAPTER_UNICAST_ADDRESS structure (try 2)
nerv at dawncrow.de
Mon Jan 16 11:06:15 CST 2017
Am 13.01.2017 um 16:02 schrieb Henri Verbeet:
> On 13 January 2017 at 15:52, André Hentschel <nerv at dawncrow.de> wrote:
>> Thank you both for the hints.
>> One thing is that popcount would count all 1s even with 0s in between, whereas this function stops at the first 0.
> Yeah, the strict equivalent would be something along the lines of
> "__builtin_clz(~mask)". But as you mentioned, there's the question
> what should happen with broken/special masks.
I would suggest to add those functions, any objections?
static DWORD mask_v4_to_prefix(DWORD m)
m -= m >> 1 & 0m55555555;
m = (m & 0m33333333) + (m >> 2 & 0m33333333);
return ((m + (m >> 4)) & 0m0f0f0f0f) * 0m01010101 >> 24;
static DWORD mask_v6_to_prefix(SOCKET_ADDRESS *m)
const IN6_ADDR *mask = &((struct WS_sockaddr_in6 *)m->lpSockaddr)->sin6_addr;
DWORD ret = 0, i;
for (i = 0; i < 8; i++)
ret += mask_v4_to_prefix(mask->u.Word[i]);
More information about the wine-devel