diff options
| author | dholland <dholland@NetBSD.org> | 2011-11-25 16:46:56 +0000 |
|---|---|---|
| committer | dholland <dholland@NetBSD.org> | 2011-11-25 16:46:56 +0000 |
| commit | bdae9a2a35e6d6a071439f4f3d482f6ac823e4e8 (patch) | |
| tree | dec6c4b44037e0f06d9bffb9b62ec92390529e50 /lib/libc/string | |
| parent | 2afcd52b0804741f13665c2a0c118b22e604757e (diff) | |
Use CHAR_BIT; don't hardwire 8. Fix logic slightly to work with arbitrary
CHAR_BIT. Compiler output unchanged (on amd64).
Diffstat (limited to 'lib/libc/string')
| -rw-r--r-- | lib/libc/string/wcscspn_bloom.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/string/wcscspn_bloom.h b/lib/libc/string/wcscspn_bloom.h index afbd2f37888..593aef250b0 100644 --- a/lib/libc/string/wcscspn_bloom.h +++ b/lib/libc/string/wcscspn_bloom.h @@ -1,4 +1,4 @@ -/* $NetBSD: wcscspn_bloom.h,v 1.2 2011/11/25 09:00:51 tron Exp $ */ +/* $NetBSD: wcscspn_bloom.h,v 1.3 2011/11/25 16:46:56 dholland Exp $ */ /*- * Copyright (c) 2011 Joerg Sonnenberger, @@ -36,22 +36,24 @@ * multiplication. */ +#include <limits.h> + #define BLOOM_SIZE 64 #define BLOOM_ARRAY_SIZE (BLOOM_SIZE / sizeof(size_t)) -#define BLOOM_MASK (BLOOM_SIZE * 8 - 1) -#define BLOOM_DIV (sizeof(size_t) * 8) +#define BLOOM_BITS (BLOOM_SIZE * CHAR_BIT) +#define BLOOM_DIV (sizeof(size_t) * CHAR_BIT) static inline size_t wcscspn_bloom1(size_t x) { - return x & BLOOM_MASK; + return x % BLOOM_BITS; } static inline size_t wcscspn_bloom2(size_t x) { return (size_t)((uint32_t)(x * 2654435761U) / - (0x100000000ULL / (BLOOM_MASK + 1))); + (0x100000000ULL / BLOOM_BITS)); } static inline void |
