git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] ewah/bitmap: silence warning about MASK macro redefinition

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 3, 2015, 06:46 UTC
Message-ID
<CAPig+cRC7M2T7OMW=GDs6S68MFo_R5guMWdhkxT+pkpYKinDdQ@mail.gmail.com>
In-Reply-To
<20150603063917.GA29008@peff.net>
On Wed, Jun 3, 2015 at 2:39 AM, Jeff King <peff@peff.net> wrote:
Show 17 quoted lines
> From: Eric Sunshine <sunshine@sunshineco.com>
>
> On PowerPC Mac OS X (10.5.8 "Leopard" with Xcode 3.1),
> system header /usr/include/ppc/param.h[1] pollutes the
> preprocessor namespace with a macro generically named MASK.
> This conflicts with the same-named macro in ewah/bitmap.c.
> We can avoid this conflict by using a more specific name.
>
> [1]: Included indirectly via:
>      git-compat-util.h ->
>      sys/sysctl.h ->
>      sys/ucred.h ->
>      sys/param.h ->
>      machine/param.h ->
>      ppc/param.h
>
> Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Show 58 quoted lines
> ---
>  ewah/bitmap.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/ewah/bitmap.c b/ewah/bitmap.c
> index 710e58c..2af94f6 100644
> --- a/ewah/bitmap.c
> +++ b/ewah/bitmap.c
> @@ -20,8 +20,8 @@
>  #include "git-compat-util.h"
>  #include "ewok.h"
>
> -#define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))
> -#define BLOCK(x) (x / BITS_IN_WORD)
> +#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))
> +#define EWAH_BLOCK(x) (x / BITS_IN_WORD)
>
>  struct bitmap *bitmap_new(void)
>  {
> @@ -33,7 +33,7 @@ struct bitmap *bitmap_new(void)
>
>  void bitmap_set(struct bitmap *self, size_t pos)
>  {
> -       size_t block = BLOCK(pos);
> +       size_t block = EWAH_BLOCK(pos);
>
>         if (block >= self->word_alloc) {
>                 size_t old_size = self->word_alloc;
> @@ -45,22 +45,22 @@ void bitmap_set(struct bitmap *self, size_t pos)
>                         (self->word_alloc - old_size) * sizeof(eword_t));
>         }
>
> -       self->words[block] |= MASK(pos);
> +       self->words[block] |= EWAH_MASK(pos);
>  }
>
>  void bitmap_clear(struct bitmap *self, size_t pos)
>  {
> -       size_t block = BLOCK(pos);
> +       size_t block = EWAH_BLOCK(pos);
>
>         if (block < self->word_alloc)
> -               self->words[block] &= ~MASK(pos);
> +               self->words[block] &= ~EWAH_MASK(pos);
>  }
>
>  int bitmap_get(struct bitmap *self, size_t pos)
>  {
> -       size_t block = BLOCK(pos);
> +       size_t block = EWAH_BLOCK(pos);
>         return block < self->word_alloc &&
> -               (self->words[block] & MASK(pos)) != 0;
> +               (self->words[block] & EWAH_MASK(pos)) != 0;
>  }
>
>  struct ewah_bitmap *bitmap_to_ewah(struct bitmap *bitmap)
> --
> 2.4.2.745.g0aa058d
Previous: Jeff KingNext: Jeff King
Message 7 of 10 in “ewah/bitmap: silence warning about MASK macro redefinition”
  1. ewah/bitmap: silence warning about MASK macro redefinitionEric Sunshine, Jun 2, 2015
  2. Junio C HamanoJun 2, 2015
  3. Jeff KingJun 3, 2015
  4. Eric SunshineJun 3, 2015
  5. Jeff KingJun 3, 2015
  6. 1/2 ewah/bitmap: silence warning about MASK macro redefinitionJeff King, Jun 3, 2015
  7. Eric SunshineJun 3, 2015
  8. 2/2 ewah: use less generic macro nameJeff King, Jun 3, 2015
  9. Eric SunshineJun 3, 2015
  10. Junio C HamanoJun 3, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.