ewah: use less generic macro name

The ewah/ewok.h header pollutes the global namespace with "BITS_IN_WORD", without any specific notion that we are talking about the bits in an eword_t. We can give this the more specific name "BITS_IN_EWORD". Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 3, 2015 at 02:39 UTC 34b935c01f28d34f6764f0e1140ad47e7abdde1b
4 files changed +23 -23
ewah/bitmap.c
+6 -6
@@ -20,8 +20,8 @@
20 #include "git-compat-util.h"
21 #include "ewok.h"
22
23 -#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))
24 -#define EWAH_BLOCK(x) (x / BITS_IN_WORD)
23 +#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))
24 +#define EWAH_BLOCK(x) (x / BITS_IN_EWORD)
25
26 struct bitmap *bitmap_new(void)
27 {
@@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)
127 void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
128 {
129 size_t original_size = self->word_alloc;
130 - size_t other_final = (other->bit_size / BITS_IN_WORD) + 1;
130 + size_t other_final = (other->bit_size / BITS_IN_EWORD) + 1;
131 size_t i = 0;
132 struct ewah_iterator it;
133 eword_t word;
@@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data)
155 uint32_t offset;
156
157 if (word == (eword_t)~0) {
158 - for (offset = 0; offset < BITS_IN_WORD; ++offset)
158 + for (offset = 0; offset < BITS_IN_EWORD; ++offset)
159 callback(pos++, data);
160 } else {
161 - for (offset = 0; offset < BITS_IN_WORD; ++offset) {
161 + for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
162 if ((word >> offset) == 0)
163 break;
164
165 offset += ewah_bit_ctz64(word >> offset);
166 callback(pos + offset, data);
167 }
168 - pos += BITS_IN_WORD;
168 + pos += BITS_IN_EWORD;
169 }
170 }
171 }
ewah/ewah_bitmap.c
+11 -11
@@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number)
102 if (number == 0)
103 return 0;
104
105 - self->bit_size += number * BITS_IN_WORD;
105 + self->bit_size += number * BITS_IN_EWORD;
106 return add_empty_words(self, v, number);
107 }
108
@@ -152,7 +152,7 @@ void ewah_add_dirty_words(
152 self->buffer_size += can_add;
153 }
154
155 - self->bit_size += can_add * BITS_IN_WORD;
155 + self->bit_size += can_add * BITS_IN_EWORD;
156
157 if (number - can_add == 0)
158 break;
@@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v)
197
198 size_t ewah_add(struct ewah_bitmap *self, eword_t word)
199 {
200 - self->bit_size += BITS_IN_WORD;
200 + self->bit_size += BITS_IN_EWORD;
201
202 if (word == 0)
203 return add_empty_word(self, 0);
@@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)
211 void ewah_set(struct ewah_bitmap *self, size_t i)
212 {
213 const size_t dist =
214 - (i + BITS_IN_WORD) / BITS_IN_WORD -
215 - (self->bit_size + BITS_IN_WORD - 1) / BITS_IN_WORD;
214 + (i + BITS_IN_EWORD) / BITS_IN_EWORD -
215 + (self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD;
216
217 assert(i >= self->bit_size);
218
@@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i)
222 if (dist > 1)
223 add_empty_words(self, 0, dist - 1);
224
225 - add_literal(self, (eword_t)1 << (i % BITS_IN_WORD));
225 + add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));
226 return;
227 }
228
229 if (rlw_get_literal_words(self->rlw) == 0) {
230 rlw_set_running_len(self->rlw,
231 rlw_get_running_len(self->rlw) - 1);
232 - add_literal(self, (eword_t)1 << (i % BITS_IN_WORD));
232 + add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));
233 return;
234 }
235
236 self->buffer[self->buffer_size - 1] |=
237 - ((eword_t)1 << (i % BITS_IN_WORD));
237 + ((eword_t)1 << (i % BITS_IN_EWORD));
238
239 /* check if we just completed a stream of 1s */
240 if (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) {
@@ -255,11 +255,11 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
255 eword_t *word = &self->buffer[pointer];
256
257 if (rlw_get_run_bit(word)) {
258 - size_t len = rlw_get_running_len(word) * BITS_IN_WORD;
258 + size_t len = rlw_get_running_len(word) * BITS_IN_EWORD;
259 for (k = 0; k < len; ++k, ++pos)
260 callback(pos, payload);
261 } else {
262 - pos += rlw_get_running_len(word) * BITS_IN_WORD;
262 + pos += rlw_get_running_len(word) * BITS_IN_EWORD;
263 }
264
265 ++pointer;
@@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
268 int c;
269
270 /* todo: zero count optimization */
271 - for (c = 0; c < BITS_IN_WORD; ++c, ++pos) {
271 + for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {
272 if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)
273 callback(pos, payload);
274 }
ewah/ewok.h
+1 -1
@@ -31,7 +31,7 @@
31 #endif
32
33 typedef uint64_t eword_t;
34 -#define BITS_IN_WORD (sizeof(eword_t) * 8)
34 +#define BITS_IN_EWORD (sizeof(eword_t) * 8)
35
36 /**
37 * Do not use __builtin_popcountll. The GCC implementation
pack-bitmap.c
+5 -5
@@ -618,7 +618,7 @@ static void show_objects_for_type(
618 while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
619 eword_t word = objects->words[i] & filter;
620
621 - for (offset = 0; offset < BITS_IN_WORD; ++offset) {
621 + for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
622 const unsigned char *sha1;
623 struct revindex_entry *entry;
624 uint32_t hash = 0;
@@ -640,7 +640,7 @@ static void show_objects_for_type(
640 show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
641 }
642
643 - pos += BITS_IN_WORD;
643 + pos += BITS_IN_EWORD;
644 i++;
645 }
646 }
@@ -772,7 +772,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,
772 break;
773 }
774
775 - reuse_objects += BITS_IN_WORD;
775 + reuse_objects += BITS_IN_EWORD;
776 }
777
778 #ifdef GIT_BITMAP_DEBUG
@@ -995,7 +995,7 @@ static int rebuild_bitmap(uint32_t *reposition,
995 while (ewah_iterator_next(&word, &it)) {
996 uint32_t offset, bit_pos;
997
998 - for (offset = 0; offset < BITS_IN_WORD; ++offset) {
998 + for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
999 if ((word >> offset) == 0)
1000 break;
1001
@@ -1008,7 +1008,7 @@ static int rebuild_bitmap(uint32_t *reposition,
1008 return -1;
1009 }
1010
1011 - pos += BITS_IN_WORD;
1011 + pos += BITS_IN_EWORD;
1012 }
1013 return 0;
1014 }