Skip to content

Commit 34b935c

Browse files
peffgitster
authored andcommitted
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>
1 parent 414382f commit 34b935c

4 files changed

Lines changed: 23 additions & 23 deletions

File tree

ewah/bitmap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "git-compat-util.h"
2121
#include "ewok.h"
2222

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)
2525

2626
struct bitmap *bitmap_new(void)
2727
{
@@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)
127127
void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
128128
{
129129
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;
131131
size_t i = 0;
132132
struct ewah_iterator it;
133133
eword_t word;
@@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data)
155155
uint32_t offset;
156156

157157
if (word == (eword_t)~0) {
158-
for (offset = 0; offset < BITS_IN_WORD; ++offset)
158+
for (offset = 0; offset < BITS_IN_EWORD; ++offset)
159159
callback(pos++, data);
160160
} else {
161-
for (offset = 0; offset < BITS_IN_WORD; ++offset) {
161+
for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
162162
if ((word >> offset) == 0)
163163
break;
164164

165165
offset += ewah_bit_ctz64(word >> offset);
166166
callback(pos + offset, data);
167167
}
168-
pos += BITS_IN_WORD;
168+
pos += BITS_IN_EWORD;
169169
}
170170
}
171171
}

ewah/ewah_bitmap.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number)
102102
if (number == 0)
103103
return 0;
104104

105-
self->bit_size += number * BITS_IN_WORD;
105+
self->bit_size += number * BITS_IN_EWORD;
106106
return add_empty_words(self, v, number);
107107
}
108108

@@ -152,7 +152,7 @@ void ewah_add_dirty_words(
152152
self->buffer_size += can_add;
153153
}
154154

155-
self->bit_size += can_add * BITS_IN_WORD;
155+
self->bit_size += can_add * BITS_IN_EWORD;
156156

157157
if (number - can_add == 0)
158158
break;
@@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v)
197197

198198
size_t ewah_add(struct ewah_bitmap *self, eword_t word)
199199
{
200-
self->bit_size += BITS_IN_WORD;
200+
self->bit_size += BITS_IN_EWORD;
201201

202202
if (word == 0)
203203
return add_empty_word(self, 0);
@@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)
211211
void ewah_set(struct ewah_bitmap *self, size_t i)
212212
{
213213
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;
216216

217217
assert(i >= self->bit_size);
218218

@@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i)
222222
if (dist > 1)
223223
add_empty_words(self, 0, dist - 1);
224224

225-
add_literal(self, (eword_t)1 << (i % BITS_IN_WORD));
225+
add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));
226226
return;
227227
}
228228

229229
if (rlw_get_literal_words(self->rlw) == 0) {
230230
rlw_set_running_len(self->rlw,
231231
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));
233233
return;
234234
}
235235

236236
self->buffer[self->buffer_size - 1] |=
237-
((eword_t)1 << (i % BITS_IN_WORD));
237+
((eword_t)1 << (i % BITS_IN_EWORD));
238238

239239
/* check if we just completed a stream of 1s */
240240
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
255255
eword_t *word = &self->buffer[pointer];
256256

257257
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;
259259
for (k = 0; k < len; ++k, ++pos)
260260
callback(pos, payload);
261261
} else {
262-
pos += rlw_get_running_len(word) * BITS_IN_WORD;
262+
pos += rlw_get_running_len(word) * BITS_IN_EWORD;
263263
}
264264

265265
++pointer;
@@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
268268
int c;
269269

270270
/* todo: zero count optimization */
271-
for (c = 0; c < BITS_IN_WORD; ++c, ++pos) {
271+
for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {
272272
if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)
273273
callback(pos, payload);
274274
}

ewah/ewok.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#endif
3232

3333
typedef uint64_t eword_t;
34-
#define BITS_IN_WORD (sizeof(eword_t) * 8)
34+
#define BITS_IN_EWORD (sizeof(eword_t) * 8)
3535

3636
/**
3737
* Do not use __builtin_popcountll. The GCC implementation

pack-bitmap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ static void show_objects_for_type(
618618
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
619619
eword_t word = objects->words[i] & filter;
620620

621-
for (offset = 0; offset < BITS_IN_WORD; ++offset) {
621+
for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
622622
const unsigned char *sha1;
623623
struct revindex_entry *entry;
624624
uint32_t hash = 0;
@@ -640,7 +640,7 @@ static void show_objects_for_type(
640640
show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
641641
}
642642

643-
pos += BITS_IN_WORD;
643+
pos += BITS_IN_EWORD;
644644
i++;
645645
}
646646
}
@@ -772,7 +772,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,
772772
break;
773773
}
774774

775-
reuse_objects += BITS_IN_WORD;
775+
reuse_objects += BITS_IN_EWORD;
776776
}
777777

778778
#ifdef GIT_BITMAP_DEBUG
@@ -995,7 +995,7 @@ static int rebuild_bitmap(uint32_t *reposition,
995995
while (ewah_iterator_next(&word, &it)) {
996996
uint32_t offset, bit_pos;
997997

998-
for (offset = 0; offset < BITS_IN_WORD; ++offset) {
998+
for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
999999
if ((word >> offset) == 0)
10001000
break;
10011001

@@ -1008,7 +1008,7 @@ static int rebuild_bitmap(uint32_t *reposition,
10081008
return -1;
10091009
}
10101010

1011-
pos += BITS_IN_WORD;
1011+
pos += BITS_IN_EWORD;
10121012
}
10131013
return 0;
10141014
}

0 commit comments

Comments
 (0)