{"thread":{"id":"39505","subject":"[PATCH] ewah/bitmap: silence warning about MASK macro redefinition","startedAt":"2015-06-02T21:47:55Z","lastAt":"2015-06-03T06:51:20Z","messageCount":10,"participants":["Eric Sunshine","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"262791","messageId":"1433281675-24893-1-git-send-email-sunshine@sunshineco.com","threadId":"39505","inReplyTo":null,"subject":"[PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-02T21:47:55Z","receivedAt":"2015-06-02T21:47:55Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On PowerPC Mac OS X (10.5.8 \"Leopard\" with Xcode 3.1), system header\n/usr/include/ppc/param.h[1] pollutes the preprocessor namespace with a\nmacro generically named MASK. This conflicts with the same-named macro\nin ewah/bitmap.c.\n\n[1]: Included indirectly via:\n     git-compat-util.h ->\n     sys/sysctl.h ->\n     sys/ucred.h ->\n     sys/param.h ->\n     machine/param.h ->\n     ppc/param.h\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n\nThe alternative is to rename MASK in ewah/bitmap.c to something less\ngeneric, resulting in a slightly more noisy patch. I chose the #undef\napproach since it's a relatively common idiom to #undef a macro before\n#defining it in order to avoid exactly this sort of redefinition\nproblem.\n\n ewah/bitmap.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/ewah/bitmap.c b/ewah/bitmap.c\nindex 710e58c..b31cf75 100644\n--- a/ewah/bitmap.c\n+++ b/ewah/bitmap.c\n@@ -20,6 +20,8 @@\n #include \"git-compat-util.h\"\n #include \"ewok.h\"\n \n+#undef MASK\n+#undef BLOCK\n #define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n #define BLOCK(x) (x / BITS_IN_WORD)\n \n-- \n2.4.2.598.gb4379f4\n"},{"id":"262797","messageId":"xmqqegltzriq.fsf@gitster.dls.corp.google.com","threadId":"39505","inReplyTo":"1433281675-24893-1-git-send-email-sunshine@sunshineco.com","subject":"Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-02T22:15:09Z","receivedAt":"2015-06-02T22:15:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On PowerPC Mac OS X (10.5.8 \"Leopard\" with Xcode 3.1), system header\n> /usr/include/ppc/param.h[1] pollutes the preprocessor namespace with a\n> macro generically named MASK. This conflicts with the same-named macro\n> in ewah/bitmap.c.\n>\n> [1]: Included indirectly via:\n>      git-compat-util.h ->\n>      sys/sysctl.h ->\n>      sys/ucred.h ->\n>      sys/param.h ->\n>      machine/param.h ->\n>      ppc/param.h\n>\n> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>\n> ---\n>\n> The alternative is to rename MASK in ewah/bitmap.c to something less\n> generic, resulting in a slightly more noisy patch. I chose the #undef\n> approach since it's a relatively common idiom to #undef a macro before\n> #defining it in order to avoid exactly this sort of redefinition\n> problem.\n\nI agree that there is nothing controversial against this use of\n#undef; I however wonder if we are stomping on _their_ use of MASK\nand breaking whatever Mac OS X wants to express with that macro,\nthough (in which case, hiding collision like this may not be\nsufficient and we have to live with the poor implementation choice\nmade by the header file and change the macro _we_ use).\n\nWill queue.  Thanks.\n\n>  ewah/bitmap.c | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/ewah/bitmap.c b/ewah/bitmap.c\n> index 710e58c..b31cf75 100644\n> --- a/ewah/bitmap.c\n> +++ b/ewah/bitmap.c\n> @@ -20,6 +20,8 @@\n>  #include \"git-compat-util.h\"\n>  #include \"ewok.h\"\n>  \n> +#undef MASK\n> +#undef BLOCK\n>  #define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n>  #define BLOCK(x) (x / BITS_IN_WORD)\n"},{"id":"262808","messageId":"20150603045117.GC15989@peff.net","threadId":"39505","inReplyTo":"xmqqegltzriq.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-06-03T04:51:18Z","receivedAt":"2015-06-03T04:51:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 02, 2015 at 03:15:09PM -0700, Junio C Hamano wrote:\n\n> > The alternative is to rename MASK in ewah/bitmap.c to something less\n> > generic, resulting in a slightly more noisy patch. I chose the #undef\n> > approach since it's a relatively common idiom to #undef a macro before\n> > #defining it in order to avoid exactly this sort of redefinition\n> > problem.\n> \n> I agree that there is nothing controversial against this use of\n> #undef; I however wonder if we are stomping on _their_ use of MASK\n> and breaking whatever Mac OS X wants to express with that macro,\n> though (in which case, hiding collision like this may not be\n> sufficient and we have to live with the poor implementation choice\n> made by the header file and change the macro _we_ use).\n\nYeah. It looks like we only use the macros a few times. I would not be\nopposed to s/(BLOCK|MASK)/EWAH_&/. We also use BITS_IN_WORD, which is\nrather generic, and is actually defined in a header file (so it affects\nthe rest of git). Probably BITS_IN_EWORD would be better.\n\nThe resulting patch is rather noisy, but I don't think there's any\nongoing work in that area (actually, I have a few things that need\ncleaned up and submitted, but the conflicts are not a big deal).\n\n-- >8 --\nSubject: [PATCH] ewah: use less generic macro names\n\nThe ewah/ewok.h header pollutes the global namespace with\n\"BITS_IN_WORD\", without any specific notion that we are\ntalking about the bits in an eword_t. We can give this the\nmore specific name \"BITS_IN_EWORD\".\n\nLikewise, ewah/bitmap.c uses the generic MASK and BLOCK\nmacro names. These are local to the .c file, but we have the\nopposite problem: on PowerPC Mac OS X (10.5.8 \"Leopard\" with\nXcode 3.1), system header /usr/include/ppc/param.h[1]\npollutes the preprocessor namespace with a macro generically\nnamed MASK. We can give these macros more specific names, as\nwell, to avoid this conflict.\n\nReported-and-analyzed-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI'm also happy to split it into two patches, and make Eric the author on\nthe MASK part.\n\n ewah/bitmap.c      | 24 ++++++++++++------------\n ewah/ewah_bitmap.c | 22 +++++++++++-----------\n ewah/ewok.h        |  2 +-\n pack-bitmap.c      | 10 +++++-----\n 4 files changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/ewah/bitmap.c b/ewah/bitmap.c\nindex 710e58c..47ad674 100644\n--- a/ewah/bitmap.c\n+++ b/ewah/bitmap.c\n@@ -20,8 +20,8 @@\n #include \"git-compat-util.h\"\n #include \"ewok.h\"\n \n-#define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n-#define BLOCK(x) (x / BITS_IN_WORD)\n+#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))\n+#define EWAH_BLOCK(x) (x / BITS_IN_EWORD)\n \n struct bitmap *bitmap_new(void)\n {\n@@ -33,7 +33,7 @@ struct bitmap *bitmap_new(void)\n \n void bitmap_set(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \n \tif (block >= self->word_alloc) {\n \t\tsize_t old_size = self->word_alloc;\n@@ -45,22 +45,22 @@ void bitmap_set(struct bitmap *self, size_t pos)\n \t\t\t(self->word_alloc - old_size) * sizeof(eword_t));\n \t}\n \n-\tself->words[block] |= MASK(pos);\n+\tself->words[block] |= EWAH_MASK(pos);\n }\n \n void bitmap_clear(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \n \tif (block < self->word_alloc)\n-\t\tself->words[block] &= ~MASK(pos);\n+\t\tself->words[block] &= ~EWAH_MASK(pos);\n }\n \n int bitmap_get(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \treturn block < self->word_alloc &&\n-\t\t(self->words[block] & MASK(pos)) != 0;\n+\t\t(self->words[block] & EWAH_MASK(pos)) != 0;\n }\n \n struct ewah_bitmap *bitmap_to_ewah(struct bitmap *bitmap)\n@@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)\n void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)\n {\n \tsize_t original_size = self->word_alloc;\n-\tsize_t other_final = (other->bit_size / BITS_IN_WORD) + 1;\n+\tsize_t other_final = (other->bit_size / BITS_IN_EWORD) + 1;\n \tsize_t i = 0;\n \tstruct ewah_iterator it;\n \teword_t word;\n@@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data)\n \t\tuint32_t offset;\n \n \t\tif (word == (eword_t)~0) {\n-\t\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset)\n+\t\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset)\n \t\t\t\tcallback(pos++, data);\n \t\t} else {\n-\t\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\t\tif ((word >> offset) == 0)\n \t\t\t\t\tbreak;\n \n \t\t\t\toffset += ewah_bit_ctz64(word >> offset);\n \t\t\t\tcallback(pos + offset, data);\n \t\t\t}\n-\t\t\tpos += BITS_IN_WORD;\n+\t\t\tpos += BITS_IN_EWORD;\n \t\t}\n \t}\n }\ndiff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c\nindex fccb42b..b522437 100644\n--- a/ewah/ewah_bitmap.c\n+++ b/ewah/ewah_bitmap.c\n@@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number)\n \tif (number == 0)\n \t\treturn 0;\n \n-\tself->bit_size += number * BITS_IN_WORD;\n+\tself->bit_size += number * BITS_IN_EWORD;\n \treturn add_empty_words(self, v, number);\n }\n \n@@ -152,7 +152,7 @@ void ewah_add_dirty_words(\n \t\t\tself->buffer_size += can_add;\n \t\t}\n \n-\t\tself->bit_size += can_add * BITS_IN_WORD;\n+\t\tself->bit_size += can_add * BITS_IN_EWORD;\n \n \t\tif (number - can_add == 0)\n \t\t\tbreak;\n@@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v)\n \n size_t ewah_add(struct ewah_bitmap *self, eword_t word)\n {\n-\tself->bit_size += BITS_IN_WORD;\n+\tself->bit_size += BITS_IN_EWORD;\n \n \tif (word == 0)\n \t\treturn add_empty_word(self, 0);\n@@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)\n void ewah_set(struct ewah_bitmap *self, size_t i)\n {\n \tconst size_t dist =\n-\t\t(i + BITS_IN_WORD) / BITS_IN_WORD -\n-\t\t(self->bit_size + BITS_IN_WORD - 1) / BITS_IN_WORD;\n+\t\t(i + BITS_IN_EWORD) / BITS_IN_EWORD -\n+\t\t(self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD;\n \n \tassert(i >= self->bit_size);\n \n@@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i)\n \t\tif (dist > 1)\n \t\t\tadd_empty_words(self, 0, dist - 1);\n \n-\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_WORD));\n+\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));\n \t\treturn;\n \t}\n \n \tif (rlw_get_literal_words(self->rlw) == 0) {\n \t\trlw_set_running_len(self->rlw,\n \t\t\trlw_get_running_len(self->rlw) - 1);\n-\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_WORD));\n+\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));\n \t\treturn;\n \t}\n \n \tself->buffer[self->buffer_size - 1] |=\n-\t\t((eword_t)1 << (i % BITS_IN_WORD));\n+\t\t((eword_t)1 << (i % BITS_IN_EWORD));\n \n \t/* check if we just completed a stream of 1s */\n \tif (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) {\n@@ -255,11 +255,11 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo\n \t\teword_t *word = &self->buffer[pointer];\n \n \t\tif (rlw_get_run_bit(word)) {\n-\t\t\tsize_t len = rlw_get_running_len(word) * BITS_IN_WORD;\n+\t\t\tsize_t len = rlw_get_running_len(word) * BITS_IN_EWORD;\n \t\t\tfor (k = 0; k < len; ++k, ++pos)\n \t\t\t\tcallback(pos, payload);\n \t\t} else {\n-\t\t\tpos += rlw_get_running_len(word) * BITS_IN_WORD;\n+\t\t\tpos += rlw_get_running_len(word) * BITS_IN_EWORD;\n \t\t}\n \n \t\t++pointer;\n@@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo\n \t\t\tint c;\n \n \t\t\t/* todo: zero count optimization */\n-\t\t\tfor (c = 0; c < BITS_IN_WORD; ++c, ++pos) {\n+\t\t\tfor (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {\n \t\t\t\tif ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)\n \t\t\t\t\tcallback(pos, payload);\n \t\t\t}\ndiff --git a/ewah/ewok.h b/ewah/ewok.h\nindex e732525..6e2c5e1 100644\n--- a/ewah/ewok.h\n+++ b/ewah/ewok.h\n@@ -32,7 +32,7 @@\n \n struct strbuf;\n typedef uint64_t eword_t;\n-#define BITS_IN_WORD (sizeof(eword_t) * 8)\n+#define BITS_IN_EWORD (sizeof(eword_t) * 8)\n \n /**\n  * Do not use __builtin_popcountll. The GCC implementation\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 2b3ff23..637770a 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -622,7 +622,7 @@ static void show_objects_for_type(\n \twhile (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {\n \t\teword_t word = objects->words[i] & filter;\n \n-\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\tconst unsigned char *sha1;\n \t\t\tstruct revindex_entry *entry;\n \t\t\tuint32_t hash = 0;\n@@ -644,7 +644,7 @@ static void show_objects_for_type(\n \t\t\tshow_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);\n \t\t}\n \n-\t\tpos += BITS_IN_WORD;\n+\t\tpos += BITS_IN_EWORD;\n \t\ti++;\n \t}\n }\n@@ -776,7 +776,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,\n \t\t\tbreak;\n \t\t}\n \n-\t\treuse_objects += BITS_IN_WORD;\n+\t\treuse_objects += BITS_IN_EWORD;\n \t}\n \n #ifdef GIT_BITMAP_DEBUG\n@@ -1001,7 +1001,7 @@ static int rebuild_bitmap(uint32_t *reposition,\n \twhile (ewah_iterator_next(&word, &it)) {\n \t\tuint32_t offset, bit_pos;\n \n-\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\tif ((word >> offset) == 0)\n \t\t\t\tbreak;\n \n@@ -1014,7 +1014,7 @@ static int rebuild_bitmap(uint32_t *reposition,\n \t\t\t\treturn -1;\n \t\t}\n \n-\t\tpos += BITS_IN_WORD;\n+\t\tpos += BITS_IN_EWORD;\n \t}\n \treturn 0;\n }\n-- \n2.4.2.745.g0aa058d\n"},{"id":"262812","messageId":"CAPig+cR3Xt5FNSYbDPhW=m5aEOMq8mCLRSe+mjYfVvdS0R382A@mail.gmail.com","threadId":"39505","inReplyTo":"20150603045117.GC15989@peff.net","subject":"Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-03T06:28:10Z","receivedAt":"2015-06-03T06:28:10Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jun 3, 2015 at 12:51 AM, Jeff King <peff@peff.net> wrote:\n> Subject: [PATCH] ewah: use less generic macro names\n>\n> The ewah/ewok.h header pollutes the global namespace with\n> \"BITS_IN_WORD\", without any specific notion that we are\n> talking about the bits in an eword_t. We can give this the\n> more specific name \"BITS_IN_EWORD\".\n>\n> Likewise, ewah/bitmap.c uses the generic MASK and BLOCK\n> macro names. These are local to the .c file, but we have the\n> opposite problem: on PowerPC Mac OS X (10.5.8 \"Leopard\" with\n> Xcode 3.1), system header /usr/include/ppc/param.h[1]\n\nThe [1] has no meaning anymore, so: s/\\[1\\]//\n\n> pollutes the preprocessor namespace with a macro generically\n> named MASK. We can give these macros more specific names, as\n> well, to avoid this conflict.\n>\n> Reported-and-analyzed-by: Eric Sunshine <sunshine@sunshineco.com>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> I'm also happy to split it into two patches, and make Eric the author on\n> the MASK part.\n\nI don't mind being an author of a patch, so splitting works for me,\nhowever, I'm also fine with whatever you and Junio prefer. (And, in\nretrospect, I agree that renaming the macros here is preferable over\nthe #undef approach.)\n"},{"id":"262813","messageId":"20150603063812.GA21319@peff.net","threadId":"39505","inReplyTo":"CAPig+cR3Xt5FNSYbDPhW=m5aEOMq8mCLRSe+mjYfVvdS0R382A@mail.gmail.com","subject":"Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-06-03T06:38:13Z","receivedAt":"2015-06-03T06:38:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jun 03, 2015 at 02:28:10AM -0400, Eric Sunshine wrote:\n\n> On Wed, Jun 3, 2015 at 12:51 AM, Jeff King <peff@peff.net> wrote:\n> > Subject: [PATCH] ewah: use less generic macro names\n> >\n> > The ewah/ewok.h header pollutes the global namespace with\n> > \"BITS_IN_WORD\", without any specific notion that we are\n> > talking about the bits in an eword_t. We can give this the\n> > more specific name \"BITS_IN_EWORD\".\n> >\n> > Likewise, ewah/bitmap.c uses the generic MASK and BLOCK\n> > macro names. These are local to the .c file, but we have the\n> > opposite problem: on PowerPC Mac OS X (10.5.8 \"Leopard\" with\n> > Xcode 3.1), system header /usr/include/ppc/param.h[1]\n> \n> The [1] has no meaning anymore, so: s/\\[1\\]//\n\nOops, I meant to include your footnote.\n\n> > I'm also happy to split it into two patches, and make Eric the author on\n> > the MASK part.\n> \n> I don't mind being an author of a patch, so splitting works for me,\n> however, I'm also fine with whatever you and Junio prefer. (And, in\n> retrospect, I agree that renaming the macros here is preferable over\n> the #undef approach.)\n\nAfter reflecting, I think splitting it into two patches makes more\nsense. I mostly noticed that we were touching the same lines, but of\ncourse it is not a problem to have two related patches in order. :)\n\nSo here is what I propose:\n\n  [1/2]: ewah/bitmap: silence warning about MASK macro redefinition\n  [2/2]: ewah: use less generic macro name\n\nI put yours first, because it solves an actual problem. We can drop 2/2\nif we decide it's just churn.\n\n-Peff\n"},{"id":"262814","messageId":"20150603063917.GA29008@peff.net","threadId":"39505","inReplyTo":"20150603063812.GA21319@peff.net","subject":"[PATCH 1/2] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-06-03T06:39:17Z","receivedAt":"2015-06-03T06:39:17Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Eric Sunshine <sunshine@sunshineco.com>\n\nOn PowerPC Mac OS X (10.5.8 \"Leopard\" with Xcode 3.1),\nsystem header /usr/include/ppc/param.h[1] pollutes the\npreprocessor namespace with a macro generically named MASK.\nThis conflicts with the same-named macro in ewah/bitmap.c.\nWe can avoid this conflict by using a more specific name.\n\n[1]: Included indirectly via:\n     git-compat-util.h ->\n     sys/sysctl.h ->\n     sys/ucred.h ->\n     sys/param.h ->\n     machine/param.h ->\n     ppc/param.h\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n ewah/bitmap.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/ewah/bitmap.c b/ewah/bitmap.c\nindex 710e58c..2af94f6 100644\n--- a/ewah/bitmap.c\n+++ b/ewah/bitmap.c\n@@ -20,8 +20,8 @@\n #include \"git-compat-util.h\"\n #include \"ewok.h\"\n \n-#define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n-#define BLOCK(x) (x / BITS_IN_WORD)\n+#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n+#define EWAH_BLOCK(x) (x / BITS_IN_WORD)\n \n struct bitmap *bitmap_new(void)\n {\n@@ -33,7 +33,7 @@ struct bitmap *bitmap_new(void)\n \n void bitmap_set(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \n \tif (block >= self->word_alloc) {\n \t\tsize_t old_size = self->word_alloc;\n@@ -45,22 +45,22 @@ void bitmap_set(struct bitmap *self, size_t pos)\n \t\t\t(self->word_alloc - old_size) * sizeof(eword_t));\n \t}\n \n-\tself->words[block] |= MASK(pos);\n+\tself->words[block] |= EWAH_MASK(pos);\n }\n \n void bitmap_clear(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \n \tif (block < self->word_alloc)\n-\t\tself->words[block] &= ~MASK(pos);\n+\t\tself->words[block] &= ~EWAH_MASK(pos);\n }\n \n int bitmap_get(struct bitmap *self, size_t pos)\n {\n-\tsize_t block = BLOCK(pos);\n+\tsize_t block = EWAH_BLOCK(pos);\n \treturn block < self->word_alloc &&\n-\t\t(self->words[block] & MASK(pos)) != 0;\n+\t\t(self->words[block] & EWAH_MASK(pos)) != 0;\n }\n \n struct ewah_bitmap *bitmap_to_ewah(struct bitmap *bitmap)\n-- \n2.4.2.745.g0aa058d\n"},{"id":"262815","messageId":"20150603063937.GB29008@peff.net","threadId":"39505","inReplyTo":"20150603063812.GA21319@peff.net","subject":"[PATCH 2/2] ewah: use less generic macro name","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-06-03T06:39:37Z","receivedAt":"2015-06-03T06:39:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The ewah/ewok.h header pollutes the global namespace with\n\"BITS_IN_WORD\", without any specific notion that we are\ntalking about the bits in an eword_t. We can give this the\nmore specific name \"BITS_IN_EWORD\".\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n ewah/bitmap.c      | 12 ++++++------\n ewah/ewah_bitmap.c | 22 +++++++++++-----------\n ewah/ewok.h        |  2 +-\n pack-bitmap.c      | 10 +++++-----\n 4 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/ewah/bitmap.c b/ewah/bitmap.c\nindex 2af94f6..47ad674 100644\n--- a/ewah/bitmap.c\n+++ b/ewah/bitmap.c\n@@ -20,8 +20,8 @@\n #include \"git-compat-util.h\"\n #include \"ewok.h\"\n \n-#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n-#define EWAH_BLOCK(x) (x / BITS_IN_WORD)\n+#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))\n+#define EWAH_BLOCK(x) (x / BITS_IN_EWORD)\n \n struct bitmap *bitmap_new(void)\n {\n@@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)\n void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)\n {\n \tsize_t original_size = self->word_alloc;\n-\tsize_t other_final = (other->bit_size / BITS_IN_WORD) + 1;\n+\tsize_t other_final = (other->bit_size / BITS_IN_EWORD) + 1;\n \tsize_t i = 0;\n \tstruct ewah_iterator it;\n \teword_t word;\n@@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data)\n \t\tuint32_t offset;\n \n \t\tif (word == (eword_t)~0) {\n-\t\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset)\n+\t\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset)\n \t\t\t\tcallback(pos++, data);\n \t\t} else {\n-\t\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\t\tif ((word >> offset) == 0)\n \t\t\t\t\tbreak;\n \n \t\t\t\toffset += ewah_bit_ctz64(word >> offset);\n \t\t\t\tcallback(pos + offset, data);\n \t\t\t}\n-\t\t\tpos += BITS_IN_WORD;\n+\t\t\tpos += BITS_IN_EWORD;\n \t\t}\n \t}\n }\ndiff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c\nindex fccb42b..b522437 100644\n--- a/ewah/ewah_bitmap.c\n+++ b/ewah/ewah_bitmap.c\n@@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number)\n \tif (number == 0)\n \t\treturn 0;\n \n-\tself->bit_size += number * BITS_IN_WORD;\n+\tself->bit_size += number * BITS_IN_EWORD;\n \treturn add_empty_words(self, v, number);\n }\n \n@@ -152,7 +152,7 @@ void ewah_add_dirty_words(\n \t\t\tself->buffer_size += can_add;\n \t\t}\n \n-\t\tself->bit_size += can_add * BITS_IN_WORD;\n+\t\tself->bit_size += can_add * BITS_IN_EWORD;\n \n \t\tif (number - can_add == 0)\n \t\t\tbreak;\n@@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v)\n \n size_t ewah_add(struct ewah_bitmap *self, eword_t word)\n {\n-\tself->bit_size += BITS_IN_WORD;\n+\tself->bit_size += BITS_IN_EWORD;\n \n \tif (word == 0)\n \t\treturn add_empty_word(self, 0);\n@@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)\n void ewah_set(struct ewah_bitmap *self, size_t i)\n {\n \tconst size_t dist =\n-\t\t(i + BITS_IN_WORD) / BITS_IN_WORD -\n-\t\t(self->bit_size + BITS_IN_WORD - 1) / BITS_IN_WORD;\n+\t\t(i + BITS_IN_EWORD) / BITS_IN_EWORD -\n+\t\t(self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD;\n \n \tassert(i >= self->bit_size);\n \n@@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i)\n \t\tif (dist > 1)\n \t\t\tadd_empty_words(self, 0, dist - 1);\n \n-\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_WORD));\n+\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));\n \t\treturn;\n \t}\n \n \tif (rlw_get_literal_words(self->rlw) == 0) {\n \t\trlw_set_running_len(self->rlw,\n \t\t\trlw_get_running_len(self->rlw) - 1);\n-\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_WORD));\n+\t\tadd_literal(self, (eword_t)1 << (i % BITS_IN_EWORD));\n \t\treturn;\n \t}\n \n \tself->buffer[self->buffer_size - 1] |=\n-\t\t((eword_t)1 << (i % BITS_IN_WORD));\n+\t\t((eword_t)1 << (i % BITS_IN_EWORD));\n \n \t/* check if we just completed a stream of 1s */\n \tif (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) {\n@@ -255,11 +255,11 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo\n \t\teword_t *word = &self->buffer[pointer];\n \n \t\tif (rlw_get_run_bit(word)) {\n-\t\t\tsize_t len = rlw_get_running_len(word) * BITS_IN_WORD;\n+\t\t\tsize_t len = rlw_get_running_len(word) * BITS_IN_EWORD;\n \t\t\tfor (k = 0; k < len; ++k, ++pos)\n \t\t\t\tcallback(pos, payload);\n \t\t} else {\n-\t\t\tpos += rlw_get_running_len(word) * BITS_IN_WORD;\n+\t\t\tpos += rlw_get_running_len(word) * BITS_IN_EWORD;\n \t\t}\n \n \t\t++pointer;\n@@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo\n \t\t\tint c;\n \n \t\t\t/* todo: zero count optimization */\n-\t\t\tfor (c = 0; c < BITS_IN_WORD; ++c, ++pos) {\n+\t\t\tfor (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {\n \t\t\t\tif ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)\n \t\t\t\t\tcallback(pos, payload);\n \t\t\t}\ndiff --git a/ewah/ewok.h b/ewah/ewok.h\nindex e732525..6e2c5e1 100644\n--- a/ewah/ewok.h\n+++ b/ewah/ewok.h\n@@ -32,7 +32,7 @@\n \n struct strbuf;\n typedef uint64_t eword_t;\n-#define BITS_IN_WORD (sizeof(eword_t) * 8)\n+#define BITS_IN_EWORD (sizeof(eword_t) * 8)\n \n /**\n  * Do not use __builtin_popcountll. The GCC implementation\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 2b3ff23..637770a 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -622,7 +622,7 @@ static void show_objects_for_type(\n \twhile (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {\n \t\teword_t word = objects->words[i] & filter;\n \n-\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\tconst unsigned char *sha1;\n \t\t\tstruct revindex_entry *entry;\n \t\t\tuint32_t hash = 0;\n@@ -644,7 +644,7 @@ static void show_objects_for_type(\n \t\t\tshow_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);\n \t\t}\n \n-\t\tpos += BITS_IN_WORD;\n+\t\tpos += BITS_IN_EWORD;\n \t\ti++;\n \t}\n }\n@@ -776,7 +776,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,\n \t\t\tbreak;\n \t\t}\n \n-\t\treuse_objects += BITS_IN_WORD;\n+\t\treuse_objects += BITS_IN_EWORD;\n \t}\n \n #ifdef GIT_BITMAP_DEBUG\n@@ -1001,7 +1001,7 @@ static int rebuild_bitmap(uint32_t *reposition,\n \twhile (ewah_iterator_next(&word, &it)) {\n \t\tuint32_t offset, bit_pos;\n \n-\t\tfor (offset = 0; offset < BITS_IN_WORD; ++offset) {\n+\t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n \t\t\tif ((word >> offset) == 0)\n \t\t\t\tbreak;\n \n@@ -1014,7 +1014,7 @@ static int rebuild_bitmap(uint32_t *reposition,\n \t\t\t\treturn -1;\n \t\t}\n \n-\t\tpos += BITS_IN_WORD;\n+\t\tpos += BITS_IN_EWORD;\n \t}\n \treturn 0;\n }\n-- \n2.4.2.745.g0aa058d\n"},{"id":"262817","messageId":"CAPig+cRC7M2T7OMW=GDs6S68MFo_R5guMWdhkxT+pkpYKinDdQ@mail.gmail.com","threadId":"39505","inReplyTo":"20150603063917.GA29008@peff.net","subject":"Re: [PATCH 1/2] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-03T06:46:17Z","receivedAt":"2015-06-03T06:46:17Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jun 3, 2015 at 2:39 AM, Jeff King <peff@peff.net> wrote:\n> From: Eric Sunshine <sunshine@sunshineco.com>\n>\n> On PowerPC Mac OS X (10.5.8 \"Leopard\" with Xcode 3.1),\n> system header /usr/include/ppc/param.h[1] pollutes the\n> preprocessor namespace with a macro generically named MASK.\n> This conflicts with the same-named macro in ewah/bitmap.c.\n> We can avoid this conflict by using a more specific name.\n>\n> [1]: Included indirectly via:\n>      git-compat-util.h ->\n>      sys/sysctl.h ->\n>      sys/ucred.h ->\n>      sys/param.h ->\n>      machine/param.h ->\n>      ppc/param.h\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n\n> ---\n>  ewah/bitmap.c | 16 ++++++++--------\n>  1 file changed, 8 insertions(+), 8 deletions(-)\n>\n> diff --git a/ewah/bitmap.c b/ewah/bitmap.c\n> index 710e58c..2af94f6 100644\n> --- a/ewah/bitmap.c\n> +++ b/ewah/bitmap.c\n> @@ -20,8 +20,8 @@\n>  #include \"git-compat-util.h\"\n>  #include \"ewok.h\"\n>\n> -#define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n> -#define BLOCK(x) (x / BITS_IN_WORD)\n> +#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))\n> +#define EWAH_BLOCK(x) (x / BITS_IN_WORD)\n>\n>  struct bitmap *bitmap_new(void)\n>  {\n> @@ -33,7 +33,7 @@ struct bitmap *bitmap_new(void)\n>\n>  void bitmap_set(struct bitmap *self, size_t pos)\n>  {\n> -       size_t block = BLOCK(pos);\n> +       size_t block = EWAH_BLOCK(pos);\n>\n>         if (block >= self->word_alloc) {\n>                 size_t old_size = self->word_alloc;\n> @@ -45,22 +45,22 @@ void bitmap_set(struct bitmap *self, size_t pos)\n>                         (self->word_alloc - old_size) * sizeof(eword_t));\n>         }\n>\n> -       self->words[block] |= MASK(pos);\n> +       self->words[block] |= EWAH_MASK(pos);\n>  }\n>\n>  void bitmap_clear(struct bitmap *self, size_t pos)\n>  {\n> -       size_t block = BLOCK(pos);\n> +       size_t block = EWAH_BLOCK(pos);\n>\n>         if (block < self->word_alloc)\n> -               self->words[block] &= ~MASK(pos);\n> +               self->words[block] &= ~EWAH_MASK(pos);\n>  }\n>\n>  int bitmap_get(struct bitmap *self, size_t pos)\n>  {\n> -       size_t block = BLOCK(pos);\n> +       size_t block = EWAH_BLOCK(pos);\n>         return block < self->word_alloc &&\n> -               (self->words[block] & MASK(pos)) != 0;\n> +               (self->words[block] & EWAH_MASK(pos)) != 0;\n>  }\n>\n>  struct ewah_bitmap *bitmap_to_ewah(struct bitmap *bitmap)\n> --\n> 2.4.2.745.g0aa058d\n"},{"id":"262836","messageId":"CAPc5daV4UDhGb-5eF_nGxrmpAArxj4X2Qm2kQ3ESMyZvic2A2Q@mail.gmail.com","threadId":"39505","inReplyTo":"CAPig+cR3Xt5FNSYbDPhW=m5aEOMq8mCLRSe+mjYfVvdS0R382A@mail.gmail.com","subject":"Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-03T06:50:34Z","receivedAt":"2015-06-03T06:50:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Tue, Jun 2, 2015 at 11:28 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Wed, Jun 3, 2015 at 12:51 AM, Jeff King <peff@peff.net> wrote:\n>> ---\n>> I'm also happy to split it into two patches, and make Eric the author on\n>> the MASK part.\n>\n> I don't mind being an author of a patch, so splitting works for me,\n\nOK, then let's have two patches, one from you each.\n\nThanks.\n"},{"id":"262840","messageId":"CAPig+cRySp4_uJYAwC-PY_Yh-YjBb0y1Tq=TwoD7d-Bpb_YANg@mail.gmail.com","threadId":"39505","inReplyTo":"20150603063937.GB29008@peff.net","subject":"Re: [PATCH 2/2] ewah: use less generic macro name","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-03T06:51:20Z","receivedAt":"2015-06-03T06:51:20Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jun 3, 2015 at 2:39 AM, Jeff King <peff@peff.net> wrote:\n> The ewah/ewok.h header pollutes the global namespace with\n> \"BITS_IN_WORD\", without any specific notion that we are\n> talking about the bits in an eword_t. We can give this the\n> more specific name \"BITS_IN_EWORD\".\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n\nYeah, splitting the patches this way makes sense and feels a bit cleaner.\n\nIt's such a simple patch that it doesn't need a reviewed-by, but for\nwhat it's worth...\n\nReviewed-by: Eric Sunshine <sunshine@sunshineco.com>\n"}]}