diff options
| author | Matthew Dobson <colpatch@us.ibm.com> | 2003-02-05 22:55:32 -0800 |
|---|---|---|
| committer | Christoph Hellwig <hch@lab343.munich.sgi.com> | 2003-02-05 22:55:32 -0800 |
| commit | ea4e0b5bc6a86a370d5b7089af4d9aa901cecf9c (patch) | |
| tree | a29b51d0344c48e60596e8c920f8a14148d15c3d /include/linux | |
| parent | 3fa327f8a756c99e76fc5f95459fc85a45bcafc5 (diff) | |
[PATCH] Broken CLEAR_BITMAP() macro
The CLEAR_BITMAP() macro in include/linux/types.h is broken and doesn't
round the bitmap size to the proper 'long' boundary.
This fixes it by creating a macro BITS_TO_LONGS that just rounds a
number of bits up to the closest number of unsigned longs. This makes
the DECLARE & CLEAR _BITMAP macros more readable and fixes the bug.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/types.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/types.h b/include/linux/types.h index 94ceb057eb64..f1c0ce5eb845 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -4,10 +4,12 @@ #ifdef __KERNEL__ #include <linux/config.h> +#define BITS_TO_LONGS(bits) \ + (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ - unsigned long name[((bits)+BITS_PER_LONG-1)/BITS_PER_LONG] + unsigned long name[BITS_TO_LONGS(bits)] #define CLEAR_BITMAP(name,bits) \ - memset(name, 0, ((bits)+BITS_PER_LONG-1)/8) + memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long)) #endif #include <linux/posix_types.h> |
