Module Name: src Committed By: dholland Date: Fri Nov 25 16:46:56 UTC 2011
Modified Files: src/lib/libc/string: wcscspn_bloom.h Log Message: Use CHAR_BIT; don't hardwire 8. Fix logic slightly to work with arbitrary CHAR_BIT. Compiler output unchanged (on amd64). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/string/wcscspn_bloom.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/string/wcscspn_bloom.h diff -u src/lib/libc/string/wcscspn_bloom.h:1.2 src/lib/libc/string/wcscspn_bloom.h:1.3 --- src/lib/libc/string/wcscspn_bloom.h:1.2 Fri Nov 25 09:00:51 2011 +++ src/lib/libc/string/wcscspn_bloom.h Fri Nov 25 16:46:56 2011 @@ -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