| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: bitops.h,v 1.11 2015/10/13 00:42:59 riastradh Exp $ */ | | 1 | /* $NetBSD: bitops.h,v 1.12 2018/08/06 00:29:49 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -59,27 +59,27 @@ __ffs64(uint64_t x) | | | @@ -59,27 +59,27 @@ __ffs64(uint64_t x) |
59 | { | | 59 | { |
60 | | | 60 | |
61 | KASSERT(x != 0); | | 61 | KASSERT(x != 0); |
62 | return ffs64(x) - 1; | | 62 | return ffs64(x) - 1; |
63 | } | | 63 | } |
64 | | | 64 | |
65 | static inline unsigned int | | 65 | static inline unsigned int |
66 | hweight16(uint16_t n) | | 66 | hweight16(uint16_t n) |
67 | { | | 67 | { |
68 | return popcount32(n); | | 68 | return popcount32(n); |
69 | } | | 69 | } |
70 | | | 70 | |
71 | static inline unsigned int | | 71 | static inline unsigned int |
72 | hweight32(uint16_t n) | | 72 | hweight32(uint32_t n) |
73 | { | | 73 | { |
74 | return popcount32(n); | | 74 | return popcount32(n); |
75 | } | | 75 | } |
76 | | | 76 | |
77 | /* | | 77 | /* |
78 | * XXX Don't define BITS_PER_LONG as sizeof(unsigned long)*CHAR_BIT | | 78 | * XXX Don't define BITS_PER_LONG as sizeof(unsigned long)*CHAR_BIT |
79 | * because that won't work in preprocessor conditionals, where it often | | 79 | * because that won't work in preprocessor conditionals, where it often |
80 | * turns up. | | 80 | * turns up. |
81 | */ | | 81 | */ |
82 | | | 82 | |
83 | #define BITS_TO_LONGS(n) \ | | 83 | #define BITS_TO_LONGS(n) \ |
84 | roundup2((n), (sizeof(unsigned long) * CHAR_BIT)) | | 84 | roundup2((n), (sizeof(unsigned long) * CHAR_BIT)) |
85 | | | 85 | |